7/12/2023 0 Comments Micros arduino timer interrupt![]() Timer0 is already set up to generate a millisecond interrupt to update the millisecond counter. ![]() If anyone has any experience with this or can point me into the right direction that would be awesome. Using arduino delay Using Arduino millis as a Delay Timer. But unfortunately I can't find a whole lot of information about this online.Īnyway, sorry for the long explanation. I tried looking for ways to set ISR priority etc. So I assume it's something like the wifi ISRs or such messung up the timing. And it seems as though the timing is generally accurate but every now and then it is about 50 microseconds later than normal. I tried to oberseve the jitter with an oscilloscope. I'm using a generic ESP8266 (ESP-12) with the Arduino Core and currently I'm using Wifi and AsyncWebserver to control the phase angle. It seems as if micros() itself loses accuracy as soon as the processor does anything else in the meantime. But for some reason the jitters always persists. I tried doing it in the main loop and delaying the last X microseconds in a while loop to ensure accurate timing. This time, we configure a timer interrupt to toggle an LED every 0.5 seconds. I even tried setting the hardware timer to earlier than necessary and then going into a while loop and waiting the last 1000 microseconds to ensure accurate timing. Favorite 4 Previously, we looked at using registers directly in Arduino and setting up external interrupts. Timer interrupts operate in the background over you main code allowing accurate repeatable timed actions. And I've been looking for a solution for a long time but I just can't find any way to do this. Obviously delaying is a terrible solution. And will occasionally even crash due to watchdog resets. The problem with that is that, if the phase angle is set to 10 % the ESP will jitter 9000 microseconds every 10000 microseconds so 90 % of the time. But so far the ONLY thing that has worked reliably (without jitter) is to delay the whole 5000 microseconds. Which does work, but the timing isn't stable. ![]() And I tried doing this using an ESP also with the hardware timer. On the ATmega I did this using one of the hardware timer without any issues. For example if the phase angle is set to 50 % the ESP would have to pulse a pin high 5000 microseconds later. I've done this before using an ATmega328P and it works fine.Įssentially a pin change interrupt is triggered at the zero cross of the sine wave and I need the the ESP to pulse a pin high for half a millisecond or so a specific time after that. I've been struggling with a timing problem and was hoping to maybe find some help here.Įssentially I've built an AC phase angle dimmer using an ESP8266. ![]()
0 Comments
Leave a Reply. |