I have read much of what is one here on the use of a stepper motor with an arduino board, but I am still not altogether sure whether it can allow me to achieve my purpose "reasonably easily". Before I get stuck in I wondered whether in principle I could achieve the following:

1. I'd like to be able to rotate a stepper using external software, which will also be recording several over instruments, by a given total number of steps.

2. The stepper should do it's thing, count each step or n steps I set and spit out the total counts to a register that my program, when required, can read. The stepper will keep working till the total number of steps are made and the register will of course just continue updating if it is isn't queried.

3. Would prefer if the number in the register is a number relative to some value I initialise it to, this is not critical at this stage, but would be handy.

4. If I change my mind and decide that the rotation I set is heading me towards disaster, I would like to be able to stop/interrupt the on going rotation.

The questions relating to the points above:

1. How quickly can I communicate and get information like a simple integer number of steps from the board? 10 times/sec, 1 time/second etc?

2. I read somewhere that every time you connect to board it runs your script from the start, this would mess up my initialisation, why is this setup that way and is there a way around this default?

I have already ordered a board but trying read as much and understand as much as possible before getting it, so don't have any code or definite questions yet but would appreciate answers to these points to get a sense of the scope available to me.

2. I read somewhere that every time you connect to board it runs your script from the start, this would mess up my initialisation, why is this setup that way and is there a way around this default?

that is the way it works, you have to write your code to suite.

So I see that I would have to initialise then do small step take value, read other instruments, and repeat. This, if you say I can communicate 100s of times per second, shouldn't be a problem. Would it be possible to keep a running count in non-volatile memory, is such a thing available?

It is just that if my external programme falls over then it might be very difficult for me to know the position of the stepper, I can't see or read it off anyway physically when I would have it running and that would be very problematic.

2. I read somewhere that every time you connect to board it runs your script from the start, this would mess up my initialisation, why is this setup that way and is there a way around this default?

that is the way it works, you have to write your code to suite.

So I see that I would have to initialise then do small step take value, read other instruments, and repeat. This, if you say I can communicate 100s of times per second, shouldn't be a problem. Would it be possible to keep a running count in non-volatile memory, is such a thing available?

It is just that if my external programme falls over then it might be very difficult for me to know the position of the stepper, I can't see or read it off anyway physically when I would have it running and that would be very problematic.

Cheers

I found the answer to my question: http://arduino.cc/playground/Main/InterfacingWithHardware#Storage

You can't just keep a count and hope they will remain in step, you need to calibrate it every time the power is applied.Remember you have a limit on the number of times you can write to an EEPROM location, it might be 100,000 times but if you are writing at the rate you are sending steps it will fail soon.

You need to reconsider what it is you are doing, you don't do stepping motors like you are suggesting, you need some form of feedback or absolute position indicator.

I have now got the stepper working and I think that my original ideaof just counting will work because I will be running it way under the stall torque and hence there shouldn't be a problem with skipped steps. Also i will have something reading the displacement that I will be able to back calibrate with as a double check. In principle of course I could read this with the UNO and check each time I step but that will be the next iteration.

So my question goes back to my original post. If I wanted to change the direction, switch the motor on and off, read the number of counts etc, could I do this through the same cable as I propgrammed the board with?

Right now I have the whole thing doing what I want, in terms of control, with external switches to do interrupts. I'd like to use a computer programme to do this instead and wondered if i would have to use the RS232 serial port?

Thanks for that. I have now got this working like so where the stepper is interrupted and the direction switched on the toggle of a switch.

What I want to ask is why when I restart serial monitor it always goes from the start of the count. If I start the serial monitor when i first uploaded the programme the count number starts at 0 and if I start the serial monitor after running for 1 minte it starts at 0, doesn't the programme just keep counting? I don't understand why the count is reset.

What I want to ask is why when I restart serial monitor it always goes from the start of the count. If I start the serial monitor when i first uploaded the programme the count number starts at 0 and if I start the serial monitor after running for 1 minte it starts at 0, doesn't the programme just keep counting? I don't understand why the count is reset.

There is some variation, but starting the serial monitor will restart an Arduino. I think this is always true for a UNO when connecting to the USB, from any OS.

... it is poor civic hygiene to install technologies that could somedayfacilitate a police state. -- Bruce Schneier

I thought so but assume there must be a way to do this without reseting the counter? How could I get the count without reseting it? using a different serial connection and reading with a separate computer programme? That's what I eventually plan to do but wanted to do it with the USB connection.

It is something that is node bynthe drivers in the PC. You could get a driver that does not reset the the arduino by toggling the DTR line but I don't know of a varent. The other way is to disconnect the auto reset on the arduino, there is a small track you can cur. But this means you have to use manual reset when uploading sketches