border
topbkg
americanflag2_z
Orders
Email Us
Contact Info
Return Policy
mc ivsa

Diverse Electronic Services

Home

Motor Controllers

Battery Chargers

Interface Circuits

Radio Controlled Devices

My Robot Page

Sample Program showing how to Control 1 Motor With an H-Bridge motor Controller and a Basic Stamp 2

 

'-----------------------------pwm1mtr.bs2-----------------------------
' written by Carl A. Kollar
'Purpose: To demonstrate the control by BS2 of the 24 volt motor
' controller described on this web page.
'
'Motor action: The motor initially remains in neutral for a few seconds.Then it:
' (1) Gradually increases in speed in the forward direction until
' it reaches full speed.
' (2) Gradually reduces speed until it stops.
' (3) Waits in neutral for awhile.
' (4) Gradually increases speed in the reverse direction
' until it reaches full reverse speed.
' (5) Gradually decreases speed until it comes to a stop.
' (6) Does it all over again.

'---------------------Define Constants & Variables-------------------------
pwmpin1 con 1
duty var byte
cycles var byte: cycles = 100
neutral var byte: neutral = 190 'pwm value for 3.0V out
full_fwd var byte: full_fwd = 217 'pwm value for 3.5V out
full_rev var byte: full_rev = 163 'pwm value for 2.5V out
x var byte: x = 0 'counter variable
pause_time var word: pause_time = 250 'pause between counter increments

'----------------------------Preliminary stuff----------------------------
pwm pwmpin1,neutral,cycles 'bring voltage up to 3.0V (neutral)
high 0 'turn on relay to apply 24V to SW lead

'----------------------------The Main Program-----------------------------
' (All sub-routine names are self-explanatory
main:
gosub neutral_stop
gosub neutral_to_forward
gosub forward_to_neutral
gosub neutral_stop
gosub neutral_to_reverse
gosub reverse_to_neutral
goto main

'***************************Sub-Routines**********************************

'Wait in neutral for awhile while keeping pwm going to maintain 2.5V
neutral_stop:
for x = 1 to 5
' debug ?x
pwm pwmpin1,neutral,cycles 'keep voltage at 3.0V (neutral)
next
return
'-------------------------------------------------------------------------

'Bring motor speed gradually to full forward
neutral_to_forward:
for x = neutral to full_fwd
' ?x
pwm pwmpin1,x,cycles
pause pause_time
next
return
'-------------------------------------------------------------------------

'Bring motor speed gradually to a stop from full forward
forward_to_neutral:
for x = full_fwd to neutral
' debug ?x
pwm pwmpin1,x,cycles
pause pause_time
next
return
'-------------------------------------------------------------------------

'Bring motor speed gradually to full reverse
neutral_to_reverse:
for x = neutral to full_rev
' debug ?x
pwm pwmpin1,x,cycles
pause pause_time
next
return
'-------------------------------------------------------------------------

'Bring motor speed gradually to a stop from full reverse
reverse_to_neutral:
for x = full_rev to neutral
' debug ?x
pwm pwmpin1,x,cycles
pause pause_time
next
return

Schematics

Model MCIPC-24 Motor Controller Connection Diagram

Schematic - Joystick/MCIPC-24 Controller

Schematic - Connecting A BS2
 to 1 Motor Controller

Schematic - Connecting A BS2
to 2 Motor Controllers

Sample Programs

Sample Program to Control 1 Motor with a BS2 and 1 MCIPC Controller

Sample Program to Control 2 Motors with a BS2 and 2 MCIPC Controllers

Sample Program To Control 2 Motors with a BS2, MCIPC-24 & Joystick

 

Notes & Views

MCIPC-24 Motor Control Notes

MCIPC-24 Motor Control Specs

Home

Motor Controllers

Battery Chargers

Interface Circuits

Radio Controlled Devices

My Robot Page