Hot!RS485 with PIC16F1708

Page: 1234 > Showing page 1 of 4
Author
toffee_apple
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2015/11/30 05:15:38
  • Location: 0
  • Status: offline
2016/02/12 04:37:06 (permalink)
0

RS485 with PIC16F1708

Hi,
 
I'm a newbie with USART, I wonder if someone can point me in the right direction for the work I want to do.
 
I have a PIC16F1708 as Master and another one as Slave.
The master has a switch that operates two different functions depending on the position of it (let's call them F1 and F2) if the Master and the Slave are NOT connected. If both are connected the switch will operate another two functions (F3 and F4).
I would like to know how the Master can check the Slave is connected (as is a separate device, like an add-on unit).
 
For more clarification, the settings to adjust F3 and F4 (when both are connected) would be setup from the Slave, and then this info should be sent to the Master. Once it is received, the Master will operate accordingly.
 
As conclusion, some questions:
- How can be checked if the slave is connected or not the Master and the Slave?
- Can this be done only using the two PIC16 or is it necessary to use additional hardware?
- Is it recommended to use interrupts?
- Is it needed a communications with 2 or 4 wires?
 
If you can provide some information it would be much appreciated, as well as examples, links to refer and learn or steps/recommendations to follow.
 
Thank you very much,
 
 
Toffee_Apple
#1

78 Replies Related Threads

    NKurzman
    A Guy on the Net
    • Total Posts : 14951
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: RS485 with PIC16F1708 2016/02/12 09:32:23 (permalink)
    0 (1)
    That is kind of Rambling.
    I would like to know how the Master can check the Slave is connected (as is a separate device, like an add-on unit).
    1. The Master asks the Slave if it is there.
    2. More elaborate, it look for the terminating resistor (this assumes one one master and on slave.
    3.Extra Hardware.
     
    Can two PIC talk with RS-485 YES
    Is it recommended to use interrupts? That depends but usually it is better.
    2 wires is half Duplex, 4 is Full Duplex, Again it depend on the Need.
     
     
    #2
    n9wxu
    Starting Member
    • Total Posts : 57
    • Reward points : 0
    • Joined: 2008/11/06 17:00:50
    • Location: 0
    • Status: offline
    Re: RS485 with PIC16F1708 2016/02/12 13:38:03 (permalink)
    +1 (1)
    You are asking a few things so stay tuned for some suggestions:
     
    1) You must implement a simple query that the master can use to see if a slave is present.  I generally use a slave version request.  This is innocuous and provides a useful information that allows the master to adapt to different slaves.
    2) No new HW is required because you will simply query the bus for the slave.
    3) It may be easier to implement RS-485 as a polled driver.  Otherwise you may have to add the DE/RE pin toggles to the UART driver.  Using interrupts will reduce the CPU impact of the driver especially when the baudrate is low.
    4) RS-485 is a half-duplex 2 wire system.  The 4 wire system is full duplex and RS-422. 
     
    EDIT: 2 communications wires and 4 communications wires.  An additional ground is required, making 3 and 5 wires total.
    post edited by n9wxu - 2016/02/15 08:45:12
    #3
    ric
    Super Member
    • Total Posts : 22098
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: RS485 with PIC16F1708 2016/02/12 15:28:10 (permalink)
    +1 (2)
    and bear in mind, even though RS485/422 is a differential signal, you SHOULD still be making a ground connection as well, so that makes it a 3 or 5 wire connection.
    (This is because most commonly available transceivers have a limited "common mode" range, which you can easily exceed if you don't connect the grounds.)

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #4
    kishor009
    Junior Member
    • Total Posts : 96
    • Reward points : 0
    • Joined: 2017/08/22 05:48:27
    • Location: india
    • Status: offline
    Re: RS485 with PIC16F1708 2017/09/01 04:12:22 (permalink)
    -1 (1)
    how to clock provide to slave by master
    #5
    RISC
    Super Member
    • Total Posts : 4585
    • Reward points : 0
    • Status: offline
    Re: RS485 with PIC16F1708 2017/09/01 04:26:36 (permalink)
    +1 (1)
    Hi,
    Do you have a XTAL oscillator connected to the PIC ?
    The PIC16F1708 will only reliably perform UART operations from internal oscillator if your application is within 0 to 60C (see datasheet figure 32-6 page 385) as the maximum error is garanteed to be less than +/-2%.
    Outside this range the error might be greater than +/-2%
    Regards
     
    #6
    kishor009
    Junior Member
    • Total Posts : 96
    • Reward points : 0
    • Joined: 2017/08/22 05:48:27
    • Location: india
    • Status: offline
    Re: RS485 with PIC16F1708 2017/09/01 04:35:28 (permalink)
    -1 (1)
    yes 12Mhz crystal is connect
    #7
    qhb
    Superb Member
    • Total Posts : 6239
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: RS485 with PIC16F1708 2017/09/01 04:58:20 (permalink)
    +1 (1)
    kishor009
    how to clock provide to slave by master

    I don't understand what you were trying to ask.
     
    #8
    kishor009
    Junior Member
    • Total Posts : 96
    • Reward points : 0
    • Joined: 2017/08/22 05:48:27
    • Location: india
    • Status: offline
    Re: RS485 with PIC16F1708 2017/09/01 05:04:44 (permalink)
    -1 (1)
    in master-slave communication using rs-485 modbus for pic16
    what is hardware is require menace how to connect master and slave.
    any one give schematic
    #9
    qhb
    Superb Member
    • Total Posts : 6239
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: RS485 with PIC16F1708 2017/09/01 05:12:50 (permalink)
    +1 (1)
    kishor009
    ...
    what is hardware is require menace how to connect master and slave.
    ...

    The word "menace" here is totally meaningless.
    I assume it is a mis-translation of some other word. Please try to explain further.
     
     
     
    #10
    kishor009
    Junior Member
    • Total Posts : 96
    • Reward points : 0
    • Joined: 2017/08/22 05:48:27
    • Location: india
    • Status: offline
    Re: RS485 with PIC16F1708 2017/09/01 05:16:06 (permalink)
    -1 (1)
    how to connect master and slave using rs-485 modbus for pic16
    #11
    qhb
    Superb Member
    • Total Posts : 6239
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: RS485 with PIC16F1708 2017/09/01 05:34:10 (permalink)
    +1 (1)
    Do you know anything about Modbus?
    Maybe you should start here: http://www.modbus.org/docs/Modbus_over_serial_line_V1.pdf
     
    #12
    kishor009
    Junior Member
    • Total Posts : 96
    • Reward points : 0
    • Joined: 2017/08/22 05:48:27
    • Location: india
    • Status: offline
    Re: RS485 with PIC16F1708 2017/09/01 05:59:42 (permalink)
    -1 (1)
    little information about that
    #13
    kishor009
    Junior Member
    • Total Posts : 96
    • Reward points : 0
    • Joined: 2017/08/22 05:48:27
    • Location: india
    • Status: offline
    Re: RS485 with PIC16F1708 2017/09/01 06:04:08 (permalink)
    -1 (1)
    if we generator baud rate for master (using software)
    then require baud rate generator  for slave?? 
     
    #14
    CinziaG
    rome burns :D
    • Total Posts : 3136
    • Reward points : 0
    • Joined: 2016/12/07 14:20:36
    • Location: Wien
    • Status: offline
    Re: RS485 with PIC16F1708 2017/09/01 06:27:29 (permalink)
    0
    Wll, both ends need a 3% precise Baud rate generator, yes
    #15
    kishor009
    Junior Member
    • Total Posts : 96
    • Reward points : 0
    • Joined: 2017/08/22 05:48:27
    • Location: india
    • Status: offline
    Re: RS485 with PIC16F1708 2017/09/01 07:18:37 (permalink)
    -1 (1)
    two pic16 are connect thought rs 485 intend of them we connect direct Tx/Rx pin of two pic16 then what happen??  
     
    i mean what is different between them?
    #16
    CinziaG
    rome burns :D
    • Total Posts : 3136
    • Reward points : 0
    • Joined: 2016/12/07 14:20:36
    • Location: Wien
    • Status: offline
    Re: RS485 with PIC16F1708 2017/09/01 07:36:09 (permalink)
    +1 (1)
    You can use PIC -> MAX485 -> wire -> MAX485 -> PIC
     
    Same speed of USART, of course
    #17
    malaugh
    Super Member
    • Total Posts : 243
    • Reward points : 0
    • Joined: 2011/03/31 14:04:42
    • Location: San Diego
    • Status: offline
    Re: RS485 with PIC16F1708 2017/09/01 08:00:44 (permalink)
    0
    If I understand the question, you want to know how you can check to see if a slave device is connected over an RS485 link, so you can change the function of a button based on this information.
     
    RS485 is half duplex, meaning you cannot transmit and receive at the same time.  Normal the master handles this by
     
    1) Setting the RS485 to transmit mode
    2) Sending a message
    3) Setting the RS485 back to receive mode and waiting for a response from the slave
     
    The slave does the opposite, it sets receive mode, waits for message, then sets transmit mode, sends a response then goes back to receive mode.
     
    To detect if the slave is present, the master needs to send a "status" message regularly, say one a second, and if the slave does not respond, then assume the slave is not present
     
     
    #18
    kishor009
    Junior Member
    • Total Posts : 96
    • Reward points : 0
    • Joined: 2017/08/22 05:48:27
    • Location: india
    • Status: offline
    Re: RS485 with PIC16F1708 2017/09/01 21:16:22 (permalink)
    0 (2)
    CinziaG
    You can use PIC -> MAX485 -> wire -> MAX485 -> PIC
     
    Same speed of USART, of course


    pin RE/DE of the max485 is connect with which pin of the pic16??
    #19
    qhb
    Superb Member
    • Total Posts : 6239
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: RS485 with PIC16F1708 2017/09/01 21:21:03 (permalink)
    +1 (1)
    kishor009
     
    ...
    pin RE/DE of the max485 is connect with which pin of the pic16??

    With whichever GPIO pin you decide to use.
    It is up to the code that you (the programmer) write to control it. You can use any general purpose pin you want.
     
     
    #20
    Page: 1234 > Showing page 1 of 4
    Jump to:
    © 2017 APG vNext Commercial Version 4.5