car dashboard

#1
Good mornig and for all of you a happy new year !!

I hope one or all of the members can help with my little problem. I'm rebuilding a dasboard for a VW T3 on the RPM side. The RPM-clock was no problem but there are two signals that i want to check and those are fuel en coolwatertemp.
By lack of space in the clockbox i will use a 08M2 and the I2C connection for the display. No problem so far. Then it becomes tricky because i see only one ADC input en one DAC output.

My question: how do i realise to use the one ADC for two signals or can change the DAC to an ADC-input.

All suggestions are welcome.

Have a nice day !!,

Hans
 

AllyCat

Senior Member
#2
Hi Hans,

Welcome to the forum and a Happy New Year.

You can use a PWM output (with a small external low-pass RC filter) for a DAC output. Much lower output impedance and higher resolution (10 bits versus 5 bits) than the internal DAC. There's only one "official" PWM output on the 08M2 (c.2) but we might be able to find another method.

Even the 08M2 has three ADC inputs (c.1, c.2 and c.4) and you can even use the "DAC" output pin as an ADC input (ReadDAC) if you're desperate (and not using it as a DAC).

The I2C does rather eat up two valuable pins (c.1 and c.2) but might be "bit banged" on other pins if essential. However, there are limits on how much I/O you can get with an 8 pin chip ! ;)

Cheers, Alan.
 

hippy

Technical Support
Staff member
#3
You need I2C ( two pins ) and two ADC inputs. The only way to implement an 08M2 solution with two separate ADC inputs would be to use bit-banging for I2C.

Bit-banged I2C should not be too difficult to achieve and there would be help available here for implementing that.

It would be recommended to get the display working with hardware I2C from a breadboard or prototype so you know that does work. That will avoid trying to figure out if it's the bit-banging code or what is being sent which is a problem if the bit-banging solution doesn't immediately work, will give a better chance of it doing so.
 

AllyCat

Senior Member
#5
Hi,
My question: how do i realise to use the one ADC for two signals or can change the DAC to an ADC-input.
Sorry, I didn't read your question carefully enough.

You can use (hardware) I2C on c.1 and c.2 and read an ADC signal on c.4. Then the DAC can be used as an ADC input by using the ReadDAC command:

The DAC has a high source resistance; set it to DACLEVEL 16 and the input/output impedance is about 30k ohms (or it can be set even higher with few "special" commands). The only problem is that the pin MUST remain as a digital output for Programming and at power-up. So you should connect a "safety" resistor of perhaps 1k between the PICaxe pin (c.0) and the analogue voltage source. If high accuracy is required, then the PICaxe can calculate the "offset errors" caused by the source impedances.

Alternatively use any two of the available ADC inputs and "bit bang" the I2C. SDA needs the remaining (digital) I/O pin but SCL is generally output-only. This might be the serial output / programming pin (c.0) , or I might put a FET (2N7000) and 1M pull-down resistor on c.3 and switch it on and off with a PULLUP 8 command. It's even "possible" on c.5 if you need another digital input for something else. ;)

Cheers, Alan.
 
#6
More "disguisting"details: First of all; the whole I2C technics is not familiar for me. I grow uo with 6502,6800 and Z80 processors but as an grandpa i still claim my place in the digital world. Ha, ha.
The two ADC signals are voltages coming from an NTC in cilinderhesd and potentiomater in the fueltank. Both are voltages fluctuating between 1 and 12V but with resisteor devider that isn't the problem. I already fixed that wit an standard output port and and a ICshaped chip relais so i can swith from one to the other.
I got stuck with controlling the I2C LCD-unit which has an adres $0x27 or $0x3F. It is not clear for me how to send data to the LCD. The adressing part is the problem. I use the setup command as follows: hi2csetup i2master, $27,i2cslow,i2cbyte.
This means for me that i made my 08M2 master, the slave adres will %00100111, dataspeed is set at slow and the adres one byte long. Correct??
When i program my PICAXE the screen stays blank although i get no errrors with prechecking or programming.
What is wrong me? Sorry with my program
At this moment a think with melanchally for my 6502 :giggle:
 

AllyCat

Senior Member
#7
Hi,
I got stuck with controlling the I2C LCD-unit which has an adres $0x27 or $0x3F.

Those are obviously "7-bit" addresses, but PICaxe uses 8-bit addressing (with the LSB always 0). So try address $4E or $7E.

Ah yes, the 6502 was a real "Programmers" micro. But as an "Engineer", I preferred the Z80. ;)

Cheers, Alan.
 

Aries

New Member
#8
If the address is 0x27 or 0x3F where the least significant bit is 1, it suggests perhaps that this is 7-bit addressing, and the address needs to be shifted left as described in the manual under hi2csetup ...
Most datasheets give the slave address in 8 bit format e.g.
1010000x - where x is don’t care (the read/write bit, PICAXE controlled)
However some datasheets use a 7 bit format. In this case the bits must be shifted
left to take account for the read/write bit.
which I think makes them 0x4E and 0x7E (01001110 and 01111110)
 
#10
Well that was a disapointing experience. The only result i get regardles which adres i use is line filled with highlighted character positions. But that is all. At this moment i put the I2C trip ar a holt and take an 18M2 chip. I have redesign my circuitboard but that goes faster then trying to understand I2C. Maybe in a retirementhome sitting in my wheel chair and drewling over my notes i will try to understand it again.
For the rest thanks for all of you and again it's proven: You cann't teach an old dog new trics ;-)
 

AllyCat

Senior Member
#11
Hi,

Firstly, have you checked the Contrast potentiometer/voltage on the LCD display?

However, if it is one of the LCDs with an "I2C Backpack", then they are not easy to drive. They require 4-bit data with "clock/enable" signals elsewhere in the transmitted bytes. But it has been done with a PICaxe and there should be program code here on the forum, so don't give up yet. ;)

Cheers, Alan.
 

lbenson

Senior Member
#12
You cann't teach an old dog new trics
Hey--this old dog (8080/Z80-era) is still learning, and some older on the forum are as well, so don't give up so quickly. Exactly which i2c LCD is this? Please post your code within the tags, "[ code]" and "[ /code]" (but without the spaces), plus a clear photo of your rig. The forum is likely to be able to get you running if you persist.
 
#13
Hello Ibenson. It's not a matter of quiting so quickly but i need the dashboard in my VW-van. So its easier for me to design a new circuitboard because i am good in doing that (i think) On the otherhand there is no pressure on the design and it is always good for the VW-van Dash mark 12 ;-)
Take notice please of the image that i made. the indentity on the chip is PCF85741 from that Lightbulb Factory in Holland (PHILIPS) The jumper is for backlight and the trimpot is for intensity. adressing should be 0x27 or 0x3F.
I hope you can make cake of it (correct expression?) or bake something else ;-)
 

Attachments

AllyCat

Senior Member
#15
Hi,

Hmm, Philips ICs have been "branded" NXP for many years now, but it will probably work fine. ;)

Yes, those LCD modules are very well-known but not all quite the same. There are various code versions on the forum, but this quite recent "Finished Project" looks like it might be a good starting point. But don't struggle with it, the total program need be only 10 or 20 lines. As we mentioned, above, the address byte will NOT be 0x27 or 0x3F. ;)

Cheers, Alan.
 
#17
I noticed that the post #2 they used a code that is for PIC's not for the PICAXE. How do I enter that in my PICBASIC? Secondly Ibenson speaks about PIC 8574 but as far i can read the label it is a PIC 85741. Any difference between them.

Can i copy the code as flat text as we called here and paste it in the PICAXE Editor? I did probably something wrong because i was doing two things and i am afraid that some female qualities starts taken over ;-)
 

lbenson

Senior Member
#18
I noticed that the post #2 they used a code that is for PIC's not for the PICAXE
Not sure what you mean. If you mean the code in post # 2 of the first thread I linked to, that's straight (if somewhat unusual) PICAXE code. It's possible that you can just paste it into PE6, download and run it, and this will appear on the 4 lines of your LCD (if it is 4x20):
Line 1 8901234567890
Line 2
Line 3
Line 4
If not, tell us what happens (adjust PICAXE 20M2 to suit your picaxe, but I think it should work for any M2 or X2).

(I just copied and pasted it into PE6, and it passes the syntax check.) If it's just 2 lines, delete or comment out the part that writes to lines 3 & 4, although if you leave them in, it probably won't matter.
 
Last edited:
#19
Hello Ibenson,

Long time no seen. I copied the program lines and replaced the first line into #picaxe 08M2. I checked the adres of the I2C module, download the program and ................. indeed it did not work. Checked wiring, OK Start reading the program and then there are some i can make anything of it. Looked in the cammands manual but it's chinees for me.

This what i can not understand, spounds maybe silly but i do not know the use of it.

1) why do I have write the type of PICAXE that i am using?
2)What is the meaning of the 'command' #MACRO and #EndMacro
3)i cannot find the description of the variable "bPtr" and "toLoc"
4
 
#20
wrong key sorry, to be continued ;-)

In the mainprogram part is a line that saids "Do : Loop" ; WHY ????? there is no Loop label. In teh mainprogram is used several times the instruction GOSUB. I can understand that but then the fun comes for me; the labels "Sendb2As........etc. have no return command. The only return-command that appears is before the progran line with the label "InitializeLCD"

Even when i load the program in the PE and single step through the program i can't make any chocalate (correct? ;-)) for the values of the variabels.
Maybe this is to high level for me? Be honest, i am old enough to take that hit.
Is there an extra command manual other then the set that is supllied here for download?

Then last but not least, my apoligies for the late response but it can't always playingtime for me.
 

premelec

Senior Member
#21
Hi... it's complicated... however commands can be found by clicking on PICAXE at top of this forum page. DO..... lots of things... LOOP does not require label. DO WHILE... or DO UNTIL also useful... Study various commands and programs that work and you'll soon know if it is too high a level for you... we learn by DOing UNTIL we get out of the LOOP ;-0

I've been programming these things for many year and still don't use MACROs - they aren't necessary though may be convenient. The reason to specify PICAXE type is so the compiler knows if your commands are OK for your particular part [they are NOT all the same - many have same commands working but some commands don't work with some
PICAXEs]. Have fun... and ALWAYS RETURN from a CALL or GOSUB...
 

lbenson

Senior Member
#22
can't always be playingtime for me
As my mother used to say, "Pity the poor working man". Myself, I'm retired.

There is some information about macros here. The code in a macro is inserted wherever the macro is used.

BPTR is a variable whose contents point to another location in the ram memory of the PICAXE. This provides "indirect" addressing. Manual 2 says this "@bptr is a variable name that can be used in any command (ie as where a ‘b1’ variable would be used). However the value of the variable is not fixed (as with b1), but will contain the current value of the byte currently ‘pointed to’ by the byte pointer (bptr)".

Hippy's original code (referred to above) provides a "stacked" set of commands. Whichever label you call, the code eventually falls through the following labels until it gets to the RETURN at the end. If you changed the order of "Sendb2AsInitByte:", "Sendb2AsCommandByte:", and "Sendb2AsDataByte:", the code wouldn't work.

The "Initialisation:" part of the code just puts some (zero-terminated) fixed strings into upper ram memory (above where the named variables b0-b27 are) after saving a pointer to each string.

In "MainProgram:", the first 4 fixed strings are written to the 4-line LCD. After 5 seconds, the 5th fixed string is written to line 2.

The "Do : Loop" at the end of "MainProgram:" is just a placeholder. Typically a program's code is executed forever in a loop, and certain things are done based on various inputs and timings. Your code would be placed within this do loop (and the code above it would be removed or replaced as needed).

Ask if you have further questions. As people have found, this is not a straightforward LCD to work with--but it is inexpensive and it can be handled .
 
#23
Hello Ibenson. Just a short note to thank you for the explanation. Now it's clear as mud ;-) By the way your mother was intelligent woman. That makes the difference between you and me: You'r retired and enjoy every day of it. I am retired and still play my roll as a donkey......... being stupid and work all day. I'll studie your ecplanation and it is more the way of programming in combination with the language that sen me in to the dark woods.
Enjoy your weekend. ;-)
 
Top