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.
451 questions
0
votes
0
answers
69
views
Gross timing error between crystals
Got two boards, getting a stable counter error ratio between the two of ~0.9895 (counted ticks divided by calculated ticks). Is this not a bit too low ? With +/- 50 ppm between the two crystals I was ...
1
vote
1
answer
83
views
Generate all frequencies between 5 and 8 kHz in steps of 1Hz
Is it possible generate all frequencies between 5000 and 8000Hz, 1Hz in between with an ATmega328?
When I create a c-program outside the Arduino IDE to calculate the frequencies with the formula ...
2
votes
2
answers
717
views
Arduino Uno Serial.write() how many bits are actually transmitted at once by UART and effect of baudrate on other interrupts
With Arduino Uno Rev3, I am trying to maintain a delicate timing while handling data transmission. I want to send 6 bytes at a time, which takes around ~44 us when I time Serial.write(). The time it ...
0
votes
2
answers
104
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 ...
2
votes
1
answer
744
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 ...
0
votes
1
answer
163
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 ...
1
vote
1
answer
366
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 ...
2
votes
2
answers
641
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 ...
1
vote
2
answers
159
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 ...
1
vote
1
answer
678
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)
{
...
1
vote
2
answers
627
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 ...
2
votes
2
answers
297
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 ...
-1
votes
1
answer
248
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 ...
-2
votes
1
answer
313
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 ...
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 ...
1
vote
4
answers
2k
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 ...
0
votes
1
answer
149
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 ...
1
vote
1
answer
223
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 ...
0
votes
1
answer
167
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;
...
1
vote
1
answer
144
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 ...
-1
votes
1
answer
167
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 ...
1
vote
0
answers
84
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 ...
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 ...
2
votes
0
answers
494
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 ...
2
votes
0
answers
135
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 (...