confusion over what "ASCII" really means

Hi all, I’m not new to arduino but I’m really stuck on this and running out of ideas…

So I have some Trinamic motor driver boards, which can use their USB software or RS485. I want to set it up with USB then run it from my arduino via UART to RS485. Seems simple enough…

The manual states that once the stepper motor board is in ASCII mode, then simple commands in ASCII can be sent. Here is an example of one:

AROL 0, 1000

This rotates device “A” to the left “ROL” at 1000 microsteps per second, motor “0”

However when I try and use a simple Serial.print(“AROL 0, 1000”); command to the UART port (confirmed its going out via oscilloscope. Nothing happens. The USB software is showing a CRC error.

So I’m thinking this is something to do with how arduino handles “ASCII”

Are there different interpretations? I’ve tried these different ways:

NORMAL PRINT:

Serial.print(“AROL 0, 1000”);

USING AN ARRAY OF CHAR:

char serialArrayOne = {65,82,79,76,32,48,44,32,49,48,48,48};

Serial.write(serialArrayOne,11);

WRITING EACH CHAR:

Serial.write(65);
Serial.write(82);
Serial.write(79);
Serial.write(76);
Serial.write(32);
Serial.write(48);
Serial.write(44);
Serial.write(32);
Serial.write(49);
Serial.write(48);
Serial.write(48);
Serial.write(48);

These all give CRC errors, are they functionally the same on the UART output?

Is there something in the comms I’m missing? what is the arduino definition of writing ASCII?

Perhaps carriage return or newline?

thanks!

Looks like you aren't sending a CRC byte/bytes - that leads me to believe you aren't sending a full packet to begin with. Can you link the datasheet you referenced?

1. In my case, the Serial Monitor shows the message "AROL 0, 1000" very well in response to the following command:

Serial.print("AROL 0, 1000");

2. The full name for ASCII is: American Standard Code for Information Interchange. In this standard, every character of the English Language Alphabet is assigned an 8-bit code (called ASCII Code) as per definition of the following ASCII Code Table.


Figure-1: ASCII Code Table

3. ASCII Codes have been developed to ensure safe and reliable data communication using UART Port; where, the Control Codes (NULL, ..., SI, ..., DLE, ..., US) will never mix up with the message codes composed of: A-Z, a-z, 0 - 9, punctuation marks, and special charcaters.

4. Control Codes are non-printable charcaters, and they are used to indicate the 'Start of Message', 'End of Message', and the like.

Power_Broker:
Looks like you aren’t sending a CRC byte/bytes - that leads me to believe you aren’t sending a full packet to begin with. Can you link the datasheet you referenced?

I don’t think I can attach it but here’s the link:

Here’s a section copied on the ASCII interface:

"

3.4 The ASCII Interface
There is also an ASCII interface that can be used to communicate with the module and to send some direct
mode commands as text strings. Only the following commands can be used in ASCII mode: ROL, ROR,
MST, MVP, SAP, GAP, STAP, RSAP, SGP, GGP, STGP, RSGP, RFS, SIO, GIO, SCO, GCO, CCO, UF0, UF1, UF2, UF3,
UF4, UF5, UF6, UF7.
Note Only direct mode commands can be entered in ASCII mode.
Note The TMCL-IDE does not support communicating with the module in ASCII mode.
So, in order to be able to use the TMCL-IDE with a module the module must be
in binary mode. We normally recommend using the binary mode as this has
some advantages over the ASCII mode. The ASCII mode is only provided here for
compatibility. For new applications it is strongly recommended to use the binary
mode.
There are also some special commands that are only available in ASCII mode:
• BIN: This command quits ASCII mode and returns to binary mode.
• RUN: This command can be used to start a TMCL program stored in memory.
• STOP: Stops a TMCL program which is currently running on the module.
3.4.1 Entering and leaving the ASCII Mode
• The ASCII command line interface is entered by sending the binary command 139 (enter ASCII mode).
• Afterwards the commands can be entered in their mnemonic form (e.g. via a terminal program).
• For leaving the ASCII mode and re-entering the binary mode enter the command BIN.
3.4.2 Format of the Command Line
As the first character, the address character has to be sent. The address character is A when the module
address is 1, B for modules with address 2 and so on. After the address character there may be spaces
(but this is not necessary). Then, send the command with its parameters. At the end of a command line a
character has to be sent. Here are some examples for valid ASCII mode command lines (assuming
that the module address is 1):
• AMVP ABS, 1, 50000
• A MVP ABS, 1, 50000
• AROL 2, 500
• A MST 1
• ABIN
The last command line shown above will make the module return to binary mode.

"

bart_dood:
At the end of a command line a character has to be sent

You need to add a ‘\r’ at the end of your packet array. This may be your problem.

Try:

char serialArrayOne[]  = {'A', 'R', 'O', 'L', ' ', '0', ',', ' ', '1', '0', '0', '0', '\r'};

Power_Broker:
You need to add a '\r' at the end of your packet array. This may be your problem.

Try:

char serialArrayOne[]  = {'A', 'R', 'O', 'L', ' ', '0', ',', ' ', '1', '0', '0', '0', '\r'};

Thanks I missed that. I updated my code etc.

I forgot I had an old logic analyzer so I hooked it up to my UART to check what was coming out. It all checks out, I've tried everything but still the stepper board won't respond. I've been talking to their support people who aren't very good, after getting nowhere for 1+ weeks with this I'm at the point of giving up.

Have you ensured your wiring is good? Maybe try swapping RX and TX

Maybe you can try Serial.println("AROL 0, 1000");

Could it be a simple thing as setting the correct speed?

Power_Broker:
Have you ensured your wiring is good? Maybe try swapping RX and TX

I used the logic analyzer to check my UART port and I also have an oscilloscope on my RS485 to check the output coming out of it. All seems ok

Still your Arduino and your board must use the same speed.
How does your Serial.begin(xxxx) look like?
And after that I think you have to include a CRC character at the end.
There is a C program sample in the pdf file.