Vehicle monitoring unit

mickm2au

Member
Hi,
This is my first picaxe project apart from flashing leds at certain temperatures with a 08m and a ds18b20.
It is a motor monitoring unit which I fitted to our diesel motorhome It uses 3 ds18b20's to measure head temp, oil temp and gearbox temp, ADC to measure battery volts and cycles through displaying them on a 2 X 16 LCD. It has high temp/low volts alarms and the alarm trigger points can be set by a series of button presses which then stores the value in eeprom. The alarms can also be acknowledged so that the indication is not so urgent but will not completely cancel until the reading comes back to the normal range.
I would welcome any comments on the code/circuit.

I'll post a pic on the next post...
 

Attachments

Last edited:

Dippy

Moderator
Looks pretty.
If it works 100% then I can't (won't) comment or criticize.
Well done, nice job.

After all, I'm sure someone could trim a few bytes off the Wii software....
 

lbenson

Senior Member
Nice. Very clean and easy-to-follow schematic (once oriented properly)--something for me to learn from there. If you could rotate it 90 degrees left, it would present better. The code is well-commented and well-structured, but would read more easily if the register names, b0, etc., were replaced with symbol names, e.g., "symbol b6 = limitValue" and similarly with eeprom locations, e.g., "symbol eeLowBatValue = 203". And you might want to reserve b0 for bit-value alarm conditions, e.g., bit0 for low battery, bit1 for high head temp, etc.

Very fine initial post--welcome to the forum.
 
Last edited:

hippy

Technical Support
Staff member
Nice project.

I won't comment on the robustness of the PSU ( it is "what you are using" ) but I would suggest showing or indicating the requirement for suitable fuses on the +12V battery and ignition feeds.
 

BeanieBots

Moderator
Nice project indeed.
As it's for a diesel, the regulator won't be at as much risk as in a petrol vehical and failure would not present any serious risk but like Hippy points out. It MUST be fused to prevent bringing down the rest of the supply in such an event.
I'd also fit a lowish value resistor and/or choke between ignition and clamp zener. Alternator overshoot can be ~30v for 10's of mS when headlights are switched off. The zener would be very stressed without current limit.
 

mickm2au

Member
Thanks for the comments guys,

Ibenson
I found it awkward to get used to symbol names but I'll give it ago in the next project whatever that is. Also, just had a thought, for just a yes/no type variable can you use one bit of a b* register so that you could have several indicators in one b register ?
Sorry about the circuit orientation, it was rotated for printing, I'll try and edit that

Just re-read your post and you've answered my question...I'll look up how its done

Hippy
I do have inline fuses for both the ing feed and the battery monitor feed but didn't show them on the circuit, also thanks for the LCD code on your website

Beaniebots
There is a 10 ohm resistor in series with the ing feed on the circuit. I could increase this value but 10 ohm seems to be the standard on most 12v vehicle projects in Silicon Chip magazine.

Mickm2au
 
Last edited:

Dippy

Moderator
I definitely use bits for simple yes/no , 1/0, boolanesque situations.
Its an obvious way to save variable consumption.

So, for example, just 'set aside' b0 and use can use bit0-bit7 as yes/no 'logic' variables.
Just remember that your bits will be lost if you use a b0 or W0.
It's all in the BASIC Manual Page 9 (of the Manual that you will get using todays "PICAXE Manual" dropdown).

Generally, this is a BIG advantage of using Symbol to declare your variables. i.e. give the b1 etc a usable name.
Get the allocation sorted at the beginning and then (hopfully) you won't overwrite things.
 

manuka

Senior Member
It's worth pointing out that folks with an extensive maths & physics background tend to "think" more clearly when using (defined) x, y style algebraical abreviations. Long winded symbol manipulations can cause "brain fog" - I experience this myself when wrangling the likes of topvalue/elapsed_time * hit_number style expressions, finding b3/b4*b5 much easier to visualise.
 

BCJKiwi

Senior Member
Re voltage inputs;

1. Would recommend replacing the 7805 with an LM2940 series regulator - designed specifically for automotive use with apropriate protections.

2. Would revisit the 22k / 5k pot + 3k3R divider values. This is capable of adjustment which would deliver excessive voltage to the 18X in1 under spike conditions where the zener clips to 20V.
 

Dippy

Moderator
Good suggestion BCJ. Always good to bullet-proof a system.
(Though with care many things can be protected with appropriate suppression).

Each to their own Stan.
Certainly for a 20 line kiddy programme I'd agree with you.
But when it starts getting bigger then I find it a good reminder.
It's also a darned sight easier to read 3 months later.
And less likely to overwrite a variable if it has unique name.
(As in , here I am on line 176, oh darn, have I used W2 before? Can I use it again now?).

I try and keep to the convention of wMyVariable; the "w" prefix to remind me its a word sized variable. Saves flicking back and forth.
But I usually forget....
Anyway, its a personal thing and whatever you're comfortable with.
(If anyone expects me to read semi-commented code only using bx and wx then forget it :) )
 

mickm2au

Member
Hi BCJ,
I've seen the LM2940 for automobile use and take your point, but I have plenty of 7805's, they're good for up to 35 volts in and they've been used in plenty of auto projects over the years, so I figure I'm pretty safe, especially on a diesel motor.

With the unit calibrated for an ADC reading of 120 at 12 volts, 20 volt applied to the battery sense lead will equal an ADC reading of 200. Although with the pot wound to max resistance and with 20 volts applied to the battery sense lead ( I just realized the 20v zener is not doing much) we would in theory get 5.47 volts at the ADC input pin, so to be absolutely safe you could do something like remove the 20 volt zener, put a 100 ohm in series with the 12v bat input (to limit zener current) with a 16 volt zener to ground from the junction of the 100 ohm and the 22k. This would limit the max volts at the ADC input to around 4.38 volts (if my maths is right!!).
 

Andrew Cowan

Senior Member
Long winded symbol manipulations can cause "brain fog" - I experience this myself when wrangling the likes of topvalue/elapsed_time * hit_number style expressions, finding b3/b4*b5 much easier to visualise.

I agree - I don't like defined symbols much... It also sometimes makes debugging other peoples programs harder (and sometimes easier)...

A
 

mickm2au

Member
As long as the B* and/or W* uses are commented at the begining I find it easier to write and follow my own programing, also some variables could be used for different purposes at different points in the program for which the original name could be meaningless. I also do a lot of Excel programing including VBA and find not naming cells and arrays etc easier.

Each to their own I guess...
 

hippy

Technical Support
Staff member
I'm surprised people find using symbol defined names harder to use. That goes entirely against my experience, and particularly when looking at someone else's code and trying to work out what it is meant to be doing without having to keep cross-referencing comments at the top of a program ( assuming they are there and correct ).

The advantage of symbol naming is that it allows anyone unfamiliar with the program to look at the code and see if there are any obvious logical flaws without having to understand the program fully. For example, is this likely to be right ... ?

w3 = w1 * w2 / 100 + w1

You have no idea without having to do further work, whereas the following is implicitly more understandable without further effort -

newBalance = oldBalance * interestRatePercent / 100 + oldBalalance

Without giving variables meaningful names, anyone looking at the code has to understand a lot more than otherwise and when seeking help that can become effort which people may be less willing to put in.

To my mind, using just the 'b' and 'w' variable names is like an author having written a novel using A, B, C, D as names of characters; one would likely quickly forget who anyone was and the plot interactions become much harder to follow.

Alternatively, imagine if every post here had the author identified by just a registration number and you had to look up that list of numbers to find who the poster was.
 

mickm2au

Member
Hippy,

I can see your point in other people looking at your code, but I'm more likely to make spelling errors every time I write a symbol and screw myself up. Maybe its left over from my original Z80 machine code programing which was all written in Hex that I cut my teeth on, (we didn't have an assembler then) and later on writing assembly language on 68705's referring to LDA 0F, LDB A1 etc and doing your maths with what few registers you had. I taught myself by reading books and magazines as my trade training was in the days of valves and early transistors, so that's when I probably went wrong. Basic is really a dream to use after that even with its limitations.

I guess I could write my code using B* and W* etc and then add the symbols later before "publishing" for other people to look at.
 
Top