How to turn on a GPIO from a device function block

2019-12-07
2022-09-29
  • BG_Automation

    BG_Automation - 2019-12-07

    I need to link a GPIO to a function block. I think I just need to point the address to the GPIO when the function block is initialized. Then control the output when needed.

    Output 25 turns on just before the SPI transmits to the relay board then turns off afterward. I don't know what is used for, but I am going to follow what the creator of the relay board did.

    Any suggestions?

     
  • lwalbert - 2022-09-29

    Hi, I was working on libraries for Pi-Plates in codesys back in 2019 too :)
    I was struggling with the same issue as you regarding GPIO25.
    Looks like you cannot access the GPIO25 outside a task eg. changing state within the library for each read/write cycles in a for loop.

    But I found a workaround: Connecting a optocoupler controlled by CS1 (chip select) to toggle GPIO25 towards Pi-Plate wire. and adjusting SPI communication speed/frequency and delay, I got it working.

    I decided to update and publish my work on github today :)

    https://github.com/lwalbert/piplates-CodeSys

    BR
    Lennart

     

Log in to post a comment.