EncSim uses the IntervalTimers (PIT) for generating the encoder signals. There are only 4 of those timers available. However, the timers are released after use so you can declare as many simulators as you want, but, you...
AttachInterruptEx does not use any Teensy hardware related things. It should run on every platform which uses at least a full gcc14 compliant toolchain. (gcc14 is required for the templates generating all that relay...
Since your signal is not in sync to the generated 200Hz, 10µs pulses, ringing of the edges of these pulses seems unlikely to me. Another idea: Maybe you get disturbances from the PC through the USB connection? Together...
Looks like, but is really difficult to say. Im using those cheap 10EUR LAs which are usually good enough for me but limited to 24MHz. You get them everywhere (e.g....
No chance to reproduce this here.
I also connected pin_out to pin3 and attached a pin interrupt to pin3 to measure the time between two pulses. No deviation from the expected value detected.
#include...
Tried your code a couple of times, 200s measurement interval each but I can not see any spurious pulses. L_min = 4.991ms L_max=4.991ms. In principle my LA could be too slow (24MHz) to see any of the the short spurious...
I never ported this code for a T4, but for my PC(c#) based uploading library I needed to siginificantly increase timeouts to be able to program a T4. I assume that deleting the large flash at the beginning of the...
The code you posted in #6 sets the column pin to low and immediately after reads in the row pins. The Teensy4 is fast enough that the level change on the column pin may have not yet arrived/stabilized at the keypad when...
Actually vsCode is a complete new development not based on vsStudio at all. Also the approach is quite different. While VSStudio is a fully fledged and fat IDE, vsCode is just a light weight editor, optimized for...
Just for the fun of it I did a quick TimerOneEx which should compile for all boards supported by TimerOne (just copy this file into your sketch folder:...
All this code is not really optimized. E.g. the waiting times are on the safe side and can certainly be reduced. You might also consider the HCS version of the shift register, this should be much faster.
...
While AndyA's solution certainly works, you might also be interested in IntervalTimerEx which can be embedded in classes out of the box https://github.com/luni64/TeensyHelpers#intervaltimerex. Just copy the two files...
Yes, this is suboptimal. You can also use this version: https://github.com/luni64/TeensyHelpers/tree/master/src/attachInterruptEx which doesn't have any dependencies (it uses std::function instead of the homebrew...
I had a quick look at your ThreePhaseMotorEncoder class. I played a bit yesterday evening and ended up with roughly the same state machine as you implemented :-).
Regarding your interrupt functions: I'd embedd the...
If it is a grey code, only one input is allowed to change at each state. This should make the decoding state machine pretty simple. Would be fun to integrate it to the EncoderTool (https://github.com/luni64/EncoderTool)...
I have absolutely no experience with TeensyThreads. Can it be that TeensyThreads uses the GPT1 timer for thread switching?
If you use a PeriodicTimer without specifiying the used timer module it uses timers from a...
This is simple. g_rising_edge_timer leaves setup with a high value (here 120000). You do not set it to zero in loop but subtract the interval g_interval (which is good). So, the first condition will be true for a couple...
Yes, you only have 2 GPTs but 20 TCKs. So I consider GPT as quite valuable :-)
Sorry added my explanation to #4 which you probably didn't see (my bad)
Edit: Crosspost with joepasquariello
const uint8_t _pin_out_ = 2;
Is perfectly fine for the compiler to identify it as compile time constant. If you want to give the compliler even more hints for optimization you can use
constepxr uint8_t _pin_out_...
IIRC, you are using the TimerTool in your project? If so, you could as well use the TCK timers for this application. They are cheap, are implemented in software only (use the cycle counters) and have the same API as the...
Don't know, I just exported the csv from the LA app.
Zooming in at t=1s shows nothing unusual in the recording:
Ok, I assume this is in your original program? So, anything else which generates some...
Here a recording of about 200 seconds with the minmal / maximal positive and negative pulse widths.
Zoomed in for better reading:
This all looks perfectly normal to me
Here the csv of the data:
Actually I started using my logic analyzer. But since I didn't see anything and it is quite tedious to scan through the recording I switched to printing out the values. I can let it run for a time and see if something...
I personally would rather write the data in a ringbuffer in the ISR and do the serial writing in the foreground code. This would make handling connection losses, slow PCs etc much easier. One could also send larger...
I had a look at your test case and, since I don't want to mess with python, I adapted the code to print the measured periods and pulsewidths directly into a serial monitor.
#pragma once
#include <Arduino.h>...
Best is to provide a minimal and complete example showing the effect.
Starting/stopping/triggering the timers of course needs some time. But once a periodic (hardware) timer runs, it should be quite stable. As...
Please try EncoderTool v3.2.0 and TeensyTimerTool v1.3.0. They should work together in the old and the new IDE.
And no, it does not accelerate things if you post the same complaint on each and every channel after I...