Touch Sensitive Dual Channel Motor Speed Controller

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Touch Sensitive Dual Channel Motor Speed Controller

Post by JohnCrow »

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.

Motor Speed Controller.JPG
Motor Speed Controller.JPG (107.75 KiB) Viewed 8449 times
The Red & Black wires from the top right of the motor control board are to a PP3 battery to power the motors.
Motor Controller-Dual Channel.fcf
(32.72 KiB) Downloaded 480 times
1 in 10 people understand binary, the other one doesn't !

User avatar
DavidA
Matrix Staff
Posts: 1076
Joined: Fri Apr 23, 2010 2:18 pm
Location: Matrix Multimedia Ltd
Has thanked: 58 times
Been thanked: 258 times
Contact:

Re: Touch Sensitive Dual Channel Motor Speed Controller

Post by DavidA »

very nice John :)

medelec35
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: Touch Sensitive Dual Channel Motor Speed Controller

Post by medelec35 »

Great project John,
I will look forward to having a play!
Thanks for sharing it with us :)
Martin

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: Touch Sensitive Dual Channel Motor Speed Controller

Post by JohnCrow »

Improvments

The EB022 Motor Board while being very versatile can be quite complex.
This is done as a tutorial on a couple of the more advanced functions available on the board.
I have changed the above program to a single channel controller, but added a couple of extra features.

Feedback.
This is Taken from pin 1 on the upper 9 way D-Connector on the EB022 and connects to PortA on the EB 006 Programmer.
I have used ADC 0 to read the output.
This gives an indication of how much power the motor is using.

With the motor in this project running at 50% it shows a feedback value of 15.
If I stall the motor by holding the shaft with my fingers it shows a value of 35.

Note - This is a toy motor. Do not attempt to stall anything larger as this could be dangerous

Enable.

A Start and Stop button has been placed on the touch screen.
This sends a signal 1 = start 0 = stop to Bit 4 on Port C.

To use this the ENA/ENB jumper needs to be in the lower position.

This also means it is possible to set the motor speed before turning it on. (Or Switch it off without having to reduce the speed).
Motor Controller-Single Channel Feedback V2.fcf
(26.31 KiB) Downloaded 468 times
1 in 10 people understand binary, the other one doesn't !

brandonb
Posts: 438
Joined: Mon Aug 29, 2011 12:26 am
Location: arizona
Has thanked: 175 times
Been thanked: 173 times
Contact:

Re: Touch Sensitive Dual Channel Motor Speed Controller

Post by brandonb »

nice build, i would like to start with graphic lcds and later touch screens, how do i know what numbers to put where for the coordinances, is there a tutorial somewhere?

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: Touch Sensitive Dual Channel Motor Speed Controller

Post by JohnCrow »

Hi Brandonb

The touch screen co-ordinates are used as follows

Top Left
X = 0 , Y = 0

Bottom Right
X = 240
Y = 320

So if you printed "Hello World" at
X= 120, Y = 160
The left side of the H would be in the center of the screen.

Its just a case of working out on paper the spacings and size of the boxes etc, then trying them on the screen and tweaking them.
Using the smallest fonts works fine in simulation but I have found the bigger fonts dont scale correctly in simulation but work fine on hardware.

If you right click on the EB076 component, select external properties and then the help button it is explained quite well.
You dont have to use the touch options on the screen if you dont need it, just as a larger display.


The EB057/58 is the same prinicple but a lot smaller
1 in 10 people understand binary, the other one doesn't !

medelec35
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: Touch Sensitive Dual Channel Motor Speed Controller

Post by medelec35 »

What I do is use paint and set the properties up to
240 wide by 320 down.
Since the work area is the same as Display on you hardware, then when hover over with the mouse to the area your interested in,
then the correct x,y coordinates are given at the bottom of the paint window.
You can also custom choose the colour in paint, the the correct values to use within Flowcode will be displayed.
See: http://www.matrixmultimedia.com/mmforum ... 64&#p26320

Martin
Martin

brandonb
Posts: 438
Joined: Mon Aug 29, 2011 12:26 am
Location: arizona
Has thanked: 175 times
Been thanked: 173 times
Contact:

Re: Touch Sensitive Dual Channel Motor Speed Controller

Post by brandonb »

thanks martin and john, i'll have a play with it

Post Reply