| Electronics Forum |
Help
Search
Members
Calendar
|
| Welcome Guest ( Log In | Register ) | Resend Validation Email |
![]() ![]() ![]() |
| nigelmercier |
Posted: November 03, 2009 06:25 pm
|
|
Member ![]() ![]() ![]() ![]() Group: Trusted Members Posts: 201 Member No.: 6,542 Joined: September 29, 2006 |
I want to make a replacement fuel gauge display for a boat, using a PIC microcontroller.
The sensor is a variable resistor activated by a float in the fuel tank; one terminal is connected to the 0V rail (although it may be possible to isolate it if necessary). The resistance of the sensor is to to be verified, but is likely to be either 0 Ohm to 180 Ohm, or 0 Ohm to 300 Ohm. The existing display is a moving coil meter in series with the sensor and the 12V rail. What would be the best way to use the existing sensor? -------------------- --
Nigel |
| kellys_eye |
Posted: November 03, 2009 07:16 pm
|
![]() Forum Addict ++ ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Spamminator Taskforce Posts: 9,985 Member No.: 2,735 Joined: June 21, 2005 |
What kind of display? Digital or analog?
Check also the the fuel level sensor isn't actually a 'stepped' sensor (magnet running up/down a tube having reed switches in it). Assuming it's a vairable analog signal it's a matter of making a voltage divider and measuring the resultant volatge and making up your own scaling factor. -------------------- May contain nuts
|
| Roccivic |
Posted: November 03, 2009 07:59 pm
|
||
|
Moderator Group: Moderators Posts: 7,483 Member No.: 7,882 Joined: January 19, 2007 |
Why do you want to use a PIC for such a dumb task? What a waste of thousands of transistors... As Dave correctly pointed out we can't really help if we don't know what you want to do... |
||
| telomere |
Posted: November 03, 2009 08:04 pm
|
||||
![]() Forum Addict ++ ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Spamminator Taskforce Posts: 4,296 Member No.: 9,502 Joined: May 18, 2007 |
Why, are those transistors in a scarcity or something? With that crazy Moore guy making twice as many every 18 months, we need to do SOMETHING with them, or they're going to pile up all over the place, we'll be buried in them. -------------------- "Sometimes I can't tell the difference between thinking and being quiet, but I'll try."
|
||||
| kl27x |
Posted: November 03, 2009 09:22 pm
|
|
Forum Addict ++ ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Spamminator Taskforce Posts: 3,863 Member No.: 4,223 Joined: February 06, 2006 |
+1. Each additional transistor is just a few more nanograms of silicon.
When you consider the potential for additional IC packaging of a multi-IC analog solution as well as potential inefficiencies (vs a microcontroller with smart power management), you might find the analog solution to be the wasteful one. |
| nigelmercier |
Posted: November 04, 2009 12:00 am
|
|
Member ![]() ![]() ![]() ![]() Group: Trusted Members Posts: 201 Member No.: 6,542 Joined: September 29, 2006 |
I'm not sure it is relevant, but I'll answer your questions ...
The new display is to be both digital and analogue, showing percentage of fuel remaining as a bar, approx number of litres, trip fuel used, current engine running time, perhaps even rate of fuel use. The tank is shaped like an elephant (or any similar irregular shape), so the current display is very non-linear. It stays at FULL for days, then drops like a stone. I want to make the device both as an exercise, and so I can have a more relevant display. Obliviously it will need to be manually calibrated. Is a simple voltage divider sufficient? I figured it would need some sort of bridge - or am I showing my age? -------------------- --
Nigel |
| kl27x |
Posted: November 04, 2009 09:49 pm
|
|
Forum Addict ++ ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Spamminator Taskforce Posts: 3,863 Member No.: 4,223 Joined: February 06, 2006 |
An ADC pin has a maximum recommended impedance, specified in the datasheet. For a typical PIC, 10k is the max recommended impedance. Any higher, and the results will be skewed. There is no minimum. The lower, the better. So you could hook the ADC pin up directly to a strong power source, so long as the max voltage isn't exceeded.
Just make sure your fixed resistor goes on the top side of the divider. Then your max voltage will be limited to where you want it to be. For instance, if your sensor has a max resistance of 300 ohms, you could remove the coil and replace it with a 600 ohm resistor. Then you'd have a voltage output of 0-4V, with a relatively low impedance. If there is any noise in the voltage source, you can put a small bypass cap between ADC pin and ground rail. |
| millwood |
Posted: November 08, 2009 01:12 pm
|
|
Forum Addict ++ ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Trusted Members Posts: 1,823 Member No.: 25,377 Joined: July 26, 2009 |
yeah, using a fixed resistor in serial with the fuel sensor would be the way to go.
I would choose a pic with internal voltage reference so you can also measure the Vdd to the mcu. |
| kellys_eye |
Posted: November 08, 2009 02:07 pm
|
![]() Forum Addict ++ ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Spamminator Taskforce Posts: 9,985 Member No.: 2,735 Joined: June 21, 2005 |
The non-linearity of the current readout is usually becasue the wrong type of pick up sensor is fitted. In your case I suspect a 'lever arm' device is installed. That, or the sliding magnet/tube version is using a tube that is too short.
To do the measurements you describe though, you'll need to know the actual flow rate which will mean sensors on the fuel feed and return pipes. -------------------- May contain nuts
|
| millwood |
Posted: November 08, 2009 02:14 pm
|
||
|
Forum Addict ++ ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Trusted Members Posts: 1,823 Member No.: 25,377 Joined: July 26, 2009 |
you can always calibrate the software to show the correct "volume", through a look-up table for example. for example, you can pre-measure the relationship between volume and sensor value, sensor volume 0ohm 1L 10ohm 2L 20ohm 30L 30ohm 50L ............ 300ohm 934L once you do the adc, you can figure out the true sensor resistance. then all you need to do is to look up that table and interpolate the volume. that should be a piece of cake for the software. |
||
| millwood |
Posted: November 08, 2009 02:16 pm
|
|
Forum Addict ++ ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Trusted Members Posts: 1,823 Member No.: 25,377 Joined: July 26, 2009 |
for flow rate, you will need to measure time (easy) and change in volume (more difficult but doable).
likely some kind of smoothing has to be done as well. but having a flowmeter will be more accurate / easier / faster. |
| millwood |
Posted: November 08, 2009 07:07 pm
|
|
Forum Addict ++ ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Trusted Members Posts: 1,823 Member No.: 25,377 Joined: July 26, 2009 |
I took this exercise to see how much of the old code i can reuse,
here is something I put together in half an hour. It consists of basically three modules: 1) a hd44780 driver that I wrote for a lcf meter I am working on right now. it acts as the display for the unit; 2) an interrupt based timer: based on a frequency generator I wrote earlier. it uses timer1. 3) an adc module that I had. every pre-determined time (specified by the user), the timer sets up a flag to trigger the adc module, which measures the resistance, converts it into volumic information to be displayed on the LCD. the calculation uses floating point library and does exponential smoothing. all of that done in 30 minutes, ![]() it does not implement a calibration / look-up function to translate ohmic readings into volumic figures - now it is simply a linear function. also, since it uses Vdd for adc reference (vs. a fixed reference voltage), the readings are subject to Vdd fluctuations. I am happy to upload the source file if you want to see. |
| Village Idiot |
Posted: November 09, 2009 12:07 am
|
![]() Forum Addict ++ ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Trusted Members Posts: 1,402 Member No.: 11,398 Joined: October 08, 2007 |
Unless the tank sending unit has some kind of mechanical damping, you will need to include a low pass filter on your fuel level signal (implemented in PIC code of course) to prevent the fuel level display from bouncing all over the place as the fuel sloshes around in the tank.
For fuel flow measurement, if your engine has electronic fuel injection, then the easy way is to monitor the signal to one of the injectors. It will be a PWM signal proportional to fuel flow. |
| millwood |
Posted: November 09, 2009 02:02 am
|
|
Forum Addict ++ ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Trusted Members Posts: 1,823 Member No.: 25,377 Joined: July 26, 2009 |
exponential smoothing is a digital low pass filter.
|
| Village Idiot |
Posted: November 09, 2009 03:15 am
|
||
![]() Forum Addict ++ ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Trusted Members Posts: 1,402 Member No.: 11,398 Joined: October 08, 2007 |
I missed that part of your post. |
||
| NGinuity |
Posted: October 27, 2010 07:35 pm
|
|
Newbie ![]() Group: Members+ Posts: 1 Member No.: 33,082 Joined: October 27, 2010 |
Hi, I was wondering if you still had this code lying around? I'm looking to do something a little simpler, with a 10 segment LED bar and this would save me a ton of time.
Thanks in advance :-) -Eric |
![]() |
![]() ![]() ![]() |
:: support us ::