Open PLC and Industrial Automation card

dstorey

New member
Hi I purchased one of these cads to link it to OpenPLC as suggested in the web site. Is there a specific library to allow this to be used with the OpenPLC editor?

thanks Dominic
 

alexburcea

Moderator
Staff member
Both editor and runtime drivers for the Industrial Automation HAT are ready and will be pushed on the OpenPLC repository next week.
I will let you know when you can update your OpenPLC to use them.
 

dstorey

New member
hi just wondering - will this be based on Python libraries or have you guys written. C++. version for the run time? I checked again today and the Github repo is still dated April 5 - so is the update still in the works?
 

alexburcea

Moderator
Staff member
Hi,

The OpenPLC Editor part pull request is waiting for approval. The Runtime part is ready (and tested) but I am waiting for some answers regarding the integrations. I will let you know the progress in the next days.
 

alexburcea

Moderator
Staff member
Both Runtime and Editor PR are pending from few days. Thiago promise that it will take care of them this week.
When these 2 PR will be merged you need to update both Editor and runtime (on the Raspberry) and use the Industrial Automation as a module in the editor.
 

alexburcea

Moderator
Staff member
Both editor and runtime modification are merged. You can use the Industrial and more of our cards with OpenPLC
 

dstorey

New member
Hi there Alex,
I have got OpenPLC and the Sequent Industrial Hat running, but I have found a problem. I have run one of the example programs which implements two timers that act in unison to toggle a LED on and off. This runs fine if I run it on a Pi without the Sequent Industrial card with a LED on physical pin 16 - it flashes the light on for 500mS, then off for 500mS forever, with no variance in timing. When I run it on the same model of Pi (Pi 3) with the Sequent card, I find that the timing is erratic, with every 20 or so seconds, the LED missing a flash. I'm using the same SD card on both Pis (one with the hat, one without) so I am reasonably confident the problem is not in OpenPLC itself. I've tested this with the regular kernel that comes with Raspian and with one I built with the real-time extensions. No differences. Both were Kernel 6.1. I've extended the period up to 2 seconds on and 2 seconds off - no difference. It's not a speed thing.

Happy to help in debugging this if you can suggest some steps.

Kr Dom
Screenshot from 2023-07-03 21-22-23.pngScreenshot from 2023-07-03 21-20-58.png
 

alexburcea

Moderator
Staff member
Strange things, I tested the Industrial with more work load.
Can you see some error messages in the OpenPLC runtime web interface?
Are you sure the card are making good contact in the pin header ( please use the provided bras standoffs to secure the card).
One more thing you can try: Install the megaind command and see how it works on your setup.
 

alexburcea

Moderator
Staff member
One more thing, I am not much a PLC guy but your connection to the LED is strange, why the blink_led coil does not go to the rail and a contact feed the LED?
 

dstorey

New member
I did make the changes suggested and to no avail. I still see occasional misses. Either the led stays on or stays off for an extra cycle, like it misses the transition. I have also upped the I2C baud rate to 400Kbps to see if this made a difference, but I still see the drops.
I installed megaind and run it:
megaind 0 board
Firmware ver 02.02, CPU temperature 36 C, Power source 24.76 V, Raspberry 5.19 V
 

alexburcea

Moderator
Staff member
The interface is writen in C. All the test I made are on a RPI4. I do not have pi3 but I will run the tests on zero and get back to you.
The skipping one interval is kind of normal because the driver write to the I2C only if the Leds are different than the previous value.
Until I setup my pi zero can you try to increase the task interval from 20ms (default) to 50?
 

alexburcea

Moderator
Staff member
I just test it on RPI zero. Reproduce your program with one second on and one second off. All work perfectly, I see one flash of the power led when the Led is on and one when led is off.
 

alexburcea

Moderator
Staff member
Hi,
Keep testing on the zero I get some time a period skip. The phenomena is rare and it is hard to debug. If you can do some code editing in the Runtime and test, it will help me a lot.
Meanwhile I create a program to check difference between led and open drain output to easily see the difference.
 

Attachments

  • ind_led.zip
    78.3 KB · Views: 2

dstorey

New member
The interface is writen in C. All the test I made are on a RPI4. I do not have pi3 but I will run the tests on zero and get back to you.
The skipping one interval is kind of normal because the driver write to the I2C only if the Leds are different than the previous value.
Until I setup my pi zero can you try to increase the task interval from 20ms (default) to 50?
I can't see that as normal ... sometimes they run a little fast, others it's staying on for a cycle or off for a cycle. Unless there is a difference in the way the LEDs operate compared to anything else. I can put another led on on of the digital outputs (with a suitable resistor or course) to check if the outputs actually do the same as the leds. I'm a coder myself and my dev radar is telling me there's some issue with resource locking going on ... especially as the Pi always locks up within 30 mins. I've run it all day today using OpenPLC, and a Led on the GPIO port.
 

dstorey

New member
OK I updated firmware to v2.06. It ran my openplc program for 12 minutes before locking up. I ran yours with it's 50mS gap but it locked up in 7mins 32 sec.

I wrote some C drivers for OpenPLC for another card last year. If you are happy to share I can cast another set of eyes over it if you like.
 
Top