Go Down

Topic: Arduino to detect 20 VDC to 0 VDC drop? (Read 564 times) previous topic - next topic

vdubtim

Hello!

Brand new to Arduino and amateur with electronics, I have a question - would like to know if this is possible

I have a remote circuit energized at 20VDC. I would like for an Arduino Uno to monitor this circuit, so that when the circuit drops to 0VDC, Arduino will execute an interrupt.

I have been looking for the answer to this, and think it might be possible with the Arduino analog comparator. I am assuming I would need a voltage divider to bring the 20VDC to a lower level acceptable to the Arduino.

I also thought about opto-isolators and relays and am not sure they would work.

robtillaart

#1
Feb 11, 2012, 09:38 am Last Edit: Feb 11, 2012, 01:59 pm by robtillaart Reason: 1
You will need a voltage divider - 4 to 1 - and do an analogread() and if it drops set a pin high. optionally a reset pin

partial core code
Code: [Select]

void loop()
{
 float voltage = 20.0 * analogRead(A0) / 1023;

 Serial.println(voltage);  // or LCD.print ..

 if (voltage < 18.0)  // assuming 18V is the warning level
 {
   digitalWrite(alarmpin, HIGH);
 }

 if (digitalread(resetpin) == HIGH)
 {
   digitalWrite(alarmpin, LOW);
  //
 }
}


update - some typo's fixed
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

MarkT

Its not clear if this is an analog or digital (on/off) signal - a resistor divider and digital pin ought to sufice if the latter.

Dunno where the 18.0 came from in that snippet BTW - and the reset pin ought to reset, not set the alarmpin!
[ I won't respond to messages, use the forum please ]

robtillaart

Quote
Dunno where the 18.0 came from in that snippet BTW - and the reset pin ought to reset, not set the alarmpin!

added a comment and fixed the alarmpin.

Thanks,
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

vdubtim

Thank you both robtillaart and MarkT! Between the two of you, my question has been answered. Arduino rocks!

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy