Dc voltage monitor - is Arduino a reasonable choice? - Page 1
Forum section: electronics / general

author: Synthtech
author_rank: Regular Contributor
timestamp: January 01, 2019, 08:51:40 am
content: I have a requirement for a device that will monitor 5 different DC voltages and that will sound an alarm if any of them drift out of range. The voltages are all within the +15V to - 15V range, for example +15V, +10.6V, -6.5V, +8.5V and -15V. (Edit: and to display the voltages on a readout).It’s time that I got into micro controllers and I think that this would be a good project to learn about programming with. I understand that I will need to scale the voltages down into something that falls within the voltage range that the microcontroller inputs or ADC can deal with, the electronics is no problem for me but my question is which micro family would suit this project.Can anyone tell me if Arduino would be a suitable platform to design this project around or should I choose another platform or even something larger like Raspberry Pi?Thanks!

author: donotdespisethesnake
author_rank: Super Contributor
timestamp: January 01, 2019, 09:07:38 am
content: If by "sound an alarm" you mean something physical like a buzzer, then Arduino would be ideal. No doubt "pro" users will tell you Arduino is awful, but it remains far and away the easiest and most accessible platform for beginners to micro controllers.

author: fchk
author_rank: Frequent Contributor
timestamp: January 01, 2019, 09:09:29 am
content: The most obvoius method would be a couple of LM339 comparators, which would do the job completely without any uC.If you absolutely must use an uC, any will do.

author: Synthtech
author_rank: Regular Contributor
timestamp: January 01, 2019, 09:34:26 am
content: Quote from: fchk on January 01, 2019, 09:09:29 amVery true, I did want to use it as a microcontroller learning exercise so I probably should take it further and add some read-outs as well. I will go back and edit my post and add that in.

author: thieringpeti
author_rank: Contributor
timestamp: January 01, 2019, 12:57:47 pm
content: Hi!Use voltage dividers for ADC inputs, and write a simple program which reads the ADC pins frequently, then use an Arduino sound library to play a tune or a beep. Only some resistors, and a small speaker or piezo buzzer is needed! For displaying the voltages, use any simple LCD module, e.g. a cheap 2x16 or 2x20 character module. Arduino libraries were available and well documentated for these.A simple example can be found there:https://www.electroschematics.com/9351/arduino-digital-voltmeter/(google: arduino voltmeter)For the negative voltage, it's a bit more difficult, but with an op-amp can be handled and converted to positive with a simple inverting amplifier circuit. Note, that that op-amp needs a symmetrical power supply.A bit complicated example for negative/positive voltages:https://electronics.stackexchange.com/questions/252431/measure-both-positive-and-negative-voltages-using-adcNote, that all the input voltages must be converted to the range between 0V and VCCMCU (5V for Arduino). Also note, that the AVR's internal 10-bit ADC isn't very precise, but a reasonable readout can be get.

author: Synthtech
author_rank: Regular Contributor
timestamp: January 01, 2019, 07:17:04 pm
content: Thank you Thieringpeti, great information. I have no problem with the electronics to build the appropriate op-amp power supply and dividers and to invert the negative voltage values to positive to suit the Arduino inputs. It’s not a big issue that the Arduino converter resolution isn’t that great, the displayed voltage values need only to be basically accurate, the system only needs to trip if the voltage of any of the rails shifts by .5V or more.Thanks for your reply, I will go with the Arduino platform then and get to work building the scaling/onverting board and power supply.

author: rstofer
author_rank: Super Contributor
timestamp: January 02, 2019, 05:34:02 pm
content: But... You didn't specify what the "range" is. Depending on how you use the ADC input span, you might not even be able to measure the "range" if it is small. This needs more detail of the specifications.Second, even if you use op amps, they will normally be powered by +- 15V and they don't work to the rails (usually) so you would need to divide the incoming voltages. Of course, it would be better if you could use single supply 5V op amps.There is a process for "offset and scale" using an op amp and 4 resistors to essentially move 15V down to the middle of the rail voltage (call it 0V for bipolar op amps, 2.5V for 5V single supply op amps) and then measure small variations.See Chapter 4 of "Op Amps For Everyone".http://web.mit.edu/6.101/www/reference/op_amps_everyone.pdfNote that examples use single supply op amps which will be a lot more convenient when connecting to the Arduino.I had this 24V battery bank for a DC powered small boat. The battery voltage needed to be between 20V and 28V (I have forgotten the exact range). I didn't care at all what the voltage was when it fell below 20V because I would be dead in the water. Offset and scale allowed me to ignore the first 20V and change the 20-28V range (8V) to something in the 0-5V range of the ADC. A little arithmetic inside the uC allowed my to display the actual voltage.

author: Synthtech
author_rank: Regular Contributor
timestamp: January 02, 2019, 09:19:43 pm
content: Quote from: rstofer on January 02, 2019, 05:34:02 pmWhat an elegant idea. So, if I am understanding you correctly, I would use op-amps and resistor dividers to shift the monitored voltages to the mid-point of their respective op-amp’s voltage range at the op-amp’s output and then use the Arduino to monitor variations from this voltage. So if for example I was using a dual rail op-amp I would scale the voltage under test using this method to read zero volts at the op-amp’s output when the input voltage is exactly in spec. So in the case of the input voltage drifting in a fault situation the op-amp’s output would deviate from zero and the Arduino would note the variation and output an appropriate result. I would decide how much variation was tolerable and use arithmetic in the Arduino program to scale the amount of variation from zero volts to equal the desired maximum variation in the voltage under test.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: January 02, 2019, 10:19:45 pm
content: Quote from: Synthtech on January 01, 2019, 08:51:40 amThat depends on how fancy you want that "display the voltages on a readout" !IIRC RaspPi has no native DC ADCs , but you could connect parts like INA199 i2c voltage/current monitor devices.It also depends on how accurate you need this to be. What is your out of bounds limit, and what % precision do you need to have ?Ardunio uses the power supply as voltage reference, and the mega328 has 10b ADCs, and 1% resistors are easy to get and cheap....- but a calibrate step could be enough to push you to under one percent overall error.Quote from: Synthtech on January 02, 2019, 09:19:43 pmClose, but you would target mid-supply on the Ardunio ADCs not zero volts, as the ADCs cannot read below 0VSimplest is just resistor dividers to GND for the +ve sense, and you can divide to VCC for the -ve rails. (target 50% Ardunio supply as the ideal good point)If you want a low cost board with display already fitted, and 12b ADCs there is this N76E003 one at $2.70https://www.electrodragon.com/product/intermittent-switching-relay-module-n76e003-mcu/

author: Synthtech
author_rank: Regular Contributor
timestamp: January 03, 2019, 07:32:10 am
content: Quote from: PCB.Wiz on January 02, 2019, 10:19:45 pmAah, thank you, that makes sense - set the correct target voltage to match the Arduino ADC’s mid point voltage so that it can swing either way. Then scale in software to set limits. I will go take a look at the link that you posted, thanks!

author: Seekonk
author_rank: Super Contributor
timestamp: January 03, 2019, 08:38:56 pm
content: I use the NANO for all these small jobs. Spend $3 and you are done. One thing to warn you of. I use a USB cable with the +5V line cut. You can use back to back diodes if that makes you nervous. This assumes you use the 5V as the reference voltage. The micro will run off whatever 5V source is higher. That can leave you with a perfectly calibrated system being way off when hooked up stand alone. Do all your calibration with the final power supply in place.

author: Synthtech
author_rank: Regular Contributor
timestamp: January 04, 2019, 12:18:28 am
content: Quote from: Seekonk on January 03, 2019, 08:38:56 pmGood advice, thank you.