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
1
vote
1answer
47 views

Arduino Uno's Timer maximum frequency using Timer Compare Interrupt, not Timer Output Pins (e.g. OC0A)

I want to achieve the generation of a custom binary signal over a digital pin at the highest possible frequency on Arduino Uno. Using Timer's output pins (e.g. OC0A), one can get a pin to toggle at a ...
1
vote
0answers
42 views

ISR for timer on Arduino MEGA gets called only once

I am trying to write an Arduino code to blink LED using timer 4 on Arduino MEGA (atmega2560). I resetted the timer registers, and entered all the necessary values to bring to 16MHz to 1Hz (rescalar = ...
0
votes
0answers
35 views

How can you switch variables recorded in memory by time?

const int KEY_LEN = 32;; unsigned long key1 = 0x76AFDBAA; unsigned long key2 = 0xC6E2F8F8; const int LED_PIN = 13; // Used digital pin 13 of the arduino to connect the transmitter unsigned long ...
1
vote
2answers
45 views

How to convert kitchen timer code into a countdown

I found this code for a kitchen timer, it was the closest thing to a countdown. The code is here: #include <LiquidCrystal.h> const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; ...
1
vote
1answer
42 views

How to program an Arduino Uno to collect data using a timer interrupt and analyze that data in matlab?

I working on a project where I want to collect sensor data (from a sensor) and I want to analyze the first 20 data sample (e.g., find the range, trendline e.t.c.). I know how to compile a timer ...
1
vote
0answers
75 views

Arduino mega PinChangeInterrupt with 16 bit timer

With reference to this question ::I have written a program by using 16-bit timer, The program is as follows . volatile uint32_t ovfCount = 0; struct Pulse { uint32_t last_toggle; uint32_t width; ...
1
vote
1answer
63 views

Issue using Arduino Mega Timer2 with PinChange Interrupt

I was working on a program to measure the pulse width , for that I thought of using Timer 2 in Arduino mega along with pin change interrupt, The program I have written is as follows volatile float ...
1
vote
2answers
54 views

Timer Interrupt Collision

I am working with a MEGA2560 trying to implement velocity ramps for three steppers at the same time. The goal is to move to different positions applying accelerations and decelerations while finishing ...
1
vote
2answers
55 views

How to exit out of a timer interrupt (ISR(TIMER1_COMPA_vect))

I have a code here where I collect an array of data and do some data analysis with the data. The only thing I'm struggle with is how to exit the ISR after I am done running my code. I am using a pre-...
1
vote
1answer
42 views

Input Capture Mode PPM signal

Greetings to all members of the Forum. I would like to express my deepest gratitude, with respect to the title of this post. The last week I am trying to capture and decode a PPM Signal from an RC ...
2
votes
2answers
331 views

Is it bad practice to multitask without timing constraints

Going through resources such as several things at the same time and with some greatly appreciated assistance on here I'm finally getting a grasp on how to multitask a microcontroller. Most examples ...
1
vote
1answer
66 views

Doing several things at the same time with functions, objects or interrupts?

First of all, thank you for taking the time to read this. I am a newbie, so apologies (done examples on arduino website, basic C++). I'm trying to get an idea of what the best way to structure a ...
1
vote
1answer
31 views

Issue with simple timer based on millis()

Sorry to bother but I am at my wits end. I'm experimenting with timers, and starting very simple. The following code is supposed to print the content of a variable each time an interval of time has ...
1
vote
1answer
39 views

4 Bit Counter up and down

we are asked to create an Arduino code that would run a 4 Bit Binary UP counter once a push button switch is pressed and then 4 Bit Binary Down counter on the second click. Then vice versa. This ...
0
votes
1answer
26 views

LF: flexible scheduler/timer library

I'm working on a few arduino projects where I've needed a flexible scheduler and/or timer library and was wondering if anyone has a library they recommend? Case 1: I have a sensor that needs to ...
1
vote
2answers
265 views

Switch on the piezo emitter for a short time

I need a short beep for every minute of change. I wrote a separate function. The signal duration should be 50 ms, the rest of the time the emitter connected to the A1 contact should be silent. A ...
0
votes
0answers
58 views

void timerIsr() doesn't work and the oscilloscope doesn't show anything

I have a project on simulation and realization of a pulsation detector. The cardiac part is coupled to an electronic thermometer in Proteus, but void timerIsr() isn't called and doesn't show anything ...
2
votes
1answer
31 views

Can Arduino uno adjust input square wave duty, phase and frequency with just timer-counter?

Requirement: I have input 4KHz pulse input Divide it's frequency in half Arbitrarily adjust phase Arbitrarily adjust duty Out put the modified pulse My solution (CPU): uint8_t cnt = 0; uint16_t t1 = ...
1
vote
1answer
109 views

Time signal. Determine the presence of pulses and their duration [closed]

I want to detect the exact time signal from an FM radio station. The signal is transmitted in the form of 5 short pulses and one long one. My task is to determine the presence of a pulse in the audio ...
6
votes
6answers
3k views

Is it possible to generate an exact 15 kHz clock pulse using an Arduino?

I want to generate a 15 kHz pulse with an Arduino using Timer1, but the problem is that if we want a 15000 Hz clock we need to initialize the timer with 1/15000 seconds or 66.66 microseconds, but we ...
0
votes
2answers
56 views

Turn on relay for amount of time by continuous input

I have a project having two input status first the input is not continuous the output buzzer relay will be on for 10 seconds and then turned off or it can be off directly by push button the second ...
0
votes
1answer
26 views

Initialising timer interrupt crashes Mega 2560

Below is the entirety of my prototype code, the cycling of pin 13 is what I use to confirm the board is restarting. The board resets continually on this implementation of initialising the interrupt. ...
1
vote
0answers
36 views

How to implementing timer interrupt with a sensor device using A0 and A1 pins

I was wondering if there is a way to program a timer interrupt to collect sensor data at a specific sampling rate? I want to attach two strain gauge sensors to A0 and A1 pins and collect the data at a ...
2
votes
3answers
133 views

How can I control blinking of LED while in timer function?

When I am in the 30-second standby function, I want to turn the LED on and off at 5-second intervals. How can I do what I want using the read_counter() function? The problem here is that I am already ...
1
vote
1answer
111 views

Timer STM32 #error This code is designed to run on STM32F/L/H/G/WB/MP1 platform! Please check your Tools->Board setting

I have installed the library of TimerInterrupt_Generic for ArduinoSTM32 module via Arduino IDE, so i have tried to test the example of library as you can see below: and i have gotten this error: ...
3
votes
2answers
262 views

Generate 1khz square signal with Arduino Mega

I want to generate a 1khz square signal with an Arduino Mega. I have read the MCU contains several timers. What i want to do is to configure one of this timers. My first question is: Is there a way to ...
1
vote
1answer
49 views

IMU (MPU9250) and Ticker on ESP32

I want to read the data from an IMU (MPU9250) periodically. To do that I use a ticker as shown in the following code: #include <Ticker.h> #include "MPU9250.h" constexpr int ...
3
votes
1answer
207 views

Measure audio frequency through pulse duration

Hello dear StackExchange users, i want to develop an Infrared blaster which i can plug into the headphone jack of a phone or console of choice. In order to communicate what frequency to modulate the ...
0
votes
0answers
30 views

Not getting input from sensor using timer

I wrote a code to move linear actuator and lights up and down using timer. But its not getting Sensor input please help me in this. #include <avr/sleep.h>//this AVR library contains the methods ...
2
votes
1answer
22 views

Serial doesent work when calling function from timer

You can try the code on your arduino UNO to better understand what is hapening in serial monitor! I want to calculate jacobian matrix from rotation matrix! float jakMATB[3][3] = { {0, 0, 0}, {0, 0, 0},...
4
votes
1answer
207 views

Arduino timer interrupts for PID

I'm working on a robotics project where an arduino nano is acting as the motion controller. I'm trying to use a trapezoidal motion profile generator and PID loop to follow that profile, but I found ...
1
vote
1answer
95 views

Problem with programming digispark ATtiny85 board with Arduino IDE

I have bought a Digispark ATtiny85 board to learn about that microcontroller. So I tried using internal register names in the code rather than using Arduino in built functions. I can get the board to ...
1
vote
0answers
33 views

Equipment wireless stopwatch

I am working in a project in order to measure spend time. My sitution is: There is a competitor that will start the game after he (or she) heard a sound (could be a sound like buzz or whistle). This ...
1
vote
2answers
89 views

Is there a way to get about a 10ns Timer resolution from an AVR CPU?

I have an 8Mhz ATM32u4 that is able to read external pulse inputs at 125ns ticks using InputCapture3 (PC7) on its 16-bit timer. Is there a magical way (bitbanging?) to get around 10ns tick resolution ...
1
vote
1answer
255 views

Timers, PWM pins and digital outputs on Arduino Mega

I'm using an Arduino Mega to control motors via PWM and Adafruit DRV8871 motor drivers. I also use TIMER1 for a timed interrupt. After adding the TIMER1 interrupt I discovered I had problems with ...
1
vote
1answer
49 views

Input Capture with Sleep Enabled on ATM32u4 board only works every second reading in SLEEP mode

In short: I have an Input Capture code and a Power-Saving code combined into one program. Both are adapted from Nick Gammon's examples that work fine independently. When I combined them into one ...
2
votes
2answers
294 views

How do I make LEDs lights up one by one according to how long the button was pressed and hold

In my project, I am trying to create a timer display with LEDs base on how long a button was pressed and hold. There are 8 LED lights in total, when the toggle button was pressed, 1st LED lights up; ...
4
votes
3answers
329 views

Programming Arduino Uno R3 to trigger a relay once every 24 hours

I programmed Arduino UNO R3 to trigger a relay once every 24 hours from the moment it is powered on I calculated milliseconds and used the function delay() 24 hours * 60 minutes each hour * 60 second ...
2
votes
1answer
44 views

Is it possible to detach an interrupt for a certain ammount of time

Hardware: Arduino Uno Software Version: 1.8.13 My sketch has an interrupt service routine that triggers with the rising edge of digital pin 2. What I want to do now is detaching the interrupt as soon ...
1
vote
2answers
281 views

help explain pulseIn function with arduino and Ultrasonic sensor

dears Engineers.. i got stuck with this issue couldn't understand.. please help with explanations. first i was upset of my ultrasonic sensor reading deviations, that is i examine my sensor indoor and ...
2
votes
2answers
119 views

Detecting an incoming 7.875 kHz pulse to use as trigger

I have written a code that detects an incoming pulse (square) of 7.875 kHz to trigger the output High for the entire duration of pulse, and trigger the output low if the pulse is off or not detected. ...
2
votes
1answer
70 views

Timer question: Phase Correct PWM at specific frequency

I am trying to create a sinusoidal wave segmented in 64 Frame, each holding a Duty cycle precisely varying from 0x00 to 0xff. This is for an Arduino Nano. I have trouble understanding the following: ...
0
votes
0answers
30 views

I am making my blinds automatic, but I don't want to use a delay

I am trying to make it so I can pull the time so that they open at 8 am and close at 10 pm. The loop is already set up to open and close the blinds completely. #include <CheapStepper.h> ...
1
vote
1answer
37 views

Can it time between blips, store the time between blips, subtract one time from the other and divide one time by another and display it?

I am counting rotations of a shaft and timing events that occur during that rotation. I wish to display the event timing as a percentage of ~1/4 of the rotation timing. This would involve recording ...
0
votes
0answers
43 views

esp32 pico kit - actual clock speed vs crystal vs max_speed etc

I am trying to understand how the clock speed in the esp32 works. I am running arduino ide 1.8.12 with 1.04 board definition - on a pico kit 4 module . The device datasheet says it has a 40mhz crystal....
1
vote
0answers
35 views

Consequences of messing with Timer 0

I'm following this tutorial to generate square waves using the timers of the attiny85, but I'm afraid this could mess with something else in the chip. This is the relevant snippet: // Set up Timer/...
1
vote
1answer
43 views

How to specify a timer's name depending on the chip it will be compiled to?

I need to enable a timer interrupt for a chip, and in the mean time, I am testing the code on Arduino Nano rather than (feed the chip, test the chip)++. So as part of the code I have to TIMSK0 |= (1 &...
0
votes
1answer
86 views

Wire Library Timer Usage

I would like to know if the Wire Library is using a Hardware Timer from the Arduino Mega 2560. And If so which Timer it is. As I am using the Timer 1. After implementing the Wire Library I have some ...
2
votes
1answer
135 views

Mega: attachInterrupt on pin 18/19/20/21 not working

Task: I'm trying to create a fan-control with the arduino mega. I'm generating a PWM signal on pin 6 and 7 and want to use interrups to measure the rpm of the fans. Problem: On pin 2 and 3 everything ...
0
votes
2answers
457 views

How to keep track of millis during sleep mode

In my application, I need to keep track of the time the application has been running as well as use sleep modes. However, when using the sleep modes, Timer0 is disabled, and therefore millis stop ...

1
2 3 4 5
9