Rally Computer

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

majerv
Posts: 17
Joined: Mon Aug 27, 2007 4:27 pm
Contact:

Rally Computer

Post by majerv »

Hello, Flowcode users!

I'm newbie at using PICs but, I've made some simple things with Flowcode already. I would like to build a Rally computer for my bike, to take part in some on-offroad competitions like the "Dakar".

The Rally Computer must have the following functions:

1. Display of the current/average/min/max speed
2. Count and store the distances: Trip1, Trip2, Overall Km
3. Display of time/date
4. Voltmeter for the battery
5. Display of the temperature of Oil/Cooling water/air with min/max data
6. Display of the RPM

I would change the functions with a 3-button switch from the Handlebar or on the Case of the computer. I would have at least 2 functions on the screen at once.

The Display should be a 128x64 GLCD.

Here are some factory modells:
http://www.sixo.de
www.http://www.touratech.com/shops/008/ ... 45214e4a83

I wonder if a PIC can do so much things.

I have found some solutions in the forum for some functions, but I don't know how to manage all the function in one/or more PICs.

If you have any idea, please tell me advices! I will say a thank you on my next "Dakar" :-)

Thanx,

gustaw

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Rally Computer

Post by Benj »

Hello

Please see here for driving your KS0108 64 x 128 graphical LCD.

http://www.matrixmultimedia.com/Flowcode_Components.php

Regarding your program, it should be possible to do everything using a single microcontroller. First I would look into using timer interrupts to calculate your speeds etc, Distances can simply be calculated by using a count value combined with a distance per count. For an example of counting pulses using interrupts please refer to the frequency counter example available from here.

http://www.matrixmultimedia.com/Flowcode_Examples.php

You will have to use a main int count variable and a second int variable to catch the first variable overflows.eg if var1 > 32000 then var1 = 0 and var2 = var2 + 1. You may also possibly need a third int variable to catch the 2nd variable rollover if your input pulses are happening very rapidly and you are going to be travelling long distances.

1 int var = approx 32000 counts before rollover
2 int vars = approx 1024000000 counts before rollover
3 int vars = approx 32768000000000 counts before rollover

Remember the key to a working program is to program in small stages getting small pieces working at a time. Eg start by displaying the current speed and take it from there.

majerv
Posts: 17
Joined: Mon Aug 27, 2007 4:27 pm
Contact:

Which PIC?

Post by majerv »

Which PIC should I use?

I've got a 18F4550, and a 16F877A these have enough ports and memory I think. I would like 16F877A better, it's easier to set the config bits.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Rally Computer

Post by Benj »

Hello

The 16F877A should have enough memory and speed to allow you to complete your project. However if you do find that your running out of resources then you can always switch to the 18F4550 further down the line without problems.

majerv
Posts: 17
Joined: Mon Aug 27, 2007 4:27 pm
Contact:

Re: Rally Computer

Post by majerv »

I have a DS1307 RTC and I would like to connect it to the 16F877a for the DATA/Time functions.
This could give the clock too, so the PIC had less to do.
I,ve connected the DS to the PIC like in the topic "Frequency Counter", but I don't know how to read the data/time from it. It could manage some functions in the computer and I could use its clock for the counting.
I've just bought the 128x64 LCD and I'm waiting for it.

I've made the tire size settings function earlier and it works fine with a 2x16 LCD, I wonder how it will be on a 128x64.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Rally Computer

Post by Benj »

Hello

It looks like the DS1307 is running on the I2C bus so you will probably have to use this to initially set up the square wave input. You should also be able to use this bus to pull out the time and date etc from the RTC. You'll probably have to look at the device datasheet and then program the I2C functions to perform the initilisation and to pull out the data.

The 128x64 LCDs are nice I think you should like the way they look and operate.

Keep us informed as to how your progressing. If your interested this may be worth submitting for an article in elektor or similar.

majerv
Posts: 17
Joined: Mon Aug 27, 2007 4:27 pm
Contact:

Re: Rally Computer

Post by majerv »

I've got the 128x64 GLCD, but I can't let it show anything. I've made a simple mistake: after downloading your custom components for the KS0108 I've attached the GLCD to the PIC as written in the readme file.

After doing this I've realized that my GLCD has another pinout. Maybe I've killed my GLCD?
I can see the black dots, and can adjust the contrast and that's all.

I've atteched the datasheet for the GLCD, has anybody an idea what to do?

majerv
Posts: 17
Joined: Mon Aug 27, 2007 4:27 pm
Contact:

Re: Rally Computer

Post by majerv »

I could test the GLCD, and it works fine with an other circuit. But with flowcode only some pixels are changing on a black background.

Any Idea?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Rally Computer

Post by Benj »

Hello

You must use the custom component combined with the gLCD custom_code.c file with the KS0108 LCDs. The actual Graphical LCD component in Flowcode is designed for use with another display. If this is what you are already doing then what are your pin connections to the display and how are you powering the LCD etc. A full list of connections to your LCD might help me to spot any potential problems.

majerv
Posts: 17
Joined: Mon Aug 27, 2007 4:27 pm
Contact:

Re: Rally Computer

Post by majerv »

Hi Benj

The GLCD I use has the following pinout:
VSS, VDD, VO, RS, R/W, E, D0-7, CS1, CS2, RST, Vout, SLA, SLK.

The GLCD Component in Flowcode has only four pins to set: Reset, Chip select, Clock, Data. I've tried it with the beta component you've adviced in the "GLCDs" topic.
What to do now? PLS HLP

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Rally Computer

Post by Benj »

The Flowcode graphical LCD component is for another type of graphical display and will not work with the KS0108 LCDs. To get the KS0108 functions working you must visit this page:

http://www.matrixmultimedia.com/Flowcode_Components.php

Read the information at the top and then download the custom code to drive the KS0108 display. There is a readme file included which details the pin connections. Once you have added the code to the correct folder use the custom component to drive the display rather then the graphical lcd component.

Hope this helps.

majerv
Posts: 17
Joined: Mon Aug 27, 2007 4:27 pm
Contact:

Re: Rally Computer

Post by majerv »

Hi Benj

The GLCD I use has the following pinout:
VSS, VDD, VO, RS, R/W, E, D0-7, CS1, CS2, RST, Vout, SLA, SLK.

The pinout in the readme file is different:
+5V, GND, Contrast Pot, RD0, RD1, RD2, RD3, RD4, RD5, RD6, RD7, RC0, RC1, 10K - +5v, RC4, RC2, RC3, Contrast Pot, +5V, 22R GND

I've tried this for the first time too but without success.
I've changed the settings in the customcode.c file too.

majerv
Posts: 17
Joined: Mon Aug 27, 2007 4:27 pm
Contact:

Re: Rally Computer

Post by majerv »

Hi Folks!

I try to learn programming the PICs parallel with Flowcode with an other program (MikroC) and that works perfect with my GLCD. But it's too difficult to export my programs there and I prefer Flowcode too. I wonder if is it possible to import the mikroC codes to flowcode to let my GLCD work.


Thanx, majerv

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Rally Computer

Post by Benj »

Hello

What is the type of gLCD that you are using. If you have a link to a datasheet etc then that would be handy.

majerv
Posts: 17
Joined: Mon Aug 27, 2007 4:27 pm
Contact:

Re: Rally Computer

Post by majerv »

I've bought it on Ebay at Sureelectronics.

Here is a picture: http://www.sure-electronics.net/mcu,dis ... 12_2_b.jpg
It's a Truly M12864-2A2 display with the Pinout:

The GLCD I use has the following pinout:
VSS, VDD, VO, RS, R/W, E, D0-7, CS1, CS2, RST, Vout, SLA, SLK.

Maybe there is a trouble with the pin connection bacause when I unplug the two cs1 and cs2 lines i can see the shapes of a text but not in the right position and it looks like repeated many times.

I write the link for the datasheet:
http://www.sure-electronics.net/mcu,dis ... 1.0_EN.pdf

majerv
Posts: 17
Joined: Mon Aug 27, 2007 4:27 pm
Contact:

Re: Rally Computer

Post by majerv »

Hi Benj,

I've found the original datasheet of my GlCD, but it's too large to attach here. Here is the link, where you can download it:
http://www.gydlcd-lcm.com/003/pdf/20051 ... 856536.rar

Thanx, majerv

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Rally Computer

Post by Benj »

Hello

Your LCD is a KS0108 type display. You should be able to use the KS0108 Beta Component to drive the display correctly. The pinout must just be changed around slightly.

Use the pin connections that are defined at the top of the custom_code.c file to work out where pins are connected to.

eg

RS pin - RC2
R/W pin - RC4
E pin - RC3

majerv
Posts: 17
Joined: Mon Aug 27, 2007 4:27 pm
Contact:

Re: Rally Computer

Post by majerv »

After weeks (and getting started to learn MikroC) I've tried again with flowcode to display data on the GLCD...AND IT WORKS!!!

The solution was: control port = B, not C :-)

I don't know why it is, but it works!

mrmagoo
Posts: 1
Joined: Tue Jan 06, 2009 10:48 pm
Location: UK
Contact:

Re: Rally Computer

Post by mrmagoo »

Have been looking at making nealry identical task (road bike rather than rally biking though).
Only real difference is once basic functionality is going I may look at adding storage to hold historical info for later use/display.
I was planning on using the same controller (i.e. KS0108) and 16F877A.
Would appreciate any picture attachments, schematics, code you could provide.
Should go a long way to getting it first time.

Thanks

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Rally Computer

Post by Benj »

Hello MrMagoo

Here is a good place to start.
http://www.matrixmultimedia.com/Flowcode_Components.php

WalkOver
Posts: 65
Joined: Fri Nov 23, 2007 11:24 pm
Contact:

Re: Rally Computer

Post by WalkOver »

Hello,

I try your code with my own GLCD.
The CS1, CS2 and Co are connected to the PORTF so I modded your code but my GLCD had a RESET PIN connected to F5 and even if I set this PIN in Flowcode, the F5 PI stay clear and the GLCD doesn't start. If i put a pull up resistor on F5, it works but I need to have this pin on my microcontroller. Why the F5 pin is impossible to set with the MM GLCD code ??

Anybody have an idea ?

Thank you for all !

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Rally Computer

Post by Benj »

Hello

Have you made sure that the corresponding tris bit has been cleared so the pin is configured as an output.

Eg
clear_bit(trisf, 5);
set_bit(portf, 5);

stabmegane
Posts: 7
Joined: Thu Dec 22, 2011 3:42 pm
Has thanked: 1 time
Contact:

Re: Rally Computer

Post by stabmegane »

Hi, i'am also trying to make a ks 0108 to work. Still no luck.
I have it connected on port D for data and port b for control, changed the pic_custom, like this


//Common defines
#define MX_DATA_PORT portd //%a
#define MX_DATA_TRIS trisd //%b
#define MX_CONTROL_PORT portb //%c
#define MX_CONTROL_TRIS trisb //%d
#define MX_CS1 0 //%e
#define MX_CS2 1 //%f
#define MX_DAT_INST 2 //%g
#define MX_ENABLE 4 //%h
#define MX_READ_WRITE 3 //%i

I didn't connect the reset pin on the lcd. You thinbk that maybe the problem?

I'm ve been trying to make it work the last 8 hours, i would appreciate some help.
Thank you in advance

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Rally Computer

Post by Benj »

I didn't connect the reset pin on the lcd. You thinbk that maybe the problem?
I think you will probably have to at least connect the reset pin to the +ve power rail for the display to work, otherwise it may simply sit in reset mode.

stabmegane
Posts: 7
Joined: Thu Dec 22, 2011 3:42 pm
Has thanked: 1 time
Contact:

Re: Rally Computer

Post by stabmegane »

Thank you for your reply.
I tried it and it almost work, but it would be nicer if i could connect it to a pin (portb,5) which i did but i still can't make it go to 1 state.
i guess i have to

clear_bit(trisb, 5);
set_bit(portb, 5);

as you mentioned but i can't figure out in which section of the code i should put it.
Thank you again .

Post Reply