Motor Control Using PWM & The EB022 Motor Board.
The EB-022 Motor board, is a very versatile addition to a collection of E-Block hardware.
This describes a simple program I’ve developed to allow independent speed control of 2 motors by means of keypad entry.
This only scratches the surface of the boards capabilities, and does not use the boards feedback monitoring options.
Required Hardware.
EB-006 Programmer with 16F877A (19.66080 MHz xtal)
EB007 Switch Board Connected to Port A
EB014 Keypad Connected to Port D
My custom 4x20 LCD Connected to Port B
EB022 Motor Board Lower D-Plug connected to Port C
EB007, EB022 and the LCD all need 5V supply from the Programmer board.
EB022 also needs a suitable supply for the motor to be driven. In this case I’m using a PP3 battery
Programming
The idea was to allow a direct entry of the required duty cycle for each motor.
The switch board is used along with the switch function in Flowcode to select either motor or to shut down both motors as an emergency stop function.
For the purpose of this project the motors will only be used running in one direction.
Having selected the motor, by pressing switch 1 or 2 The Duty Cycle is entered on the keypad. This is then displayed on the LCD.
The keypad macro is fairly straightforward and allows a value of 1 to 99 to be entered.
(For 1 to 9 # must be pressed to enter the value)
The 2nd motor can then be selected or the first have its value changed by pressing switch 1 again.
Or if required only one motor need be used.
Switch 3 will disable both PWM, causing both motors to stop.
The program will restart in 5 seconds, and wait for the duty cycle settings to be entered, in the same way as if reset had been pressed on the EB006.
Macros M1 & M2 are used to simplify formatting the messages on the LCD.
Not all motors will work with the lower values. In fact at this point in the development, I’m using a pair of old PC processor fans, and these don’t start with anything less than about 50% Duty Cycle, though once running they can be slowed to about 25%.
This is partly due to the fact I’m only using 9V to run the fans which are actually rated at 12V
Having read the Duty cycle value from the keypad, it is converted to a speed value suitable to use in the PWM macro
Speed = (Duty*256)/100
This is used in the macro as below
2,128 Would set PWM Channel 2 to 128 (50% Duty Cycle)
It should be pointed out that Motor 1 connects to PWM2 and Motor 2 connects to PWM1 on the EB022 board.
It may be nessesary to adjust the PWM settings to find the optimum. These are the settings that gave the best results with the test motors being used.
This is going to form the basis of another project, which will be undertaken once the remaining hardware has been sourced.
Motor Control Using PWM
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Motor Control Using PWM
Very interesting article John.
Thanks for sharing!
What I do if I want to run a motor with a duty of <15% (spec is 10 - 100%)e.g 11% My duty formula uses:
If required duty <15 then duty = 20: delay for a few seconds :duty=11
Thanks for sharing!
Most motors that run on a lower duty require a slight boost before reducing the PWM so motor can run at a slower speed. This is to get over the starting inertia. ( I think thats the right term :p )JohnCrow wrote:
Not all motors will work with the lower values. In fact at this point in the development, I’m using a pair of old PC processor fans, and these don’t start with anything less than about 50% Duty Cycle, though once running they can be slowed to about 25%.
This is partly due to the fact I’m only using 9V to run the fans which are actually rated at 12V
What I do if I want to run a motor with a duty of <15% (spec is 10 - 100%)e.g 11% My duty formula uses:
If required duty <15 then duty = 20: delay for a few seconds :duty=11
Martin
- JohnCrow
- Valued Contributor
- Posts: 1367
- Joined: Wed Sep 19, 2007 1:21 pm
- Location: Lincolnshire
- Has thanked: 364 times
- Been thanked: 716 times
- Contact:
Re: Motor Control Using PWM
Thanks Martin,
Thats a good idea, I've tweaked my flowchart and added that option.
I'll try it on hardware when i get time.
Thats a good idea, I've tweaked my flowchart and added that option.
I'll try it on hardware when i get time.
1 in 10 people understand binary, the other one doesn't !