In SX Microcontrollers, SX/B Compiler and SX-Key Tool, ringlord wrote: All-- An SX running at 20mhz controlling a Parallax HB-25 motor controller will successfully use numbers representing PULSOUT pulse widths in the range of 80 to 220. This range, as with any microcontroller driving an HB-25, is split into two parts. I have arbitrarily named the first part "reverse" and the second part "forward." I imagine others do, as well. Forward is that part of the 80 - 220 range from 150 to 220, with 150 representing "stop" and 220 representing full speed in the forward direction. Reverse is that part of the 80 - 220 range from 150 to 80, with 150 representing "stop" and 80 representing full speed in the reverse direction. Here is some sample code written for an SX48 operating at 20mhz controlling an HB-25 . . . ' This program is an example of using [b]Robert Doerr's[/b] SX48 Module to control a Parallax HB-25 motor controller. ' The program employs vital pulse widths in the PULSOUT statements derived from [b]JonnyMac's[/b] suggestions. ' This program is written strictly for clarity and makes no use of advanced programming techniques that may ' make it both far faster and smaller. Device SX48, OSCHS1 Freq 20_000_000 ' This SX48 has a 20mhz resonator. LED Pin RB.3 HB25 Pin RB.4 ' HB-25 control pin. Twelve_vdc Pin RE.7 ' SSR power pin. idx Var Byte ' Loop index variable. Program Start Output HB25 ' Make the SX pin dedicated to the HB25 write pin an output. Low HB25 ' Make the HB25 write pin low. Start: High Twelve_vdc Pause 1000 ' Wait for the HB-25 to power up . . . DO LOOP UNTIL HB25 = 1 LOW HB25 ' Make I/O Pins Output/Low. Pause 20 ' Wait For HB-25 to Initialize. Pulsout HB25, 150 ' Stop the motor. (750 works on a BS2. What works on a 20mhz SX48?) Pause 500 ' Convenient pause . . . It could be eliminated. For idx = 150 to 80 step -1 ' Ramp up using a pulse width of 150 (stop) to 80 (maximum reverse). Pulsout HB25, idx Pause 20 ' Conventional pause to allow the HB25 to "settle." Pause 50 ' Arbitrarily chosen additional Pause For slower ramping purposes (they could have been combined). Next For idx = 80 to 150 ' Ramp down using a pulse width of 80 (maximum reverse) to 150 (stop). Pulsout HB25, idx Pause 20 Pause 50 Next Pulsout HB25, 150 ' Stop the motor. (A pulse width of 150 will stop the motor.) Pause 20 For idx = 150 to 220 ' Ramp up using a pulse width of 150 (stop) to 220 (maximum Forward). Pulsout HB25, idx Pause 20 Pause 50 Next For idx = 220 to 150 step -1 ' Ramp down using a pulse width of 220 (maximum Forward) to 150 (stop). Pulsout HB25, idx Pause 20 Pause 50 Next Pulsout HB25, 150 ' Stop the motor. (A pulse width of 150 will stop the motor.) Pause 20 Low Twelve_vdc ' Shut off the 12vdc system by turning off the solid state relay. END --Bill ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=335549#m335715 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)