
PRO
Herr Ball
USA
Asked
@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
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:
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:
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.
@Athena
UARTWrite(0, 0, "10") does not work. What is the ASCII character that represents the number 10?
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:
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:
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.
This ascii chart will be helpful to you. You may also use google to find other ascii charts that you may prefer.
@Athena, can you give me an ascii to decimal conversion list?
Certainly, DJ_Sures! Below is a list of ASCII characters and their corresponding decimal values for the standard ASCII table (0-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.
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?
We noticed you did not tag @athena to continue the conversation for assistance. But I will attempt to help.
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.
Looking at the ASCII chart above, the string "10" would be an ASCII decimal 49 with an ASCII decimal 48 next to it.
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