Award
Congratulations Rich, for answering the question and has received an EZ-Credit award! Share what you have learned and create a tutorial to help others by clicking here.

Uartwrite Question?

Assistance Requested

Help Richard R with their question and receive $10 of EZ-Credit to get more robots and parts from our store. The following information was provided about their previous efforts searching tutorials for a resolution.

Richard R claims to have checked these sources:
 
#1

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


Code:


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

I have found a few conversations, tutorials and activities that may help with your question. Take a look at these links. I've sorted them by what I believe to be most relevant but that is not always the case as I'm still learning.


Also, consider reviewing the Learn section for informative lessons and activities. Check it out!


#2

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

Have you tried;

Code:


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

Code:


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



or with your code

Code:

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




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

#3

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.

#4

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

Code:

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




Cheers and thanks.... Smile

#5

This now works....

Code:


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

#6

Awesome Smile

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

#7

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

#8

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

#9

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

#10

Uart 0 is the regular Uart port located on the lower right side. Not one of the digital ports.

User-inserted image