Search results

  1. L

    check ALL if the elements in an array meets a condition

    Yes, exactly! 100% of the items have to meet the condition :)
  2. L

    check ALL if the elements in an array meets a condition

    Hello forum, I am trying to check if ALL the elements of an array meets a condition. the pseudocode should be: if (all the elements in the array > value) { do something; } I don't need a check for every element like the following that I have already tryed: for (uint i = 0; i < 6; i++) {...
  3. L

    two functions calls in the same intervalTimer

    There was a problem inside my PID_Compute function: I was uploading some global variables in a wrong way. I have built a void function that computes both PID controls inside it and now it works! :D
  4. L

    two functions calls in the same intervalTimer

    Thank you Paul. Actually there are some more rows of code that are needed to send the signal to the motors. The problem is that the code works properly with only the first PID function (if I comment the second one) and also with only the second PID function (If I comment the first one).
  5. L

    two functions calls in the same intervalTimer

    Hi forum, Is it possible to call the same function two times in the same intervalTimer? I am trying to compute the same function with different input in an interval timer that runs at 1 kHz. void functionMotorControlTimer() { Input1 = (float)(LC_1); Input2 = (float)(LC_2)...
  6. L

    <PID_v1.h> myPID.Compute() function in IntervalTimer on Teensy 3.5

    Hi alisondmurray, I think you have copied and pasted my post from this link: https://forum.pjrc.com/threads/50538-lt-PID_v1-h-gt-myPID-Compute()-function-in-IntervalTimer-on-Teensy-3-5
  7. L

    baudrate problem with teensy to teensy byte package communication

    Hi everybody, I have implemented both the data acquisition and the writing on the SD card in the void loop (no more timers and interrupts) and I am able to save the data on the card at 1 kHz. There are some more details to be fixed but now the code works way better than before. Thank you again...
  8. L

    QueueArray library max queue size

    wow, thank you. I will try it! :)
  9. L

    QueueArray library max queue size

    Thank you very much for the help! Actually, when I write in the buffer I can see the size of the buffer increasing from 0 to 8 but myBuffer.length_front() is always 0. This is my code: #include "circular_buffer.h" Circular_Buffer<byte, 8, 512> myBuffer; #define BYTE_PACKET 512 uint8_t...
  10. L

    QueueArray library max queue size

    I have a little trouble using Circular Buffer. I have initialize the buffer as follows: #include "circular_buffer.h" Circular_Buffer<byte, 8, 512> myBuffer; bacause I need 8 slots of 512 bytes. And I am writing the 512 bytes as follows: myBuffer.write(SDPacket,BYTE_SD_PACKET); and it...
  11. L

    QueueArray library max queue size

    Thank you for the suggestions. I will try to use Circular Buffer!
  12. L

    QueueArray library max queue size

    Hello forum, I have a very quick question that I was not able to solve online. Which is the maximum default size of a queue in the Queue Array library? And how can I set a different size of the queue? Thank you very much, Lorenzo
  13. L

    baudrate problem with teensy to teensy byte package communication

    Thank you every body for your precious help. I am actually working on the code and I am trying to implement your suggestions. I will let you know any progress as soon as possible! :)
  14. L

    baudrate problem with teensy to teensy byte package communication

    You are right rcarr, thank you. I do not know how I could manage the transfer of data between different interrupts without using noInterrupts(), interrupts() ...
  15. L

    baudrate problem with teensy to teensy byte package communication

    Thank you all for the precious suggestions. I have modified the baud rate to 2000000, both T3.2 and T3.5 are working at 96 MHz, T3.2 sends data at 1 kHz (seems properly) and T3.5 tries to receive data at 1 kHz in the main loop. Then data are saved in the SD card at 1 kHz. The code seems to work...
  16. L

    baudrate problem with teensy to teensy byte package communication

    Thank you for the suggestions, I will try to implement both the 4th start byte in the packet and a sort of state machine to read the incoming data. Actually, Teensy 3.2 works at 96 MHz whereas Teensy 3.5 at 120 MHz (by default, I have not changed anything). I have tryed to modify the...
  17. L

    baudrate problem with teensy to teensy byte package communication

    Yes, I am sorry. I have tryed to make it a little more comprehensible: Thank you very much for your valuable help.
  18. L

    baudrate problem with teensy to teensy byte package communication

    Thank you very much. Yes, SERIAL_Incoming_Data. is a union that collects the incoming data. In the code there are two more timers: one for the control of two motors and one for the writing on SD card. A third one will be added to send data to the laptop via serial at 25 or 50 Hz (just for a...
  19. L

    baudrate problem with teensy to teensy byte package communication

    Thank you Paul. Following your suggestions, I have moved the receiving part of the code in the void loop and implemented the check for the first three bytes. Now the baud rate is set to 230400 and I am sending data at 500 Hz. In the following you can find my code, but It still does not work...
  20. L

    baudrate problem with teensy to teensy byte package communication

    Thank you very much for the useful information and suggestions Paul. I have already implemented the function "checkPacket(SERIAL_Incoming_Data.vData)" that checks the start and the end of the package. I will implement a check on the start bytes before collecting the whole message. If I move...
  21. L

    baudrate problem with teensy to teensy byte package communication

    Do you mean setup the transmission in the main loop and the receiving in SerialEvent()? How can I be sure about the transmission frequency in this case? Thank you
  22. L

    baudrate problem with teensy to teensy byte package communication

    Thank you for the interesting suggestions. The other SPI device is a Dual Encoder Breakout and I am using it to read two encoders at 2000 Hz (in an interval timer function). Then the encoder data are elaborated and send to Teensy 3.5 with all the other data of the 34-bytes package as fast as...
  23. L

    baudrate problem with teensy to teensy byte package communication

    Is the problem due to the fact that the protocol is inside an interval timer?
  24. L

    baudrate problem with teensy to teensy byte package communication

    There could be something wrong in the code :) I have implemented the sending and receiving function inside an interval timer because I really need to send data at a specific frequency. This is the interval timer function that sends the data: void functionSERIALTimer() { unsigned long...
  25. L

    baudrate problem with teensy to teensy byte package communication

    Thank you for the suggestion. Unfortunately Teensy 3.2 has only one SPI port and I am already using it. I need to use a serial communication... Any suggestion on how to improve it? If you have any hint about the interval time and the baudrate I would be grateful :)
  26. L

    baudrate problem with teensy to teensy byte package communication

    Good evening forum! I am trying to send data from a Teensy 3.2 to a Teensy 3.5 through Serial communication. I am sending a 34 bytes package on Serial1 (to Serial1). The code for the T3.2 and the T3.5 are implemented inside an IntervalTimer. In particular if I am using a baudrate of 115200...
  27. L

    Hard real time in Teensy 3.5

    Thank you for the suggestions. I have already implemented a timer priority (highest priority for the "small" timer that control the motor and default priority for the timer reading data from serial port) and now the code seems to work properly at 500 Hz. I think it will be hard to make it work...
  28. L

    problem with union in Teensy 3.5

    It works with #pragma pack(push, 1) and #pragma pack(pop) ! :D Thank you very much for the suggestion KurtE!
  29. L

    <PID_v1.h> myPID.Compute() function in IntervalTimer on Teensy 3.5

    Hi everybody, I am trying to use the library <PID_v1.h> in Teensy 3.5. In particular I would like to execute the myPID.Compute(); inside an IntervalTimer function at a frequency of 1 kHz. Inside the function I also increase a counter (motor_control_counter) that I print on the serial monitor...
  30. L

    problem with union in Teensy 3.5

    Hello forum! I have a little problem with an union in Teensy 3.5. I am sending binary data packages from a Teensy 3.2 to a Teensy 3.5 via Serial communication. I am using a union structure to unpack and extract data from the received packages. My problem is that, if I use this structPacket...
  31. L

    Hard real time in Teensy 3.5

    Thank you GremlinWrangler. I will try for sure to swap the array being written and write the old one. If I do not consider the SD card, is there a way to understand if my timers are really working at my defined frequency? Is there a way to block the execution of the software if the timers are...
  32. L

    Hard real time in Teensy 3.5

    Thank you very much GremlinWrangler. I need deterministic writing in my code (1 kHz). If there is a way to easily write at 1 kHz in binary on the SD I would be grateful. Otherwise, could you give me more suggestions about the writing on a flash IC from Teensy? You can find the critical part...
  33. L

    Hard real time in Teensy 3.5

    Hi everybody, I am developing a software on Teensy 3.5 in which I have implemented three different timers at 1 kHz. One of the timers should save data on a SD card. If I save the millis() at each iteration, the data are not saved at 1 kHz but there are some delays of 5-6 ms (instead of each...
  34. L

    Normally open transistor to control the inhibit of a driver from Teensy 3.5

    Thank you rcarr! I have solved the problem with a TIP120 that I already had in the lab.
  35. L

    Normally open transistor to control the inhibit of a driver from Teensy 3.5

    Hi everybody, I am using a driver Advanced Control Driver 12A8-QDI to control a DC motor from Teensy 3.5. I would like to control the inhibit pin of the driver to be sure that it is disabled/enabled when I want. The inhibit pin enables the driver when it is connected to ground and disabled it...
  36. L

    PID library is blocking when the setpoint is reached

    Thank you very much Manitou, so maybe the problem is not due to the PID function...
  37. L

    PID library is blocking when the setpoint is reached

    Hi everybody, I am trying to control the speed of a DC motor with Teency 3.5 by reading data from the encoder. Everything seems working but, when the motor reaches the setpoint speed the PID.Compute function is blocking and the motor stops moving. My question is: which should be the output of...
  38. L

    SPI communication with DAC MAX532 from Teency 3.5

    Thank you very much Theremingenieur!! :D :D This solves my problem! I have added the following line at my code and the "begin" and "end" transactions lines: SPISettings setMAX532(2000000, MSBFIRST, SPI_MODE0); Bytes were sent in the correct order. Here is the final version of the code that...
  39. L

    writing binary file on SD card in Teency 3.5

    Thank you very much turtle9er and WMXZ! :)
  40. L

    Write data on SD card from Teency 3.5

    Sorry, could you explain it a little better and post your code? Thank you.
  41. L

    SPI communication with DAC MAX532 from Teency 3.5

    Hello forum, I am opening a new post about SPI communication with DAC since I am not able to solve the following problem since two weeks. I am trying to communicate with a DAC MAX 532 from Teency 3.5 https://datasheets.maximintegrated.com/en/ds/MAX532.pdf Here is my code: #include <SPI.h>...
  42. L

    delay in nanoseconds on Teency 3.5

    Hello everybody, Is there a way to add a delay in nanoseconds on Teency 3.5? I have tryed to search some examples but I could not find any. Thank you! :)
  43. L

    Enable and disable only one interrupt

    Good morning forum! I am trying to figure out how to enable and disable only one interrupt at a time on Teency 3.5, because by using "noInterrupts();" and "interrupts();" all the interrupts are disabled at the same time. Is there a way? Thank you :)
  44. L

    writing binary file on SD card in Teency 3.5

    I have one more question: Is there a way to write binary data on the SD card without closing the file at the end of the writing? The opening and closing operations are becoming really time-consuming if I would like to increase the writing frequency (for example at 1 or 2 kHz). In case the...
  45. L

    writing binary file on SD card in Teency 3.5

    Thank you very much WMXZ. I checked the file to be opened and I have also implemented the closing of the file after a number of cycles. In the previous script also the storage of DataPackets in SDPacket was wrong. Now the code works and I can write data on my SD card. Here it is the final...
  46. L

    writing binary file on SD card in Teency 3.5

    I have tryed the following code to write 512 bytes on the SD card but there is no file on the SD card. The 512 bytes (SDPacket) are composed by 16 packets (dataPacket) of 30 bytes each. Why is it not writing anything on the card? Thank you for any suggestions :) #define BYTE_DATA_PACKET 30...
  47. L

    writing binary file on SD card in Teency 3.5

    Thank you very much Paul. Tomorrow I will try it on my Teency 3.5. :) I have just a little question: If I would like to write on the SD card 8 values (or more) which are acquired at each loop, how can I store them in a queue in order to fill the 512 byte buffer?
  48. L

    writing binary file on SD card in Teency 3.5

    Hello forum! Where can I found a complete example on how to write a binary file on SD card in Teency 3.5? Thank you very much in advance, Lorenzo
  49. L

    Write data on SD card from Teency 3.5

    Hi everybody, I am trying to write data on a SD CARD SanDisk 16 GB U1 from Teency 3.5. I would like to log data from different sensors and I was wondering which is the maximum frequency for writing data on the card. This is my function for the data writing: void functionSDcardTimer() {...
  50. L

    DAC on Teency 3.5

    Thank you for your help Donziboy2. Now my DAC MAX532 seems to work, the connections for the unipolar mode are as follows: Pin Connected to 1 Shorted to 3 2 10V (I used a KA78L05A linear voltage regulator) 3 Channel A Output 4 GND 5 GND 6 Shorted to 8 7 10 V 8 Channel B Output 9 DC Power...
Back
Top