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)
import snap7.client
from snap7.snap7types import *
from snap7.util import *
class DBObject(object):
pass
offsets = { "Bool":2,"Int": 2,"Real":4,"DInt":6,"String":256}
db=\
"""
Temperature Real 0.0
Cold Bool 4.0
RPis_to_Buy Int 6.0
Db_test_String String 8.0
"""
def DBRead(plc,db_num,length,dbitems):
data = plc.read_area(areas['DB'],db_num,0,length)
obj = DBObject()
for item in dbitems:
value = None
offset = int(item['bytebit'].split('.')[0])
if item['datatype']=='Real':
value = get_real(data,offset)
if item['datatype']=='Bool':
bit =int(item['bytebit'].split('.')[1])
value = get_bool(data,offset,bit)
if item['datatype']=='Int':
value = get_int(data, offset)
if item['datatype']=='String':
value = get_string(data, offset)
obj.__setattr__(item['name'], value)
return obj
def get_db_size(array,bytekey,datatypekey):
seq,length = [x[bytekey] for x in array],[x[datatypekey] for x in array]
idx = seq.index(max(seq))
lastByte = int(max(seq).split('.')[0])+(offsets[length[idx]])
return lastByte
if __name__ == "__main__":
plc = snap7.client.Client()
plc.connect('10.10.55.109',0,0)
itemlist = filter(lambda a: a!='',db.split('\n'))
deliminator='\t'
items = [
{
"name":x.split(deliminator)[0],
"datatype":x.split(deliminator)[1],
"bytebit":x.split(deliminator)[2]
} for x in itemlist
]
#get length of datablock
length = get_db_size(items,'bytebit','datatype')
meh = DBRead(plc,10,length,items)
print """
Cold:\t\t\t{}
Tempeature:\t\t{}
RPis_to_Buy:\t{}
Db_test_String:\t{}
""".format(meh.Cold,meh.Temperature,meh.RPis_to_Buy,meh.Db_test_String)
plc.disconnect();
The Raspberry Pi has many Industrial Control Applications and many ways to interface with current Industrial Protocols. I am starting a Raspberry Pi Industrialized Google+ Community to gather people smarter than me to answer questions,give tutorials on Raspberry Pi and PLC interfaces, show present and upcoming raspberry pi hardware, and to show off their cool industrial projects using the Raspberry Pi. Since I'm a python fan here's a list of Ethernet/Serial Based Protocols I've found:
Any Other Serial ASCII Device <--> Modbus TCP, Siemens S7, Koyo ECOM, EtherNet/IP-->
Cheap HMI Screen Replacement.HMI can cost $1000s and since the Raspberry Pi can integrate with several protocols it could be a decent replacement to save some $$$, £££, or €€€ depending on where you live. Of course it may take some knowledge on either HTM5 with websockets or using QT as your front ends.
Serve Sensor Data. Since many of the protocols developed in python, c++, and others include Server or RemoteIO like modes it can serve as a cheap sensor interface to a PLC. Normally a temperature sensor/transmitter either 4-20mA or 0-10v costs $100+ also. (unless you get this PT100 RTD 4-20mA for $8). What's great about the Pi is that is can handle tons of sensors and you can map it out it your programming. Keep in mind that none of these solutions are hardened for the industrial environment (although neither is the Raspberry pi....)
Custom Raspberry Pi.Lastly I am going to mention the customizable Raspberry Pi. Yes, Customizable! Element14 can customize the board to fit your process a little better. Adding Wifi, more GPIO, onboard Flash memory, and others.