BasicMicro - Forums

www.basicmicro.com
It is currently Mon May 21, 2012 1:15 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Communication between 2 AtomPro
PostPosted: Mon May 02, 2011 11:51 pm 
Offline
Guru

Joined: Sun Dec 20, 2009 10:52 pm
Posts: 76
Hi,

I am trying to communicate between 2 AtomPro 24M. I guess I should use P14 and P15 and Hserin and Hserout.
Can somebody help me for the wiring between the 2 AtomPro and help me with the code?

Thanks

Chris


Top
 Profile  
 
 Post subject: Re: Communication between 2 AtomPro
PostPosted: Tue May 03, 2011 10:15 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 11:00 am
Posts: 903
Location: Temecula, CA
Just connect the TX from one to the RX of the other and then the same in the other direction(eg 14 to 15) from each to each. Using hserial commands either chip can talk to the other one without losing data, even at the same time.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: Communication between 2 AtomPro
PostPosted: Wed May 04, 2011 12:46 am 
Offline
Guru

Joined: Sun Dec 20, 2009 10:52 pm
Posts: 76
Thanks Nathan. It looks easy enough... :-)

Chris


Top
 Profile  
 
 Post subject: Re: Communication between 2 AtomPro
PostPosted: Wed May 04, 2011 3:20 am 
Offline
Guru

Joined: Sun Dec 20, 2009 10:52 pm
Posts: 76
Hi Nathan,

It's not that easy after all.
I don't know which baud rate I should use BAP, BAP40... I don't see anything on the data sheet of BAP24M?
Could you give me a sample of code that I could use to communicate between the 2?

Thanks

Chris


Top
 Profile  
 
 Post subject: Re: Communication between 2 AtomPro
PostPosted: Wed May 04, 2011 4:05 am 
Offline
Guru

Joined: Sun Dec 20, 2009 10:52 pm
Posts: 76
I tried the code below on both BAP24M after connecting the Pin14 to Pin15 on both without any succes :

Code:
temp       var         word
emit       var         word
enableserial1
sethserial1 h9600,h8databits,hnoparity,h1stopbits

emit=200
main:
   hserout [dec emit]
   hserin [dec temp]
   serout s_out,i9600,[dec temp,13]
   pause 2000
   emit=emit+1
goto main


thanks

Chris

PS I realized BAP means Basic Atom Pro :-(


Top
 Profile  
 
 Post subject: Re: Communication between 2 AtomPro
PostPosted: Wed May 04, 2011 6:14 am 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 527
Hi Chris,

Not sure here, but since you are using DEC to get input, I believe that it is waiting for a non-decimal character to be read before it returns, so it the program is probably hanging in the first HSERIN. You might try a simple change to the program like:

Code:
   hserout [dec emit, 13]

The CR should give the other side something to tell it to finish the read. Personally when I do communications like this I prefer to do fixed length packets or the like...

Could maybe do it something like:
Code:
   hserout [dec5 emit\5]
   hserin [dec5 temp\5]


So I would normally avoid the conversion of the binary data to ascii, so could probably do it with something like:
Code:
   hserout [emit.highbyte, emit.lowbyte]
   hserin [emit.highbyte, emit.lowbyte]


Or you could do it like:
Code:
   hserout [str emit\2]
   hserin [str emit\2]

This last way is how I would often do this, as I often output things like arrays. The \2 says output or input 2 bytes. So if emit was an element with 6 words in it you would change the \2 to \12.

I know for sure that the Bap28 handles H125000 just fine and now reason it should not handle H500000, which the H8/3696 manual suggests is the fastest baud...

Good Luck
Kurt


Top
 Profile  
 
 Post subject: Re: Communication between 2 AtomPro
PostPosted: Wed May 04, 2011 9:02 am 
Offline
Guru

Joined: Sun Dec 20, 2009 10:52 pm
Posts: 76
Good guess Kurt :-)
Here is the code which is now working great, thanks to your help.

Code:
temp       var         word
emit       var         word
enableserial1
sethserial1 H500000,h8databits,hnoparity,h1stopbits

emit=200
main:
   hserout [dec emit,13]
   hserin [dec temp]
   serout s_out,i9600,[dec temp,13]
   pause 2000
   emit=emit+1
goto main


Chris


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 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