I'm using these single coil latching relays: HTTP 301 This page has been moved, in order to power down my project when voltage drops below a certain level.
Like so:
...
#define IrEmitterPIN 3
#define PSPIN 7
...
#define VOFF 365L
...
long int pvalue = VOFF * 3;
...
void setup(void)
{
digitalWrite(PSPIN, HIGH); // turn the LED on (HIGH is the voltage level)
pinMode(PSPIN, OUTPUT);
delay(15); // wait for a second
pinMode(PSPIN, INPUT);
Serial.begin(9600);
...
}
void loop(void)
{
...
if (pvalue < VOFF) {
#if DBUG > 0
Serial.println("POWER 0FF");
#endif
xmit("oF", "-99", "-99");
digitalWrite(PSPIN, LOW); // turn arduino off
pinMode(PSPIN, OUTPUT);
}
}
The part that turns off the project works.
I don't know if there is a way to reset the relay upon power on. Ie return it to the reset condition, so in order to power on one needs to press SW1. Currently it just remains in the last position it was before power off. So if the project is on and I disconnect the battery, upon reconnecting it, everything powers-up immediately.
Thinking aloud.
At this point of time, the only thing that is available is the lipo voltage. According to the data sheet this is guaranteed to work down to 3.75V.
So I need to connect lipo + to relay#10 and gnd to relay#1 in a way that will be overwritten when arduino takes over. Then arduino will supply 5V to relay#1 and relay#10 must be connected to gnd through C1's positive........
To get the voltage reversal, you need to connect relay pin 1 to arduino pin 7 and relay pin 10 to arduino pin 6. On power up you gnd 7 and high pulse 6, to release you do the opposite. I would place a non-polarized capacitor across the relay coil to help limit the back emf spikes going to the adruino.
Hi @rcorr,
When power is initially plugged-in, and the relay is in the released state (or resetting position), there is no power to the arduino.
Initially i tried to use a 22uF cap, but it could not produce enough energy, in order to reset the relay and turn the project off, (when pin7 was driven low). Are there non polarized capacitors at this range?
I think I'm stuck...
Actually this setup is derived (by trial & error) from post #4 in this thread.
Initially I tried retrolefty's setup as is, but it needs the arduino pin to be held constantly high (if I remember correctly).
According to the data sheet this is guaranteed to work down to 3.75V.
The part number in the link you provided is the 3V relay that has a "must operate voltage" of 2.25V. Is this the actual relay you have that's being controlled by a 5V signal?
tzanampeths:
. . . . . but it needs the arduino pin to be held constantly high (if I remember correctly).
I do not understand why you are changing pin 7 to be an input in your code. You need to keep the capacitor charged otherwise no current will flow when pin 7 is set to low output.
I've used many single coil latching relays, but not with 5V or 3V coils. What I've found is that they respond much better and very reliably with a sharp square impulse rather than the exponential signal derived from a capacitor.
Usually the control impulse period is specified in the datasheet. This code will provide a sharp square impulse with 20ms duration and will reset the relay on startup.
@archbald you're right. It worked like this during testing, obviously because the capacitor still had some charge, as the tests time periods where very short. Last night I left it running overnight and obviously the cap had been discharged and would not reset the relay. So the pin must remain high. (This probably means that the 22uF was also correct/enough).