T Chap
10-10-2006, 11:57 AM
Over the past week I built a 3 axis cnc 6 wire uni stepper controller using one Propeller. I have borrowed code from here and there and have things really close to what I want for the basics of this stepper motor driver. There is one thing I cannot solve after many hours of experimenting.
There is a waitpne for A Step pin to go high, then it checks for the direction and calls a routine to move the motor either forward or backward one step, updating an index each iteration depending on direction. That part works great. Wherever the last index seqeunce was is what the motor stays at indefinitely, i.e. %1010 keeps coil 1A high and 2A high, so the motor is on constantly whether braked or moving when stepped. I want to cause the motor to not brake after X ms, for example, a repeating code block checks to see if the motor has moved, and times how long it has not moved. If it has not moved for X ms, change the outputs to %0000, so no more braking plus pwm noise. The motor is running from a cog, and I can send the motor random sequences from another cog as well that clearly disturbs the motor, so I know that it is getting the info. The problem is, I cannot cause the motor to reset to %0000 after any amount of time by checking for movement, pausing, sending 0000 to reset. The code to run the motor does not repeat, it is one iteration per step. Why is it that it still has some affect on the motor although it is not repeating a position sequence? My guess is, that even though one cog can send an outout state of %xxxx, any other cog sending its own state to the same pins does not negate the state that is held by any other cog, so they battle it out between clock cycles. Ok assuming that is correct, I attempted to put some lines at the end of each move iteration that said that if a variable was X, send out %0000, The problem there was getting some variable to interact in the very short time between the top of the move iteration and the end query of the variable to release it
Pub Start
repeat
outa[24..27] := %0000 ' does not affect the cog that has the motor pins at any state whether braked or moving
IF pauseMotor == 1 ' at the end of each move iteration, doesn't work
outa[24..27] := %0000
The work in progress is attached, if anyone can suggest a method that would allow me to test for a move, if no more movement for x time, turn off motor WITHOUT affect the index, that would be very helpful. What I intend to do is have the encoder always checking itself against the step count, so even if stopped with no holding torque, the motor can position itself back to where it should be if it moves out. On the cnc the current limiting noise is no big deal, but on other applications I have to kill the noise somehow. There are no more pins to mult to AND gates to control things externally, so this has to happen in code.
Thanks in advance
Post Edited (originator99) : 10/10/2006 5:16:44 AM GMT
There is a waitpne for A Step pin to go high, then it checks for the direction and calls a routine to move the motor either forward or backward one step, updating an index each iteration depending on direction. That part works great. Wherever the last index seqeunce was is what the motor stays at indefinitely, i.e. %1010 keeps coil 1A high and 2A high, so the motor is on constantly whether braked or moving when stepped. I want to cause the motor to not brake after X ms, for example, a repeating code block checks to see if the motor has moved, and times how long it has not moved. If it has not moved for X ms, change the outputs to %0000, so no more braking plus pwm noise. The motor is running from a cog, and I can send the motor random sequences from another cog as well that clearly disturbs the motor, so I know that it is getting the info. The problem is, I cannot cause the motor to reset to %0000 after any amount of time by checking for movement, pausing, sending 0000 to reset. The code to run the motor does not repeat, it is one iteration per step. Why is it that it still has some affect on the motor although it is not repeating a position sequence? My guess is, that even though one cog can send an outout state of %xxxx, any other cog sending its own state to the same pins does not negate the state that is held by any other cog, so they battle it out between clock cycles. Ok assuming that is correct, I attempted to put some lines at the end of each move iteration that said that if a variable was X, send out %0000, The problem there was getting some variable to interact in the very short time between the top of the move iteration and the end query of the variable to release it
Pub Start
repeat
outa[24..27] := %0000 ' does not affect the cog that has the motor pins at any state whether braked or moving
IF pauseMotor == 1 ' at the end of each move iteration, doesn't work
outa[24..27] := %0000
The work in progress is attached, if anyone can suggest a method that would allow me to test for a move, if no more movement for x time, turn off motor WITHOUT affect the index, that would be very helpful. What I intend to do is have the encoder always checking itself against the step count, so even if stopped with no holding torque, the motor can position itself back to where it should be if it moves out. On the cnc the current limiting noise is no big deal, but on other applications I have to kill the noise somehow. There are no more pins to mult to AND gates to control things externally, so this has to happen in code.
Thanks in advance
Post Edited (originator99) : 10/10/2006 5:16:44 AM GMT