473,795 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python in Process Control?

Hello,

is it that my know-how to use Google is insufficient or...

....does really noone use Python for industrial control applications?

At least I didn't manage to find any publicly available modules for such
things as OPC/fieldbus communication etc...

TIA,

best regards,

Wolfgang Keller
Jul 18 '05
26 7728
Neil Benn wrote:
Just out of interest - which tecan robot were you interfacing
to - every Tecan robot that I've ever programmed comes with a high level
API (Toolbox, Gemini, Logic, WinWash, Magellen).
I meant to mention, but only barely implied, that the source is
actually available, on Engenuity's project page. It was a
Cavro RSP9000 robot.
I would think however
that controlling a tecan robot in the environment that it is typically
being used in (life sciences R+D) is not industrial control (its my job
BTW!). It's not like making milk....
I use the terms "industrial control" and "automation " rather
interchangeably , along with "laboratory robotics" and other
terms. It's all the same thing, regardless of the end user,
except when regulatory issues get involved (aeronautics, FDA
approvals, etc).
IMHO, I think that Python is not a suitable piece of software for
industrial control as it has poor support for bytes (a string shouldn't
be used to store bytes!) and also bit twiddling is difficult (people who
ask about his on the Python newsgroup are usually shouted at).
Well, let me see how to answer this politely. :-) What you *think*
and what is reality are not necessarily the same thing. ;-) No,
the more polite answer is really that this is an area where perhaps
it's more a matter of opinion than anything else, and mine differs
from yours.

Python certainly has *excellent* ("perfect"?) support for manipulating
bytes, and if you consider that a string is not a string, but is
actually a sequence of bytes, then other than being misnamed for
this application area, a string provides great support for bytes...
certainly *in practice* it works wonderfully, and I guess as someone
who has used Python very successfully for industrial control I'm
somewhat qualified to say so.

As for bit-twiddling, it's rarer than you might think to have to
do more than the odd shift, OR, and AND masking, and maybe an
exclusive-OR or two for spice, and Python is well enough suited that
this isn't really an issue. Performance-wise, if you have to do
such things to a very high-bandwidth stream of data, it might run
into troubles, but (a) there are options, and (b) it hasn't bothered
me yet...

I was going to show an example from the Cavro code mentioned above,
but all it took was a few | and & operations and it's too boring
to show.
The
other thing that is a problem for python in this is that it is very
difficult in python to make your your client is aware of all the errors
that you can throw and as you know, when controlling equipment there is
a lot of things that are out of your control (an exception that is
rarely thrown will often not be caught if the programmer never sees it
running and gets lazy).
Absolutely! Uncaught exceptions would be a real pain to a customer.

So would untested code.

Not using good testing procedures would be a real sign of carelessness
or sheer incompetence. I hope no one would subcontract for industrial
control software with anyone who would actually produce software of
the sort you describe above. Of course, I recommend and use test-driven
development for my code, and don't suffer from the problems you
describe. And did I mention that the software worked flawlessly the
first time it ran, and has had no bug reports in the month or two
of use it has seen since then? ;-)

Note also that these problems have nothing to do with Python,
and everything to do with poor programming practices.
apps a little easier to write - although I still spent about 2 days
trying to work out how to make a variable volatile (culminating in
understanding the threading module!).
All variables are "volatile" in Python, at least in most senses of
the word. I don't understand what you were doing...
The serial module is good but I
think that a model of input and output streams with listeners/observers
would make far more sense, currently I have to make a polling loop to
receive the data,
You might want to investigate the use of Twisted's serial module,
which wraps around PySerial and effectively provides this, instead
of doing the polling loop approach (which, by the way, I also used
in the Cavro code but might change to Twisted in a later version).
Good to see that you didn't use ActiveX (if one more company _boasts_
that their equipment comes with 'industry standard' ActiveX I think I'm
going to cry)!! Believe it or not I still have to interact with some
equipment using DDE!!!!


Actually, we *did* use ActiveX, unfortunately, because that's what
the customer wanted to use to interface LabVIEW to the driver. It
does work, and works reliably, but in the end it's the use of
LabVIEW for this stuff to which I object more strongly than I
object to the use of ActiveX. (Without LabVIEW in the picture,
however, ActiveX would also have been unnecessary, as we would
have gone pure-Python.)

-Peter
Jul 18 '05 #11
Peter L Hansen wrote:
Wolfgang Keller wrote:
There seem to be some Python bits out there, for example MatPLC and
Lintouch use Python and some commercial products as well (PyDACHS), but
unfortunately there doesn't seem to be a more or less consistent library
for industrial automation or a coordinated effort to build up one.

What, in your opinion, would it take to start one? I'm able to
offer the use of a server to host a web site, and would be happy
to register a domain name or something, but those are the easy
bits. Some kind of core group to get it off the group is likely
more important than a name, though sometimes threads in this
group might lead one to suspect otherwise. ;-)


No need to do servers/websites/domains, just use sourceforge...

David
Jul 18 '05 #12
On 2004-10-01, Neil Benn <be**@cenix-bioscience.com> wrote:
IMHO, I think that Python is not a suitable piece of software
for industrial control as it has poor support for bytes (a
string shouldn't be used to store bytes!)
It's incovenient, but it works. I often end up converting the
string representation to/from a list of integers.
and also bit twiddling is difficult (people who ask about his
on the Python newsgroup are usually shouted at).


Bit twiddling didn't used to be difficult, but it's getting
more so. :( Programs that used to be fine are now throwing
warnings about shift operations, hex constants, and things like
that.

A while back, somebody wrote a pure-python fixed-length integer
class that looked like it would be handy. A C implimentation of
byte arrays would be very handy, since then you wouldn't have
to convert back and forth between strings and lists of
integers.

The combination of a C-language byte-array and C-language
fixed-length integer operations would kill.

--
Grant Edwards grante Yow! I feel partially
at hydrogenated!
visi.com
Jul 18 '05 #13
David Fraser wrote:
Peter L Hansen wrote:
I'm able to offer the use of a server to host a web site, ...


No need to do servers/websites/domains, just use sourceforge...


SourceForge is, from my perspective, an incredibly unreliable
and awkward beast, and I'd be loathe to host anything on it
at this point. I _might_ host an actual project on it, but
I certainly wouldn't consider it for what I'm actually picturing
in this discussion, which is some sort of "Python in Automation"
"portal" or whatever they're called these days... something
along the lines of a combination of a wiki, maybe an RSS feed
(if someone will explain what the benefit is), a mailing
list, and maybe some sort of Vaults-style way for people to
provide links to their own projects (some of which, doubtless
would be SourceForge-hosted).

The simplest thing that could possibly work (tm) of course,
is a wiki and a mailing list, and I can have that up in
a few minutes if desired...

-Peter
Jul 18 '05 #14
In article <MJ************ ********@powerg ate.ca>,
Peter L Hansen <pe***@engcorp. com> wrote:
Jul 18 '05 #15
In article <ma************ *************** ***********@pyt hon.org>,
Neil Benn <be**@cenix-bioscience.com> wrote:
Jul 18 '05 #16

"Neil Benn" <be**@cenix-bioscience.com> wrote in message
news:ma******** *************** *************** @python.org...
IMHO, I think that Python is not a suitable piece of software for
industrial control as it has poor support for bytes (a string shouldn't
be used to store bytes!)


That's largely a matter of attitude I think; many would argue that byte
strings shouldn't be used to store text.
Jul 18 '05 #17
In article <ma************ *************** ***********@pyt hon.org>,
Neil Benn <be**@cenix-bioscience.com> wrote:
Jul 18 '05 #18
On Fri, 01 Oct 2004 15:08:11 GMT, cl****@lairds.u s (Cameron Laird)
declaimed the following in comp.lang.pytho n:
consistency of my observations. EVERY time I do process control,
there are days (sometimes--hold your hats; this is no
exaggeration--months (!)) of pleading, "No, I really want the
documentation where you say what it's supposed to do, and what it
really does", then the the getting-the-right-cables interval of
Not process control, but my current assignment fits this
roadblock quite well.

I'm stuck with writing a requirements document, software design
document, and then the software, to read a binary stream from device-X.
The only documentation I have for device-X is that I have a 2400baud
RS-232 connection. There is no documentation as to parity, word-length,
stop bits, or handshaking. I'm guessing 8N1 as it is binary data, but
will have to determine handshaking by trial&error.

Furthermore, I don't know how many bytes are in the data stream
per data item. The people who would know if it is fixed or variable
length, or if it even has a delimiter between data items, stonewall with
a "you have no need to know that information".

Scarier thought, device-X is loaded from device-Y which appears
to be using 5-level (+parity?) paper tape! (I'm sure it isn't a 9-pin
tape -- looked like 4pin, sprocket, 2pin). Maybe I'm expected to receive
5-bit data and convert to 8-bit to write as hex...

Just typical government imposed SNAFU... (and people wonder why
so many projects go over budget?)

-- =============== =============== =============== =============== == <
wl*****@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
=============== =============== =============== =============== == <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.ne tcom.com/> <

Jul 18 '05 #19
I work with process automation myself, and I belive that writing an OPC
server is *not* a trivial task, even in python. There are some good
books available on this subject, the OPC-foundations home page contains
some good references.

If you want to get started with client code quickly, you could try the
QuickOPC ($) library from OPC-labs (www.opclabs.com). Setting up a
client in python with that library is three lines of code (really!):
------
import win32com.client
import time
s = win32com.client .Dispatch('OPCL abs.EasyDA')

def test(times=1000 0):
v = s.ReadItem('',' Matrikon.OPC.Si mulation', 'Saw-toothed
Waves.Real8','' ,0)
t0 = time.clock()
for i in range(times):
v = s.ReadItem('',' Matrikon.OPC.Si mulation', 'Saw-toothed
Waves.Real8','' ,0)
print time.clock()-t0

test(1000)

Jul 18 '05 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
9910
by: Alex Hunsley | last post by:
I'm running a monitoring script under linux written in python. It's nohup'ed so that I can log out and it will continue running happily and so on, but sometimes I need to kill the script before editing the source and relaunching it. Question is, what's the nicest way to kill the python process under linux? Is a simple 'kill ' the nicest way to do it, or is there a different signal I should send it? ta alex
2
2896
by: Michele Simionato | last post by:
Is there a way to send a SIGINT/KeyboardInterrupt to a Python process (knowing the pid) that works both on Unix and Windows? Michele Simionato
8
4355
by: MackS | last post by:
Hello! This question does not concern programming in python, but how to manage python processes. Is there a way to "name" a python process? At least on Linux, if I have two python programs running, they both run under the name "python" #pidof program1.py #pidof program1.py
0
1672
by: Shanon | last post by:
Hi, I would to know if there're some way to have a dump of all the threads started by a python process. I want to see the TID corresponding of each thread because I need them to get the CPU time of each thread by the command top. Thanks -- View this message in context: http://www.nabble.com/Thread-Dump-of-a-python-process-t1089322.html#a2840609
4
3155
by: yossi.kreinin | last post by:
Hi! Is there a way to save the state of a Python process for later inspection with a debugger? One way to do this is to dump core, but is the result usable for debugging with pdb (it can be debugged by gdb, which can inspect PyObjects in a CPython core, for example, but it's not much fun)? If there is no way to do this today, are there essential difficulties in implementing this on top of an OS support for "raw" core dumps?
7
1535
by: tylerca | last post by:
I'm attempting to start some process control using Python. I've have quite a bit of literature on networking, and have made some tinkering servers and clients for different protocols HTTP, FTP, etc... But now it's time for the murky web of industrial protocol. I'm looking to start with IO and servo controls via Ethernet. Questions: Is there an existing forum on this already? What protocols are the most python friendly? i.e. are...
1
6758
by: Adam Atlas | last post by:
What is the best way for a Python process (presumed to be a script run by the interpreter binary, not embedded in some other program) to restart itself? This is what I've been trying: import __main__ for path in sys.path: path += '/' + __main__.__file__ if os.access(path, os.F_OK): break else:
1
4757
by: Salim Fadhley | last post by:
Does anybody know of a python module which can do process management on Windows? The sort of thing that we might usually do with taskmgr.exe or process explorer? For example: * Kill a process by ID * Find out which process ID is locking an object in the filesystem * Find out all the IDs of a particular .exe file * Find all the details of a currently running process (e.g. given an
0
982
by: Fredrik Lundh | last post by:
projects.gg.aaron@gmail.com wrote: do you control the other process? can you make it listen to a local socket or a named pipe? </F>
0
9522
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10165
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10002
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9044
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5565
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2921
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.