Asked — Edited
Resolved Resolved by Rich!

Uartwrite Question?

Trying to send the below code via serial to my SSC-32 servo board to test servo movement... it gives me an error because $pw is greater than 255 (max for a byte which I do understand)... It's probably me not getting it, but how do I send numbers greater than 255?

This is the error "Error on line 6: Value was either too large or too small for an unsigned byte."


$pw=1000
$m =2500
UARTInit(0,1,9600)
:start
$pw=1000
UARTWrite(0,1,"#0P",$pw,"T",$m,13)
sleep(2500)
$pw=2000
UARTWrite(0,1,"#0P",$pw,"T",$m,13)

sleep(2500)
Goto(start)


ARC Pro

Upgrade to ARC Pro

Take control of your robot's destiny by subscribing to Synthiam ARC Pro, and watch it evolve into a versatile and responsive machine.

United Kingdom
#1  

Bearing in mind I've not used the UARTWrite function yet nor the SCC32 but...

Have you tried;


UARTWrite(0,1,"#0 "+$pw+" T "+$m,0x0D)

In other words, having the whole "#0 1000 T 2500" part sent in one go rather than piece by piece.

Note, I prefer to use hex for ascii characters hence the 0x0D rather than the 13 for a carriage return. 13 may work fine.

Also, are you missing the "P" so should it be


UARTWrite(0,1,"#0 P "+$pw+" T "+$m,0x0D)

or with your code

UARTWrite(0,1,"#0", "P",$pw,"T",$m,13)

Edit: I guess you edited before I finished typing and added that P in:)

United Kingdom
#2  

Suggestion #2... change

$pw = 1000

to

$pw = "1000"

I'll have a proper look tomorrow but I need sleep, just thought I'd throw a couple of ideas at you before I head up though (it's also an insight in to how I guess at things if I don't know.

#3  

Crap.... you're a genius Rich... this worked...

UARTWrite(0,1,"#0P"+$pw+"T"+$m,13)

Cheers and thanks....:)

#4  

This now works....


$pw="1000"
$m ="2500"
UARTInit(0,1,9600)
:start
$pw="1000"
UARTWrite(0,1,"#0P"+$pw+"T"+$m,13)
sleep(2500)
$pw="2000"
UARTWrite(0,1,"#0P"+$pw+"T"+$m,13)

sleep(2500)
Goto(start)

United Kingdom
#5  

Awesome:)

Just out of curiosity, why not use SendSerial? Not that it makes much of a difference (in fact, I don't even know what the difference would be other than the command used and it's syntax).

#6  

No reason, just got used to using the Uart commands when I was messing with my iRobot Create.... kind of a habit now... I guess I could just go back to sendserial....

Cheers

#7  

Can you use the Sendserial command on Uart 0 port of V4?

#8  

You have to specify the Digital port when using the SendSerial command. Don't know which d port is associated with UART 0.