BasicMicroUK - Forums

www.basicmicro.co.uk
It is currently Fri Apr 27, 2018 6:01 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Need help reading packets from an iRobot create with atompro
PostPosted: Thu Aug 22, 2013 2:28 pm 
Offline
New User

Joined: Thu Aug 22, 2013 2:11 pm
Posts: 3
So here is a simple code that works only with 1 byte packets sent from my Create... it does not work with packets that have 2 bytes... I have tried everything. It does however work if I use RealTerm and set the display to Int16... What am I doing wrong with my atom code? Will it even work with 2 byte packets?

only works with 1 byte packets, how do it get this to read 2 packet returns?
volt1 var word
volt2 var word

serout 0,i57600,[128, 131] 'puts create in safe mode

main:
serout 0,i57600,[142,24] 'asking create for battery temp... works because it is 1 byte
serin 1,i57600,[volt1] 'save temp in volt1
serout s_out,i57600,[dec volt1,13] 'send result back to my computer
pause 1000
goto main


Top
 Profile  
 
 Post subject: Re: Need help reading packets from an iRobot create with ato
PostPosted: Sat Aug 24, 2013 7:49 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 7:00 pm
Posts: 1316
Location: Temecula, CA
Please provide a link to what you are talking to.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: Need help reading packets from an iRobot create with ato
PostPosted: Sat Aug 24, 2013 9:52 pm 
Offline
New User

Joined: Thu Aug 22, 2013 2:11 pm
Posts: 3
Thanks for getting back to me... I don't really have a very informative link... but here is the robot I am using with my BAP28 for communicating with the iRobot Create... http://store.irobot.com/family/index.js ... ProductAge

I know how to send info to the Create... But I can only get back 8bit info... How do I get 16bit info using this...

If you can help with receiving 16bit info with the BAP28 in general, I can figure out the rest for my specific needs with the Create..

serin 1,i57600,[volt1] 'save value in volt1 (how do I get this to read 16bit?)

Hope this helps
Thanks


Top
 Profile  
 
 Post subject: Re: Need help reading packets from an iRobot create with ato
PostPosted: Sun Aug 25, 2013 2:27 pm 
Offline
Master

Joined: Tue Nov 21, 2006 5:34 pm
Posts: 662
There are several ways to read in a 16 bit value. Not sure in your case if the first byte is high byte or low byte... Often depends on processor.

Something like this should work:
Code:
volt1 var word
serin 1,i57600,[volt1.lowbyte, volt1.highbyte] 'save value in volt1

Again depending on your stream you may need to swap lowbyte and highbyte...

Or could do it in a couple of steps:
Code:
volt_low    var byte
volt_high   var byte
volt1         var word

serin 1,i57600,[volt_low, volt_high]
volt1 = (volt_high << 8) + volt_low;


Top
 Profile  
 
 Post subject: Re: Need help reading packets from an iRobot create with ato
PostPosted: Sun Aug 25, 2013 10:02 pm 
Offline
New User

Joined: Thu Aug 22, 2013 2:11 pm
Posts: 3
KurtEck wrote:
There are several ways to read in a 16 bit value. Not sure in your case if the first byte is high byte or low byte... Often depends on processor.

Something like this should work:
Code:
volt1 var word
serin 1,i57600,[volt1.lowbyte, volt1.highbyte] 'save value in volt1

Again depending on your stream you may need to swap lowbyte and highbyte...

Or could do it in a couple of steps:
Code:
volt_low    var byte
volt_high   var byte
volt1         var word

serin 1,i57600,[volt_low, volt_high]
volt1 = (volt_high << 8) + volt_low;

First byte is Highbyte so I'll just use this... serin 1,i57600,[volt1.highbyte, volt1.lowbyte]

Thanks a million!!!!
Richard


Top
 Profile  
 
 Post subject: Re: Need help reading packets from an iRobot create with ato
PostPosted: Tue Aug 27, 2013 3:29 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 7:00 pm
Posts: 1316
Location: Temecula, CA
That will also work. The highbyte modifier changes depending on the variable type so it always gets the high byte no matter the variable type.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO