Shop OBEX P1 Docs P2 Docs Learn Events
Accurate Stepper Motor Timing — Parallax Forums

Accurate Stepper Motor Timing

gtslabsgtslabs Posts: 40
edited 2007-06-21 18:57 in BASIC Stamp
I have a stepper driver for a Nema 23 motor. I need it to step at a very accurate rate of 1% but very slow around 1 pulse per second or slower. I need to send it step and directions at specific intervals but over long periods of time - up to 6 days.· Using a pause would introduce error in the timing.·

I was reading the propeller thread and came across them talking about a similar issue.
The propeller has some built in functions show here: http://forums.parallax.com/attachment.php?attachmentid=47508

Can the BS2 also use a similar approach? Is there any example equivalent code?

Thanks in advance
Steve

Comments

  • metron9metron9 Posts: 1,100
    edited 2007-06-15 05:09
    You can't keep accurate time inside the BS2 but you can read an accurate time from an external chip.

    http://www.parallax.com/detail.asp?product_id=604-00005

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-06-15 05:51
    If all the BASIC Stamp has to do is perform the stepping, it should be able to do this on its own. Its timing is based on a ceramic resonator, which has at least the 1% accuracy you require. You can use a PAUSE to do the timing as long as you compensate for the overhead introduced by the other statements in the loop. It will take some experimenting to get it just right. This does get complicated, though, if the Stamp has to be doing other tasks in between steps. Then (but only then), an external time-keeper would be essential.

    -Phil
  • gtslabsgtslabs Posts: 40
    edited 2007-06-15 13:26
    So with the DS1302 I assume I would have to continually poll it looking for the next second. Will it return fractional seconds?
  • metron9metron9 Posts: 1,100
    edited 2007-06-15 14:09
    No, it keeps time on its own. You just read the seconds, minutes, hours, days and years information into the stamp. I don't know the crystal specs off hand but they are similar to the average wristwatch because it is a watch crystal.

    Over time it will have a certain amount of drift perhaps a few seconds slow or fast each month for example. Your question though is a little more complicated to explain. If I tell you its 10 seconds after 12:00 noon and you look at the clock and say no its 12 seconds after 12:00 noon we are both wrong because it is now 15 seconds after 12:00 noon.

    The same logic applies to microprocessors. Since you have a clock that runs a certain number of instructions per seconds that puts a limit on the resolution you have to work with. I think the DS1302 has a 1 second resolution for OUTPUT. When you read the value for example, if you could read it 1/4 second after it changes from a 1 to a 2 then you would be 1/4 second off from the real time. If you read it just before it turned say a milisecond before it changed from 1 to 2 then you would be 999 milliseconds off. But that is not cumulative so the next reading you take could be within 1 millisecond. I guess if you poll it for a change the most you would be off is the time it takes to actually read the data.

    You need to define your time criteria a bit more and your stepper output resolution over the time period you wish to operate the device.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • nowhohanowhoha Posts: 4
    edited 2007-06-21 18:57
    Could the GPS module provide a more accurate time base?
Sign In or Register to comment.