BasicMicro - Forums

www.basicmicro.com
It is currently Mon May 21, 2012 12:48 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Wireless Communication with the Nano
PostPosted: Sun May 02, 2010 4:27 am 
Offline
Citizen

Joined: Thu Oct 30, 2008 8:50 pm
Posts: 39
Hi,

I've been trying to use this transmitter and receiver pair with the nano 18:
http://www.sparkfun.com/commerce/produc ... ts_id=8945
http://www.sparkfun.com/commerce/produc ... ts_id=8948

But so far I can't seem to get the right data back. The interval which the receiver receives stuff is correct most of the time (about once a second, which is how often I have the transmitter transmitting; every now and then there is a little noise outside of that, but not too much). So I think it's kind of working. If I unplug the transmitter, for instance, the receiver stops receiving anything. I plug the transmitter back in and the receiver starts spitting out data again. However, the data being received seems relatively random.

I tried implementing it using a simple check-sum byte attached to the end of the message and used that to see if the data was valid and ignoring everything else that wasn't validating with the checksum, but that just resulted in it never receiving a valid message So I went back to the drawing board just to see if I could get something that looks correct sometimes. Any tips here would be much appreciated.

Transmitter Code (the data line on the transmitter is hooked to pin 4):

Code:
MSG VAR BYTE

Initialize:

   MSG = 0;
   
main:

   SEROUT p4, I1200, [DEC MSG];

   MSG = MSG + 1;
   Pause 1000;
   
   if(MSG > 10) then
      MSG = 0;
   endif

goto main



Receiver code (the data line on the receiver is also hooked to pin 4, but obviously a different nano):

Code:
MSG VAR BYTE

Initialize:

   MSG = 0;

main:

   SERIN p4, I1200, [DEC MSG];
   

   if(MSG > 0) then
      SEROUT s_out, I1200, ["MSG: ", DEC MSG, 10,13];      
   endif

   MSG = 0;

goto main


Top
 Profile  
 
 Post subject: Re: Wireless Communication with the Nano
PostPosted: Sat Jul 31, 2010 1:32 pm 
Offline
New User

Joined: Sat Jul 31, 2010 11:17 am
Posts: 3
hello hiskeyd:
In my applications i have had more success with using [str {var}] on bothe ends. i have used the xbee and hard wired with this method with no porblem. this setup is hard wired between the atom pro 40 and a nano 28.

Code:

'Tx side
serin p0,i19200,[str go\2]
serout p20,i19200,[str sticks\4,str buttons\2]



Code:
'rx side
serout p6,baud2,["go"]
serin p7,baud2,3000,err,[str nanoin\6]



In my code "go" is just used to synchronize, or to ask for data.
Your output to terminal is fine.

hope this helps.

tmac


Top
 Profile  
 
 Post subject: Re: Wireless Communication with the Nano
PostPosted: Sun Aug 01, 2010 12:36 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
I believe you have a synchronization problem. The only data you are sending are numbers. No spaces or carriage returns and nothing to indicate the beginning of the number. So when you receive that data on the other end the receiving chip is going to start reading in with the first value digit it receives and since there are no spacers it will keep reading in digits until it hits 10 digits. So you will always have random junk.

Change your send command to this:

Code:
   SEROUT p4, I1200, [DEC MSG," "];


By adding the space your receiver will now know when it gets to the end of a number. For example:

Your sent data will be somethign like this "0 1 2 3 4 5 6 7 8 9 10 0" etc...

Currently your sent data looks like this:

"0123456789100123456789100" etc.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


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

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO