Pages: [1]   Go Down
Author Topic: Arduino to detect 20 VDC to 0 VDC drop?  (Read 503 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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
« Last Edit: February 11, 2012, 07:59:14 am by robtillaart » Logged

Rob Tillaart

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

0
Offline Offline
Shannon Member
****
Karma: 200
Posts: 11730
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

[ I won't respond to messages, use the forum please ]

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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,
Logged

Rob Tillaart

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

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: