Q. I have a (fuel) gauge that accepts a configurable resistance range (0-500 ohm, two-wire, one to ground), which I want to control with an micro controller (Arduino Pro Mini or Nano with an Atmel 328P).
Some considerations:
- I'm already using SPI for a CAN bus, and am hesitant to add another device on the SPI bus, as the CAN bus is rather mission critical. i.e. don't want to miss CAN messages. Also it requires quite a lot of wires.
- I also already use i2c, adding an i2c device would be straight forward in this application. I mention this because I see i2c digi pots out there.
- Accuracy is somewhat needed (say <10%). I've seen that most digi-pots have an relative accuracy of max ~20%. However, they continue to explain that the relative accuracy is low, but I'm not sure what that means.. this question probably merrits its own topic though, so forget that for now unless it's a one sentence answer.
- Ideally the components required are through-hole/DIP, but this is not a hard requirement.
I think the gauge is designed to be controlled by a rheostat, as it requires a linear resistance range, correct me if my assumption is wrong).
What would be my options? Could it somehow be done using the Arduino's analog output? When researching, I've come across Digi-Pots, DACs and JFETs. But the application was never the same as what I'm doing, often using PWM and more geared towards voltages then to resistance...
Update; Some more details:
- Fuel gauge has two wires, a positive and a negative. The positive wire sends out a 5V, 17-19mA current (for those who want to know, it's a Speedhut gauge).
- Arduino is 5V and, depending on which analog PWM pin you use, outputs a PWM signal at either 490Hz or 977Hz. The duty cycle is controllable in the code between 0-100%.
- The application is automotive. The vehicle is 24V. The gauges are 12V, fed by a small buck controller. The gauge has a microcontroller, and I suspect runs at 5V.
Update; output not as expected:
I'm measuring a constant ~19kOhm on the circuit output (multi meter between "output"-wire and ground). I would expect it to vary as the PWM duty cycle changes.
I've not hooked the fuel gauge up yet, as first I want to make sure the circuit is OK. I have hooked up my multi meter instead. Maybe it simply doesn't work like that, perhaps the multi meter current output is too weak?
PWM output is correct according to my multi meter; it gives me a nice 490Hz 0-100% duty cycle.
I've attached a photo of my breadboard layout. My phone doesn't have a great camera, so i've added the names of the components. What's not clear on the photo is that both the 10k resistor coming from the LM and pin 3 of the Mosfet are on the same row 10, the tiny 10pF resistor is on rows 10 and 11. I think I've copied the schematic pretty accurate. I did not have some exact resistor values, so I've used close ones, which I think should be good enough to see output.
I'm not just chucking my problem over the fence, but any pointers would be welcome, I'm still only a few months into this stuff. :) Thanks!
*typo: 10pf = 10nf