PICtoPIC by 1-wire


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

    Post PICtoPIC by 1-wire

    Hi all
    I have some problems to connect 2 PIC16F648A using portB.0 with OWIN/OWOUT command.
    The PIC-1 (master) call PIC-2, like an iButton, with this code that I cann't change:
    ----------------------
    IB VAR BYTE[8]
    OWOUT PortB.0, 1, [$33]
    PAUSE 5
    OWIN PortB.0, 0, [STR IB\8]
    ----------------------
    The PIC-2 must to reply at PIC-1 reset with "presence" pulse, read "$33" and send it 8 byte.

    Is it possible do it with PBP without ASM code?
    Can anyone help me with ASM code if indispensable?

    Thank in advance

    cip

  2. #2
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Cip,

    PIC to PIC connection using 1-Wire is not that simple.
    when using OWIN / OWOUT both the PICs claim to be a master.

    I have already spent hours to write a 1-Wire slave routine for the PIC, no success so far.

    What you could do is: use SerIn / SerOut

    When Idle your Slave is in a SerIn loop
    As soon as it has been "called" it replies on the same Port using SerOut.

    The Master "calls" the Slave using SerOut and after sending its Bits it listens on the same port for the slaves reply using SerIn.

    Even this will require some lines of code to get the timing right and make it fail safe, assuming the slave has more to do than looping waiting for it's masters call.

    If you can afford to use some more port Bits (up to 3)
    "handshaking" will be easier.

    @all members
    Does anyone have a better solution ?

    rgds.
    Last edited by NavMicroSystems; - 10th March 2004 at 15:58.

  3. #3
    cip's Avatar
    cip Guest


    Did you find this post helpful? Yes | No

    Post

    Thank you for reply.
    I'm huppy: my question is not so stupid!
    I *must* use only PortB.0 pin and reply to PIC-1 like an iButton.
    I write this routine for PIC-2 (work fine without ONE error with OSC_INT at 4 MHz):
    ------------------------
    LOOP:
    input PortB.0

    'wait reset pulse
    WAIT_L:
    if PortB.0 = 1 then WAIT_L
    WAIT_H:
    if PortB.0 = 0 then WAIT_H

    'tPDH
    pauseus 15

    'start PRESENCE pulse
    low PortB.0
    pauseus 60
    high PortB.0

    'tRSTH
    pauseus 450

    ' read Function Command ($33)
    owin PortB.0, 0, [FC]

    goto LOOP
    ---------------------------

    But I don't know to continue... :-(
    I can send to PIC-1 only a correct byte with OWOUT command, no more.
    I think the problem is the timing...

    Thanks

    cip

  4. #4
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    I guess it's a bit more than just the timing . . .

    You will have to shift the bits in and out "manually"
    and your Slave Routine will have to interrupt driven.

    This is probably a good questions to our Experts (Melanie?)

    As Mentioned earlier: I haven't had any luck yet to run a PIC as 1-Wire Slave.

    But if you manage to get this working I would be interested in your solution.

    rgds:

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


    Did you find this post helpful? Yes | No

    Default

    You need something such as a shift left.

    For example a reciever:

    counter var byte
    result var byte

    Loop:
    result =0

    for counter=0 to 7

    'Here you check for your sending bit
    Loop2:
    if Portb0.0=then Loop2
    'Here you do NOT go ahead, unless the bit goes to zero
    Loop3:
    if portb0.0=1 goto Loop3

    Pauseus 50 'Wait until transmitter has time toggle bit


    'Here you put your bit into register and shift left to add.
    'If you do it 8 times, you have a complete byte
    result=Portb0.0
    result=result << 1
    Pause 1 'Give time for transmitter to toggle bit to 0
    next counter


    Transmitter:

    Dcounter var byte
    counter var byte
    number var byte
    T var Porta.bitoftransmitter
    DigNumber var byte

    number=2468

    for counter=7 to 0 step -1
    DigNumber=Dig Number 7

    for Dcounter=0 to 7
    High T
    pauseus 10 'remember, you can't go past 50us,because of reciever
    Low T

    T=DigNumber0.7
    pauseus 20 'enough time for receiver to read!!
    T=0 'TURN IT OFF!!!!!
    DigNumber.7=DigNumber.7 <<1
    Pause 1 'give time for receiver to do its job
    Next Dcounter

    Pause 100 '(give time for display to print it out)
    Next counter


    Dwayne

  6. #6
    chip_emulator's Avatar
    chip_emulator Guest


    Did you find this post helpful? Yes | No

    Default one wire slave

    Hi Everibody

    Anyone as implemented 1-wire slave with Pic?
    I want to start it, any help will be great!

    Regards

    Chip

Similar Threads

  1. Thermo 7 segments - little problem
    By fratello in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 27th July 2013, 07:31
  2. RS485 bus - starting probem
    By wurm in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th January 2010, 13:35
  3. 32 bit square root
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 6th May 2009, 03:37
  4. one line led light make image
    By bioul in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 12:19
  5. HSERIN doesn´t work
    By wurm in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th July 2007, 14:23

Members who have read this thread : 0

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