Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

PIC to PC serial problem....

Status
Not open for further replies.

hhhsssmmm

Member level 1
Joined
May 14, 2009
Messages
37
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,732
pic to pc

Hello

Im trying to network a multidrop RS-485 network. Please see the enclosed diagram of how i have made the wiring arrangement.


- Board A represents the PC with RS-232 to RS-485 convertor

- Board B represents PIC board 1 with MAX488 line driver

- Board C represents PIC board 2 with MAX488 line driver


Both PIC boards B and C are the same using PIC18F4220 with 4MHz crystal.

Now i can get one way communication (from PC to PICs only) and my string of characters are successfully received by the PICs. The data is sent from the PC in packets and each packet is uniquely addressed to each PIC board.

Now when I attempt to do the reverse, that is send a reply back from PIC board C....& not simultaneously with board B, the packet successfully reachs the PC. However now when the same is attempted with PIC board B only, again making sure not simultaneously with PIC board C, then the packet never reaches the PC.

It appears only PIC board C is able to send packets to the PC.

Im also making each TX pin on the PIC an input pin when NOT transmitting. I only make it output direction, when Im getting ready to transmit.

As a simple test program, Im only sending out a packet when I press a button on the PIC boards (B or C). Therefore im in control of when a packet should be transmitted. Therefore, i can not understand this puzzle of why the packet failure from PIC board B.

Please can someone help me to achieve sending packets successfully from both PIC boards (B and C) back to the PC (each board taking turns in TXing and NOT simultaneously TXing)....using the same wiring connection is shown in my diagram. If there needs to be any change made, then please also let me know.

Thank you

Haseeb
 

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
14,447
Helped
4,744
Reputation
9,503
Reaction score
4,515
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
123,227
pic to pc communication

It looks like board C is permanently driving the bus.

You have to make sure that the drivers are only enabled while you are transmitting then disabled afterward. Unfortunately, if B and C drive simultaneously, you will get garbage out so you need to implement a protection system in software to cater for such bus collisions.

Brian.
 

hhhsssmmm

Member level 1
Joined
May 14, 2009
Messages
37
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,732
pic to pc serial

hello Brian

thats exactly what im doing...

Im using C18 compiler so i dissable the TX pin when NOT transmitting by making it an input pin ... i use this code statement.

TRISCbits.TRISC6 = 1; //make TX pin input

and then when i wish to transmit....i make it output by this statement...

TRISCbits.TRISC6 = 0; //make TX pin output


of course the pins are reverted back their previous state as soon as the packet is sent.

so now with this information...can u analyze and help me?

thank you

haseeb
 

betwixt

Super Moderator
Staff member
Joined
Jul 4, 2009
Messages
14,447
Helped
4,744
Reputation
9,503
Reaction score
4,515
Trophy points
1,393
Location
Aberdyfi, West Wales, UK
Activity points
123,227
com serial pic pc

It sounds like you are disabling the wrong pin. By changing the TRIS bits you can drive or read the PIC pins but the problems is with the RS485 driver. Even with the PIC set to input mode (TRIS = 1) the driver IC is still feeding your bus.

I think you have to drive the RS485 transceiver enable to control whether it is attached or isolated from the bus. You may have to allocate another PIC pin to connect to the driver disable pin. You should be safe to leave the receiver permanently enabled but if more than one transmitter activates you will get bus contention.

Brian.


Just checked the data sheet - drive DE high to transmit and low when not transmitting.
 

hhhsssmmm

Member level 1
Joined
May 14, 2009
Messages
37
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,732
pic board c

thank you so much brian...

i will try ur suggestion. i will now have to use MAX483 instead in order to use the DE and RE pins. im sure my project will now work.

thank you

haseeb
 

madicalphy

Member level 4
Joined
Jul 22, 2007
Messages
68
Helped
5
Reputation
10
Reaction score
2
Trophy points
1,288
Activity points
1,630

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top