Skip to main content

Questions tagged [timers]

Timers are the hardware in the processor used to count and time events. Use this tag for questions about the hardware timers.

Filter by
Sorted by
Tagged with
0 votes
1 answer
17 views

Does changing the prescale for Timer 0 or Timer 2 affect the micros() function?

I am using an ATTiny88 to drive a PWM device. First of all, digging through the literature, it's hard to tell what the differences between the ATTiny85 and ATTiny88 are, and the vast majority of ...
LesRhorer's user avatar
0 votes
2 answers
45 views

Timer setup interferes with LED blinking logic

This example is a simplified version of what I really need to do, but I think it demonstrates the problem (= my misunderstanding?). I need to use a timer to count microseconds; my code shows how I ...
Bryan Hanson's user avatar
0 votes
1 answer
37 views

Arduino Mega 2560 time delays counting between events on different pins

I am wondering how I can precisely count time delays between rise events happening on 4 different lines/pins using Input Capture of Arduino Mega 2560. How can I synchronize timer/counters? Appreciate ...
Bakyt's user avatar
  • 9
1 vote
1 answer
157 views

Emulating Arduino Uno with QEMU: interrupts do not work

So I wrote this code for Arduino Uno: // file qemu.ino void setup() { Serial.begin(9600); } void loop() { Serial.println(millis()); } And then compiled and uploaded it to the real ...
lch361's user avatar
  • 11
-1 votes
2 answers
435 views

I need a 10KHZ PWM signal from pin 3 and 11 using timer 2

The op of pin 11 should be inverse of pin 3. I used digitalreadfast and digitalwritefast and used simple if else. But the delay is high as 10us. What should i do? I found this code in forum but its ...
Pranav Pillai's user avatar
0 votes
1 answer
120 views

Unable to get keypad key in while loop [closed]

I'm a beginner into Arduino so I have a little problem where I'm trying to do a countdown on LCD using while loop but I'm also trying to get a key input inside that same while loop. Problem is that ...
DevChips's user avatar
0 votes
1 answer
55 views

Use TCC1 timer to generate PWM on personnal board built with SAMD21E18A

I'm trying to generate a PWM signal from TCC1. I have a personnal board built with SAMD21E18A. I want to use pin 27 PA30, in my variant.cpp I have this line: { PORTA, 30, PIO_PWM, PIN_ATTR_DIGITAL|...
simon's user avatar
  • 133
1 vote
1 answer
329 views

Square wave generator generates a shorter pulse from time to time

I am using an arduino Micro to generate 8 square waves on 8 pins. The idea is as follows: on pin 13 is the main square wave. It represents a certain BPM (beats per minute). The other 7 pins should ...
Janw's user avatar
  • 294
0 votes
1 answer
154 views

Problem with Bing generated code for automated chicken coop door

Glenn from Sweden here. I was wondering if some kind soul could help me out here. My partner bought a cheap chinese knock-off automatic chicken coop door that operates based on sunlight. Link to the ...
Glenn's user avatar
  • 13
2 votes
2 answers
353 views

Using Internal Timer Interrupt to Read Analog Sensor

I'm having difficultly using an internal timer interrupt with my Arduino Nano to properly capture a specific value from a linear potentiometer and then instantly stopping the actuator. I basically ...
wickedhurricane's user avatar
1 vote
0 answers
165 views

ESP32 trouble with running ledcWrite inside of ISR

ESP32-S2 (Wemos/Lolin S2 mini) Arduino 2.1.1 on Windows 11 Hello, Thank you for taking the time to read this post and for any assistance you can provide. I consider myself a newbie when it comes to ...
Michael.G's user avatar
1 vote
2 answers
141 views

Arduino UNO Power interruption

Do you have to upload the UNO after the applied power is disconnected? Does the UNO retain the code without any power? And when the power is disconnected, if the code is retained, will the timers ...
Woodenfish's user avatar
1 vote
0 answers
235 views

Using library functions in timer ISR ESP32

I'm trying to use a library function in my ISR function that uses the internal timer to trigger every 1 ms. The chip that I'm using is an ESP32-C3-MINI. Here is my current code: main.cpp #include <...
Max's user avatar
  • 111
1 vote
1 answer
468 views

50% duty cycle PWM signal with calculated frequency

#include <PWM.h> int led = 9; void setup() { InitTimersSafe(); Serial.begin(115200); Serial.println(); variable_freq(); pinMode(A0,INPUT); } void variable_freq() { while(true) { ...
curious_direwolf's user avatar
0 votes
0 answers
189 views

SDI-12 protocol, working with SoftwareSerial

I have a Teros 11 moisture sensor that I have managed to make it work with the SDI-12 arduino library. However, this library does not work with SoftwareSerial and this is critical for me. There is a ...
user1584421's user avatar
  • 1,405
1 vote
2 answers
456 views

Timer 1 "Set on Compare Match" in Normal Mode - Not working

I'm using the hardware timers on the 328 for phase angle control of a triac with zero-crossing detection. I am encountering some strange behavior with the "Set on Compare Match" feature not ...
saustinp's user avatar
0 votes
1 answer
249 views

DS3231 with Arduino Nano for Timing precision

I am in need to synchronize two separate circuit boards working with Arduino nano. The need is to activate one relay using Arduino-1 after 45 min and another relay using Arduino-2 after 45.36 seconds. ...
Lawliet's user avatar
  • 183
2 votes
2 answers
244 views

Arudino receiving interrupt command BEFORE entering sleep mode causing it not to receive any interrupt commands in order to wake up

I've written code for an Arduino Nano that when a button is pressed, it sends an IR command. It is set so that if no button press has been received for a period of 10 seconds, it will enter sleep mode ...
99natmar99's user avatar
0 votes
1 answer
721 views

Arduino nano timing precision

How precisely can an Arduino nano be timed? The project I am working on needs two Arduino nano to work synchronously. Arduino one have to activate a relay after 2700 sec and Arduino two have to ...
Lawliet's user avatar
  • 183
-1 votes
1 answer
192 views

How to read analog sensor data with different timers in arduino

I have three analog sensors like voltage, temperature and pressure. I need to measure the voltage and temperature every 10 ms and I need to measure the pressure alone every 30 ms by using the timers ...
Pritha's user avatar
  • 1
2 votes
1 answer
98 views

Ramping servo motor taking longer than calculated

I'm learning how to code a "BOE Shield bot" with a partner at my university (first year). To clarify for those that do not know: a BOE Shield bot is a small robot equipped with 2 servo ...
ShootinLemons's user avatar
-2 votes
1 answer
272 views

1Hz & 32Hz from 32.768 kHz on ATmega328P at 8MHz & DS3231 32K

I have a 32.768 kHz signal at the ATmega328P input. I need to get 2 signals from this signal: 1Hz and 32Hz. How well will it work? How to do this with a ATmega328P Timer/Counter? What gain will the ...
Andre's user avatar
  • 27
-1 votes
1 answer
620 views

Stopwatch stop/start button and reset

i am trying to make a stop watch with a stop/start button and a reset button i have made this #include "RTClib.h" //Setup the Real Time Clock, DS3231 RTC_DS3231 rtc; const byte SQWinput = 2;...
Amr Ahmed's user avatar
0 votes
1 answer
2k views

Teensy 4.1 / 4.0 When to use FlexPWM vs QuadTimer pins to strobe LEDs

I want to strobe 3 LEDs (at independent frequencies and duty cycles) via mosfets with a duty cycle of 0.05%-1% at a frequency range of 24-100 hz. I would like to hold 1% or better accuracy for both ...
Robb Godshaw's user avatar
4 votes
1 answer
641 views

ISR for very fast processes, strange code found. Has ISR effect on timer behaviour?

I found the following code within an example for performing very fast changes on a PWM-output. It works, however I'm wondering about some details. TIMER2 was set up in setup() as follows: TCCR2A = 0; ...
Ariser's user avatar
  • 577
1 vote
4 answers
982 views

How to efficiently code a long duration timer

I'm working on a battery-powered project. I'm trying to write code, which checks the battery voltage every 30 minutes and changes the color of a LED accordingly. Should I still be using millis() or is ...
Zhelyazko Grudov's user avatar
3 votes
2 answers
3k views

Attach the Arduino ISR function to the class member

I intended to use a timer interrupt for limited instances of a class in my ESP32 Arduino project. My first code conception was as follows: portEXIT_CRITICAL_ISR(&lock0); } ...
Hamid s k's user avatar
  • 143
0 votes
1 answer
123 views

Safely extend TCNT1 / ICR1 to 24 bits using TOV1

I'm hoping to time external events on a '328p Arduino that will occur slowly enough that they'll overflow the 16-bit counter TCNT1. In a different scenario I'd prescale the counter, but I need the ...
Jim Mack's user avatar
  • 235
1 vote
1 answer
596 views

Interval timer on Arduino: Doubt about TimerOne library

I want to synchronize a timer interrupt from a button is pressed. I want to read a button state 3 seconds later from the first pulse moment (to identify long pressed button, 3 seconds for this example)...
Juanma's user avatar
  • 113
1 vote
1 answer
184 views

Where am I going wrong in modifying Timer0 and the ISR interrupts in this example?

(Arduino) Hello I don't know where I am going wrong here, please advise. In the end I want to step a bipolar motor, HIGH/LOW, using Timer0 with OCR0A and OCR0B interrupts to adjust the motors step ...
localmartian's user avatar
1 vote
0 answers
807 views

Pulse period capture with SAMD21

I need to count the number of pulses in a moving window (e.g. last 60 seconds) using as less CPU time as possible. The first step is to use TCC to capture pulse period. The pulses arrive randomly at ...
7E10FC9A's user avatar
  • 209
0 votes
1 answer
131 views

Why do I get different times when using analogRead() inside while loop?

I have the following code which checks the latency of another board. int triggerPin = 13; int dataPin = 9; int ejectorPin = A0; unsigned long t_start = 0; unsigned long t_end = 0; ...
Farahi's user avatar
  • 3
1 vote
1 answer
98 views

Arduino pro mini sampling rate

what are the possible sampling rate the user can set in Arduino pro mini using ADCSRA registers. I want to set my desired sampling rate through registers, is it possible?
varman's user avatar
  • 21
1 vote
1 answer
126 views

I am trying to add a countdown to my Arduino code but it does 0 days, 04:09:36 instead of starting at 7 days

The code I use probably has a math problem since an Arduino can only count a 16 bit integer. This problem is with the WeekDelay() function. The project is for an Aerogarden. It pumps water into the ...
alexlikesallthegamez's user avatar
-1 votes
1 answer
128 views

I have been having a lot of trouble adding a countdown to a piece of code [closed]

This is the code. The /// are where I added the countdown. Unfortunately the countdown only goes down 9 seconds. What I want it to do is go down the full 24 hours. I have been trying to fix this error ...
alexlikesallthegamez's user avatar
-1 votes
1 answer
120 views

Can't get 1 second on a ATMega168 timer

TCCR1A = 0; TCCR1B = 0; OCR1B = 0xFF00; TCCR1A = (1<<WGM10) ; TCCR1B = (1<<CS12) | (1<<CS10);; //set the pre-scalar as 1024 TIMSK1 = (1 << OCIE1A); This doesn't ...
Rick Dearman's user avatar
-1 votes
1 answer
72 views

Cannot change pointer for port in main loop

I am testing on an Arduino UNO. I want to use timer1 and interrupts to create various LED patterns. The LEDs may span multiple ports i.e PORTB and PORTD. I want to use a "volatile uint8_t*" ...
Tommy Ray's user avatar
1 vote
0 answers
80 views

Millis() based timer program for 24x7 usage in Arduino [duplicate]

I have made an irrigation system using Arduino. Timer program is based on comparing the previous Millis() and current Millis(). I want to know the chance for error when the currentMillis() overflows ...
Prakash K K's user avatar
0 votes
1 answer
343 views

Timer to send a periodic pulse [closed]

I am looking for a very low power, small component (perhaps an arduino) that will send a pulse 3.3V logic HIGH pulse once every X seconds to another system. I want to be able to configure X (maybe a ...
rfii's user avatar
  • 170
3 votes
2 answers
1k views

MPU6050 Arduino Jeff Rowberg library interrupt Issue

I was trying to get the data from MPU6050 using the Arduino library mentioned here. The following code is an edited version of the sample code given in the library folder which seems to be working ...
Lawliet's user avatar
  • 183
1 vote
0 answers
232 views

Variable frequency PWM, without changing timers

I need variable frequency output - 0-5000Hz with some duty cycle. I do not want to change timers, because I am using delays, serial and CAN, so I do not want them to be affected by changed timers. I ...
Voyze's user avatar
  • 11
2 votes
0 answers
430 views

External Interrupt and Input Capture pin | Arduino MEGA

I have a code for finding the rpm of one system calling here as engine , the engine have a hall sensor output and I have tried the following Code #define SERVO_MIN 2000 #define SERVO_MAX 4000 struct ...
Lawliet's user avatar
  • 183
0 votes
1 answer
2k views

Seeeduino XIAO write and read PWM duration (period) using timers

I am trying to communicate between two Seeeduino XIAO (chip: ATSAMD21G18A-MU) by way of TCC capture using register timers. Square wave pulse duration varies from 200ns to 4us. I found these two code ...
MeSo2's user avatar
  • 177
2 votes
0 answers
100 views

Is a PWM phase duration set with OCR1A a reliable way to communicate values to other Arduinos?

I am working on communicating 4 switch states across multiple Arduinos using only one pin. It must be as fast as conceivably possible. Currently I have a master Arduino reading all 4 switches (...
MeSo2's user avatar
  • 177
2 votes
1 answer
80 views

Interrupt takes longer than expected [closed]

I am trying to write a delay function in C, which should take 0.5 seonds then carry on. I am aware that there are libraries for this purpouse, I want to make it myself. #include <avr/interrupt.h>...
ibroketheinternet's user avatar
1 vote
2 answers
3k views

Arduino Reset via Software (every day)

Dear Stack Exchanger's, I want to reset my Arduino and system in every 24h for preventing frozen software and also other connectivity stuffs. I wrote a program which connects a digital pin to reset ...
Felix Pursian's user avatar
1 vote
2 answers
426 views

run a function for a certain amount of time! [duplicate]

i'm working on a project where i need to run a function for 20 minutes and the function writes to memory using EEPROM every minute. How can i make the function run for 20 minutes, i was thinking of ...
rohithrathod banoth's user avatar
2 votes
1 answer
151 views

How can I read the Timer direction in phase correct PWM?

I have had to use Timer0 with phase correct PWM and a prescaler of 1. This results in a 32khz PWM frequency and obviously impacts millis, delay and micros. (Timer1 and Timer 2 are also in use so ...
Simm's user avatar
  • 51
1 vote
0 answers
52 views

How do I synch the Arduino PID library with an external timer for turn-rate control?

I have been trying to use the Arduino PID library for controlling the rate of turn (in deg/sec) of a wall-following robot. The robot's operating system uses TIMER5 on an Arduino MEGA2560 to update a ...
starship15's user avatar
1 vote
1 answer
88 views

How to set 60 min beeper?

I am trying to make a device that will register latency and number of shocks for passive avoidance behavior in drosophila. My device has two buttons green and red. I press green when I put a fruit fly ...
Alex's user avatar
  • 11

1
2 3 4 5
9