Asked — Edited
Resolved Resolved by thetechguru!

Uart Compass

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.

Manual


ARC Pro

Upgrade to ARC Pro

ARC Pro will give you immediate updates and new features needed to unleash your robot's potential!

PRO
Canada
#1  

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!

#3  

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?

#4  

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

#6  

Quote:

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

#7  

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

#8  

@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.

#9  

$ 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 ).

#10  

@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.