I have an Uno R3 running into a Pololu TIC 249 to control a NEMA 11 stepper motor. I am only moving it a small amount with variable speed from a pot.
My question is: I can run the TIC by itself and can get all kinds of speed from the stepper. When I connect the Uno up to it I cannot get any speed, and if I set the value too low the motor won't start like it did with the TIC stand alone. With the TIC by itself I could go really fast and it never stalled when starting.
Is my code not working right? This has me baffled.
int steppin = 12;
int dirpin = 11;
int stepdelay;
const int stepPin = 12;
const int dirPin = 11;
void setup() {
// put your setup code here, to run once:
pinMode(steppin,OUTPUT);
pinMode(dirpin,OUTPUT);
digitalWrite(dirpin,HIGH); // direction pin either HIGH or LOW to move in either direction
}
void loop() {
// put your main code here, to run repeatedly:
int val = analogRead(A0);
stepdelay = map(val,0,1023,900,200);
digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
for(int x = 0; x < 5375; x++) {
digitalWrite(steppin,HIGH);
delayMicroseconds(stepdelay);
digitalWrite(steppin,LOW);
delayMicroseconds(stepdelay);
}
digitalWrite(dirPin,LOW); //Changes the direction of rotation
for(int x = 0; x < 5450; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(stepdelay);
digitalWrite(stepPin,LOW);
delayMicroseconds(stepdelay);
}
}
AccelStepper will help with the acceleration, but the 50,000 steps/sec the TIC advertises outclasses the 4000 steps/sec top speed AccelStepper advertises:
You could of course let the TIC do the stepping, and just control it via any of the high-level interfaces.
That way, you’re not bothered whether your code is fast enough.
Sounds interesting @lastchancename , so, I am a noob, tell me more please!
Just yesterday I have run onto the TIC Ardunio Stepper Motor Control Library and it looks interesting. I haven't gotten into it yet but it appears that it can do the commands that the TIC Control Center software does but from Ardunio.