BasicMicroUK - Forums

www.basicmicro.co.uk
It is currently Thu Apr 26, 2018 11:53 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: ATOM to ATOM serial communication with flow control question
PostPosted: Wed Dec 29, 2010 12:03 am 
Offline
Citizen

Joined: Thu May 06, 2010 2:43 pm
Posts: 16
I've made this into a new topic because I am no longer interfacing an ATOM to a parallax stamp. I couldn't figure out how to edit the title of the previous topic.

I've been working on this all day, and have got basic serial communication between two ATOMS with a rudimentary flow control pin. My code is almost identical to Dale's code in his post on January 28th, 2002, in the topic on PIC to PIC serial communication (http://forums.basicmicro.net/atom-f484/pic-to-pic-serial-problem-t4277.html.) I have also spent hours on this forum looking at any and all other chip to chip serial topics.

Like I said, I have got this working, but sometimes the flow pin will just not reset. With both chips turned on, if I pull the flow control wire and connect it from P4 on the transmitting chip directly to Ground, it will make the chip start sending serout commands again. Is there anything I can do to make this setup more reliable? Different resistors, caps, what? I am not an electrical engineer and could really use the help here.

Transmitting ATOM code:
Code:
temp var byte
high 0
pause 1000
low 0

temp = "1"
input 4

main
high 20
pause 40
low 20
pause 40

if IN4 = 1 then main
pause 50
serout P2,n2400,[temp]

high 21
pause 40
low 21
pause 40

goto main


and receiving chip code:
Code:
temp var byte
high 0
pause 1000
low 0
high 14

main
pause 500

low 14
serin P15,n2400,[temp]
high 14

if (temp = "A") then
high 22
pause 2000
low 22
pause 1000
elseif (temp = "1")
high 23
pause 2000
low 23
pause 1000
elseif (temp = "C")
high 24
pause 2000
low 24
pause 1000
elseif (temp = 1)
high 25
pause 2000
low 25
pause 1000
else
high 0
pause 2000
low 0
pause 1000
endif
pause 1000
goto main


and my circuit diagram:
Attachment:
2atoms12-28-10.jpg
2atoms12-28-10.jpg [ 163.61 KiB | Viewed 5437 times ]

This is exactly the resistor setup of my actual circuit. I am pulling the flow control wire high, because a low signal triggers the transmit chip, and I am pulling the serial wire low, because I am using normal (non-inverted) serial data.

Any ideas on resistors or caps, or a different setup altogether?

Also, I have run a robo claw with 300 feet of wire between it and the controlling ATOM chip. I want to use the same amount of distance between the two ATOMS. Will this be possible? Do I need TTL/RS232 transceiver chips?

Thanks.


Top
 Profile  
 
 Post subject: Re: ATOM to ATOM serial communication with flow control ques
PostPosted: Wed Dec 29, 2010 4:30 pm 
Offline
Citizen

Joined: Thu May 06, 2010 2:43 pm
Posts: 16
My diagram has the flow control wire attached to P3 of the transmitting atom instead of P4 where it should be. This is a mistake in the drawing, not the actual circuit.


Top
 Profile  
 
 Post subject: Re: ATOM to ATOM serial communication with flow control ques
PostPosted: Wed Dec 29, 2010 6:39 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 7:00 pm
Posts: 1316
Location: Temecula, CA
Two things I would change. Replace the 2.2megaohm resistors with 2.2kohm or even 1kohm resistors. The megaohm(millionohm) resistors will have almost no pullup capability. Replace the 1000ohm resistors with 220 to 330ohm resistors. The 1000 ohm resistors are for current limiting but 1000ohm is way too high(your leds will be very dim).

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: ATOM to ATOM serial communication with flow control ques
PostPosted: Wed Dec 29, 2010 6:58 pm 
Offline
Citizen

Joined: Thu May 06, 2010 2:43 pm
Posts: 16
Okay. I have got this working with hserin. Acidtech, thanks for clarifying on the resistors. I hope this post provides a clear concise example of serial/hserial communication between two Atom chips.

transmitting ATOM:
Code:
temp var byte
temp1 var byte
temp2 var byte
temp = "0"
temp1 = "1"
temp2 = "2"
 
main
high 20 'not sent LED
pause 40
low 20
pause 40
serout P2,i2400,[temp]
serout P2,i2400,[temp1]
serout P2,i2400,[temp2]
high 21 'sent LED
pause 40
low 21
pause 40
goto main


Receiving ATOM:
Code:
enablehserial
sethserial H2400
temp var byte

main
pause 500
hserin [temp]

if (temp = "A") then
high 22 'signal A LED
pause 200
low 22
pause 10
elseif (temp = "0")
high 23 'signal 0 LED
pause 200
low 23
pause 10
elseif (temp = "1")
high 24 'signal 1 LED
pause 200
low 24
pause 10
elseif (temp = "2")
high 25  'signal 2 LED
pause 200
low 25
pause 10
else
high 0 'Fault LED
pause 200
low 0
pause 10
endif
goto main


And the circuit:
Attachment:
12-29-10-2atoms-serial.jpg
12-29-10-2atoms-serial.jpg [ 262.34 KiB | Viewed 5415 times ]


The receiving ATOM uses hardware serial to buffer the signals from the transmitting ATOM. My hardware serial lines on the transmitting ATOM are taken, so I had to use software serial.

Also, I am 99% sure that the commands "enablehserial" and "sethserial" are not included in the "reference manual version 1" (though sethserial1 and sethserial2 are included, and yes, this was confusing). I am not sure about any manual that may be in the forum, though it seems like the hserin section is not there. I think I discovered the "enablehserial" from someone's code on the forum.


Top
 Profile  
 
 Post subject: Re: ATOM to ATOM serial communication with flow control ques
PostPosted: Wed Dec 29, 2010 7:44 pm 
Offline
Master

Joined: Tue Nov 21, 2006 5:34 pm
Posts: 662
Quick one. With the new versions of Studio, enablehserial and enablehserial2 are no longer needed or commands...

SetHserial (IMO) should have it's own section in the manual, but is covered in the manual on a page right after hserin (page 102)

Kurt


Top
 Profile  
 
 Post subject: Re: ATOM to ATOM serial communication with flow control ques
PostPosted: Wed Dec 29, 2010 8:49 pm 
Offline
Citizen

Joined: Thu May 06, 2010 2:43 pm
Posts: 16
I'm using version 1.0.0.32 and it gave errors without "enablehserial". Thanks for giving me the heads up on the new version of the software. I didn't see it had come out.

I have also now successfully tested the above circuit with 330 feet of wire between the two chips and with two separate power supplies. The grounds of the chips and supplies are connected with an additional 330 foot conductor.


Top
 Profile  
 
 Post subject: Re: ATOM to ATOM serial communication with flow control ques
PostPosted: Wed Dec 29, 2010 9:01 pm 
Offline
Master

Joined: Tue Nov 21, 2006 5:34 pm
Posts: 662
Yep they keep posts of the new releases up under the News forum. The current one is in this thread:
news-f481/basicmicro-studio-2-0-0-7-t9507.html

I also try to keep up with what the changes are and post them on the Lynxmotion thread:
http://www.lynxmotion.net/viewtopic.php?f=4&t=5463

Glad you got it working!

Kurt


Top
 Profile  
 
 Post subject: Re: ATOM to ATOM serial communication with flow control ques
PostPosted: Thu Dec 30, 2010 7:12 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 7:00 pm
Posts: 1316
Location: Temecula, CA
Correct, the 1.0 Studio required the enablehserial directives. As of approx 2.0.0.5 those directives are nolonger needed. Also we added support for the second hardware serial port on some AtomPro processors into the hserial commands which required the SetHserial commands to be renamed(eg SetHSerial1 and SetHSerial2). The manual in the forums is the current most up to date manual for the current release of Studio. Obviously old versions of studio will not always be compatible with the newest release. Also the download section of the main website always has nearly the latest release available. it tkaes a little while to get the webmaster to update that for me.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: ATOM to ATOM serial communication with flow control ques
PostPosted: Tue Jan 04, 2011 5:16 pm 
Offline
Citizen

Joined: Thu May 06, 2010 2:43 pm
Posts: 16
So concerning long distance serial communication, are there any sort of filters or capacitors or any special components or connections that would maximize a long distance chip to chip serial connection? I am not having problems chip to chip at 330 feet (which is my maximum distance) but I would like to make that connection as stable as possible. I do have shielded twisted pair wire between the chips. Anything else?

I know the obvious answer is that TTL serial is not made for long distance communication, but...

Thanks


Top
 Profile  
 
 Post subject: Re: ATOM to ATOM serial communication with flow control ques
PostPosted: Tue Jan 04, 2011 6:22 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 7:00 pm
Posts: 1316
Location: Temecula, CA
Thats pretty long. However the slower you communicate the longer you can go.

For long serial you should use MAX232 or equivalent circuits to drive the serial lines. Even those have range limits.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: ATOM to ATOM serial communication with flow control ques
PostPosted: Tue Jan 04, 2011 8:31 pm 
Offline
Master

Joined: Tue Jun 22, 2010 9:15 pm
Posts: 228
For long distances, use RS-422 or RS-485 differential pair drivers/receivers. Also make sure you have the proper termination resistors. Try the MAX485/RS-422 chips.

Alan KM6VV

blake3 wrote:
So concerning long distance serial communication, are there any sort of filters or capacitors or any special components or connections that would maximize a long distance chip to chip serial connection? I am not having problems chip to chip at 330 feet (which is my maximum distance) but I would like to make that connection as stable as possible. I do have shielded twisted pair wire between the chips. Anything else?

I know the obvious answer is that TTL serial is not made for long distance communication, but...

Thanks

_________________
Visit:
http://groups.yahoo.com/group/SherlineCNC/
http://tech.groups.yahoo.com/group/HexapodRobotIK/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO