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 CCS Technical Support

uart multi slave (pic16f887)
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
khanh my



Joined: 01 Apr 2013
Posts: 13

View user's profile Send private message

PostPosted: Tue Apr 02, 2013 9:26 am     Reply with quote

please give me one sample code using uart or rs485
slave 1 sends one to master
slave 2 send 2 to the master
master two of them on screen display lcd
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Tue Apr 02, 2013 9:55 am     Reply with quote

I can't see your picture (or I got fed up of waiting for it to load).

Quote:
by the way I asked if communication rs485 without using max485 or max487 or any one of anything else?
I just cross-connection 2 pins TX and RX

Does this mean you're trying to do something like this?
Code:
      Master PIC                          Slave PIC1
 
      ----------                           --------
     |          |                         |        |
     |       TX |-------------------------| RX     |
     |          |                      |  |        |
     |          |                      |  |        |
     |       TX |-------------------------| TX     |
     |          |                  |   |  |        |
      ----------                   |   |   --------
                                   |   |
                                   |   | 
                                   |   |   --------
                                   |   |  |        |
                                   |    --| RX     |
                                   |      |        |
                                   |      |        |
                                    ------| TX     |
                                          |        |
                                           --------


                                          Slave PIC2

Where TX and RX are the PICs UART pins.


This is getting rather tedious.

Page numbered 329 in 2013 version of CCS manual shows you how to connect up for RS485.

You have 1 master which has to control communications both ways between master and each of the slaves.

You're now getting several of us telling you the same thing.

Mike
khanh my



Joined: 01 Apr 2013
Posts: 13

View user's profile Send private message

PostPosted: Tue Apr 02, 2013 10:27 am     Reply with quote

Mike Walne wrote:
I can't see your picture (or I got fed up of waiting for it to load).

Quote:
by the way I asked if communication rs485 without using max485 or max487 or any one of anything else?
I just cross-connection 2 pins TX and RX

Does this mean you're trying to do something like this?
Code:
      Master PIC                          Slave PIC1
 
      ----------                           --------
     |          |                         |        |
     |       TX |-------------------------| RX     |
     |          |                      |  |        |
     |          |                      |  |        |
     |       TX |-------------------------| TX     |
     |          |                  |   |  |        |
      ----------                   |   |   --------
                                   |   |
                                   |   | 
                                   |   |   --------
                                   |   |  |        |
                                   |    --| RX     |
                                   |      |        |
                                   |      |        |
                                    ------| TX     |
                                          |        |
                                           --------


                                          Slave PIC2

Where TX and RX are the PICs UART pins.


This is getting rather tedious.

Page numbered 329 in 2013 version of CCS manual shows you how to connect up for RS485.

You have 1 master which has to control communications both ways between master and each of the slaves.

You're now getting several of us telling you the same thing.

Mike

http://i1343.photobucket.com/albums/o791/ngbaanh16/Untitled_zps8ea47eee.png
you can edit on my code?
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Tue Apr 02, 2013 10:42 am     Reply with quote

Should have asked earlier.

1) Are you using REAL hardware?
OR
2) Is it ALL ISIS simulation?

Mike
khanh my



Joined: 01 Apr 2013
Posts: 13

View user's profile Send private message

PostPosted: Tue Apr 02, 2013 2:10 pm     Reply with quote

Mike Walne wrote:
Should have asked earlier.

1) Are you using REAL hardware?
OR
2) Is it ALL ISIS simulation?

Mike

I do real circuit
khanh my



Joined: 01 Apr 2013
Posts: 13

View user's profile Send private message

PostPosted: Tue Apr 02, 2013 3:29 pm     Reply with quote

ezflyr wrote:
Hi,

Your picture file(s) seem to be missing. Can you check them and get back to us?

No, you need something like a MAX485 device to successfully implement RS-485 communications. These chips allow multi-drop communications over a pair of wires. You need to add 'Enable =' to your #use rs232 declaration, and you need to dedicate a pin on each PIC to control the direction of data on the RS485 bus.

John


hi you
I do not need to communicate away, only one small model for the study
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Tue Apr 02, 2013 4:13 pm     Reply with quote

I can now see your schematic more clearly.
You appear to be trying to connect as I showed in my ASCII version.
It is possible, but NOT the way to go.

It's been suggested several times already to use real interface devices and dedicate a pin to control the enable for each of your TTL to RS485 devices.

Nobody here is going to give you sample code.

You must get the hardware sorted before attempting code.

Mike
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Apr 02, 2013 5:31 pm     Reply with quote

Mike is 100% right, you MUST get the hardware corrected first !!

1) be sure to bias the RS-485 lines according to specs.

2) PICs as shown in your schematic will NOT run.

3) start with just 2 PICs,get working 100% THEN add the 3rd PIC.

hth
jay
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Tue Apr 02, 2013 7:34 pm     Reply with quote

Hi guys,

I'm pretty sure this is a simulation effort only. I suspected as much, so I asked for a photo of the real hardware. The OP posted a broken link to his photo, and has since ignored a request to correct the link. I'm pretty sure he did this because there is no actual hardware, so this whole thread is probably a waste of time..... Hopefully, the OP will prove me wrong, but I doubt it!

John
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Apr 02, 2013 8:04 pm     Reply with quote

or he has real hardware , wired according to the 'simulation' schematic !
In which case it can never,ever work.


jay
khanh my



Joined: 01 Apr 2013
Posts: 13

View user's profile Send private message

PostPosted: Wed Apr 03, 2013 10:48 am     Reply with quote

Mike Walne wrote:
I can now see your schematic more clearly.
You appear to be trying to connect as I showed in my ASCII version.
It is possible, but NOT the way to go.

It's been suggested several times already to use real interface devices and dedicate a pin to control the enable for each of your TTL to RS485 devices.

Nobody here is going to give you sample code.

You must get the hardware sorted before attempting code.

Mike

I changed the hardware by adding max487
now who can help me to write one code small as follows:
slave 1 sends number 1 to master
slave 2 sends number 2 to the master
master shows those 2 numbers on LCD
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Wed Apr 03, 2013 1:46 pm     Reply with quote

Hi,

I think it's pretty clear that there is no "real hardware", and that this is a pure Proteus simulation. That violates the forum rules because we don't want to be troubleshooting Proteus issues here, only CCS ones.

Another problem is that you seem to want someone to just hand you some working code, and we don't do that here either. Everything you've posted so far suggests that you are just cobbling together code you have found without any understanding at all....

The schematic you posted is also not correct. Did you even search the internet for the suggested way to connect the MAX487? For example, I'm not sure I've ever seen an implementation that does not tie pins 2 and 3 together.....

Good Luck!

John
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Wed Apr 03, 2013 2:48 pm     Reply with quote

Im assuming you actually have power connected to your RS485 devices.
(It's not shown on your schematic.)

I'm not going to GIVE you sample code.

At the risk of being sent to the tag-team naughty corner I advise:-

a) Sort out your code one section at a time.
b) Get it 100% correct, then proceed.
c) Do as temtronic suggested a while ago.
Get your master to talk to one slave only then progress to more slaves.

A very simple version of your code could go something like this:-

Master asks Slave1 to transmit:-

1) Slaves all disable their TX control.
2) Master enables its TX control.
3) Master tells all slaves it wants slave1 to transmit by sending out say a character '1'.
4) Slave1 receives and recognises character.

In response Slave1 transmits:-

5) Master disables its TX control.
6) Slave1 enables its TX control.
7) Slave1 sends a known return character.
8) Master receives and recognises character.
9) Loop back to 1.

If you do all of the above in a tight loop you SHOULD be able to watch all the activity on any 'scope.
It will check your hardware is functional.

Mike
temtronic



Joined: 01 Jul 2010
Posts: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Apr 03, 2013 3:07 pm     Reply with quote

re: individual control of re and te(rcv enable, tx enable).

It does allow for some nice multimaster-multislave control under software though these days the 'rs-485' chips can have an active rcvr.
I used it back in the early days (PCM 2.459ish) for a proprietory system, still in use today.

The key or trick with 3 or more PICs is to divide and conquour! Start small,get 2 working, then 3, 4,...128,though the most I've had in the field has been 62 nodes.

There is a LOT of threads on this subject,some great code,even CCS has examples so I suspect a 'hardware' issue is the basis of the problem.

hth
jay
khanh my



Joined: 01 Apr 2013
Posts: 13

View user's profile Send private message

PostPosted: Wed Apr 03, 2013 6:37 pm     Reply with quote

thanks all
I also want to support CCS, but the hardware you asked so I gave up, my project is more complex, but I have know communication rs485 to ask, I asked simple matter to develop my project,
I am a student doing thesis for graduation
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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