lcostello
Howdy all,

I've got an interesting problem here specifically related to the development branch of OpenPLC. I have the main branch installed on one RPi 4B, and the development branch installed on a second RPi 4B.

On the main branch RPi4, I am able to add slave devices (specifically, I'm using an Arduino Mega), and they function normally. However, on the development branch RPi4, when I add slave devices, the runtime never actually begins search for the slave device. Both are added using the Web Server > Slave Devices tab.

Another interesting note - the RPi4 with the development branch installed didn't have WiringPi installed by default. So it's possible there's some dependency not installed on this RPi.

I'd appreciate any help in resolving this issue, and getting my "development branch" RPi connected to the Arduino.

Thanks!

PS: Here's a console printout for the development RPi4:
[2021-11-17 12:55:04.929] [info] OpenPLC Runtime starting...
[2021-11-17 12:55:04.931] [info] Skipped load persistence because file cannot be read.
[2021-11-17 12:55:04.931] [info] Setting main thread priority to RT
[2021-11-17 12:55:04.931] [info] Locking main thread memory
[2021-11-17 12:55:04.959] [info] Starting service interactive
[2021-11-17 12:55:05.001] [info] Starting service modbusslave
[2021-11-17 12:55:05.043] [info] Interactive Server: Listening on port 43628
[2021-11-17 12:55:05.074] [info] Starting modbus slave on port 502
[2021-11-17 12:55:05.074] [info] Server: Listening on port => 502
[2021-11-17 12:55:06.273] [info] Starting service dnp3s
[2021-11-17 12:55:06.341] [info] Starting thread (0)
[2021-11-17 12:55:06.342] [info] Listening on: 0.0.0.0:20000
[2021-11-17 12:55:06.342] [info] DNP3 outstation enabled on port 20000
[2021-11-17 12:55:06.502] [info] Starting service enip
[2021-11-17 12:55:06.531] [info] Starting enip on port 44818
[2021-11-17 12:55:06.531] [info] Server: Listening on port => 44818


and here's a console printout for the main branch RPi4:
OpenPLC Runtime starting...
Interactive Server: Listening on port 43628
Device Arduino is disconnected. Attempting to reconnect...
Warning: Persistent Storage file not found
Connected to MB device Arduino
Issued start_modbus() command to start on port: 502
Server: Listening on port 502
Server: waiting for new client...
Issued start_dnp3() command to start on port: 20000
DNP3 ID manager: Starting thread (0)
DNP3 ID DNP3_Server: Listening on: 0.0.0.0:20000
Issued start_enip() command to start on port: 44818
Server: Listening on port 44818
Server: waiting for new client...
Issued stop_pstorage() command
Reply 0 0
thiagoralves
Use only the master branch code. Development branch is broken.
Reply 0 0
lcostello
Hey Thiago!
Is DNP3 implementation still only available in the development branch? I see that DNP3 is stated to only be implemented in the development version as per the documentation, but quite a few DNP3 specific files in the main branch.

If DNP3 is implemented in the main branch, how is the map between the OpenPLC addresses & the DNP3 bindings defined?

I've been trying to learn this by reading thru the core code, but C++ is new to me so it's taking some learning 🙂

Thanks!
Reply 0 0
thiagoralves
DNP3 was always implemented on the master branch since the beginning. The development branch was a side code to create a headless version of OpenPLC with some DNP3 improvements. To use DNP3 on the master branch, all you have to do is edit the  https://github.com/thiagoralves/OpenPLC_v3/blob/master/webserver/core/dnp3.cfg config file (on your Raspberry Pi the path will probably be ~/OpenPLC_v3/webserver/core/dnp3.cfg ). DNP3 mapping follows Modbus mapping according to this reference document:  https://www.openplcproject.com/reference/modbus-slave/
Reply 1 0
lcostello
Good to know - appreciate the explanation! I think this conflicts with https://www.openplcproject.com/reference/dnp3-outstation/, which states DNP3 is only available via the development branch.


I do have a different issue, that I'm not sure if it's worth opening another topic to discuss. I currently have my Raspberry Pi connected to the Arduino Mega; pin D22 / map %IX100.0 on the Arduino toggles an LED in position at %QX1.0 on the Pi.
The pin at D22 is set high, the LED turns on very quickly. However, when the logical high / 5V signal is removed, the LED takes about 2-3 seconds to turn off.

I'm not sure if:
(a) This issue is in software, and I can speed this up
(b) This is an issue with my wiring -- I was thinking a pull-down resistor on the Arduino D22 might speed this process up. I'll give it a go and see if it helps.

Any thoughts?
Thanks!
Reply 0 0
thiagoralves
lcostello wrote:
Good to know - appreciate the explanation! I think this conflicts with https://www.openplcproject.com/reference/dnp3-outstation/, which states DNP3 is only available via the development branch.

Not quite... what says in there is that those capabilities were only available on the development branch. DNP3 support is there on both master and development branches, but the master branch does not have the flexible binding features explained on that page.

lcostello wrote:
However, when the logical high / 5V signal is removed, the LED takes about 2-3 seconds to turn off

When you remove 5V signal from an input pin, you cannot assume it will go immediately to ground. In fact, the pin state is completely undefined, because it does not have neither 5V or GND in it. That's why you need pull up or pull down resistors. They will guarantee the state of the pin (either high or low, depending it if is a pull up or pull down) when nothing is connected to the pin.
Reply 0 0
lcostello
Ahh, I totally misread that then.

Quote:

When you remove 5V signal from an input pin, you cannot assume it will go immediately to ground. In fact, the pin state is completely undefined, because it does not have neither 5V or GND in it. That's why you need pull up or pull down resistors. They will guarantee the state of the pin (either high or low, depending it if is a pull up or pull down) when nothing is connected to the pin.


That's what I was thinking. Thanks for your help sir! 🙂
Reply 0 0
Reply