Radio Control Speed Controler Help

I have built a speed controler board using an 08M Picaxe chip and the Program bellow

symbol DEAD_BAND = 3
symbol REVERSE_DEAD_ZONE = 150 + DEAD_BAND
symbol FORWARD_DEAD_ZONE = 150 - DEAD_BAND
symbol MOTOR_OUT = 2
symbol RELAY = 1
symbol TIME_PERIOD = 40 'do pwm in the input pwm space period (18ms)




start:

w2 = 0
pulsin 3,1,w0 'working range 58-250 with 150 being equivalent to a 1.5ms PWM input
if w0 = 0 then start
if w0 >= 153 then REV '60 - 250
if w0 <= 147 then FWD '58 - 140
goto start

FWD:
LOW RELAY 'reverse relay on
w2 = 147 - w0 'proportional magnitude value
w3 = w2 * TIME_PERIOD 'ime period as a proportion of control input
pulsout 2,w3
goto start



REV:
HIGH RELAY 'reverse relay off
w2 = w0-153 'proportional magnitude value
w3 = w2 * TIME_PERIOD 'time period as a proportion of control input
pulsout 2,w3
goto start


Not my program buy the way.. I am getting some odd thinks happen
1. When i move my stick from centre to th forward possion the motor will speed up and as i get to the full forward position the motor will start to decreese speed. only get full (ISH) speed at 3/4 position????????????????
2. When starting the motor under a slight load the botor will just vibrate / buzz will not move ????????

Any help will be welcome

Regards Andy Quirot
 

manuka

Senior Member
Please supply details of your motor & power supply-a schematic & layout picture will also assist.
 

goom

Senior Member
I did not examine your code in detail, but I would suggest that a PWM output is appropriate rather than the PULSOUT command. Here is some code for a -08M which does work. It uses a latching reversing relay, but would be simple enough to adapt to a non-latching type.
For low current applications <1A), directly driving a logic level MOSFET works OK, but a MOSFET driver is definitely preferred, and essential for higher currents (due to gate capacitance, switching frequency, linear MOSFET operation and all that jazz discussed many times on this forum).

Code:
'Reversing motor speed control using latching relay for reverse
'Kevin Goom, 15 August 2006
'PICAXE-08M connections are:
' Leg 1                   +5V
' Leg 2 (Serial in)       Tie to Ground through 10K resistor
' Leg 3  (In4/Out4)        Pulse input from radio receiver
' Leg 4  (In3)             NC
' Leg 5 (In2/Out2)    PWM to motor (via 500 ohm resistor and IRF530 MOSFET)
' Leg 6 (In1/Out1)    Output to latching relay for forward operation (via ULN2003)        
' Leg 7 (Out0/Serial Out) Output to latching relay for reverse operation (via ULN2003)
' Leg 8                   Ground
symbol PW_null=w2  'Name the null position input pulse width
symbol PWin=w1   'Name the input pulse width
symbol Duty=w0   'Name the duty cycle
symbol Hysteresis=b6 'Name the amount of hysteresis
symbol Dir=b7   'Name the direction flag (0 = forward, 1=reverse)
Hysteresis=3   'Set hysteresis
Dir=0    'Set direction flag to forward initially
low 0    'Initial state of output to reverse of latching relay
low 1    'Initial state of output to forward of latching relay
pulsout 1,10000  'Set latching relay to forward with 0.1 sec pulse
       
initialise:
   pwmout 2,255,0     'Make sure motor is off initially
   Pause 500      'Wait 1/2 second initially
   pulsin 4,1,PW_Null    'Measure the input pulse width initially (null position)
   if PW_Null<135 or PW_Null>165 then initialise'Go back if no valid null input detected
restart:
   pwmout 2,255,0     'Stop PWM signal to motor on signal loss
   pulsin 4,1,PWin     'Measure the input pulse width initially (null position)
   if PWin<75 or PWin>225 then restart 'Go back if no valid input detected
recheck:
   pulsin 4,1,PWin     'Measure the input pulse width
   if PWIn<75 or PWin>225 then restart 'Go back if no valid input detected
   if PWin > PW_Null then forward_  'Check for forward rotation
reverse_:
   Duty=PW_Null-PWin
   if Duty<hysteresis then stop_  'Stop motor if input within deadband 
 if Dir=1 then ContR
  pwmout 2,255,0    'Stop PWM signal to motor
  Pause 500     'Pause for 1/2 second on changing forward to reverse
    pulsout 0,10000      'Set latching relay to reverse with 0.1 sec pulse
   ContR:
 Dir=1      'Set the direction flag to reverse
   Duty=Duty*26 max 1020    'Set duty cycle from 0 to 1023
   pwmout 2,255,Duty    'Send PWM signal to motor
   goto recheck     'Return to measure input pulse
forward_:
   Duty=PWin-PW_Null
   if Duty<hysteresis then stop_  'Stop motor if input within deadband
 if Dir=0 then ContF
  pwmout 2,255,0    'Stop PWM signal to motor
  Pause 500     'Pause for 1/2 second on changing reverse to forward
    pulsout 1,10000    'Set latching relay to forward with 0.1 sec pulse
   ContF:
 Dir=0      'Set the direction flag to forward
   Duty=Duty*26 max 1020    'Set duty cycle from 0 to 1023
   pwmout 2,255,Duty    'Send PWM signal to motor
   goto recheck     'Return to measure input pulse
stop_:
   pwmout 2,255,0     'Stop PWM signal to motor
   goto recheck     'Return to measure input pulse
 
Top