PI 4 CM, T500 and Node-Red

Hello,

I have reviewed the TIC Controller documentation, and several libraries from various programming languages, to include Pololu’s own various libraries, in attempts to understand and identify the serial command structure and values that need to be passed to the T500 from within Node-Red to operate a Stepper-based linear actuator connected to a Seeed reTerminal (Raspberry Pi 4 CM).

With a USB cable connected from the T500 to a USB port on the reTerminal, it works quite well calling ticcmd utility from an exec node with the cmd line switches passed via an inject node, and from the ticgui opened on both the Pi and a Win10 PC. But for the intended application I would like to avoid using a USB adaptor, if at all possible. I have tried with both i2c (via i2c pins), and non-USB serial (via RX/TX/GND pins using serial port /dev/ttyAMA2) and cannot seem to break thru to getting an understanding of the proper syntax.

I currently have one of the additional serial ports configured and deployed in a Node-Red flow, which appears to be working, as it shows Status: connected for both in and out nodes.

Can anyone provide some guidance, please?

Thanks much, in advance, any help or direction to a resource is truly appreciated.

Hello.

I am not very familiar with Node-Red, and we do not have any specific resources for it. However, if you could post your code (or even just the bytes you are sending), I would be glad to take a look. Please specify if the code you post is for your I2C or TTL serial test. Additionally, could you post a copy of your Tic settings file? You can save a copy of your Tic settings file from the “File” drop-down menu of the Tic Control Center software.

Brandon

Hello Brandon, Thank you for responding so quickly. Per your request, attached is my settings.txt file from the T500.

Currently, I have the T500 attached to the PI 4 via RX/TX pins on the T500 to TX/RX on PI with a level shifter between, and the linear actuator attached via serial port: /dev/ttyAMA2 at 9600 baud.

Using the Pololu protocol, this is the decimal command (adapted from the User’s Guide, Chap 9) that I am using to move the stepper actuator to position 5000 as decimal buffer from a Node-Red inject node: [170, 14, 224, 4, 136, 19] which will actually be sent as a hex buffer: 0xaa, 0xe, 0xe0, 0x4, 0x88, 0x13, during the inject process.

I did reattach the T500 to a Win10 PC via USB cable just to confirm operation, and, again, was able use both ticcmd and ticgui without a problem. In addition, I was running a USB sniffer application on the Win10 PC trying to get some clues as to what commands and data are going back and forth under the surface.

ACTUONIX S20 with POLOLU TIC500 for AUTOTESTER - tic_settings - 080922.txt (1.3 KB)

From the bytes you listed, it looks like you might be trying to send a set target position command using the Pololu protocol, but there are a couple of problems with it.

The first problem I see is with the command byte. The command byte for the set target position command is 0xE0, but when using the Pololu protocol, it must have its most significant bit cleared. So, instead of 0xE0, you should use 0x60. You can find more information about the Pololu protocol near the end of the “Serial command encoding” section of the Tic user’s guide.

The set target position command is a 32-bit write command, so after the command byte, you should have 5 more bytes (for a total of 7 with the Pololu protocol). The first one should contain the most significant bit for each of the following 4, and the rest should be the data bytes 1-4 with their most significant bits cleared, as described in the “Serial command encoding” section of the Tic user’s guide, under the “32-bit write” heading.

If you try making those changes and still have problems, could you post the updated byte sequence you are sending and specify what you are expecting it to do (e.g. set the target position to 2000)?

Brandon

So, if I want to Set Target Position to 5000, using Pololu protocol, my understanding at this point would be:

0xAA (decimal 170) to declare Pololu protocol
0x0E (decimal 14) for device number
0x60 (decimal 96) command - Set Target Position, LSB of command 0xE0 is 0x60
0x05 (decimal 5) for position of Most Significant Bit in string relative to command bit position, based on 32-bit write (little endian) example in doc
0x00 (decimal 0) both this bit and next bit set to 0, to fill out 32-bit position bits
0x00 (decimal 0)
0x08 (decimal 8) position 5000 in hex is: 0x1388, LSB of 0x88 is 0x08
0x13 (decimal 19) MSB of target position
For a decimal command buffer of: [170, 14, 96, 5, 0, 0, 8, 19].

This still is not working, I suspect I need to send an --exit-safe-start (or --resume equivalent) command before above, but at least am I understanding the structure and principles correctly, now?

The documentation is confusing to me. Also, is there an error in the hex values in Serial 32-bit Write example to arrive at: 1,234,567,890?

Thank you, again.

Hello.

I do not see an error in the documentation example for setting the target to 1,234,567,890, but the bytes you listed for setting it to 5000 are incorrect. To set the target to 5000, the bytes should be:

Description Byte
Start byte 0xAA
Device Number 0x0E
Command byte 0x60
MSbs 0x01
Data1 0x08
Data2 0x13
Data3 0x00
Data4 0x00

To help explain how those MSbs and Data# bytes are determined, here is a breakdown using your example of 5000:

5000 represented as a 32-bit binary is: 00000000 00000000 00010011 10001000

The MSbs byte contains the most significant bit from each of the bytes that make up the target: 0001 (i.e. 00000001)
Data1 is the least significant byte (10001000) with its most significant bit cleared: 00001000
Data2 is the next byte (00010011) with its most significant bit cleared: 00010011
Data3 is the next byte (00000000) with its most significant bit cleared: 00000000
Data4 is the most significant byte (00000000) with its most significant bit cleared: 00000000

By the way, I generally recommend doing this programmatically instead of hard-coding it, especially if you need to change the position often. While we do not have any examples for doing that in Node-Red, you might find some of the examples in the “Writing PC software to control the Tic” section of the user’s guide helpful, for example, the code for the set target command in the “Example serial code for Windows in C” (starting at line 124). That example uses the compact protocol, but the code for the MSbs and data bytes would be the same.

From your settings file, I expect your Tic will be throwing a command timeout error (unless you are sending certain commands every second). So, you will need to send an exit safe start command to allow the Tic to control the motor again before sending the set target position command. Please note that you can adjust or disable the command timeout feature in the “Input and motor settings” tab of the Tic Control Center Additionally, you can disable safe start if needed in the “Advanced settings” tab. While it is useful to disable those safety settings for testing, I generally recommend using them once you get it working properly. For reference, the serial bytes to send the exit safe start command in the Pololu protocol (with the default device number) are: 0xAA 0x0E 0x03.

Brandon

Thank you very much, Brandon!
I need to digest the information you provided. But, to clarify, I am only hard-coding any of these commands and values to establish a repeatable baseline of operations, then I was going to move on to passing variables, etc.