Demand Peripherals     Robotics and Automation Made Easy

DC2: Dual DC Motor Controller

The DC2 peripheral controls the speed and direction of two brushed DC motors using the D7HB H-Bridge card. The motor speed signals are pulse width modulated (PWM) signals with a programmable PWM frequency and a duty cycle between 0 and 100 percent.



The DC2 peripheral requires the D7HB dual H-Bridge card,



Resources let you control each motor as well as set the PWM frequency. A watchdog timer can shutdown both motors if the host stops writing to the peripheral.

mode0, mode1 : mode of operation for the motor.
The mode is encoded as a single character with the codes assigned as follows:
     b -- brake (power on default)
     f -- forward
     r -- reverse
     c -- coast

power0, power1 : PWM 'ON' time as a percentage.
The speed resolution is 10 bits for PWM frequencies below 20 KHz. The speed resolution is 8 bits for a PWM frequency of 78 KHz. Reading this give the _current_ speed. Writing it sets the _target_ speed. Current speed is subject to the constraints of slow start and slow stop so the current speed and the target speed might not be the same. That is, when you read the speed you might not immediately get back what you wrote to it.

pwm_frequency : PWM frequency in Hertz.
The driver tries to assign a frequency as close as possible to the one specified. For example, a requested frequency of 12510 Hertz might result in an actual PWM frequency of 12500 Hertz. The PWM frequency is the same for both motors. The default PWM frequency is 20000 Hertz.

watchdog : Timeout in milliseconds.
As a safety feature, the FPGA hardware can turn both motors off if there is no speed or mode update within the specified time. The time is specified in milliseconds and has a maximum value of 1500 milliseconds. The resolution of the watchdog timer is 100 milliseconds, and a value of zero turns off the timer. The default value is 300 milliseconds.



Set the PWM frequency to 20KHz, put both motors into forward mode, set the watchdog timer to 500 ms, and set the PWM percentage to both motors to 65 percent.

     pcset dc2 pwm_frequency 20000
     pcset dc2 watchdog 500
     pcset dc2 mode0 f
     pcset dc2 mode1 f
     pcset dc2 power0 65
     pcset dc2 power1 65