Canada
Asked — Edited

Uart Question When Tx And Receiving Unsigned Chr

There is an issue when sending ASCII code through the UART ports. For some reason the ASCII code is getting lost in the translation. It is hit or miss, some codes make it through fine and some don't get sent at all. Error saying that the expression is not in quotes. If the code is sent the received transmission shows a question mark. I have included an example with the ASCII code 255, it gets sent but RX is a ? and not the y with two dots above it.

If you can correct this issue with the scripting you would have me sold on the EZ B.

Great platform and fun to use.

Thanks DJ

Start 1: UARTInit(0,1,1000000)

7: $handshake=GetAsByte(255) # ASCII code 255

8: UARTWrite(0,1,$handshake) # not all codes will be TX

10: Print($handshake)

ÿ # symbol that code represents

14: Sleep(1000)

16: $x = UartAvailable(0, 1)

18: print("Bytes in buffer: " + $x)

Bytes in buffer: 1

20: $TX_DATA = UARTRead(0, 1, $x)

22: print("Received: " + $TX_DATA)

Received: ? # RX Issue or TX issue

25: Print ("done")

done


ARC Pro

Upgrade to ARC Pro

Discover the limitless potential of robot programming with Synthiam ARC Pro – where innovation and creativity meet seamlessly.

PRO
Synthiam
#1  

The value being received is correct - what the symbol looks like (i.e. a y with dots of a ?) is due to Windows Locale interpreting the character and should not be used to determine if it is the correct variable:)

Use the GetByteAt() command or GetByte() command to return the ascii ordinal value.

*Note: I removed the other duplicate post. We can use this one

#2  

Thanks DJ I should have tried that first. I appreciate your patience.

#3  

I just tried your suggestion and I received the value 63 which is the code for " ? ". I believe there may be a bug in the EZ Scipt.
The following is from the console after running the script.

Start 1: $handshake=GetAsByte(255) 2: $AX_ID=GetAsByte(14)
3: $length=GetAsByte(7) 4: $AX_Write_Data=GetAsByte(3) 5: $table=GetAsByte(30) 6: $LSB=GetAsByte(188) 7: $MSB=GetAsByte(2) 8: $LSB2=GetAsByte(30) 9: $MSB2=GetAsByte(0) 10: $checksum=GetAsByte(237) 13: $test=$handshake+$handshake+$AX_ID+$length+$AX_Write_Data+$table+$LSB+$MSB+$LSB2+$MSB2+$checksum 18: UARTWrite(0,1,$test) 28: $x = UartAvailable(0, 1) 30: print("Bytes in buffer: " + $x) > Bytes in buffer: 11 32: $RX_DATA = UARTRead(0, 1, $x) 34: print("Received: " + $RX_DATA) > Received: ?? 36: $Data_0=GetByteAt($RX_DATA,0) 37: $Data_2=GetByteAt($RX_DATA,2) 39: Print ($Data_0 +" "+ $Data_2) > 63 14 # 63 is the question mark and 14 is the correct number Done (00:00:00.4523841)

PRO
Synthiam
#4  

Do you have a logic analyzer? I believe it might help you diagnose the issue.

If you would like to experiment without a Logic Analyzer, you can use the Serial Terminal (EZB) found in the General section of Project -> Add Control

What device are you connecting to?

#5  

I'm using the EZ-B port D5 and sending it to the Dynamixel servo, ID14 and using a return data line to the EZ-B port D6.

#6  

I just sent the same instruction from D5 to D6 without the Dynamixel servo and received the same result.

There are no issues if a send text with quotation marks its only when I send unsigned char.

#7  

I did a little research.

I think you have data framing issue within the coding for the EZ Script. Check the settings for the data frame size and or the parity and stop bits.

PRO
Synthiam
#8  

The EZ-B has no data framing issues in our testing. And unless there is a physical defect with the STM32 ARM Processors, the UARTs are working as expected. The ez-b firmware has all UARTs set for...


  USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  USART_InitStructure.USART_StopBits = USART_StopBits_1;
  USART_InitStructure.USART_Parity = USART_Parity_No;
  USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;

Perhaps your wire has line noise. Can you show me a logic analyzer screenshot of the framing error you are referring to?

Also, keep in mind that your script is constantly Initializing the UART in the first line of code. You only need to initialize it once - perhaps in a different script or Connection Script?

Every time you run the code the UART is being physically re-initialized. That's like starting and stopping your car's engine at every street light.:)