Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Set voltage level external interrupt Arduino UNO

Status
Not open for further replies.

imranahmed

Advanced Member level 3
Advanced Member level 3
Joined
Dec 4, 2011
Messages
817
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
Karachi,Pakistan
Activity points
6,493
Please let me know I connected a LDR to Arduino UNO at pin A0 analog pin and Arduino UNO`s sleep and wake instructions are programmed. But only external interrupt is available for wake up of microcontroller cpu. I want to wake up microcontroller at a certain voltage level defined by me. Do we set external interrupt voltage to trigger at pre-defined level?

Full working code is below but voltage level to trigger external interrupt at pin2 is want to know?

Code:
#include <avr/sleep.h>
#define interruptPin 2
unsigned long lastTimeOut = 0; 
unsigned long timeOut = 5000;
const int LDR_PIN = A0;

void Sleep(){
sleep_enable(); // Enable sleep mode
attachInterrupt(0,wakeUp, LOW); //Attach interrupt to pin 2
set_sleep_mode(SLEEP_MODE_PWR_DOWN);//Full Sleep mode
delay(1000);
digitalWrite(LED_BUILTIN, LOW);// LED OFF
//delay(1000);
sleep_cpu();
Serial.println("Just Woke Up");
digitalWrite(LED_BUILTIN, HIGH);// LED ON
}
void setup() {
  Serial.begin(9600);
  pinMode(interruptPin, INPUT_PULLUP);
  pinMode(LDR_PIN, INPUT);
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);
  lastTimeOut = millis(); 

}

void loop() {
  int ldr = analogRead(A0);
  int v = (5*ldr)/1023;
  Serial.println(v);
 if((millis() - lastTimeOut) > timeOut){
      lastTimeOut = millis(); 
      Sleep();
    } 
 //   delay(1000);
}
void wakeUp(){
Serial.println("Interrupt Fired");// message to serial port
sleep_disable();// Disable sleep mode
detachInterrupt(0);// remove interrupt from pin 2
}
 

There are compound parts available whioch have a Vref and a
comparator in one package.




Regards, Dana.
 
There are compound parts available whioch have a Vref and a
comparator in one package.




Regards, Dana.
Can I use LM393 because it is only available here and if I would like to buy MAX954 or TLV3011 it will take some time to reach but I need urgently?
 

Can I use LM393
it is a comparator.
Whether you can use it in your application depends on: power supply requirements, input signal requirements, ouput signal requirements, timing...
Did you give any electrical requirement or information?

Klaus
 

it is a comparator.
Whether you can use it in your application depends on: power supply requirements, input signal requirements, ouput signal requirements, timing...
Did you give any electrical requirement or information?

Klaus
Yes use for Arduino UNO external interrupt trigger at certain voltage level set by me and full code is available in first post
 

Hi,

I did a search on the datasheet for "no power supply" and "certain voltage level" --> no results.
Let´s blame it on a bad datasheet. ;-)

Klaus
 

Hi,

I did a search on the datasheet for "no power supply" and "certain voltage level" --> no results.
Let´s blame it on a bad datasheet. ;-)

Klaus
:giggle:
Power supply is 5V and interrupt trigger voltage is 4V.
 

Hi,

* datasheet on first page says LM393 has a supply voltage range of 2.0V ... 36V.
--> There is no doubt that 5V is within this range.

* datasheet says "input common mode voltage range" is 0V ... VSupply - 1.5V. So if supply voltage is 5v then the upper limit is 5V -1.5V = 3.5V.
--> 4V is not operational, but it will cause no damage.

Don´t expect that I read all datasheets for you.

Klaus
 

Hi,

* datasheet on first page says LM393 has a supply voltage range of 2.0V ... 36V.
--> There is no doubt that 5V is within this range.

* datasheet says "input common mode voltage range" is 0V ... VSupply - 1.5V. So if supply voltage is 5v then the upper limit is 5V -1.5V = 3.5V.
--> 4V is not operational, but it will cause no damage.

Don´t expect that I read all datasheets for you.

Klaus
Ok, I have to find one which is VSupply - (less than 1.5) means 1 or 0.5 but 0.5 is better.
0V.......VSupply - 0.5 = 5V-0.5V=4.5V??
--- Updated ---

Ok, I have to find one which is VSupply - (less than 1.5) means 1 or 0.5 but 0.5 is better.
0V.......VSupply - 0.5 = 5V-0.5V=4.5V??
If I change Power Supply to 3.3V instead of 5V.Will it within range? For LM393.
One more thing I want to add I can change detection level not necessary 4V 2.5V is good for 5V power supply.
 
Last edited:

You can use LM393 with its Vcc = 5V and a 2.5 V reference voltage, derived
from 5V or whatever.

However if the Vin to the comparator exceeds, over temp, Vcc - 2V phase reversal
will occur because your input exceeds 3V (Vcc of 5V - 2V limit on common mode
over temp). See ap note on this.

**broken link removed**

Note in ap note an LM339 (not LM393) can have one input, say Vref, in the CM range and if other
input goes outside CM range (within absolute max specs) no phase reversal will occur.

Either scale the Vin low enough with an R divider and use a low Vref, say a 1V for trip level
(same as Vref) or get a comparator, single supply, that common mode rail to rail on
input. Even a R-R OpAmp could be used in comparator mode (if you do not need open collector
output). Or use a zener on input to clamp it to stay in CM range.

Don't forget to put some hysteresis around it to handle noise suppression.



Regards, Dana.
 
Last edited:
phase reversal
will occur because your input exceeds 3V
I don´t think so.

AN says: phase reversal, occurs when the input of the comparator violates the negative common-mode voltage range.

Klaus
 

I don´t think so.

AN says: phase reversal, occurs when the input of the comparator violates the negative common-mode voltage range.

Klaus

I dont think so -

The range between 3.5 V and 4 V is the gray zone, where the device appears to still function at 25°C and
above, but critical specifications are deteriorating, such as offset voltage, bias current and particularly
propagation delay as the input stage is gradually cut off. These effects may not be immediately apparent.
Operating at low temperatures will cause failures. Operation in this zone must be avoided.
Between 4 V and 5 V, and even up to 36 V, the input stage is cut off and input bias current is falls to zero.
The actual cut-off threshold depends on temperature. Comparator operation ceases. DO NOT operate in
this area!

" Comparator operation ceases. DO NOT operate in this area!" If comparator operation ceases what is the output ?
I would say undefined, and could be phase reversed.

Regards, Dana.
 

You can use LM393 with its Vcc = 5V and a 2.5 V reference voltage, derived
from 5V or whatever.

However if the Vin to the comparator exceeds, over temp, Vcc - 2V phase reversal
will occur because your input exceeds 3V (Vcc of 5V - 2V limit on common mode
over temp). See ap note on this.

**broken link removed**

Note in ap note an LM339 (not LM393) can have one input, say Vref, in the CM range and if other
input goes outside CM range (within absolute max specs) no phase reversal will occur.

Either scale the Vin low enough with an R divider and use a low Vref, say a 1V for trip level
(same as Vref) or get a comparator, single supply, that common mode rail to rail on
input. Even a R-R OpAmp could be used in comparator mode (if you do not need open collector
output). Or use a zener on input to clamp it to stay in CM range.

Don't forget to put some hysteresis around it to handle noise suppression.



Regards, Dana.
I am very thankful to you Dana, you give a very important information. I will do it.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top