communication between pics


Closed Thread
Results 1 to 6 of 6
  1. #1
    meyou's Avatar
    meyou Guest

    Default communication between pics

    1 ) I need to design the board that contain the 32 pics and 1 master pic. 32 pics need to send the data/report to master pic. I want to know the best way to do that. can be direct connected to master pic? What type of the communication can be use?

    thank you.

  2. #2
    Join Date
    Jul 2004
    Location
    ISRAEL
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: communication between pics

    Originally posted by meyou
    1 ) I need to design the board that contain the 32 pics and 1 master pic. 32 pics need to send the data/report to master pic. I want to know the best way to do that. can be direct connected to master pic? What type of the communication can be use?

    thank you.
    The process:
    you can use with the serin serout command.

    1-combine oll the slave RX pin together (32)
    2-combine oll the slave TX pin together with 32 470R resistor
    3-combine the master TX to the slave RX with 470R resistor
    4-combine the master RX to the slave TX with 470R resistor

    THE RESISTOR IS FOR ERRORS in time you make experiments.
    after everything work ok you can get out the 32 470R resistor.



    example code that i made before few month
    this code refer to 10 slaves with one master

    master code:

    after the master receive data frome one of the slave
    ia transmit the data with tx module.
    (pic 16f84)


    DEFINE OSC 8 '8Mhz xtal
    INCLUDE "MODEDEFS.BAS"
    SEND VAR BYTE
    key var byte
    KEY_CODE VAR BYTE
    RKEY_CODE VAR BYTE
    A VAR BYTE
    B VAR WORD
    trisa.0=1

    'waite for kbd signal
    START:
    LOW PORTB.0
    A=A+1
    IF A=1 THEN
    KEY_CODE=$A
    GOTO TRANSMIT0
    ENDIF
    IF A=2 THEN
    KEY_CODE=$B
    GOTO TRANSMIT1
    ENDIF
    IF A=3 THEN
    KEY_CODE=$C
    GOTO TRANSMIT2
    ENDIF
    IF A=4 THEN
    KEY_CODE=$D
    GOTO TRANSMIT3
    ENDIF
    IF A=5 THEN
    KEY_CODE=$E
    GOTO TRANSMIT4
    ENDIF
    IF A=6 THEN
    KEY_CODE=$AA
    GOTO TRANSMIT5
    ENDIF
    IF A=7 THEN
    KEY_CODE=$BB
    GOTO TRANSMIT6
    ENDIF
    IF A=8 THEN
    KEY_CODE=$CC
    GOTO TRANSMIT7
    ENDIF
    IF A=9 THEN
    KEY_CODE=$DD
    GOTO TRANSMIT8
    ENDIF
    IF A=10 THEN
    KEY_CODE=$EE
    GOTO TRANSMIT9
    ENDIF

    GOTO START

    TRANSMIT0:
    SerOut PORTA.1,N9600,["A9"] 'pic1
    GOTO IN
    TRANSMIT1:
    SerOut PORTA.1,N9600,["B9"] 'pic2
    GOTO IN
    TRANSMIT2:
    SerOut PORTA.1,N9600,["C9"] 'pic3
    GOTO IN
    TRANSMIT3:
    SerOut PORTA.1,N9600,["D9"] 'pic4
    GOTO IN
    TRANSMIT4:
    SerOut PORTA.1,N9600,["E9"] 'pic5
    GOTO IN
    TRANSMIT5:
    SerOut PORTA.1,N9600,["AA"] 'pic6
    GOTO IN
    TRANSMIT6:
    SerOut PORTA.1,N9600,["BB"] 'pic7
    GOTO IN
    TRANSMIT7:
    SerOut PORTA.1,N9600,["CC"] 'pic8
    GOTO IN
    TRANSMIT8:
    SerOut PORTA.1,N9600,["DD"] 'pic9
    GOTO IN
    TRANSMIT9:
    SerOut PORTA.1,N9600,["EE"] 'pic10

    IN: 'wait for reply frome the slave
    SerIn PORTA.0,N9600,2,WAITE,["ABC"],RKEY_CODE,KEY
    WAITE:
    IF A=>10 THEN A=0 'send the data to the tx module
    if KEY_CODE=RKEY_CODE THEN SEROUT PORTA.2,N2400,["DEF",KEY_CODE,KEY]
    KEY=0
    RKEY_CODE=0
    GOTO START

    the slave code:
    this pic read several key frome ps2 keyboard
    and send the data to the master

    (pic16f84)

    DEFINE OSC 12 '12Mhz xtal
    INCLUDE "MODEDEFS.BAS"
    clock_pin var porta.2
    data_pin var porta.3
    SEND VAR BYTE
    key var byte
    KEY_CODE VAR BYTE
    KEY_CODE=$A
    A VAR BYTE
    B VAR BYTE
    TRISA.0=1
    trisa.3=1
    trisa.2=1
    pause 1000
    'waite for kbd signal
    start0:
    'IF KEY=$F0 THEN B=1
    if (data_pin=0)and(clock_pin=0)then go 'waite for signal frome kbd
    GOTO START0


    'start read data
    go:
    gosub dealay_0 'delay for clock finish "0" (dealay start bit)
    gosub dealay_1 'delay for clock finish "1" (dealay bit 0)
    key.bit0=data_pin 'read bit 0
    gosub dealay_0 'delay for clock finish "0"
    gosub dealay_1 'delay for clock finish "1"
    key.bit1=data_pin 'read bit 1
    gosub dealay_0
    gosub dealay_1
    key.bit2=data_pin 'read bit 2
    gosub dealay_0
    gosub dealay_1
    key.bit3=data_pin 'read bit 3
    gosub dealay_0
    gosub dealay_1
    key.bit4=data_pin 'read bit 4
    gosub dealay_0
    gosub dealay_1
    key.bit5=data_pin 'read bit 5
    gosub dealay_0
    gosub dealay_1
    key.bit6=data_pin 'read bit 6
    gosub dealay_0
    gosub dealay_1
    key.bit7=data_pin 'read bit 7
    gosub dealay_0
    gosub dealay_1
    'paritybit.bit0=data_pin
    gosub dealay_0
    gosub dealay_1 'dealay for stop bit
    gosub dealay_0 'dealay for stop bit
    'IF B=1 THEN TX
    'goto START0

    TX:
    if (key=$29)or(key=$11)or(key=$14)or(key=$05)or(key=$ 06)or(key=$04)_
    or(key=$0C)or(key=$03) then WAITE_PAST
    'B=0
    GOTO START0

    WAITE_PAST:
    A=A+1
    PAUSEUS 10
    IF PORTA.0=1 THEN A=0
    IF (A=10)AND(PORTA.0=0) THEN RECIVE
    GOTO WAITE_PAST
    RECIVE:
    SerIn PORTA.0,N9600,["A9"]
    PAUSEUS 500
    SEROUT PORTA.1,N9600,["ABC",KEY_CODE,KEY]
    A=0
    PAUSE 100
    GOTO START0



    dealay_0:
    if clock_pin=0 then dealay_0
    return

    dealay_1:
    if clock_pin=1 then dealay_1
    return

    if you have more question send me email.
    Attached Files Attached Files

  3. #3
    Join Date
    Jul 2004
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    Is there any limited number of pics can be connected to all the tx and rx pin? How about the 230 pics? It's ok?

  4. #4
    Join Date
    Jul 2004
    Location
    ISRAEL
    Posts
    6


    Did you find this post helpful? Yes | No

    Default limited

    Originally posted by mazlan
    Is there any limited number of pics can be connected to all the tx and rx pin? How about the 230 pics? It's ok?
    yes it is possible
    but you need to calculate the time that take to the master pic
    to ask all the slave pic if they have a data to send


    Eyal

  5. #5
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Mazlan,

    M>>Is there any limited number of pics can be connected to all the tx and rx pin? How about the 230 pics? It's ok?<<

    I have a theory...(but haven't checked it out, because of no situation that is needed).

    With the Serin command, and the "ID" letters, you should be able to control as many as you want, and communicate back and forth very easily.

    For example:
    ChipNumber[4] var byte

    Loop:
    some kind of interupt gosub talk

    Goto Loop

    Talk
    ChipNumber="ZZ00";
    Serout Pin1,T2400,ChipNumber,Val.
    Serin Pin2,T2400,"ZZ01",Val.
    gosub routine
    etc. etc. ZZ00 is chip 1 ZZ01 is chip 2 etc...
    return
    As soon as chip is activated, you can jump to a subroutine
    to transfer data with the same principal.

    routine:
    while Val <> endof transmission
    Serin Pin2,"TZZ",Val
    do something with Val
    end while
    return


    You can actually have chips talking back and forth to each other similar to a eithernet situation.

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  6. #6
    Join Date
    Jul 2004
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    I think it's better to put the switching diode to every communication line for protection.

Similar Threads

  1. connect two pics
    By soki in forum mel PIC BASIC Pro
    Replies: 28
    Last Post: - 23rd September 2008, 06:29
  2. Retrieving infos from multiple PICs on a bus/chain
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 15th October 2007, 04:42
  3. Replies: 2
    Last Post: - 10th June 2005, 02:34
  4. Replies: 8
    Last Post: - 11th November 2004, 20:08
  5. 256 Pics Communicate to 1 Master Pic
    By mazlan in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 15th July 2004, 13:11

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts