Pin glitch when cog stops.
wch7693
Posts: 4
Hello all,
I am interfacing the Propeller to a stepper motor driver circuit implementing the L297 stepper motor controller. The L297 has a direction and step input, and generates the proper bit output sequence to drive an H-Bridge or whatever you're using to drive the stepper motor. I have developed a routine called RunMotor that sends the appropriate amount of pulses to the L297 to move it a specific number of steps at a given rotational speed. This routine works great, but when I put it in a separate cog to run it in the background, something happens on the direction and step pins when the routine ends and the cog stops that makes the motor go an additional unwanted step. I have verified that it happens at cog shutdown by putting a one second delay right before the routine ends, and the motor will move the correct amount of steps, wait a second, and then go an additional step.
So, my question is, is there a way to make a cog shut down such that when pins are low at the end of the routine, they stay low through shutdown and do not glitch?
Thanks,
Bill H.
I am interfacing the Propeller to a stepper motor driver circuit implementing the L297 stepper motor controller. The L297 has a direction and step input, and generates the proper bit output sequence to drive an H-Bridge or whatever you're using to drive the stepper motor. I have developed a routine called RunMotor that sends the appropriate amount of pulses to the L297 to move it a specific number of steps at a given rotational speed. This routine works great, but when I put it in a separate cog to run it in the background, something happens on the direction and step pins when the routine ends and the cog stops that makes the motor go an additional unwanted step. I have verified that it happens at cog shutdown by putting a one second delay right before the routine ends, and the motor will move the correct amount of steps, wait a second, and then go an additional step.
So, my question is, is there a way to make a cog shut down such that when pins are low at the end of the routine, they stay low through shutdown and do not glitch?
Thanks,
Bill H.
Comments
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Just a few PropSTICK Kit bare PCBs left!
Thanks alot for your fast responses!
Your idea will work. However, it's not necessary for the cog that's terminating to do anything. DIRA is set to 0 automatically upon stopping.
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Just a few PropSTICK Kit bare PCBs left!
The key to Rayman's proposal is to set DIRA to 1 and OUTA to 0 from a cog that remains alive. The cog that starts the L297 cog may, itself, terminate, rendering such settings impotent. OTOH, if the starting cog is the top-level cog, and it subsequently sets DIRA to some other value for another purpose, the prior setting will be lost. His idea will work. It just has to be implemented correctly.
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Just a few PropSTICK Kit bare PCBs left!