a timer that goes logic high or low every 15mins (hardware version)

Status
Not open for further replies.

ElectricSpidey

Joined Dec 2, 2017
3,335
You have to know a lot more than just how to program to get accurate timing cycles in a micro.

It can take some pretty heavy math.

You need to know the exact frequency of the clock and how many execution cycles it takes to start and stop a delay timer and to toggle a pin state, time to poll the code...etc.
 

Thread Starter

timtim1234

Joined Nov 30, 2023
246
You have to know a lot more than just how to program to get accurate timing cycles in a micro.

It can take some pretty heavy math.

You need to know the exact frequency of the clock and how many execution cycles it takes to start and stop a delay timer and to toggle a pin state, time to poll the code...etc.
Some code has been posted, so I would assume that was all figure out?
 
So as I was saying in my last post I am open to other raw IC that can be programmed, maybe the ttiny85 is the best one for this project? Or maybe there is one better than the ttiny85?
Sorry, I got distracted. The ATtiny85 is fine for doing what you want as long as you can live with the small inaccuracies in timing. I've not used it myself but it looks like you can buy programmer boards which plug into your computer USB port which have an 8 pin DIL socket into which you insert the ATtiny85. Presumably you can then extract the processor and insert it into your circuit.

These seem to use the Arduino IDE as well - it has a pretty good track record. Whether it can cope with all the Arduino instructions, I've no idea so I'd suggest trying a simple loop with delay instruction to check it out. Also, as suggested, you can make simple code mods to adjust the 15 minute timing. If someone asks for a 15 minute time without specifying a tolerance it's usually acceptable to be 15 minutes plus/minus six seconds - i.e. 0.1 minutes?
 

MisterBill2

Joined Jan 23, 2018
27,611
You can get the divide by 54,000 using two binary dividers and a diode and gate. The binary math is indeed a bit tedious,but the actual implementation is not so very bad. And the whole system will not need any additional support. And no need to learna program language, no matter how simple it may be.
 

Thread Starter

timtim1234

Joined Nov 30, 2023
246
You can get the divide by 54,000 using two binary dividers and a diode and gate. The binary math is indeed a bit tedious,but the actual implementation is not so very bad. And the whole system will not need any additional support. And no need to learna program language, no matter how simple it may be.
Could you please post a circuit schematic example?
 

panic mode

Joined Oct 10, 2011
5,008
i am not sure what is the device that you are triggering and if the delay really need to be so precise. chances are simple solution using CD4060 and 555 may be sufficient.

if you are interested in programming, i strongly suggest to get something that is ready made and easy to use. or you will quickly learn about frustration...

Arduino is probably the best choice to start. You can get clone for few bucks, software is free and there is tons of examples and tutorials.

DigiSpark is a compact Arduino like board. it is a way to go if starting with ATTINY85. but... it is a bit more involved than working with regular Arduino - it may need to be flashed (and for that you may need to have another device like arduino), it does need downloading and installing correct drivers, when programming it need to be unplugged when starting compile and plugged back into USB when prompted. for doing something occasionally this is fine but if you plan to spend a lot of time on it, this can be annoying. Also memory is tiny so this is really meant for things where space is at premium.

Then there are others... bluepill, blackpill, ESP32, RPI...it all comes down to what you need.
For someone that need easy entry, Arduino Uno is a way to go.
 

Thread Starter

timtim1234

Joined Nov 30, 2023
246
i am not sure what is the device that you are triggering and if the delay really need to be so precise. chances are simple solution using CD4060 and 555 may be sufficient.

if you are interested in programming, i strongly suggest to get something that is ready made and easy to use. or you will quickly learn about frustration...

Arduino is probably the best choice to start. You can get clone for few bucks, software is free and there is tons of examples and tutorials.

DigiSpark is a compact Arduino like board. it is a way to go if starting with ATTINY85. but... it is a bit more involved than working with regular Arduino - it may need to be flashed (and for that you may need to have another device like arduino), it does need downloading and installing correct drivers, when programming it need to be unplugged when starting compile and plugged back into USB when prompted. for doing something occasionally this is fine but if you plan to spend a lot of time on it, this can be annoying. Also memory is tiny so this is really meant for things where space is at premium.

Then there are others... bluepill, blackpill, ESP32, RPI...it all comes down to what you need.
For someone that need easy entry, Arduino Uno is a way to go.
Yes, you are correct, it don't have to be precise. If the circuit has an adjustment on it for time, I could build it and see how it works. If someone could post a circuit schematic of this circuit, that would be great. I prefer hardware over ic programming :) iam old school type :)
 

panic mode

Joined Oct 10, 2011
5,008
if the interval is 15min, this means 450sec (4.5min) on, and 450sec off
edge can be used to trigger monostable to get nice pulse.
the period is 900sec meaning frequency is 1/900s=0.00111 Hz.
the 14 stage ripple counter divides by 2^14 or 16384 so oscillator frequency need to be 16384 times higher. in other words in need to be 18.2Hz.
so now you need to adjust RC values of CD4060 oscillator to make that frequency and use the last state to trigger 555 or whatever you want to use to form 1sec pulse (since 450sec is too long).

so...

oscillator part:
1721843433326.png
using Ct as 4.7nF you get
Rt = 18k resistor in series with 10k trimmer pot
R2 can be some 56-82k (2-10x larger than Rt but keep in mind that Rt value changes since we have trimpot)

done...

next part 1sec monostable...
so google "555 calculator" to get something like
https://www.digikey.de/en/resources/conversion-calculators/conversion-calculator-555-timer

you can find that 10uF and 91k seem to be a good starting point. if you need to dial it in, replace it by series of resistor (47k) and trimpot (100k) to have value range 47-147k. or for wider range use 10k fixed resistor and 250k trimpot

done...

next part, this timer need to be triggered by pulse. say 10ms...ish...
using same calculator we can see that suitable values are 91k (or 100k) and 0.1uF.
so instead of button connected from TRIGGER to GND, use capacitor between TRIGGER and last output of CD4060

done.....

1721844853180.png
 
Last edited:

Thread Starter

timtim1234

Joined Nov 30, 2023
246
if the interval is 15min, this means 450sec (4.5min) on, and 450sec off
edge can be used to trigger monostable to get nice pulse.
the period is 900sec meaning frequency is 1/900s=0.00111 Hz.
the 14 stage ripple counter divides by 2^14 or 16384 so oscillator frequency need to be 16384 times higher. in other words in need to be 18.2Hz.
so now you need to adjust RC values of CD4060 oscillator to make that frequency and use the last state to trigger 55 or whatever you want to use to form 1sec pulse (since 450sec is too long).

so...

oscillator part:
View attachment 327742
using Ct as 4.7nF you get
Rt = 18 resistor in series with 10k trimmer pot
R2 can be some 56-82k

done...

next part 1sec monostable...
so google "555 calculator" to get something like
https://www.digikey.de/en/resources/conversion-calculators/conversion-calculator-555-timer

you can find that 10uF and 91k seem to be a good starting point. if you need to dial it in, replace it by series of resistor (47k) and trimpot (100k) to have value range 47-147k. or for wider range use 10k fixed resistor and 250k trimpot

done...

next part, this timer need to be triggered by pulse. say 10ms...ish...
using same calculator we can see that suitable values are 91k (or 100k) and 0.1uF.
so instead of button connected from TRIGGER to GND, use capacitor between TRIGGER and last output of CD4060

done.....

View attachment 327743
WOW ok thanks once i get all the parts in i will build this. :) thank you very much
 

panic mode

Joined Oct 10, 2011
5,008
The accuracy was demanded several times but never confirmed. Solutions using two or more digital ocs and microcontrollers were rejected as well.so that's that...
 

be80be

Joined Jul 5, 2008
2,395
Code:
const int ledPin = 1; // Pin connected to the LED

unsigned long previousMillis = 0; // Variable to store the last time LED was updated
const long interval = 1000; // Interval at which to blink (milliseconds)
const long timerInterval = 15 * 60 * 1000; // 15 minutes in milliseconds

bool ledState = LOW; // Initialize LED state

void setup() {
  pinMode(ledPin, OUTPUT); // Initialize the LED pin as an output
}

void loop() {
  unsigned long currentMillis = millis(); // Get the current time

  if (currentMillis - previousMillis >= timerInterval) {
    // It's time to toggle the LED
    previousMillis = currentMillis;

    if (ledState == LOW) {
      ledState = HIGH;
    } else {
      ledState = LOW;
    }

    digitalWrite(ledPin, ledState); // Toggle the LED
    delay(interval); // Wait for 1 second
  }
}
just upload and your done
 
Last edited:

Thread Starter

timtim1234

Joined Nov 30, 2023
246
Code:
const int ledPin = 13; // Pin connected to the LED

unsigned long previousMillis = 0; // Variable to store the last time LED was updated
const long interval = 1000; // Interval at which to blink (milliseconds)
const long timerInterval = 15 * 60 * 1000; // 15 minutes in milliseconds

bool ledState = LOW; // Initialize LED state

void setup() {
  pinMode(ledPin, OUTPUT); // Initialize the LED pin as an output
}

void loop() {
  unsigned long currentMillis = millis(); // Get the current time

  if (currentMillis - previousMillis >= timerInterval) {
    // It's time to toggle the LED
    previousMillis = currentMillis;

    if (ledState == LOW) {
      ledState = HIGH;
    } else {
      ledState = LOW;
    }

    digitalWrite(ledPin, ledState); // Toggle the LED
    delay(interval); // Wait for 1 second
  }
}
just upload and your done
[/QUOTE
Code:
const int ledPin = 13; // Pin connected to the LED

unsigned long previousMillis = 0; // Variable to store the last time LED was updated
const long interval = 1000; // Interval at which to blink (milliseconds)
const long timerInterval = 15 * 60 * 1000; // 15 minutes in milliseconds

bool ledState = LOW; // Initialize LED state

void setup() {
  pinMode(ledPin, OUTPUT); // Initialize the LED pin as an output
}

void loop() {
  unsigned long currentMillis = millis(); // Get the current time

  if (currentMillis - previousMillis >= timerInterval) {
    // It's time to toggle the LED
    previousMillis = currentMillis;

    if (ledState == LOW) {
      ledState = HIGH;
    } else {
      ledState = LOW;
    }

    digitalWrite(ledPin, ledState); // Toggle the LED
    delay(interval); // Wait for 1 second
  }
}
just upload and your done
You have to know a lot more than just how to program to get accurate timing cycles in a micro.

It can take some pretty heavy math.

You need to know the exact frequency of the clock and how many execution cycles it takes to start and stop a delay timer and to toggle a pin state, time to poll the code...etc.

here is someone said about using a mirco so i am not sure if the code you posted has this in mind?
the code you posted will that work with a ttiny85 chip?
 
Status
Not open for further replies.
Top