PDA

View Full Version : Sendin data from PIC to PIC



mastero
- 26th November 2005, 07:17
Hello all ,

This is my first post so hello to everyone here.

I have two 16f628 and i am using serin and serout for comunication

chip (1) is master and chip (2) is slave it will just be in a loop to take command.

chip(1) gets the command from pc rs232 and checks it then sends the command to chip (2) basic port high and port low. thing.

SERIN PORTA.1 , 84 , [RELAY, DEC STAT]

above is the rs232 in for chip 1 when the chip1 receives 21 from the pc it refers to RELAY if RELAY is 2 then it send the remaining data in stat to chip 2 for execution so will this work ?

SERIN PORTA.1 , 84 , [RELAY , DEC STAT]

IF RELAY = 50 THEN OUTR2

OUTR2:
IF STAT = 0 THEN SEROUT PORTA.7 , 84 , [DEC STAT]

will the above code send the data of stat to the chip2 ?

Thanx
Mastero

BobK
- 26th November 2005, 12:43
Hi Mastero,

Save yourself alot of work and goto www.rentron.com and look for the project titled "12pin serial I/O interface". It is a project based on the 16F84 and has all the code there that you need to send commands from a PC to the project to control 12 pins on a PIC. This should get you what you want to do.

BobK

mastero
- 26th November 2005, 13:56
Hi Mastero,

Save yourself alot of work and goto www.rentron.com and look for the project titled "12pin serial I/O interface". It is a project based on the 16F84 and has all the code there that you need to send commands from a PC to the project to control 12 pins on a PIC. This should get you what you want to do.

BobK

I know that, but my problem is not PC to PIC its PIC to PIC

Its like i have two PIC chips and when the first chips gets a specific info it does nothing but just sends that info to the chip 2 for execution ... chip 2 is always in a waiting loop to receive command from chip 1.

Mastero

BobK
- 26th November 2005, 16:38
Hi Mastero,

Okay so you take this concept and have your first PIC send the request to the other PIC. I have a project going on where I have 20 PICs gathering alarm information and they simply send the data to a master board that displays the information on a display and then prints it out on a POS printer. I simply use SEROUT2 from the sending boards and monitor a "busy" line that tells the sender the line is clear and the receiver looks for the "busy" line to go low at which time is enters a SERIN2 routine. The receiver keeps the "busy" line low until the end user acknowledges the receipt of the alarm and then the receiver clears the busy line and awaits any new traffic.

Is this like something you are trying to do? I just thought that why would you have one PIC receive a command from a PC just to retransmit it to another PIC when one could do the whole thing and eliminate the middle man.

BoBK

Charles Linquis
- 26th November 2005, 18:00
Without knowing what you are really trying to accomplish -

I use SERIN, SEROUT (and SERIN2, SEROUT2) extensively to accomplish PIC-PIC communcation.

Some things to consider:


Both PICs should be crystal controlled. The internal 4Mhz oscillators usually aren't accurate enough for reliable communication. There are many ways around this, but if you are a beginner, take the easy approach - use a crystal, oscillator or resonator to insure they are both running at a known frequency.

I assume that you aren't using a level converter (such as a MAX232) anywhere in the system.

Use a pull-up or a pull-down resistor on the data line between the two parts.
Use a pull down if you are sending data inverted (recommended), or a pull-up if you are sending data "true". This will help insure that all bytes - including the first one, are received properly. A 10K resistor will work fine.

Start out at 2400 baud. If you need faster communication, you can later run at up to 38K baud if both your PICs are running at 20Mhz.

As a debug aid, you can connect the PICs output directly to a PC if you are running in INVERTED mode. This can be a great help in figuring out what is really going on.

mastero
- 28th November 2005, 05:39
Thanxs guys will work on it and post later..

Mastero

Dwayne
- 28th November 2005, 17:42
Take a look at the FAQ,

I have wrote a section on this very thing...

Dwayne

mastero
- 29th November 2005, 14:40
Thanx but i already solved that problem .... the two pics are comunicating fine ... as required ...

I am using 16f628A the new problem i am facing is the RAM, when i am under 27 every thing is fine but when i cross 30 things go the other way ... what is the max ram to work with for the 16f628.?

search for RAM came back negative on this forum

Any help is good

Thanx

Mastero