Touch Sensitive Dual Channel Motor Speed Controller
Posted: Thu Apr 12, 2012 7:24 pm
This is a simple program to show some of the simple aspects of the new touch screen e-block.
The display in this project mimics the windows progress bar as a dual channel motor speed controller.
However in this application it is on a touch screen, so can be dragged by touching it with a finger or plastic pointer.
It is not recommended to use any form of metal as a pointer as this could damaged the screen. I have also put a mobile phone screen protector over the screen. (A non sticky type, which can be easily removed and replaced without leaving any residue on the delicate screen surface)
Hardware:
EB006 Programmer with standard crystal and 16F877A
EB 022 Motor Driver
EB 076 Touch Screen
EB635 Dual IDE Cable
Small low voltage DC motors (x2) (Or small pc type fans)
PP3 Battery to power the motor.
Motor 1 = CCP2
Motor 2 = CCP1
It should be noted that a lot of motors won’t start until they get for example a mark-space ratio of 40% , it can then be lowered to the required setting. This is again dependant on the specific motor or fan being driven.
Also I found the small fans used on PC motherboards only run in 1 direction, if you wire them in reverse they don’t work.
The small motors used for these tests will start at about 16%, but they will then keep running if the speed is reduced to 12% Below 12% they stop altogether.
The motors used here have a maximum speed of about 12000 rpm
Description:
A simple splash screen is displayed for a moment when the program is first started, this shows basic details etc.
This screen clears and the main screen is shown.
Both the Touch Screen and the Motor Controller need to be connected to Port C
(Default settings, though they can be changed by the patch system.)
For the initial project however it was decided to keep the default settings, as this makes any debugging easier, especially as I have a previous project for controlling the motor board on Port C.
Two vertical boxes were drawn on the screen with Y Co-ordinates running from 30 to 285.
This gives 255 positions. (i.e. 1 Byte) . Note because the upper value is 285, integer variables have to be used.
These are shown in foreground colour white.
If the inside of the box is touched or dragged, the colour changes to yellow on motor 1 and red on motor2, down to the touch point. These correspond to the colour of the rubber band holding the motor in the mounting clip.
Because it starts at Y = 30, 30 is subtracted from the value of the “Y” co-ordinate when it is read from the touch screen.
This is then sent to the PWM component to drive the motor board.
Exact settings of the PWM depend on the type of motor being driven.
The percentage of full power is displayed in the centre of the box.
This is calculated by
(Touch Position * 100)/255
It is done this way rather than doing the division first because the program is using integer maths, and this would have introduced large errors.
The numbers down the LHS of the display are the approximate values sent to the PWM.
The flowchart is well documented and easy to follow.
The Red & Black wires from the top right of the motor control board are to a PP3 battery to power the motors.
The display in this project mimics the windows progress bar as a dual channel motor speed controller.
However in this application it is on a touch screen, so can be dragged by touching it with a finger or plastic pointer.
It is not recommended to use any form of metal as a pointer as this could damaged the screen. I have also put a mobile phone screen protector over the screen. (A non sticky type, which can be easily removed and replaced without leaving any residue on the delicate screen surface)
Hardware:
EB006 Programmer with standard crystal and 16F877A
EB 022 Motor Driver
EB 076 Touch Screen
EB635 Dual IDE Cable
Small low voltage DC motors (x2) (Or small pc type fans)
PP3 Battery to power the motor.
Motor 1 = CCP2
Motor 2 = CCP1
It should be noted that a lot of motors won’t start until they get for example a mark-space ratio of 40% , it can then be lowered to the required setting. This is again dependant on the specific motor or fan being driven.
Also I found the small fans used on PC motherboards only run in 1 direction, if you wire them in reverse they don’t work.
The small motors used for these tests will start at about 16%, but they will then keep running if the speed is reduced to 12% Below 12% they stop altogether.
The motors used here have a maximum speed of about 12000 rpm
Description:
A simple splash screen is displayed for a moment when the program is first started, this shows basic details etc.
This screen clears and the main screen is shown.
Both the Touch Screen and the Motor Controller need to be connected to Port C
(Default settings, though they can be changed by the patch system.)
For the initial project however it was decided to keep the default settings, as this makes any debugging easier, especially as I have a previous project for controlling the motor board on Port C.
Two vertical boxes were drawn on the screen with Y Co-ordinates running from 30 to 285.
This gives 255 positions. (i.e. 1 Byte) . Note because the upper value is 285, integer variables have to be used.
These are shown in foreground colour white.
If the inside of the box is touched or dragged, the colour changes to yellow on motor 1 and red on motor2, down to the touch point. These correspond to the colour of the rubber band holding the motor in the mounting clip.
Because it starts at Y = 30, 30 is subtracted from the value of the “Y” co-ordinate when it is read from the touch screen.
This is then sent to the PWM component to drive the motor board.
Exact settings of the PWM depend on the type of motor being driven.
The percentage of full power is displayed in the centre of the box.
This is calculated by
(Touch Position * 100)/255
It is done this way rather than doing the division first because the program is using integer maths, and this would have introduced large errors.
The numbers down the LHS of the display are the approximate values sent to the PWM.
The flowchart is well documented and easy to follow.
The Red & Black wires from the top right of the motor control board are to a PP3 battery to power the motors.