PDA

View Full Version : pic to pic communications



nrtshrdvr
- 4th July 2004, 16:48
Hello everyone.
I am new to the programming world and pics. I have been assigned with a project of making 2 16F877 pics comunicate with eachother. one will send a command and the other will do the command and report back that it was done. Is there someone who could explain this to me so I can understand it.


thank you all for your time

Squibcakes
- 15th July 2004, 07:54
Maybe another question for the FAQ? (Which is looking good!)

I need some further guidence from the PIC GODS/ess at Melabs....

I haven't had any luck getting two pics to talk on a very basic level and I think it has to do with the wiring.

Do the pics need to be wired via a resistor and serial data sent / received in inverted mode?

Or is a straight wire connection, no inverted mode good enough?

I just can't get the combination right!

I've had no problems sending and receiving data with and without a MAX chip to terminal programs.. but pic2pic? #&*@!!!

Cheers

Melanie
- 15th July 2004, 13:36
Getting two PICs to talk to each other in it's simplest form is ONE WIRE (plus Vss/Ground) connected from one PIC to the other. No other Hardware.


However, this is a HUGE topic. You can do a posting every day for a year and still not cover everything.

There are so many variables. A solution encompassing one set of variables, would be totally inappropriate for another.

Before making any kind of move in any direction you need to be armed with your design criteria...

1. How far apart are the PICs?
2. Are they both on the same PCB?
3. How many wires can you connect between the two PICs?
4. If not on the same board, are they connected by Cable?
5. If so, how many wires have you got to play with?
6. Is the interconnection going to be in a noisy environment?
7. Are you interconnecting by Laser, Infra-red, Wireless, Satellite or other method?
8. How FAST does the Data Transfer need to be?
9. Are you sending a BYTE, WORD or whole heap of Data?
10. Do you need verification that the Data has been Received?
11. Is the interconnection Bi-Directional?
12. If Bi-Directional, is that just for verification of reception or for actual Data flow?
13. Are the PICs xtal or resonator controlled? All of them?
14. How many of them are going to be interconnected?
15. And by what methodology (peer-to-peer, slave-master, token-passing, TCP/IP etc)?
16. Are the PICs going to be busy doing other things whilst the communication is being transmitted/received or otherwise exchanged? Or are they just sitting there waiting for things to happen?

That's just a VERY brief (and incomplete) list.

Answers to the above will probably pose more questions, and only then can you start a plan for getting these things connected and talking.

nrtshrdvr
- 16th July 2004, 02:11
Melanie;
Thank you for the reply. as it stands I have the communications thing going but not how I want it to go. My original plan was to have 2 pics talk to eachother but now I find that I will need to have one talk to a computer through a 9pin serial connection.
This is the issue now. How to get the pic to recieve the data from the computer and decifer what it means.
My thought is that serial transfers 1 byte at a time and one command is usually 8 to 10 bytes long
This is where I am finding it diffuclt to program.

Any help is always apprecated.
Thanks
Tom.

Originally posted by Melanie
Getting two PICs to talk to each other in it's simplest form is ONE WIRE (plus Vss/Ground) connected from one PIC to the other. No other Hardware.


However, this is a HUGE topic. You can do a posting every day for a year and still not cover everything.

There are so many variables. A solution encompassing one set of variables, would be totally inappropriate for another.

Before making any kind of move in any direction you need to be armed with your design criteria...

1. How far apart are the PICs?
2. Are they both on the same PCB?
3. How many wires can you connect between the two PICs?
4. If not on the same board, are they connected by Cable?
5. If so, how many wires have you got to play with?
6. Is the interconnection going to be in a noisy environment?
7. Are you interconnecting by Laser, Infra-red, Wireless, Satellite or other method?
8. How FAST does the Data Transfer need to be?
9. Are you sending a BYTE, WORD or whole heap of Data?
10. Do you need verification that the Data has been Received?
11. Is the interconnection Bi-Directional?
12. If Bi-Directional, is that just for verification of reception or for actual Data flow?
13. Are the PICs xtal or resonator controlled? All of them?
14. How many of them are going to be interconnected?
15. And by what methodology (peer-to-peer, slave-master, token-passing, TCP/IP etc)?
16. Are the PICs going to be busy doing other things whilst the communication is being transmitted/received or otherwise exchanged? Or are they just sitting there waiting for things to happen?

That's just a VERY brief (and incomplete) list.

Answers to the above will probably pose more questions, and only then can you start a plan for getting these things connected and talking.

Melanie
- 16th July 2004, 23:36
Here's a sample program, thrown together for fun this lunchtime, to demonstrate bi-directional dialogue with a PC running something like Hyperterminal. It runs at 300 baud so almost any PIC will run it without an Xtal or Resonator.

Yes, whatever you type is echoed back to you as feedback. UPPERCASE and lowercase and cOmBINatIOns are handled with reasonably idot-proof command interpretation...

You can even use the BACKSPACE Key and have the PIC perform rudimentary line editing.

The object of the program is to demostrate how commands can be passed from the PC User and acted upon by the PIC.

PIC has five LED's which can be remote controlled in a variety of ways with commands like ON, OFF, BLINK, SWEEP and BEER. The major commands have sub-parameters which can be added to make control more interesting. Plenty of expansion for you to do your own thing.

Example:

ON Switch ON all LEDs
ON 2 Switch ON LED number 2
ON 4 7 Switch ON LED number 4 for 7 seconds
BLINK 1 15 Blink LED number 1 15 times
OFF 1 Switch OFF LED number 1
SWEEP 25 Sequentially Sweep all LEDs 25 times

Try to break it (if you can) by typing combinations of garbage....

Full instructions in the program comments.

Melanie