New gauges programming.
I got a fair amount accomplished with programming the gauges today. At least the temp gauge at any rate. I didn’t do anything with the fuel gauge)Thermistors are fickle little things that don’t lend themselves to easy programming for a novice. They don’t have a linear resistance profile that would make them easy to read from. They are logarithmic.
There are equations that can relate the ADC input in the microcontroller to the real temperature, but I don’t need actual temperatures, as I’m only driving a dummy gauge. Close enough is good enough. The actual engine temp is calculated in the Megasquirt and I don’t have to program that thankfully.
I do however have a sheet that shows what the resistance reads at various temperatures, and from that I can calculate the ADC, and from that I can assign a position in the stepper motor.
I used a function called a “MultiMap” in Arduino. It allows me to assign certain inputs to certain outputs, and between the points are linearly approximated. For example, I know that at operating temp (190F) I want the needle to point right to the first line on the gauge. 230F I want at the beginning of the overheat, and 240F I want the needle pegged at the top. I’ll probably set it to flash some warning lights as well when it starts to overheat.
The points on the gauge aren’t linear with the temperatures I want for them so writing an equation is out of the question.
At first I was calculating what the ADC input would be at a given temperature with a given bias resistor by hand, but after doing that for 20 minutes I realized Excel should be able to make quick work of it.
I spent 2 hours writing the formulas in the sheet and teaching myself how to use the “concatenation” capabilities, but it was weĺl worth it. Depending on which bias resistor I choose for the top half of the voltage divider, I could gain resolution in the higher temps. But the downside is the circuit then consumes more power. Because I’m not displaying ACTUAL temperature, I don’t really need too much resolution. Right now I’m using a 2.2k bias resistor, but I’m going to lower it to 680 ohms when I design the actual board. That will be a very easy change in the code thanks to the multimap generator I wrote.
I made up some SMD adapter boards that allow me to use my SMD components on my breadboard. That makes it so I don’t have to stock 2 of all my components (one through hole and one SMD) This way they all pack very nicely into my SMD parts organizer, and there’s zero risk of shorting out the long exposed legs on through hole resistors pushed into the breadboard. I still need to populate the rest of the boards though.
You can see in the pictures the screenshot of my Excel spreadsheet. I put in the values I want and it spits it out so all I have to do is copy and paste it, and it’s already in the correct format and syntax. I highlighted one of the output cells so you can see what the formula looks like to make it in case you need it for something else.
After I got the multimap generator finished I installed the GM temp sensor into my motor. The water neck has two spots for coolant sensors. One was no doubt for an emmissions computer, and the other for the gauge. My EFI tstat housing has three spots I believe. I hope to eventually drive all the gauges through the CANbus from the Megasquirt, but if that doesn’t work out, I can still discreetly measure everything I need.
I was able to put a lighter on the end of the sensor and drive the needle all the way up the scale, then it would slowly cool back to ambient.
The GM sensor has a 3/8NPT thread on it. The factory senders have some metric thread on it. Luckily the factory thread is very close in size to 3/8NPT so I just need to run the tap through it. I tapped it and installed the new sensor.
I have a battery powered USB phone charger that I use to power a cheap bluetoth receiver for my garage radio. I used that to power the Arduino and plugged it in to the sensor. It read exactly where I expected it to at around 75F. I’ll probably lower that point a little further towards the “cold” line.
I started the engine and let it idle for 20 minutes. It was extremely satisfying watching the the needle slowly creep up then stop right below the operating temp line. I must have a 180F or 185F thermostat in it. It’ll take ten seconds to change that datapoint in the multimap.
I also found the other fender mirror and debugged my electric mirror adapter board. I’ll send two of those boards off to be made, and I’ll post those details when I install and wire them up. But at least now I have two fender mirrors and shortly I’ll have a proper temp gauge!
I still need to cough up the $40 for the capacitive fuel level sender. That one will be a linear input and that will make it very easy to program the gauge. Physically installing it will be a different matter though. I’m not yet sure how I’m going to do that, but I’m sure it won’t be too tough once I get into it!