Shop OBEX P1 Docs P2 Docs Learn Events
bs2: fastest way to accurately send pulses — Parallax Forums

bs2: fastest way to accurately send pulses

RGuyserRGuyser Posts: 90
edited 2006-06-04 01:13 in BASIC Stamp
ello!

for this project i am doing i need to send pulses very quickly, the simplistic method i have been using seems to be limited.

spI VAR word

spI=3200 'set steps per inch to 3200

FOR x = 1 TO inches
FOR xstep= 1 TO spI

HIGH stepper1
PAUSE 1
LOW stepper1
PAUSE 1
NEXT
NEXT

i do this because the numbers(spI) i am using easily exceed the limit. inches is a multiplier for SPI. i am pretty sure the 'pulsout' command may be faster, but how do i get it to send an accurate number of pulses?

Thanks!

Comments

  • FranklinFranklin Posts: 4,747
    edited 2006-06-03 17:06
    How quickly is "quickly"?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • RGuyserRGuyser Posts: 90
    edited 2006-06-03 21:48
    'as quick as possible?'

    without a scope or other equipment to measure thee current rate, i have no idea what would be correct, unfortunately.. but, roughly 4-8 times faster would be fine...i suppose i should do an experiement with just pulsout and how fast it can pulse... the stepper driver circuitry probably wont work after pulses get either too close together, or too short...
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2006-06-04 01:13
    The cycle would be faster if you leave out the PAUSEs. As it is, you have a HIGH pulse about 1.14 milliseconds long followed by a low period of about 1.9 milliseconds in the inner loop. If you take out the pauses, it will be faster at HIGH 0.14 millisecond and LOW 0.9 millisecond. (On original Stamp BS2) Those are ballpark estimates based on 140 microseconds for LOW and HIGH and 750 microseconds for the FOR:NEXT processing.

    With PULSOUT you could trim off a little, here to HIGH 1 millisecond and low about 1.1 millisecond:

    FOR xstep= 1 TO spI
    PULSOUT stepper1,500 ' 500 for 1 millisecond on original BS2
    NEXT

    There are tricks you can do to get faster sequences of pulses, by using the PWM or the SHIFTOUT commands, but with those the pulse widths might be too short. For example the following command generates 73 pulses in a lttle over 1 millisecond:
    PWM stepper1,73,1
    but each HIGH pulse is only 4.5 microseconds long.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
Sign In or Register to comment.