Search results

  1. luni

    Low-level library and timer assistance -- TeensyStep library ???

    Wow, this is quite a master piece. Happy to support your awsome project. Need to leave now...
  2. luni

    Low-level library and timer assistance -- TeensyStep library ???

    The Quads are only 16bit which will limit the minmal possible steprate. Adjusting the prescaler on the fly would help but I'm afraid that this will open another can of worms. I'll stick with the PITs for the main timer and use the TMRs instead of the FTMs for the pulse generation. Lets see how...
  3. luni

    Low-level library and timer assistance -- TeensyStep library ???

    I'm currently working on a project which will include some steppers. Thus, chances are good that I need to get TeensyStep working with a T4 anyway. I can't promise anything but I'll try. As you already mentioned: don't expect better performance compared to a T3.5/6 but for normal applications it...
  4. luni

    Encoder Issues

    Maybe something with the interrupts. Wild guess: the T2 doesn't use interrupts on the pins you are using. T3 and T4 do. I don't know if the MIDI stuff also uses interrupts. Maybe some T3 specific clash?. Just add your midi code to the example I gave you (replace the serial.prints by your midi...
  5. luni

    Encoder Issues

    To check if the hardware works you might use a simple test program which only checks the encoder part. I just tested the following on a Teensy 3.2 and it works without issue (note: it uses the EncoderTool library) #include "Arduino.h" #include "EncoderTool.h" using namespace EncoderTool; //...
  6. luni

    TeensyTimerTool

    This https://github.com/manitou48/teensy4 is always a good starting point if you need to do some low level programming. It contains some examples for input capture using the GPT module
  7. luni

    TeensyTimerTool

    Great, I'll do some testing these days and generate a new release for the library manager afterwards.
  8. luni

    TeensyTimerTool

    Sorry, didn't mention that the library lives on GitHub. https://github.com/luni64/TeensyTimerTool, And here an instructiion on how to install if from there: https://roboticsbackend.com/install-arduino-library-from-github/ I'll update the library manager after some testing later.
  9. luni

    How do you organize large sketches?

    Actually you can by using anonymous namespaces. Here an example: test.h #pragma once namespace someNamespace { extern int getVar(); extern int publicVar; } test.cpp namespace someNamespace { namespace // anonymous/private namespace { int privateVar = 42; } int...
  10. luni

    TeensyTimerTool

    @joepasquariello. Yes this is a lambda expression. Here some explanation about the origin of the name: https://www.baeldung.com/cs/lambda-functions . Actually the c++ syntax for lambdas is quite simple and logical. Here the full (AFAIK) syntax of a lambda expression: [capture list](parameters)...
  11. luni

    TeensyTimerTool

    Sorry, that was a bug. Can you try version 1.4.3? The following code correctly generates 500kHz signals on pin 0 and 1 using the PIT and GPT1 modules. It works for 24Mhz and 150MHz clock frequency settings. #include "TeensyTimerTool.h" using namespace TeensyTimerTool; PeriodicTimer...
  12. luni

    Syntax question, timing function idea

    ... or, if you don't like std::function / std::bind you can simply use a lambda: void timeit(void(*f)()) { elapsedMillis time; f(); printf("took %d\n", (unsigned)time); } void g1(){ delay(120); } void g2(int x){ delay(x); } void setup() { while (!Serial); timeit(g1)...
  13. luni

    Syntax question, timing function idea

    You can also use std::function and std::bind to achieve this without macros: #include <functional> void timeit(std::function<void()> f) { elapsedMillis time; f(); printf("took %d\n", (unsigned)time); } void g1(){ delay(120); } void g2(int x){ delay(x); } void setup() {...
  14. luni

    New Stepper Motor Library

    Thanks for spotting this. I'll have a look whats going on there. Might take a couple of days.
  15. luni

    libstdc++ exception handling (__verbose_terminate_handler) causing bloat in output binary

    Changing the c-library would obviously require a lot of testing. And I still believe that Paul had a good reason for using newlib in the first place. So I don't think this will happen soon (if ever). IMOH, the workaround suggested by @jmarsh, would be much less intrusive and has about the same...
  16. luni

    libstdc++ exception handling (__verbose_terminate_handler) causing bloat in output binary

    There probably are good reasons to use newlib instead of newlib-nano by default. I'm just wondering because ARM developped it for use in embedded processors as opposed to newlib which is meant for linux. The missing float printf / scanf can be activated by adding `-u _printf_float` and `-u...
  17. luni

    Compilation fails

    Seems to be the same issue as discussed here: https://forum.pjrc.com/index.php?threads/compile-once-warning-s-compile-again-no-warnings.74822/post-341746
  18. luni

    libstdc++ exception handling (__verbose_terminate_handler) causing bloat in output binary

    @shawn: the "smallest-code" option uses the nano version of newlib which is optimized for embedded systems. You can switch to it using the compiler switch --specs = nano.specs. Looks like newlib-nano doesn't have the exception stuff compied in...
  19. luni

    uploading hex file via teensy loader

    Since you are doing a c# application you might be interested in TeensySharp. https://github.com/luni64/TeensySharp Getting a list of currently connected Teensies is a simple as this: var Watcher = new TeensyWatcher(); foreach (var Teensy in Watcher.ConnectedTeensies) {...
  20. luni

    How to trigger interrupt on falling/rising edge of sent PWM signal?

    Simplest would be to connect the PWM pin to another pin and attach the interrupt to this.
  21. luni

    Generating/Approximating a PPS signal from Teensy 4.1

    Thanks, fixed it in v0.1.3
  22. luni

    EncoderTool wrong value on first anti-clockwise adjustment after power up

    The library is pretty imune against any bouncing as long as bounces don't overlap. I.e., if your encoder bounces so badly that one switch still bounces while the other switch changes transition you might get wrong counts. The same might happen if your encoder bounces extremely fast so that...
  23. luni

    Possible to determine which teensy board from bootloader?

    If your Teensy is already in bootloader mode you can read out the USB-HID usage constant with (probably) any HID library. The HID-Usage then defines the Board. See here for a list...
  24. luni

    EncoderTool wrong value on first anti-clockwise adjustment after power up

    Thanks for spotting it. I just published v3.2.2 on GitHub which fixes the issue. May take a few hours until the Arduino & PlO library managers detect the changed version.
  25. luni

    EncoderTool wrong value on first anti-clockwise adjustment after power up

    Sorry, it is in your library folder `EncoderTool/src/Single/Encoder.h` https://github.com/luni64/EncoderTool/blob/master/src/Single/Encoder.h
  26. luni

    EncoderTool wrong value on first anti-clockwise adjustment after power up

    OK, I can reproduce the issue with powercycling. During the `begin()` function the library sets the pinmode of the input pins to the required value and immediately after that reads in the starting values of the A/B pins. For some reason I don't really understand, it needs some time between...
  27. luni

    EncoderTool wrong value on first anti-clockwise adjustment after power up

    The datasheet is a bit unclear, can it be that this encoder has only half a quadrature period per detent? You can try by setting it to CountMode::full and see how much the count value increases if you rotate the encoder by one detent. I tested by resetting between trials. Going to do...
  28. luni

    EncoderTool wrong value on first anti-clockwise adjustment after power up

    I tested your code with a directly connected encoder (common GND) without any additional stuff. It works without issue here.
  29. luni

    EncoderTool wrong value on first anti-clockwise adjustment after power up

    Looks like it doesn't read the pinlevels at startup correctly. How did you connect the encoder?
  30. luni

    Compile once: warning(s), Compile again: no warnings?

    Thats not an error in your code but some glitch in the Arduino IDE. Seems like deleting the files in your temp folder fixes ist: https://forum.arduino.cc/t/internal-error-in-mingw32-gt-pch-use-address/1107884
  31. luni

    Teensy 4.1 stack size of 13k enough?

    If you switch the standard library from the default newlib to newlib-nano your size difference shrinks down to a few 100 bytes. Here some info about the two versions of the standard library: https://mcuoneclipse.com/2023/01/28/which-embedded-gcc-standard-library-newlib-newlib-nano/ Switching...
  32. luni

    Teensy 4.1: can't get combined UDP/TCP server to work (now with example code)

    I recently stumbled over std::optional which comes in handy for such situations. Of course, changing an already published API is a no-go, but std::optional seems to be a nice tool for the toolbox... #include <optional> std::optional<unsigned> parsePacket() { bool gotSomePacket = true...
  33. luni

    Very high code RAM usage

    Instead of SMALLEST_CODE you could also try to add --specs=nano.specs which will switch to newlib-nano (same as SMALLEST_CODE does) but keeps the optimization level.
  34. luni

    Very high code RAM usage

    Looks like you don't compile for gnu++17. Make sure -std=gnu++17 is set in your build options
  35. luni

    Crash when putting FlexCAN objects in RAM2

    You are right of course. To be on the save side one should use DMAMEM alignas(A) uint8_t buf[sizeof (A)]; // statically allocate memory for an object of type A to allocate the buffer.
  36. luni

    Crash when putting FlexCAN objects in RAM2

    Here a quick test which shows that the compiler relys on initialization during startup. class A { public: int i = 42; const int c = 17; void print() { Serial.printf("i=%d &i=%p\n", i, &i); Serial.printf("c=%d &c=%p\n", c, &c); } }; DMAMEM A a; void setup()...
  37. luni

    Help with Teensy Loader

    I have successfully worked on a proof of concept to upload ehex files with TeensySharp. However, I haven't integrated it into the library yet. Anyway, the purpose of TeensySharp is to allow users to integrate Teensy detection and firmware upload from within a dotNet PC application. Looks like...
  38. luni

    RESOLVED - T4.1 using Bounce2, boolean operators not working as expected.

    Actually isPressed() returns the debounced state of the button. So, replacing pressed() by isPressed() in @japreja s code should work. Here an example showing the behaviour of isPressed() #include "Bounce2.h" Button b1; void setup() { pinMode(1, OUTPUT); b1.attach(0, INPUT_PULLUP)...
  39. luni

    Lightweight C++ callbacks

    Thanks, I'll fix that. However, CallbackHelper was just an experiment to understand how those things work. Please note that since the new TD1.59, the core contains teensy::Inplace_function which is a much better solution.
  40. luni

    Encoder Tester

    Thanks for spotting this. I'll have a look
  41. luni

    getting fatal error: teensy4/teensy.h: No such file or directory when running code below

    You can't. For frequency measurements see here: https://www.pjrc.com/teensy/td_libs_FreqCount.htm For pulse height you need to use analogRead, but that will be difficult if you have short pulses For pulse width see here...
  42. luni

    getting fatal error: teensy4/teensy.h: No such file or directory when running code below

    Paul gave you the link to the documentation of the library in #13 above. It contains all information how to use it. However, it does not contain a "simple list of commands". I can give you examples if you tell us what you want to achieve with the library
  43. luni

    getting fatal error: teensy4/teensy.h: No such file or directory when running code below

    You didn't specify how precice you need that pulse. If you only need something roughly 10ns you can use the following code. It will generate a pulse of about 13ns every 50ms. IntervalTimer timer; void pulse() { digitalWriteFast(0,HIGH); //digitalWriteFast(0,HIGH); add more of those lines...
  44. luni

    using DMAMEM

    Technically you'd put the objects in DMAMEM, not the class. Here an example: c1 lives in ITCM, c2 lives in DMAMEM and c3 in FLASHMEM class myClass { public: unsigned i = 42; }; myClass c1; DMAMEM myClass c2; FLASHMEM const myClass c3; void setup() { while (!Serial){ }...
  45. luni

    WebUSB on teensy

    I just gave WebSerial a try. This is also very simple to use: Here a simple test web page: <!DOCTYPE html> <html> <head> <title>Page Title2</title> </head> <body> <h1>WebSerial Tester</h1> <button type="button" id="connectButton">Connect to Teensy</button> <p></p> <button...
  46. luni

    WebUSB on teensy

    @PaulS, Maybe I didn't understand this correctly, but I always thought WebUSB is a low level API where you directly communicate to endpoints / interfaces etc. Thus, wouldn't you need a corresponding driver on the Teensy side to make this work? When you just need to exchange data over USB between...
  47. luni

    JSON Deserialization slow'ish, blocks Stepper Motors

    Actully accelstepper::run() is not very expensive and the T4.1 processor is quite fast. Here a simple test which moves 4 steppers with random parameters. tick() calls the run() functions of the steppers in a timer interrupt every 100µs. During the execution it sets pin 12 HIGH for testing the...
  48. luni

    JSON Deserialization slow'ish, blocks Stepper Motors

    Did you try to simply call the accelstepper::run() functions from a timer interrupt?
  49. luni

    WebUSB on teensy

    In case WebHID is sufficient: I did try it some time ago, it worked nicely with minimal code: https://forum.pjrc.com/index.php?threads/making-webusb-work-with-the-teensy-what-is-pluggableusb.60782/post-247184. I just tried it, it still compiles and works, also the test website is still online.
Back
Top