A little Stepping motor Help
Zap-o
Posts: 452
A little Stepping motor Help is needed.
I am running the code below and it works great. it basically runs 2 times in the repeat loop (Full Step). The idea is that I will store the byte array "StepArray" in eeprom for dynamic reasons. Now instead of running 2 times I want to run it once so that I can half step. My problem is that I cant get a bit pattern "StepArray" that works for 1/2 stepping.
Any ideas ?
I am running the code below and it works great. it basically runs 2 times in the repeat loop (Full Step). The idea is that I will store the byte array "StepArray" in eeprom for dynamic reasons. Now instead of running 2 times I want to run it once so that I can half step. My problem is that I cant get a bit pattern "StepArray" that works for 1/2 stepping.
Any ideas ?
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 StepMotor1 = 9 'A- StepMotor2 = 10 'B- StepMotor3 = 11 'B+ StepMotor4 = 12 'A+ VAR Byte StepArray [noparse][[/noparse] 8 ] Pub Start Dira [noparse][[/noparse] StepMotor1..StepMotor4 ]~~ StepArray [noparse][[/noparse] 0 ] := %1010 ' StepArray [noparse][[/noparse] 1 ] := %0110 StepArray [noparse][[/noparse] 2 ] := %1001 StepArray [noparse][[/noparse] 3 ] := %0101 StepArray [noparse][[/noparse] 4 ] := %1010 ' same as above in full step mode StepArray [noparse][[/noparse] 5 ] := %0110 ' same as above in full step mode StepArray [noparse][[/noparse] 6 ] := %1001 ' same as above in full step mode StepArray [noparse][[/noparse] 7 ] := %0101 ' same as above in full step mode Running(200) Pub Running(Speed) Repeat outa [noparse][[/noparse] StepMotor1..StepMotor4 ] := StepArray [noparse][[/noparse] 0 ] pauseMs(Speed) outa [noparse][[/noparse] StepMotor1..StepMotor4 ] := StepArray [noparse][[/noparse] 1 ] pauseMs(Speed) outa [noparse][[/noparse] StepMotor1..StepMotor4 ] := StepArray [noparse][[/noparse] 2 ] pauseMs(Speed) outa [noparse][[/noparse] StepMotor1..StepMotor4 ] := StepArray [noparse][[/noparse] 3 ] pauseMs(Speed) outa [noparse][[/noparse] StepMotor1..StepMotor4 ] := StepArray [noparse][[/noparse] 4 ] pauseMs(Speed) outa [noparse][[/noparse] StepMotor1..StepMotor4 ] := StepArray [noparse][[/noparse] 5 ] pauseMs(Speed) outa [noparse][[/noparse] StepMotor1..StepMotor4 ] := StepArray [noparse][[/noparse] 6 ] pauseMs(Speed) outa [noparse][[/noparse] StepMotor1..StepMotor4 ] := StepArray [noparse][[/noparse] 7 ] pauseMs(Speed) Pub pauseMs(Delay) waitcnt((clkfreq / 10_000) * Delay + cnt)
Comments
You can easily move a block of 12 bytes from the EEPROM into the table (@FullSteps) to change the table for a given motor.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA
Problem is that using data in the DAT section makes my code not update-able. I like to store most variables in the 12c EEprom. This allows my firmware to be updated sort of like Microsoft will do with windows.
What I am after is a pattern of %1s and %0s to half step that is derived from the code above that I posted. I have the full step working with said code its trying to do half stepping.
---
Another way of asking...
If I can full step using this
How can I half step?
Post Edited (Zap-o) : 5/21/2010 6:47:37 PM GMT
Perhaps you don't understand the full-step/half-step thing. Full steps engage two coils, half steps engage just one. I've never seen any stepper code that used the full-step table for half steps. Even if you could come up with an algorithmic solution, chances are that it would be far less elegant (and maintainable) than a two-table solution.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA
Yea I am a bit lost on the half step concept. Mainly because a stepper motor can be wired up several ways hence my desire to keep my program flexible at run time. I have a solution that allows me to update my code while the propeller is running and store this update permanently in EEprom. This allows the customer or me to tweak all settings versus me sending them a firmware upgrade - sort of like plug and play. The example code I posted above is just an example for simplicity. True its not elegant [noparse]:)[/noparse]
I appreciate the explanation of full step vs. half step. I think I am understanding the concept clearer.
I'm not sure what you mean "wired up several ways" -- for correct motion you need to wire the coils in the correct order. I seems like you're trying to add flexibility to your code so you can allow the coils to be wired willy-nilly; do you really want to do that?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA
http://www.rayslogic.com/propeller/Programming/Stepper/Stepper1.zip
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm
Yea I don't want to "willy nilly" the coils but you never know what a customer is going to do and once the motor is installed its a night mare to un-hook everything. I work with grad students and as smart as some are I am always amazed at how the small things hang them up.
Rayman,
Ill look over the code example
Gents - thanks for the help
For further reference I wrote about controlling steppers in my column a few years ago:
-- www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol7/col/NV136.pdf
This shows how to write a Spin method that you can launch into its own cog, letting it run "in the background" while your main program does other things.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA
halfstep switches on one coil A then two coil A and coil B then switches off coil A etc. you would store this pattern in an array
and for fullstepmode you would not use
index 1 coil A on B off
index 2 coil A and B on
index 3 coil A off B on
but
index 1 coil A on B off jump over index 2 right to
index 3 coil A off B on
anyway
you said something you don't want to use the DAT-section
Whenever you store a program to the EEPROM EVERYTHING of your code gets stored in the EEPROM including all DAT-sections
now if you are worried about the adresses you could store your values at the upperend of the RAM/EEPROM
the "ultrahyper-felxible" solution that allows your customers to wire whatever they want has its price by having more hardware with autodetecting everything wiring uni/bipolar number of coils etc. etc.
set a limit to the flexibility and describe it very well in the manual. If you write an EASY to understand manual your customers will be very happy and follow and obey your restrictions described in the manual.
(most manuals are written very fast and are more a repetitorium to the author than a manual you can learn from)
How about a hardware that allows halfstepping and can be switched by software to fullstepping?
best regards
Stefan
Even if wired incorrectly, you can get there without know the details of the motor; the process is explained here:
-- digital.ni.com/public.nsf/allkb/0AEE7B9AD4B3E04186256ACE005D833B
And my memory tells me to do this if the motor doesn't move or just vibrates/buzzes:
A) Swap outer leads -- if that doesn't work, then...
Swap inner leads -- if motor runs backward then...
C) Flip all
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA