CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC18F252 RS232 problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jseidmann



Joined: 04 Nov 2004
Posts: 67

View user's profile Send private message Send e-mail

PIC18F252 RS232 problem
PostPosted: Thu Nov 04, 2004 4:28 pm     Reply with quote

I am currently using the CCS compiler (version 3.190). I have several circuit boards each identical in terms of hardware and software and they each have a different address. They are each supposed to listen to the 485 bus and not respond until their are enabled, and then they are the only ones supposed to respond.

Now, the problem occurs infrequently (like 1 in 100 times) that sometimes two boards talk at the same time although one of them is not even enabled! I dont know if there was some sort of bug in the compiler for the 232 communications that I was not aware of. Currently, the configuration for the RS232 is:

#USE RS232(Baud=19200, XMIT=PIN_C6, RCV=PIN_C7, BITS=8, PARITY=N, ENABLE=PIN_RS485, ERRORS)

the PIN_RS485 is declared elsewhere in the program to the corresponding pin which is used to enable the RS485/RS232 communication.

These all seem to work a large majority of the time, but I occasionally have two or so boards talking at the same time which makes my network go bonkers. I've looked through the code and it looks OK, and the compiler handles the enable for the RS485 and what really throws me for a loop is that it doesnt work only a small percentage of the time, not ALL the time even though nothing changes from one event to the next.

Now, the computer that talks to these boards is just a plain VB program that enables one board and asks it for data, gets the response, and then enables another board, so on and so forth.

My main question was if anyone knows some bug that might cause this to happen or may have some other suggestions. you help would be extremely appreciated


--Jon
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Thu Nov 04, 2004 4:43 pm     Reply with quote

Can't answer your question directly as there are too many unknowns. However I have multiple PICs reliably sharing a RS485 bus but have taken a different approach to addressing the devices. I can address each device in-and (not using RS485 address) and the designated device will respond immediately. This has worked reliably without any overlap. I also use a single broadcast command to interogate all slaves simultaneously. Each slave starts a "window" timer unique to the serial number (address) of the slave. When a slaves timer expires it gains access to the bus.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
jseidmann



Joined: 04 Nov 2004
Posts: 67

View user's profile Send private message Send e-mail

do you enable them separately?
PostPosted: Thu Nov 04, 2004 4:49 pm     Reply with quote

Do you enable them separately or always together and they respond in that window? How do you handle it?
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Thu Nov 04, 2004 5:16 pm     Reply with quote

Quote:
Do you enable them separately or always together and they respond in that window? How do you handle it?


All devices on the bus are always active. A slave responds immediatey if it has been uniquely identified in the command packet from the bus master however this address (actually the serial number of the slave) is carried is in-band.

The other mode of operation, which is the normal mode, a slave calculates its window timer based on its serial number. Serial number 0 can respond anytime in the first 26ms after the broadcast command is received form the master. The 26ms was derived from a generic system timer I was using and I refer to this as the base window period. Similarly the tranmit window for serial number 5 is between 130ms and 156ms (5 x 26mS ) after receipt of the broadcast command from the bus master. In other words time division multiplexing is used to determine when a slave can transmit in reponce to the general query command from the us master. Serial number 0 replies in window 0, serial number 1 replies in window 1 etc...

This is described in the October issue of Circuit Cellar magazine in the article "Intelligent Sensor Heads". It describes the protocol and there is a listing on their ftp server.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group