cmd_dcmotor_setup
Command to setup pins to control DC motor
Calling Sequence
cmd_dcmotor_setup(h,driver_type,motor_no,pin_no_1,pin_no_2)
Parameters
h :
Board number, reserved for future use. For this version, any number would do
driver_type :
1=Motorshield Rev3, 2=L298, 3=L293
motor_no :
ID used to identify motor to be connected
pin_no_1 :
Depends on the driver type, choose the correct pins for the purpose. For example, using L293 require PWM pin to be selected.
pin_no_2 :
Depends on the driver type, choose the correct pins for the purpose. For example, using L293 require PWM pin to be selected.
Description
Arduino board does not deliver enough power, so it is necessary to use a H-bridge circuit/IC to control the motor. There are several types of H-bridge IC that do not all operate on the same principle. For example, the L298 requires the use of a PWM signal with current sense. The L293 uses two PWM to set the speed and direction. Ready-to-use Shields are also available.
Remember that the PWM is 8-bit (0 to 255). The input of the block could accept any value, but it would saturate at +- 255.
Examples