Control of a DC motors with H-Bridge chips

Warning message

The Propeller Object Exchange system is decommissioned and replaced with a GitHub repository to house the same existing and future Propeller objects. As of 12/5/2019, this site is read-only. You can continue to browse and download objects from here for a limited time; however, please begin using the Parallax Propeller repository for future reference.
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
Request group membership
By: created: 2013-04-04 | updated: 2013-04-04


Control speed and direction of DC motors using H-Bridge chips such as the LMD18201
The setMotor procedure sets the duty cycle (0%-100%), direction and delay per % change in duty cycle. The delay per % change in duty cycle allows the motor speed to ramp up and down in a smooth manner. The amount of delay to use will depend on the characteristics of the motor and the load on the motor. This procedure is operating open loop which means that if the delay
per % change in duty cycle is not long enough you can over run the motor. The procedure keeps track of the direction of the motor and will ramp the speed to 0 before changing direction. The setMotor procedure is run in a new cog which waits for any previous operation to quit before starting the new one. The setMotor cog is released after the new motor setting has been reached. The pwm loop will run constantly in its own cog to keep the motor running at the set duty cycle. A test program is included that controls two motors.
Original File Upload
Package icon PwmMotors.zip8.58 KB