Pwmpal
shank_blue
Posts: 1
Can a pwmpal generate a 50% duty cycle waveform. i am using a bs2p. i am wanting to generate a pulse with 5.2ms ontime and 5.2ms offtime.Attached is my code. but the pwmpal does not seem to output aything.
' =========================================================================
'
' File....... PWM_Simple_Motor.BS2
' Purpose.... Simple DC motor control
' Author..... Parallax
' E-mail..... support@parallax.com
' Started....
' Updated.... 29 JUL 2004
'
' {$STAMP BS2p}
' {$PBASIC 2.5}
'
' =========================================================================
'
[noparse][[/noparse] Program Description ]
' Demonstrates simple DC motor control with the PWMPAL.
' NOTE: Do NOT connect a DC motor directly to the PWMPAL / Stamp. You
' must use a buffer (transistor, MOSFET, etc.) to switch the current
' required by the motor.
'
[noparse][[/noparse] Revision History ]
'
[noparse][[/noparse] I/O Definitions ]
PpPin PIN 0 ' PWMPAL Serial I/O
SpdCtrl PIN 8 ' speed button
'
[noparse][[/noparse] Constants ]
#SELECT $stamp
#CASE BS2, BS2E, BS2PE
T9600 CON 84
T19K2 CON 32
T38K4 CON 6
#CASE BS2SX, BS2P
T9600 CON 240
T19K2 CON 110
T38K4 CON 45
#CASE BS2PX
T9600 CON 396
T19K2 CON 188
T38K4 CON 84
#ENDSELECT
PpBaud CON T9600
MotorNum CON 1 ' PWMPAL motor output
Yes CON 1 ' for active-high
MinSpeed CON 25 ' minimum DC to spin motor
'
[noparse][[/noparse] Variables ]
speed VAR Byte ' speed, 0% to 100%
status VAR Byte ' motor control status
onTime VAR Word ' PWM timing
offTime VAR Word
'
[noparse][[/noparse] EEPROM Data ]
'
[noparse][[/noparse] Initialization ]
Setup:
SEROUT PpPin, PpBaud, [noparse][[/noparse]"!PWMSS", %00010000]
'
[noparse][[/noparse] Program Code ]
Main:
SEROUT PpPin, PpBaud, [noparse][[/noparse]"!PWMM1",104,0,104,0]
GOTO Main
END
Any idea why it is doing this.
Thanks
' =========================================================================
'
' File....... PWM_Simple_Motor.BS2
' Purpose.... Simple DC motor control
' Author..... Parallax
' E-mail..... support@parallax.com
' Started....
' Updated.... 29 JUL 2004
'
' {$STAMP BS2p}
' {$PBASIC 2.5}
'
' =========================================================================
'
[noparse][[/noparse] Program Description ]
' Demonstrates simple DC motor control with the PWMPAL.
' NOTE: Do NOT connect a DC motor directly to the PWMPAL / Stamp. You
' must use a buffer (transistor, MOSFET, etc.) to switch the current
' required by the motor.
'
[noparse][[/noparse] Revision History ]
'
[noparse][[/noparse] I/O Definitions ]
PpPin PIN 0 ' PWMPAL Serial I/O
SpdCtrl PIN 8 ' speed button
'
[noparse][[/noparse] Constants ]
#SELECT $stamp
#CASE BS2, BS2E, BS2PE
T9600 CON 84
T19K2 CON 32
T38K4 CON 6
#CASE BS2SX, BS2P
T9600 CON 240
T19K2 CON 110
T38K4 CON 45
#CASE BS2PX
T9600 CON 396
T19K2 CON 188
T38K4 CON 84
#ENDSELECT
PpBaud CON T9600
MotorNum CON 1 ' PWMPAL motor output
Yes CON 1 ' for active-high
MinSpeed CON 25 ' minimum DC to spin motor
'
[noparse][[/noparse] Variables ]
speed VAR Byte ' speed, 0% to 100%
status VAR Byte ' motor control status
onTime VAR Word ' PWM timing
offTime VAR Word
'
[noparse][[/noparse] EEPROM Data ]
'
[noparse][[/noparse] Initialization ]
Setup:
SEROUT PpPin, PpBaud, [noparse][[/noparse]"!PWMSS", %00010000]
'
[noparse][[/noparse] Program Code ]
Main:
SEROUT PpPin, PpBaud, [noparse][[/noparse]"!PWMM1",104,0,104,0]
GOTO Main
END
Any idea why it is doing this.
Thanks
Comments
http://www.parallax.com/Store/Accessories/MotorServoControllers/tabid/160/CategoryID/35/List/0/Level/a/ProductID/67/Default.aspx?SortField=ProductName%2cProductName
The sample codes will support all of the BS2's.
Dave
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dave Andreae
Parallax Tech Support·