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

'-----------------------------pwm1mc7mtr.bs2-----------------------------

' written by Carl A. Kollar

'Purpose: To demonstrate the control by BS2 of the MC7 motor

' controller described on this web site. Can be used with

' either 12 or 24 volt models.

'

'Motor action: The motor (1) Gradually increases in speed in the forward

' direction until it reaches full speed. (2) Gradually

' reduces speed until it stops. (3) Gradually increases speed

' in the reverse direction until it reaches full rev. speed

' (4) Gradually decreases speed until it comes to a stop.

' (5) Does it all over again.

'---------------------Define Constants & Variables-------------------------

enable_port con 0: low enable_port 'disable MC7 while initializing

pwm_out_port con 1

fwd_port con 2

rev_port con 3

duty var byte

cycles var byte: cycles = 10

min_speed var byte: min_speed = 52 'pwm value for 1.0V out

max_speed var byte: max_speed = 165 'pwm value for 3.2V out

x var byte: x = 0 'counter variable

pause_time var word: pause_time = 15 'pause between counter increments

max_speed_time var byte: max_speed_time = 150

'------------------------Initialize----------------------------------------

low fwd_port 'Put MC7 in "neutral" by making both direction ports low

low rev_port

high enable_port 'enable the controller

'----------------------------The Main Program-----------------------------

' (All sub-routine names are self-explanatory)

main:

gosub set_forward_direction

gosub min_to_max

gosub max_to_min

gosub set_reverse_direction

gosub min_to_max

gosub max_to_min

goto main

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

'Bring motor speed gradually from a stop to full speed

min_to_max:

for x = min_speed to max_speed 'gradually increase speed

pwm pwm_out_port,x,cycles

pause pause_time 'wait specified time

next

for x = 1 to max_speed_time 'stay at max. speed for awhile

pwm pwm_out_port,max_speed,cycles

next

return

'-------------------------------------------------------------------------

'Bring motor speed gradually to a stop from full speed

max_to_min:

for x = max_speed to min_speed 'gradually decrease speed

pwm pwm_out_port,x,cycles

pause pause_time 'wait specified time

next

return

'------------------------------------------------------------------------

set_forward_direction:

high fwd_port 'enable forward

low rev_port 'reverse not enabled

return

'-------------------------------------------------------------------------

set_reverse_direction:

low fwd_port 'forward not enabled

high rev_port 'enable reverse

return

Download this sample program.

Pinout Table

Analog Control Connection Diagram
Digital Control Connection Diagram
Digital Control Connection Diagram for BS2
Digital Control Connection Diagram for PIC16F84

To see spec sheets and connection diagrams on the MC7 in .pdf format, click HERE

Sample programs- BS2 control of an MC7 controller (in Stamp2 basic)

Sample programs- PIC16F84 control of an MC7 controller
(in PicBasic, hex, assembler & machine language)

Home

Motor Controllers

Battery Chargers

Interface Circuits

Radio Controlled Devices

My Robot Page