From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Hobbyist Toolkit

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding Support for a New LINX Remote I/O Device - Teensy 4.0

Hi,

Back in May '21, I have started a project in which I need to use a Teensy 4.0 board. In the lab we use the Teensy 4.0 board for most of the applications. Because I am familiar with Labview and not much with Arduino, I thought I could try to use Labview also for creating the interface for the data acquisition and control tasks for the experiments we want to run. I want to develop some code for sending signals and reading data from sensors as well as visualizing what is happening in a graphical and more user friendly way than with Arduino core capabilities.

 

It turned out that the Teensy 4.0 is not listed among the devices supported by the LINX toolkit. I tried to follow the instructions listed here "https://www.labviewmakerhub.com/doku.php?id=learn:tutorials:libraries:linx:misc:porting_device" but I was not able to make all the required changes.

 

I tried address the list of changes to be made to the .cpp and .h files for the libraries.

 

However, even with information I found online about the Teensy 4.0, I am still not sure what I should put for the following variables/definitions. If any of you knows what I should put for these variables/settings it would be great. Thank you in advance.

 

  • Number of SPI Speeds: Update NUM_SPI_SPEEDS with the number of supported SPI clock rates.
  • I am not sure about the SPI Speeds because it seems that both ARDUINO (https://www.arduino.cc/en/reference/SPI) and Teensy (https://www.pjrc.com/teensy/td_libs_SPI.html) recommend not to use SPI Speeds definitions and dividers. They seem to recommend to use SPISettings with SPI.beginTransaction() to configure SPI parameters. In this case, I am not sure how to adapt the sample .cc and .h files.
    Number of UART Channels: Update NUM_UART_CHANS with the number of UART channels on the device.
    Number of UART Speeds: Update NUM_UART_SPEEDS with the number of supported UART baud rates.

Also, in the Config.h, I am not sure about these changes:

  • Set the device family code
  • What is the family code for the Teensy 4.0? Where can I find it?
    Set the ARDUINO_VERSION to match the IDE version used to build the firmware. This is used to deal with some API changes in the different wiring versions.
  • For the Teensy 3.0 and 3.1 the version was set to 105. I currently have the 1.8.15, do I need to put something related to this or just leave the 105?

Can anyone help?

 

Thank you in advance for your attention to this post and for your assistance.

 

Best, Massimo

0 Kudos
Message 1 of 2
(1,226 Views)

Hi Massimo,

 

You could base your project on the LinxPjrcTeensy30 files.

For the first version use the existing SPI_CLOCK_DIV values and number of UART channels. Modify it when you have a prototype running on the Teensy 4.0. 

 

LinxWiringDevice.cpp would need modifying to use the newer SPI functions.  You may only need to increase the SPI_CLOCK_DIV values due to the faster PLL clock of the SPI interface on the Teensy 4.0. 

 

I think there are 7 UARTS on the Teensy 4.0.  They will support the existing baud rates.

 

The device family value for PJRC boards is defined in Firmware/Source/core/device/utility/LinxPjrc.cpp

 

DeviceFamily = 0x03;

 

DeviceId 2 is used for the Teensy 3.0 and DeviceId 3 is used for the Teensy 3.1

You could use DeviceId =  4 for your board.

 

ARDUINO_VERSION is used in LinxWiringDevice.cpp. It is OK to leave the value set to 105.

 

Cheers,

Andy.

0 Kudos
Message 2 of 2
(1,160 Views)