Two OneWireMaster on one Raspberry PI 5

s1mon
2025-06-10
2025-10-21
  • s1mon - 2025-06-10

    Hi,

    I want to use two OneWireMaster on a Raspberry Pi5.
    I'm running Codesys Control for Raspberry Pi 64SL V 4.15.0.0.

    Under Linux I've configured two GPIOs for 1w bus usage on GPIO4 and GPIO27.
    Under Linux both masters seem to work fine and I can readout both sensors connected to both GPIOs.
    The two masters are 'w1_bus_master1' and 'w1_bus_master2'.
    In Codesys I've configured to OneWireMasters with the corresponding file paths.
    But in Codesys the 2nd onewiremaster "w1_bus_master2" doesn't work.
    Status is showing "OnewireMaster : Not running"

    What am I doing wrong?
    Does Codesys on Raspberry support multiple OneWireMasters?

    Any help is appreciated.

     
  • eschwellinger

    eschwellinger - 2025-06-12

    check if the second onwire master is accessible in the configfile path setting.
    /etc/codesyscontrol/

     
  • s1mon - 2025-06-13

    Thx for the hint.
    It works if I add following line to the .cfg file.

    PlaceholderFilePath.2=/sys/devices/w1_bus_master2, $OneWire2$

    Is there a documentation how to modify this config file?

    Will this be overwritten if I do an update of the CodesysControl Runtime?

     
  • eschwellinger

    eschwellinger - 2025-06-13

    CODESYScontrol.cfg will be overwritten, CODESYSControl_Usr.cfg not.

     
  • s1mon - 2025-10-18

    If I add "PlaceholderFilePath.2=/sys/devices/w1_bus_master2, $OneWire2$" to the CODESYScontrol.cfg I can use a 2nd OneWireMaster in the Codesys Runtime. But then my EtherCAT_Master is not working any more.
    Any Idea?

    Is there any instruction or documentation how a 2nd OneWire Bus Master can be used within Codesys Runtime on a raspberry pi 5?

     
  • eschwellinger

    eschwellinger - 2025-10-18
    1. you need to have an own task for the one wire and io update these slaves in an own low prio task!
     

    Last edit: eschwellinger 2025-10-18
  • s1mon - 2025-10-19

    All Sensors from the OneWire Master are assigned already to a seperate task with low prio (26) that runs with 1s cycle time.
    My EtherCat Task is running with Prio 1.

    It all works fine, until I adjust the CODESYScontrol.cfg or the CODESYScontrol_Usr.cfg files so that it supports a 2nd OneWire Master in the Codeys Runtime.
    If I change something in this config file and reboot my EtherCat Master stops working.

     
  • eschwellinger

    eschwellinger - 2025-10-20

    hm.. could you add the project or at least parts of it?

     
  • s1mon - 2025-10-20

    yes sure. Thx for your support!
    This is the Codesys project stripped down only to my EtherCat and OneWire Configuration.

    The Project now contains only one OneWire Master on GPIO4.

     
  • eschwellinger

    eschwellinger - 2025-10-21

    the project has only one OneWire Master - so if you add the setting
    "PlaceholderFilePath.2=/sys/devices/w1_bus_master2, $OneWire2$ to the config file it will fail and the Ethercat task will be blocked by the OneWire Master readings?

     
  • s1mon - 2025-10-21

    I don't know why the EtherCat fails, but what happens is:

    First I have only one 1WireMaster running on my Raspberry Pi and EtherCat is running fine.
    Then I'd like to add a 2nd 1WireMaster.
    Therefore I enable a 2nd GPIO Pin on the raspberry in the file "/boot/firmware/config.txt".

    dtoverlay=w1-gpio,gpiopin=4,pullup=0
    dtoverlay=w1-gpio,gpiopin=23,pullup=0
    

    To be able to use this 2nd 1WireMaster in Codesys Runtime I Adjust the CODESYScontrol.cfg file and add there:
    PlaceholderFilePath.2=/sys/devices/w1_bus_master2, $OneWire2$

    After a reboot the EtherCat Master is not working any more.
    I didn't even add a 2nd OneWire Master in Codesys, but still if I do the EtherCat does not work.

    Do you have an idea why?

     
  • eschwellinger

    eschwellinger - 2025-10-21

    Could you check the taskcycle time in the taskmonitor (online monitor) - do you really see this 1s on Ethercat Task?
    Need to check this on my hardware but will take some time...

     

Log in to post a comment.