Hi everyone,
I've got a Little Problem with my stepper Controller Software.
Here's what I got:
PIC18F14K22 with 0-10V analog Input (divided down to 0-3.3V)
Stepper Motor is driven by an Trinamic TMC246.
The aim: translating the Input Signal 0-10V to different Motor Positions.
The stepper Motor in General works fine. The Problem is that i'm not quite sure what's the best way to scale the AD value (0-1023) to the steps of the Motor. The Motor is supposed to do exactly x number of steps when the Input is changed from 0V to 10V.
I calculate the number of steps like this:
new_pos = advalue * max_number_of_steps
Stepping to the new Position:
if(new_pos > cur_pos) {
do_step();
cur_pos += 1023;
}
if(new_pos < cur_pos) {
do_step();
cur_pos -= 1023;
}
This appears to work accurately, but since there is always a bit of difference between new_pos and cur_pos, the Motor keeps on moving back and forth. When I insert a threshold, inside the if-statements, it appears that i'm losing some steps along the way.
Any tip on this Topic would be really appreciated. I think i'm just missing something very obvious here...dang..already 10pm and i'm still in the Office and the bloody IE keeps Messing up my spelling.
Cheers
André