Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Help with Counter circuit to turn relay on and off

Status
Not open for further replies.

jack0987

Member
I have an arduino with an internet shield2 that every now and then
stops responding to web requests and I have to power recycle it.

At present, I do not know what causes this, but as a backup I would like to put together
a simple 5VDC counter circuit to power recycle it with a relay to turn it off and then back on
let us say every one or two hours or once a day perhaps. Exact timing is not important.

So, roughly, I need to create:

1. A 5VDC circuit using TTL stuff I have on hand
2. A counter add up circuit
3. After the recycle is done, I need to reset the count.
4. If the Arduino is in use with a web request, I also need to reset the count to prevent the interruption.
This I can take care of in the Arduino code by outputting a logic high or low.


Using an on hand TLC555CP, I made a circuit that pulses about 10 times a minute. (I have attached this image)
I should be getting about one pulse per second, but probably did not do something right but can work with it.

Now I would like to add the counter part and need some help to how to go about doing it. Please comment.
 

Attachments

  • 555timer.gif
    555timer.gif
    15.5 KB · Views: 151
I think a CD4060 would be a better solution than a 555. It is an oscillator circuit followed by a 14 stage counter. It will give you a long timing period using reasonable value timing components.

Les.
 
Theres nothing wrong with ideas so far however heres a bit of lateral thinking, if you want to reset the 'duino you can make it do that itself, there are at least 2 ways:

resetFunc() resets the chip.

Or you could enable the watchdog timer and go into a continuous loop, the watchdog will time out and reset the chip for you.

No hardware solution.
 
Theres nothing wrong with ideas so far however heres a bit of lateral thinking, if you want to reset the 'duino you can make it do that itself, there are at least 2 ways:

resetFunc() resets the chip.

Or you could enable the watchdog timer and go into a continuous loop, the watchdog will time out and reset the chip for you.

No hardware solution.

I am willing to try what you have suggested, but as I understand it Arduino kind of frowns on this approach and it may not work in this case.

As a backup, I am going to add the timer solution to insure I get a hard reset.
 
I think a CD4060 would be a better solution than a 555. It is an oscillator circuit followed by a 14 stage counter. It will give you a long timing period using reasonable value timing components.

Les.

I like your idea, but an application circuit I googled up (http://www.electronicecircuits.com/electronic-circuits/cd4060-timer-circuit-1-minute-to-2-hours) shows that the CD4060 operates at 9 to 12 VDC and I wanted something a 5VDC so I can power it with the power supply on hand. Besides I would have to order one up, but I still like the idea.

At least now I know, or think I know, that I have to build up a ripple counter and only have two 74HC109's in my parts box. So a wash maybe.
 
The data sheet for the CD4060 specifies the operating voltage to be 3.0 to 15.0 volts.
(If I was doing it I would use an ATtiny13 or PIC12F1822 as a timer. They would not need any additional components.)
Les.
 
Last edited:
The data sheet for the CD4060 specifies the operating voltage to be 3.0 to 15.0 volts.
(If I was doing it I would use an ATtiny13 or PIC12F1822 as a timer. They would not need any additional components.)
Les.

Since I can use the CD4060 at 5VDC, I think I will go with that perhaps unless I learn more.

Can I cascade it to gain more time if needed?

Still Looking in my parts box to see if I have other choices.
 
This might be of use to you:

**broken link removed**
 
I don't think you will need to cascade 4060s If you run the oscillator at 1 Hz then the output will give about 4.5 hours.

Les.
 
This might be of use to you:

**broken link removed**

Thanks. Much like what I am planning, I think, and I can set the relay cycle time. About 10 seconds should do it.

Please let me ask this question.

If I reset the count from the Arduino, will it trigger the relay? That I do not want to happen.
 
Here's the design of a long CD4060 timer circuit.
 
Below is a schematic that may be of interest (it is the result of an investigation into the longest period of oscillation that you could reasonably get from a FET 555 timer and capacitors from DigiKey):

2017_02_17_ISS1_ETO_C555_LONGEST_PERIOD_PULSE_GENERATOR_V2.png

CIRCUIT DESCRIPTION

(1) The C555 is configured as a free running multivibrator with a period of around 14 minutes, which is the longest period I could manage with a reasonably priced timing capacitor, C1.
(2) The /RESET output comprises a 200uS negative going pulse every 14 minutes (but see note (7)).
(3) The Q output of the C555 is free to drive a suitable load.

NOTES
(1) The period of the negative output pulse is set by R5/C2.
(2) All capacitors are ceramic X7R dialectric of 10V minimum working voltage, +-10% or tighter.
(3) The frequency of the output pulse is set by R6/C1.
(4) R6 cannot be made any higher than 10M Ohm
(5) C1 must be a ceramic or film capacitor.
(6) IC6B, pin 6 must be a Schmitt input.
(7) The period can be extended by adding more 47uF ceramic capacitors in parallel with C1. Each added 47uF capacitor will add another 14 minutes to the period. Note that you can get reasonably priced 100uF and 220uF X7R ceramic cpacitors from ebay, rather than DigiKey.
(8) The timer must be a FET type, TLC555, LMC555- an ordinary 555 will probably not work.

DATASHEETS
(1) https://www.ti.com/lit/ds/symlink/tlc555.pdf
(2) https://www.ti.com/lit/ds/symlink/cd4093bc.pdf

SUPPLIERS

(1) https://www.digikey.co.uk/product-d...rica/GRM32ER71A476ME15L/490-6543-1-ND/3845740
(2) **broken link removed**
lpid=122&chn=ps&adgroupid=36165537022&rlsatarget=pla-277568742470&adtype=pla&poi=&googleloc=1007219&device=c&campaignid=738474636&crdt=0
(3) **broken link removed**
 
Last edited:
Theres nothing wrong with ideas so far however heres a bit of lateral thinking, if you want to reset the 'duino you can make it do that itself, there are at least 2 ways:

resetFunc() resets the chip.

Or you could enable the watchdog timer and go into a continuous loop, the watchdog will time out and reset the chip for you.

No hardware solution.
I'm with Dr Pepper on this, a watchdog reset is a perfectly acceptable method of resetting in this situation. It can be done in a 100% controlled manner (not in flash writes or anything dodgy), and to make it quicker just adjust the watchdog time prior to the while(); loop and you're golden.

Fixing the root cause is the best option, but a watchdog reset until then is fine. This also saves having redundant extra hardware when you finally do fix the issue and no longer require periodic resets.
 
I'm with Dr Pepper on this, a watchdog reset is a perfectly acceptable method of resetting in this situation. It can be done in a 100% controlled manner (not in flash writes or anything dodgy), and to make it quicker just adjust the watchdog time prior to the while(); loop and you're golden.

Fixing the root cause is the best option, but a watchdog reset until then is fine. This also saves having redundant extra hardware when you finally do fix the issue and no longer require periodic resets.

I have ordered up some parts for a hardware solution which I still intend to build as a safety.

However, I just brought one of the Arduino units home to install the watchdog. I found a write up here:

https://bigdanzblog.wordpress.com/2014/10/24/arduino-watchdog-timer-wdt-example-code/

It may be for an Arduino Mega and I do not know if I can put it on my Arduino Uno R3. Also, my Uno R3 is close to the limit of code size. Eventually, I intend to replace the UNOs with a mega but not now.

Please have a look at the write up and comment.
 
I've never used the Arduino framework (I always just do ground-up embedded C dev), but seeing as its generally just a library wrapper layer, it'll just probably work.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top