Asked

UART And ASCII Dec.

@DJ

My question pertains to UART communication. Hopefully I can explain this ... lol?

ASCII UARTWrite(0,0,"49") in decimal form is = 1 UARTWrite(0,0,"50") in decimal form is = 2 UARTWrite(0,0,"51") in decimal form is = 3 Yada Yada Yada UARTWrite(0,0,"57") in decimal form = 9

How do I write the decimal form of 10? UARTWrite(0,0, "49 48")   Does not work?

Does my question make sense?


Related Hardware EZ-B v4
Related Control EZ-Script Console

ARC Pro

Upgrade to ARC Pro

Experience the transformation – subscribe to Synthiam ARC Pro and watch your robot evolve into a marvel of innovation and intelligence.

PRO
Canada
#1  

Hello Herr_Ball,

Your question does make sense. When you're using the UARTWrite command in ARC, you're sending data to a UART port. If you want to send the decimal value 10, you need to send the ASCII character that corresponds to the decimal value 10, which is a line feed (LF) character.

In ASCII, the character '1' has a decimal value of 49, and '2' has a decimal value of 50, as you've mentioned. However, to send the value 10, you don't send the characters '1' and '0' separately. Instead, you send the single character whose ASCII value is 10.

To send the decimal value 10 over UART, you would use the following command:

UARTWrite(0, 0, 10)

This sends the actual byte value of 10 (which is a non-printable control character in ASCII, specifically the line feed) to the UART port.

If you want to send the two characters '1' and '0' to represent the number 10 as text, you would send them as a string:

UARTWrite(0, 0, "10")

This sends the ASCII values for '1' followed by '0', which would be interpreted as the string "10" by the receiving device.

Remember that when you're sending numbers as ASCII characters, you're actually sending the character representation of that number, not its binary value. If the device you're communicating with expects the binary value, send it as a number, not as a string. If it expects ASCII characters, send the string representation.

I hope this clarifies your question! If you need further assistance, feel free to ask.


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
#2  

@Athena

UARTWrite(0, 0, "10")  does not work. What is the ASCII character that represents the number 10?

PRO
Canada
#3  

Apologies for the confusion earlier. The ASCII character that represents the number 10 is actually a control character for a line feed (LF). In ASCII, printable characters start from the value 32 (space) and up. The value 10 is a non-printable control character.

If you want to send the decimal number 10 as a single byte value over UART, you would not use the ASCII representation. Instead, you would send the byte value directly like this:

UARTWrite(0, 0, 0x0A)

Here, 0x0A is the hexadecimal representation of the decimal value 10. When you use this command, it sends the byte value 10 (line feed in ASCII) to the UART port.

If you are trying to send the two-digit number "10" as ASCII characters, you would indeed use:

UARTWrite(0, 0, "10")

This sends the ASCII codes for '1' followed by '0', which would be interpreted as the string "10" by the receiving device.

If UARTWrite(0, 0, "10") does not work as expected, please ensure that the device you are communicating with is configured to interpret the data correctly and that the baud rate and other UART settings match between the two devices.


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
#4  

This ascii chart will be helpful to you. You may also use google to find other ascii charts that you may prefer.

User-inserted image

PRO
Synthiam
#5  

@Athena, can you give me an ascii to decimal conversion list?

PRO
Canada
#6  

Certainly, DJ_Sures! Below is a list of ASCII characters and their corresponding decimal values for the standard ASCII table (0-127):

ASCII Character | Decimal Value
----------------|--------------
NUL             | 0
SOH             | 1
STX             | 2
ETX             | 3
EOT             | 4
ENQ             | 5
ACK             | 6
BEL             | 7
BS              | 8
HT              | 9
LF              | 10
VT              | 11
FF              | 12
CR              | 13
SO              | 14
SI              | 15
DLE             | 16
DC1             | 17
DC2             | 18
DC3             | 19
DC4             | 20
NAK             | 21
SYN             | 22
ETB             | 23
CAN             | 24
EM              | 25
SUB             | 26
ESC             | 27
FS              | 28
GS              | 29
RS              | 30
US              | 31
Space           | 32
!               | 33
"               | 34
#               | 35
$               | 36
%               | 37
&               | 38
'               | 39
(               | 40
)               | 41
*               | 42
+               | 43
,               | 44
-               | 45
.               | 46
/               | 47
0               | 48
1               | 49
2               | 50
3               | 51
4               | 52
5               | 53
6               | 54
7               | 55
8               | 56
9               | 57
:               | 58
;               | 59
<               | 60
=               | 61
>               | 62
?               | 63
@               | 64
A               | 65
B               | 66
C               | 67
D               | 68
E               | 69
F               | 70
G               | 71
H               | 72
I               | 73
J               | 74
K               | 75
L               | 76
M               | 77
N               | 78
O               | 79
P               | 80
Q               | 81
R               | 82
S               | 83
T               | 84
U               | 85
V               | 86
W               | 87
X               | 88
Y               | 89
Z               | 90
[               | 91
\               | 92
]               | 93
^               | 94
_               | 95
`               | 96
a               | 97
b               | 98
c               | 99
d               | 100
e               | 101
f               | 102
g               | 103
h               | 104
i               | 105
j               | 106
k               | 107
l               | 108
m               | 109
n               | 110
o               | 111
p               | 112
q               | 113
r               | 114
s               | 115
t               | 116
u               | 117
v               | 118
w               | 119
x               | 120
y               | 121
z               | 122
{               | 123
|               | 124
}               | 125
~               | 126
DEL             | 127

This list covers the standard ASCII characters from 0 to 127,including control characters (0-31) and the printable characters (32-127). For extended ASCII characters (128-255),you would need to refer to an extended ASCII table,as those values are not standardized and can vary depending on the character encoding used.

Please note that when sending control characters (like LF,CR,etc.) through UART or other communication protocols,you would typically send the decimal value directly,rather than the character representation.


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
#7   — Edited

I understand the ASCII chart.

ASCII UARTWrite(0,0,"49") in decimal form is = 1 UARTWrite(0,0,"50") in decimal form is = 2 UARTWrite(0,0,"51") in decimal form is = 3

Instead of writing: UARTWrite(0, 0, "1") ... the number 1 you must write: UARTWrite(0, 0, "49") ..  the ASCII code

Instead of writing: UARTWrite(0, 0, "2") .. the number 2 you must write: UARTWrite(0, 0, "50") .. the ASCII code

Instead of writing: UARTWrite(0, 0, "10") ... the number 10 What should I write as the ASCIIcode?

#8  

We noticed you did not tag @athena to continue the conversation for assistance. But I will attempt to help.

  1. The string "10" is an ASCII string character "1" with an ASCII string character "0" next to it. That makes it a number "10". Also, a string "20" is a "2" with a "0" next to it.

  2. Looking at the ASCII chart above, the string "10" would be an ASCII decimal 49 with an ASCII decimal 48 next to it.

  3. If you're attempting to send a string of "10", it would be easiest to use the UARTWriteString() function instead. https://synthiam.com/Support/javascript-api/UART/hardwareUartWriteString

UART.hardwareUartWriteString(0, "10");
  1. If you have reasons for using UartWrite() instead of the above suggestion, you would send both ascii decimal values...
UART.hardwareUartWrite(0, [49, 48]);