Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

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, February 3, 2016

Python Snap7 S7-1200 Simple Reading/Writing Memory Example



import snap7.client as c
from snap7.util import *
from snap7.snap7types import *

def ReadMemory(plc,byte,bit,datatype):
    result = plc.read_area(areas['MK'],0,byte,datatype)
    if datatype==S7WLBit:
        return get_bool(result,0,bit)
    elif datatype==S7WLByte or datatype==S7WLWord:
        return get_int(result,0)
    elif datatype==S7WLReal:
        return get_real(result,0)
    elif datatype==S7WLDWord:
        return get_dword(result,0)
    else:
        return None

def WriteMemory(plc,byte,bit,datatype,value):
    result = plc.read_area(areas['MK'],0,byte,datatype)
    if datatype==S7WLBit:
        set_bool(result,0,bit,value)
    elif datatype==S7WLByte or datatype==S7WLWord:
        set_int(result,0,value)
    elif datatype==S7WLReal:
        set_real(result,0,value)
    elif datatype==S7WLDWord:
        set_dword(result,0,value)
    plc.write_area(areas["MK"],0,byte,result)

if __name__=="__main__":
    plc = c.Client()
    plc.connect('10.10.54.2',0,1)
    print ReadMemory(plc,420,0,S7WLReal)
    WriteMemory(plc,420,0,S7WLReal,3.141592)
    print ReadMemory(plc,420,0,S7WLReal)

    #DONE!!

Saturday, January 2, 2016

Raspberry Pi - SCADA - Another Video Tutorial Snap7 Python for S7-1200 PLC

Another Simple snap7 Python Tutorial



Covers creating a simple example on turning on and off a PLC output.

 import snap7.client as c
 from snap7.util import *
 from time import sleep


 def WriteOutput(dev,bytebit,cmd):
     byte,bit = bytebit.split('.')
     byte,bit = int(byte),int(bit)
     data = dev.read_area(0x82,0,byte,1)
     set_bool(data,byte,bit,cmd)
     dev.write_area(0x82,byte,data)

 def main():
     myplc = snap7.client.Client()
     myplc.connect('10.10.54.2',0,1)
     for x in range(10):
         WriteOutput(myplc,'0.0',x%2==0) # turns true every other iteration
         sleep(1)

 if __name__ == "__main__":
     main()

Thursday, December 24, 2015

New S7-1200 & Snap7 Walkthrough Video Uploaded


I'm going to try and start a series of videos on python snap7 tutorial using my Raspberry Pi.
Here's the setup walkthrough :-)
Youtube link: https://youtu.be/yJNEsI5KJxs

Subscribe to my channel to keep up to date  Channel Link

Let me know what kind of things you'd like to see in the series :-)

Enjoy!