bookmaker32
USA
Asked
— Edited
Resolved by thetechguru!
Hi Guys, I want to hook up my Sure Compass to UART and the manual says to send all commands in ASCII. I know how to convert text to ASCII but I am stumped as to how to put it into the UART commands in ARC script. Has anyone done this? I have seen and read the info on I2C in reference to the Compass but can't find anything on using UART.
Hi @Bookmaker32, there's an example built into ARC to do two way UART communication.
Check under: Examples -> EZ-Script Function Syntax -> UART peripheral
Hope that helps!
So, your compass has two communication methods, one is i2c. The other is UART or serial rx/tx. So assuming you have a ezb v4 pick your interface i2c or serial, pick your port and script via that method. Check out the EZ-Script manual and search for UART, those are the script commands you would want.
https://synthiam.com/Tutorials/EZScript-Manual.aspx
I have done all that and I am totally aware of the UART examples but my question is how do you write ASCII in the data area of the command. uartwrite(0,0,036 115 117 114 101 032 103 097 013 010) that won't work. Justin, you mentioned serial. How would that look?
I doubt the instructions are talking about ASCII code, probably just means to send as text. Do you have a link to the compass manual?
Alan
the manual is in my first post
doh.... Teaches me to read the forum and try to work at the same time.
I'll take a look.
Alan
OK. I am pretty sure they were meaning Ascii as synonymous with text, so you would just send text (since their example shows just entering the text) . Otherwise, if you really need to force ASCII encoding, then prefix each with 0x ie.
0x036 0x115 0x117 0x114 0x101 0x032 0x103 0x097 0x013 0x010
except in the uartwrite command you probably will need to add 0x0d, 0x0a to the end of the line for the required CR/LF whether or not you can send text or need to ASCII convert.
Alan
@thetechguru, many thanks. I am at work so I can't play with it right now but I am sure that will solve the issues I have been having.
$ x=GetAsByte ( value )
This will convert the data to the ASCII character. I had to use the same protocol to communicate with my Dynamixel servos. In Phython its chr ( value ).
@mtiberia, Thank you for the input but I am a novice when it comes to coding so if you don't mind can you expand a bit on exactly what to do. The manual says to send "$sure ga " to get the direction. How would that look in script? I am feeling really inept.