Search results

  1. 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...
  2. 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.
  3. 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
  4. 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.
  5. 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()...
  6. 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...
  7. 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)...
  8. 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.
  9. luni

    Encoder Tester

    Thanks for spotting this. I'll have a look
  10. 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...
  11. 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
  12. 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...
  13. 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){ }...
  14. 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...
  15. 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...
  16. 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...
  17. luni

    JSON Deserialization slow'ish, blocks Stepper Motors

    Did you try to simply call the accelstepper::run() functions from a timer interrupt?
  18. 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.
  19. luni

    Force windows to re-enumerate teensy USB device

    If resetting the device would do what you need, you could use tyCommander:
  20. luni

    Teensyduino 1.59 Beta #5

    Yes, I'll never understand why the Arduino IDE doesn't have a simple "clean all". Anyway, the note is issued during compiling, not linking. So, in this case forcing a rebuild doesn't help.
  21. luni

    Teensyduino 1.59 Beta #5

    I can reproduce that with @PaulStoffregen s code. I also saw that the warning/note is generated by the compiler, not the linker. So, opposed to what was written in the StackOverflow link it doesn't help doing a clean recompile. Anyway, you can get rid of the note with the compiler flag...
  22. luni

    Teensy 4.1 program compiles fine, but upload attempts fail

    If you post the hex file I can try to reproduce the issue.
  23. luni

    Teensyduino 1.59 Beta #5

    The warning seems to be about linking code compiled with an older compiler to code compiled with a newer compiler. See here for details: https://stackoverflow.com/a/48149400/1842762. Are you sure that you are doing a clean rebuild? Are you linking any precompiled librarys (*.a files) to your...
  24. luni

    Teensyduino 1.59 Beta #5

    There still is a leftover from the old code in intervaltimer.h: https://github.com/PaulStoffregen/cores/blob/c5e716375532ae0d8b912d7034707c0859b68801/teensy4/IntervalTimer.h#L73C2-L78C3 here the corresponding PR: https://github.com/PaulStoffregen/cores/pull/701
  25. luni

    IntervalTimer calling function with parameters

    Registering an interrupt service routine (ISR) is usually done by storing its address in a table (often called the "vector table"). The IntervalTimer.begin() function does this for you. If an interrupt wtih number n occurs, the processor basically looks up the address stored at position n of...
  26. luni

    Does x/2 compile to arithmetic right shift?

    @cmarcus: Here you can experiment: https://godbolt.org/z/djMe46bj1 As mentioned above, signed integers generate much more code than an unsigned version
  27. luni

    High bandwidth comm between Teensy4.1 and PC

    Couple of years ago I did a lot of experiments with high speed data transfer over usb serial. It turned out that on Win10 you can stably transfer some 10MByte/sec from a Teensy to a dotNet (C#) application. However, there is a known bug in the Windows CDC driver which silently drops data if you...
  28. luni

    Teensy 4.0 underperforming and orange led is dimmer than originally.

    What happens if you remove the serial.print from loop()?
  29. luni

    Stepper motor is vibrating due to reading output current using Modbus or serial read using micros or multithreading!

    Can't you simply call the accelstepper run function from a timer interrupt?
  30. luni

    GCC 11

    Some time ago there was a discussion in the forum about a very similar issue when an if clause checking the return value of new was not called correctly. Here the corresponding code void setup() { while (!Serial); void *p = new byte[1024 * 600]; // try to allocate 600kB (which is too...
  31. luni

    GCC 11

    Here a very simple method to check if something is eating up too much stack. https://forum.pjrc.com/index.php?threads/teensy-4-1-cannot-make-use-of-free-memory-resulting-in-fw-crash.73203/#post-328880 Anyway, seems to be an interesting issue. Couldn't you upoload the code somewhere?
  32. luni

    New Stepper Motor Library

    Usually you would use a *HCT since the input levels are better suited for a 3.3V controller output. But, the output rating of a HC/HCT chip is a bit borderline. Your driver is specd for typically 10mA (max 16mA) input current (probably a optocoupled input). IIRC the HC/HCT output is speced for...
  33. luni

    New Stepper Motor Library

    Thanks for the datasheet. Looks like you are right. Currently TeensyStep4 has the pulse polarity hardcoded, so I see 2 possibilities You'll need a level shifter anyway since the driver requires >3.5V logic level. So, using an inverting shifter seems to be the simplest solution (something like a...
  34. luni

    New Stepper Motor Library

    Are you sure that the DM805 needs a falling edge? This would be very unusual for Leadshine. Can you post a datasheet?
  35. luni

    How to access the internal RTC in a Teensy 4.0?

    Here a minimal example: void setup(){ } void loop(){ time_t time = rtc_get(); // read the current time from the RTC Serial.print(ctime(&time)); // convert time_t to readable string and print out delay(1000); } which prints: Sat Jan 6 12:42:43 2024 Sat Jan 6 12:42:44 2024 Sat...
  36. luni

    Serial comunication between Teensy 4.1 and Arduino Nano 33 IOT

    Use Serial.print((char)Serial.read()); to see the characters
  37. luni

    Very high code RAM usage

    However, you can enable it by placing asm(".global _printf_float"); into setup()
  38. luni

    Advice on program construction - DMX

    What do you mean by "gather variables"? If you want to access class member variables from outside you can either make them public (not recommended) or write a 'getter' and/or a 'setter' function. The advantage of this approach is that you can prevent users of your class messing with the...
  39. luni

    Interrupt on Serial Data receive Teensy 4.0 USB port

    It probably runs on yield. e.g. after loop or while delay or other long running functions are spinning, or whenever you call yield in your code. But yes, this is not an interrupt.
  40. luni

    Teensyduino multiple devices flash at the same time

    I'm not very fluent in python. So, I wonder if this is really programming the boards in parallel or one after the other?
  41. luni

    Interrupt on Serial Data receive Teensy 4.0 USB port

    Neither did I. So I did a quick test with USB-Serial which works nicely. Might come in handy sometime... void serialEvent() // do your parsing here { char c = Serial.read(); // do something with the character if(c == '1') { Serial.println("--------------"); Serial.println(c)...
  42. luni

    Teensyduino multiple devices flash at the same time

    BTW: for easy installation the library can be found on nuget. Documentation is a bit out of date but the examples in the gitHub repo should show how to use it. https://www.nuget.org/packages/lunOptics.libTeensySharp/1.0.1?_src=template
  43. luni

    Teensyduino multiple devices flash at the same time

    If you are using windows you can use TeensySharp for such things. I did a quick proof of principle using this c# script: using libTeensySharp; var watcher = new TeensyWatcher(); // provides a list of connected Teensies foreach (var teensy in watcher.ConnectedTeensies) // print the list {...
  44. luni

    TeensyTimerTool

    You can set the priority directly using the NVIC. Note that the priority can only be set for a complete timer module, not for the individual channels of a module. For example, if you set the priority of the TMR2 module, all 4 channels of this module will get the same priority. Here is an example...
  45. luni

    Teensy 4.1 interrupt trigger on wrong edge

    Last time I checked, a DSB took quite some time. Generating a double invokation on timer interrupts is quite easy since the underlying ISR is very lean. E.g., if you only set a flag or toggle the LED, you need a DSB to prevent double invokation. However, due to the checking of which pin was...
  46. luni

    Electronic circuit to convert 0.8-4.2 to 0-5 VDC

    Looks like the controller has a simple serial interface (set speed by sending a byte). So, instead of an EE solution you could think of using a Teensy (or a cheap controller like a XIAO) to read in the throttle value, calculate the required speed from it and send it to the motor controller. They...
  47. luni

    micros() rollover period on Teensy 4.1

    Micros returns a 32bit result. It overflows every 2^32 µs which is every 4.295E9 µs (=4295s = 71.6min). To prolong this you can store the value in the lower 32 bits of a 64bit variable. Then look periodically (at least once every 71min) if the read out value is smaller than the last one. In this...
  48. luni

    xenForo Improvements

    Doesn't work here as well
Back
Top