Timing between LCD and Stepper motor

Hi Guys,

before I try and describe my problem here's the list of parts I'm using. Uno R3 Big Easy driver - http://www.schmalzhaus.com/BigEasyDriver/ Colour LCD shield - https://www.sparkfun.com/products/11062 400 step/rev stepper - https://www.sparkfun.com/products/10846

I'm building an automatic guitar pickup coil winder. not the first time its been done for sure, but I've got my own share of problems developing mine. basically, I can run the motor comfortably up to 500rpm. it starts to get a bit "sketchy" at about 575/600rpm. all my programming for user input is complete, the user is able to set the speed (in RPM), the number of Turns, usually up to 10000 possibly more (each turn is a full revolution of the stepper), and the guage for the magnet wire being used. I'd also like to display on the LCD the "Status" being one of the following, "Ramp Up" "Running" and "Cool Down". ramp up and cool down being steady increase/decrease in speed for both stability of the stepper and so there's no sudden jerks on the copper wire. I'd also like to display the number of turns remaining.

my problem is, that as soon as I try and do anything else while the stepper is running at a decent speed the arduino seems to take too long to process before the next instruction to be sent to the stepper and then the stepper will seize. even a simple "Serial.println(output);" will make the stepper jerk at 500rpm. I'm only trying to update a single line of text on the LCD at the moment, changing "Ramp Up" to "Running" as soon as the stepper reaches 500rpm but this causes it to seize.

any suggestions?

Do you have the motor using a different power input than the arduino (but having the grounds connected)? If not, it may be that both the LCD and the motor running off the the arduino internal power is too much. The other thing is whether the motor driver is like the servo library, which disables PWM on pins 9 and 10 (and the LCD appears to use pin 9).

the stepper runs at 1.7A so yes it's on seperate power. I've gone through the libraries to make sure that the LCD and stepper do not use conflicting pins already so that rules out those two.

there's a small jerk in the motor where it almost stops if I do a serial.println() while it's running, so I need a way to make the LCD update run faster or in the background only between stepper commands.

Can you confirm that you are using the hardware serial port to communicate with the LCD?

How long are the strings you are sending to the LCD, and how often are you sending them?

It would be easier to help if you post your code.

You are trying to do two things that require very good timing. Serial communication and running a stepper at higher pulse rates. Your experiance mirrors my own. The Arduino is a <20MHz processor nd getting it drive a stepper motor at high rpm demands that the pulses come at just the right moment or the rotor and magnetic field get out of sync and it results in a stall. Serial communication has to be pretty timing exact as well.

I have built a robot on the basis of dual steppers and I2C commands sent to a ChipKit Uno32 running at 80MHz. I could not get enouh RPM from the Arduino. The problem came when it was stepping and a new I2C command was coming in. Same issue, stalled out if the motors were moving more a moderate speed. Even at 80Mhz I can still hear the hicup if the I2C transmission is more than a byte or two.

At 600RPM and half stepping you need 4000 pps to keep it rotating. That’s 250 uSecs from one pulse to the next so that’s all the time you have till you need to generate the next pulse. To send 10 characters at 9600baud is going to run close to 7 or 8mS I think. At 38800 thats still 1ms, See the issue? I had trouble doing much else useful at pulse rates exceeding 4-5KHz and keeping the motors turning, even with good acceleration to speed.

I see that the latest version of the Arduino environment now use the serial hardware to buffer out writes as non-blocking if I understand it correctly. Are you using the latest release?

thanks for your help guys, but I ended up taking a different and much more stable/acurate approach. after some research too…
I used an interrupt timer to run the stepper, so that it would always take priority over any other code. the rest of the code runs the LCD, and other input/output functions without even the slightest “jerk” from the stepper. I’ve tested this up to 1300 RPM on a 400step/rev stepper… that’s 8666 steps/sec :astonished:.

to be able to vary the RPM throughout so that I could ramp up and cool down the stepper so there weren’t any sudden jerks there is a section of code that either increases or decreases the timer compare register.

let me know if you want to see the code I used to get this working. it did mean though that I pretty much had to re-write some libraries that I was using and could not use a stepper library.