Gramps
Senior Member
Good Morning,
I'm attempting to drive a Cytron MD20A motor controller with the funny PWM coming from my RC receiver.
Online searching says:
"RC PWM is a pulse varying between 1 and 2ms, repeated approximately every 20ms (may be as short as 11ms or as long as 22ms)
Standard RC pulses are just a specialized form of PWM. A typical RC servo expects a signal every 20ms, however, this can vary from servo to servo. The pulse itself most often ranges from 1 ms to 2 ms, with 1.5 ms being the neutral position."
Question:
If the RC pulse width determines the direction of the motor, what determines the speed of the motor?
Is it the speed the pulses are sent?
This is the motor driver I want to use.
Project overview.
The motor controls the right and left movement of a steering axle on a robot Rover.
The brushed 10amp motor we're using was a Dewalt right angle drill in a former life.
There is a pot mounted on the steering axle that acts as a limit switch.
The inputs to the motor controller are standard PWM and a switch looking for either 5 volts to turn right or zero volts to turn left.
I'm assuming we should use a pulsin command to read the strange pwm signal from the RC receiver. Correct?
Several of you contributed to this code listed below.
Could it be adopted to this new input or would it be better to start over?
Thanks, Gramps
I'm attempting to drive a Cytron MD20A motor controller with the funny PWM coming from my RC receiver.
Online searching says:
"RC PWM is a pulse varying between 1 and 2ms, repeated approximately every 20ms (may be as short as 11ms or as long as 22ms)
Standard RC pulses are just a specialized form of PWM. A typical RC servo expects a signal every 20ms, however, this can vary from servo to servo. The pulse itself most often ranges from 1 ms to 2 ms, with 1.5 ms being the neutral position."
Question:
If the RC pulse width determines the direction of the motor, what determines the speed of the motor?
Is it the speed the pulses are sent?
This is the motor driver I want to use.
PN00218-CYT7 Cytron 20A 6-30V DC Motor Driver MD20A
Makermotor provides variable speed gear motors and single speed motors for applications such as bbq rotissier motor, experimental motor for lab, conveyor motor system, and welding turn table. Our products cover speed range from low speed gear motors to high rpm variable speed motors.
makermotor.com
Project overview.
The motor controls the right and left movement of a steering axle on a robot Rover.
The brushed 10amp motor we're using was a Dewalt right angle drill in a former life.
There is a pot mounted on the steering axle that acts as a limit switch.
The inputs to the motor controller are standard PWM and a switch looking for either 5 volts to turn right or zero volts to turn left.
I'm assuming we should use a pulsin command to read the strange pwm signal from the RC receiver. Correct?
Several of you contributed to this code listed below.
Could it be adopted to this new input or would it be better to start over?
Thanks, Gramps
Code:
'Alan's cleaned up Shadow-Bot feedback control code / limits updated 11-14-20
'Note; working nice!
#picaxe 28x2
#no_data
#no_table
; The next line can reduce the PWM frequency ** NEW ** (Cannot put comments in #define lines)
#define pwmfreq PWMDIV16,
Symbol DEADZONE = 2 ; Switch motor off (Make as small as practical)
Symbol MotorSpeed = w4 ; (To replace the "300" in the present PWMOUT code)
Symbol LOOPGAIN = 33 ; i.e. MAXPWMVALUE / SLOWZONE (= 399 / 12)
Symbol PWMPERIOD = 199 ; Equivalent Max Duty Cycle is 799
Symbol desired_pot_value = b1
Symbol feedback_pot_value = b3
Symbol diff = b4
Symbol desired_pot = 13 'B.5
Symbol feedback_pot = 11 'B.4
Symbol MOTOR = B.0 ' Energize PWM
Symbol Direction = B.7
Symbol MAXPWMVALUE = 399 ; ** ONLY HALF OF THE AVAILABLE DRIVE VOLTAGE !
Symbol old_feedback_value= b5
Symbol old_desired_value= b6
Symbol ENDSTOP_A = 60 ; desired_pot MINimum value
Symbol ENDSTOP_C = 210 ; desired_pot MAXimum value
Symbol CREEP = 160 ; PWM value to run slowly * HIGH ENOUGH TO START
Main:
controlMotor1:
Readadc Desired_pot, desired_pot_value
Desired_pot_value = Desired_pot_value MIN ENDSTOP_A MAX ENDSTOP_C
pause 100
Readadc feedback_pot, feedback_pot_value
pause 100
If old_feedback_value<>feedback_pot_value or old_desired_value<> desired_pot_value then
old_feedback_value=feedback_pot_value
old_desired_value=desired_pot_value
sertxd("Desired/Feedback: ",#desired_pot_value," ",#feedback_pot_value,13,10)
endif
if desired_pot_value > feedback_pot_value then
diff=desired_pot_value - feedback_pot_value
else
diff=feedback_pot_value - desired_pot_value
endif
if diff > DEADZONE then
MotorSpeed = diff * LOOPGAIN max MAXPWMVALUE min CREEP; Limit range of motor speed
if desired_pot_value > feedback_pot_value then
high Direction ; Set forward direction
else
low Direction ; Set reverse direction
endif
pwmout pwmfreq MOTOR , PWMPERIOD , MotorSpeed; Slows motor within SLOWZONE ** NEW **
else
pwmout MOTOR , OFF ; STOP
endif
goto main
Last edited: