ICP via optocouplers?


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Jun 2007
    Posts
    15

    Default ICP via optocouplers?

    Anyone with experience of ICP of 18F... (or 16F...) via optocouplers?
    I need electrical isolation for safety reasons between the PIC circuit and a permanently-connected-PC-with-Internet.
    Can use LVP or an onboard source of higher voltage for MCLR pin.
    I realize this is not a hardware forum, but it is the kind of place where someone might have tried something like this...

    Tips, suggestions etc. appreciated!

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: ICP via optocouplers?

    Never tried, don't know if it's straight forward or tricky as hell (since the PGD-pin is bi-directional for example) but if I were to try it I'd probably try with one of ADUM series digital isolators or something like that.

    But what's the application? Why is there a permanently connected PC to the programming port of the PIC?
    Is it perhaps possible to initially program the PIC with a bootloader and then, instead of trying to isolate the ICSP pins, use an isolated RS232 connection to the PC? That way you have isolated serial AND programming at the same time.

    /Henrik.

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: ICP via optocouplers?

    between the PIC circuit and a permanently-connected-PC-with-Internet
    I don't understand why you want to use ICSP (which I assume is what you meant). Surley it would be easier to use either USB and RS232, which could both be connected via optocouplers. Your optocouplers would have to be real fast to use USB 2.0

    Sorry in advance if I've misunderstood.

    George

  4. #4
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: ICP via optocouplers?

    There is somewhere documentation for this
    http://www.microchipdirect.com/produ...words=AC244005
    So you can take a look how they did that.
    But I also don't understand why you need this...
    EDIT: http://ww1.microchip.com/downloads/e.../50002085B.pdf
    Page 130-133
    Last edited by pedja089; - 2nd March 2016 at 09:07.

  5. #5
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: ICP via optocouplers?

    Why not just use a bootLoader? That way you can update the firmware via. the rs232 connection.
    Dave Purola,
    N8NTA
    EN82fn

  6. #6
    Join Date
    Jun 2007
    Posts
    15


    Did you find this post helpful? Yes | No

    Default Re: ICP via optocouplers?

    Thanks for all the replies, apologies for the late response.
    Yes, it would make a lot more sense to use a bootloader, and although I will take a look at the adapter described in the link sent by Pedja089, it is probably not certified for the 10kV isolation that the application demands.

    The application is for an existing piece of hardware built around a 18F67K22 - production changes to the hardware itself would be expensive.
    That's why I was considering using an external optocoupler-based adapter and connecting it permanently to the ICSP port on the existing hardware.

    The problem with using a bootloader is that there is no remotely-accessible reset function on the existing hardware. If it were a new design, I could use an output pin from the MCU to drive a one-shot pulse circuit which would pull down the MCLR pin causing a reboot and the option of entering the bootloader via the existing (already optoisolated to 10kV!) RS485 port (goes to the USART of the MCU). Are the any pre-coded bootloaders for this MCU that can be accessed from the main (PBP) code - i.e. post-boot, WITHOUT a reset button? Suggestions on how to do a reboot without reset button, and without pulling MCLR low? Maybe by using the WDT and with a USART command calling a timeout?

  7. #7
    Join Date
    Jun 2007
    Posts
    15


    Did you find this post helpful? Yes | No

    Default Re: ICP via optocouplers?

    ... and for the curious:

    The application is existing PIC-based hardware used for environmental monitoring in grain storage silos.
    Because of the potentially explosive atmosphere, there are strict requirements on the hardware used. Thus the opto-isolation on all ports to the "outside world".
    The hardware is already in use in several places around the world, including places where it would be very expensive to go to do a firmware update on site. But because of new items of associated hardware, changes to the code in the controller MCU are occasionally needed.

  8. #8
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: ICP via optocouplers?

    You don't need reset for bootloader. Why bootloader must start first?
    I always load hex file via main app in external eeprom, or in upper half of PIC FLASH memory.
    In main app there is already all you need to connect to PC or whatever. So use that to load HEX from PC.
    Code:
        INTCON=0
        FOR Adr=32768 TO 65023 STEP BlockSize
            ERASECODE Adr
        NEXT Adr
        FOR Adr=0 TO 32255
            Err=0
            FwReceive:
            Err=Err+1
            IF Err=250 THEN
                GOTO DeliteAndReset
            ENDIF
            HSEROUT2 ["A:",DEC6 Adr,3]
            HSERIN2 100, FwReceive, [WAIT("D:"), Tmp0, Tmp1]
            IF Tmp0<>Tmp1 THEN GOTO FwReceive
            Adr.15=1
            WRITECODE Adr,Tmp0
            Adr.15=0
        NEXT Adr
        GOTO StartBootloader
    And at end of code there is bootloader that copy from upper half to a lower half of FLASH. That bootloader is precompiled.
    Code:
    @ ORG .65024
    StartBootloader:
    ASM
     dw 0EF3Dh, 0F07Fh, 06EF6h, 06AF8h, 00E94h, 06E7Fh, 00E55h, 06E7Eh, 00EAAh, 06E7Eh, 0827Fh, 00000h, 0947Fh, 0EF3Ah, 0F07Fh, 06AF8h 
     dw 00E80h, 06E7Fh, 00009h, 050F5h, 0EF3Ah, 0F07Fh, 06AF8h, 06EF5h, 0000Ch, 028F6h, 00B3Fh, 0E109h, 00E84h, 06E7Fh, 00E55h, 06E7Eh 
     ETC...
    Code for that is:
    Code:
    DEFINE RESET_ORG .65024
    
    Adr VAR WORD
    Tmp VAR BYTE
    BlockSize       VAR BYTE BANKA SYSTEM
    @ MovLW BLOCK_SIZE
    @ MovWF BlockSize
    
    FOR Adr=0 TO 32255 STEP BlockSize
        ERASECODE Adr
    NEXT Adr
    
    FOR Adr=0 TO 32255 'Ne diraj zadnjih 512B
        Adr.15=1
        READCODE Adr,Tmp
        Adr.15=0
        WRITECODE Adr,Tmp
    NEXT Adr
    @ RESET
    EDIT:
    Hope that this is not too confusing...
    EDIT2:
    Last edited by pedja089; - 22nd March 2016 at 17:41.

  9. #9
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: ICP via optocouplers?

    Norbert, As a matter of fact I always place some kind of reset command or sequence into my serial comm routines for just that issue. I usually use the key combination "ctrl Z" which then places the target processor into a 10 second timeout which enables me to disconnect the terminal program and start the bootloader program. Works a treat... Been using it for years now...
    Dave Purola,
    N8NTA
    EN82fn

  10. #10
    Join Date
    Jun 2007
    Posts
    15


    Did you find this post helpful? Yes | No

    Default Re: ICP via optocouplers?

    Pedja - very instructive video!
    Since there is an onboard 1Mbit FRAM on the hardware that could be used for the intermediate storage of the serially-uploaded code, I'll give it a try. Thanks for the suggestion and your code - I think I get the general drift of it.

    On this thread [URL="http://www.picbasic.co.uk/forum/showthread.php?t=10144 "], BradB suggests setting a flag in EEPROM for bootloader/no bootloader at next reset. That sounds useful too, to avoid having to catch the bootloader in time after reset, which can be timing critical - as per your suggestion, Dave.

    And a little too late, a thankyou to DarrelT who in an old thread suggested RTFM and @ RESET...

  11. #11
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: ICP via optocouplers?

    Hi One way to reset would be to clear the watchdog timer yourself,
    and jump to an endless loop that fails to clear it.

    Serial over a Toslink cable would give the 10 kV isolation.
    I've found 0.2uF capacitance across the Toslink receiver
    output to ground (instead of a cap in series used for digital audio)
    overcomes the receiver's clock jitter, and allows the DC serial signal.

Similar Threads

  1. Labx2 icp problem .. help please
    By DavidFMarks in forum Schematics
    Replies: 5
    Last Post: - 8th December 2007, 17:23

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