Go Down

Topic: rtc to replace an arduino logic high pulse (Read 334 times) previous topic - next topic

Fredric58

Good afternoon, The attached schematic is a simple Mosfet latch circuit created by Kevin Darrah which I got off of youtube. L-1 and L-2 are attached to the Arduino. A logic HIGH PULSE on L-1 will turn the circuit ON and another Logic HIGH PULSE to L-2 will turn the circuit OFF.

What modification to this schematic is required to utilize the DS3231 SQW/INTO alarm signal to replace L-1 logic HIGH PULSE from the Arduino to activate this circuit?

Though not marked both BJT transistos are currently NPN's

A pictures worth a thousand words.

The goal is to have the RTC "alarm" turn on the circuit at a specific time, and then have a logic high pulse to L-2 from the Arduino turn OFF the circuit hours later.

Many thanks, Have a great weekend!


wvmarle

RTC outputs are open collector outputs, so you need a pull-up resistor that's strong enough to switch on the transistor. Probably drop that base resistor as well.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Fredric58

hi and thank you, can you draw it out to where i can follow it? schematics are much easier to follow in my case.

thanks

wvmarle

#3
Jul 21, 2018, 10:15 am Last Edit: Jul 21, 2018, 10:17 am by wvmarle
Like the left-hand schematic:

Disadvantage (especially when on battery power) is that the RTC has to pull the line low all the time to keep the circuit engaged, wasting 0.5 mA of current. But then I realised that Q7 is basically an open collector output itself, so you can connect the alarm of the RTC directly to that point omitting the complete transistor, like in the circuit on the right. Now you will switch off on a logic LOW from the RTC, so you just have to tell it to reverse its alarm logic (I assume this can be done - at least other RTCs can do just that).
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Fredric58

Thank you very much for the input. I am rather new to electronics so I will have to study this awhile before it sinks in.

In retrospect it seems the open drain of the RTC will work fine in that all that needs to be done at L-1 is pull the P-CH VP2106 Gate LOW to turn on the circuit??? Eliminating the transistor at L-1 as well

Then use a logic HIGH at L-2 from the Arduino to turn it off.

Do you think a pull up would be required on the SQW?

RTC's are a new editions to my projects so I'm going to assume that when the RTC alarm goes off it basically dumps to ground? Is that correct?

Thanks for your assistance!

 

wvmarle

Indeed, L1 can be replaced by an open collector output (also called open drain, same thing). Such an output can only sink current, not source any, so requires a pull-up to create a high level signal. They're used a lot because they're cheap to create, and logic level agnostic: regardless of the voltage used within the device that has this output, you can pull it up to any voltage the output transistor can handle (so a 24V device can be used safely for 3.3V logic levels, and a 5V device with 12V or higher logic levels). Disadvantage: only driven low, not driven high.

If you're connecting it to an Arduino: be careful to switch using pinMode rather than digitalWrite! This as an open collector switches basically between INPUT and OUTPUT, LOW (a normal pinMode(pin, INPUT) sets the pin to LOW as well). In code:

Code: [Select]

pinMode(L1pin, INPUT); // L1 output is inactive.
pinMode(L1pin, OUTPUT); // L1 output is active, pulling it low.


If you set the L1 to logic HIGH while the nmos is conducting, you create a  short.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Fredric58

Ok, so this is what I'm thinking. When the 5V switch is turned on the 10K holds the P CH gate HIGH so it's OFF. When the RTC dumps the P CH to ground I get 5V OUTPUT and the N CH is turned ON, holding the P CH OFF till the gate of the N CH goes to GND and turns it OFF

wvmarle

Should work like that - you can do without the NPN & 1k on the L2 connection. Just connect L2 directly to that nmos. Then a low output switches off the circuit, setting the pin to INPUT (default state upon startup) keeps it on.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

Fredric58

" Then a low output switches off the circuit, setting the pin to INPUT (default state upon startup) keeps it on."

Not sure I understand this logic. When the circuit is ON (5V OUTPUT) There will be voltage at the gate of the N CH. The Arduino pin reads that as INPUT while the circuit is ON?

To ground the gate of the NMOS to turn it OFF, I do what?

Thanks, I'm pretty much a beginner.



wvmarle

You don't have to read an input for a pin to be an input. Upon startup all pins are set to input, high impedance, effectively disconnected from the circuit.

Then to ground it, simply set it to output, which unless set otherwise will be low.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

lastchancename

How are you programming and managing the RTC?
All this fizzy latching logic may be irrelevant if you're using an Arduino or other cpu.
Just do everything inside the code.
Experienced responders have a nose for laziness, (they were beginners once)... expecting the poster to contribute to the learning experience.

Fredric58

Hi, the RTC works outside the "code", it is simply "a switch" The alarm is set to trigger at 5pm and 5 am, THAT turns on the circuit that powers the Arduino and other devices. After 3 hours, the Arduino sends a signal to L-2 which shuts down the power completely. In POWER _DOWN the Arduino uses approx 3-4 uA. "supposedly", according to the original author, the "simple latch circuit" uses LESS power than the Arduino in POWER_DOWN mode. My project is battery powered, EVERY milla, micro nano amp is crucial. My project doesn't do ANYTHING 18 hours a day. So the less power consumption I have during those 18 hours the better.

All suggestions are welcome as I am a beginner with a little experience. BUT!!!! I can happily say I have gone from my project working/running for 1 day, to over 3 weeks. But still would like to expand that to 3 months. I haven't any "formal" training in electronics or writing code. But it has become an obsession. 

What would be cool, is if the RTC alarm was a logic HIGH. because once you start a NMOS they run till you dump the gate to ground, and there would be no need for the pull up resistors. Which I believe would save power. the project on a RTC. The RTC turns on the project/powers the Arduino, THEN, the Arduino tells the power supply to TURN OFF till the next RTC alarm tells it to turn back ON.

I have no way to quantify which uses less power than to build one and see how long it lasts. Instead of days, it take weeks now. But still as much fun as it was in NOV 2014 when I started this project.

Thanks to all for putting up with me!

 

 




Go Up