Sunday, February 19, 2017

Raspberry Pi - pymodbus Youtube Series

I've been out of the game lately on my blog and wanted to give an update of my latest work on youtube.. I've been able to post a few video tutorials on pymodbus and wanted to show a preview of my youtube tutorial roadmap.

Pymodbus ModbusTCP - Reading Holding Registers
Pymodbus ModbusTCP - Reading & Writing Holding Registers
Pymodbus Raspberry Pi as Modbus Serial<->TCP Bridge
Pymodbus - RPi as ModbusTCP Slave Temperature Sensor
SCADA Datalogger - snap7 and Pymodbus
Pymodbus ModbusTCP - Reading And Writing Raspberry PI GPIO using ModbusTCP
Raspberry Pi - Tutorials - Snap7 Python - Raspberry Pi as S7 Device
Raspberry Pi - Tutorials - Snap7 Python - Reading & Writing Rpi GPIO using snap7 and Kepsever
Raspberry Pi - Tutorials - SCADA SQL Logger - snap7 and Pymodbus MSSQL

Dates are not yet decided.  I hope to get two of these a month. Let me know if you wish to see another one
So far these 4 are done:

Raspberry Pi - Tutorials - Pymodbus ModbusTCP - Setup & Quick Example (Writing To Twido M Memory)

 

Wednesday, December 28, 2016

Rasberry Pi - Tutorials - S7-1200 & Snap7 Python - Controlling the PLC Using Rpi GPIO


Long awaited video on how to use the Rpi GPIO to control aspects of the PLC.

Intro to controlling Raspberry Pi's GPIO using python:

Raspberry Pi - Tutorials - GPIOZero - Controlling LEDS Using Rpi GPIO



Using the snap7zero and gpiozero to control the S7-1200 PLC with the Raspberry Pi:

Rasberry Pi - Tutorials - S7-1200 & Snap7 Python - Controlling the PLC Using Rpi GPIO

Wednesday, May 11, 2016

snap7 reconnecting code snippet

In some cases your pi may lose connection with your PLC.. here's some helpful code to get it reconnected (I whipped this up pretty quick, and it's currently untested)
def connect(plc,ip):
    while True:
        #check connection
        if plc.get_connected():
            break
        try:
            #attempt connection
            plc.connect(ip,0,0)
        except:
            pass
        sleep(5)
        
plc = snap7.client.Client()
connect(plc,'10.10.55.109')
while True:    
    try:
        #do stuff 
                
    except Snap7Exception as e:
        connect(PLC)
        # break
connect(plc,ip) method puts your pi in an infinite loop till it is connected. make sure you wrap your methods with a try,except.