RS232, PLC and Python.


10 posts
by Arceles » Tue Jun 26, 2012 3:07 pm
Good day everyone, this is my first post regarding this little tiny but handy device.

Recently in my work it has come to our attention the power that packs the Raspberry Pi and the fact that it can use an UART like the RS232.

The thing is, where are completely newbies regarding linux, all our environments have been in windows and visual basic (we are a very small group of guys that serve automation purposes).

So, having said all of this our questions goes more or less like this:

Is there an example of data acquisition through rs232 for raspberry?

Which is the best way to save acquisitions into a txt file? say... 100 acquisitions create a new txt file?

I myself have a bit of experience with ubuntu and the ps3 but my knowledge goes only as far as installing programs and the os itself, my knowledge in programming is mostly C, Basic and Visual Basic, we want to try python for the easy to learn curve that it apparently has.

Please note that I'm not exactly asking for the code but rather... where to start, for example how to compile phyton examples and how to run them into the raspberry, in this very case the RS232 is essential for this.

Thank you very much in advance for all your help, we really appreciate it.
Posts: 12
Joined: Tue Jun 26, 2012 2:56 pm
by bryancole » Wed Jun 27, 2012 6:27 am
For RS232, you need the PySerial package. See

http://pyserial.sourceforge.net/

On linux, it's a fairly simple wrapper for the /dev/ttyS* serial port devices but it makes RS232 access fairly painless.

HTH
BC
Posts: 9
Joined: Sun Jun 10, 2012 7:47 am
by bryancole » Wed Jun 27, 2012 7:07 am
To comment on your question about saving acquisitions to a file: you can use a txt-file if you like, but pythom makes a few other options available. sqlite is an embedded SQL database which comes with python and is good for relational or table-like data. If your acquisitions comprise a block of numbers (arrays of data), HDF5 (via the PyTables library - http://www.pytables.org) might be a good option although I've not tried it on the RPi. An alternative to PyTables is h5py (http://h5py.alfven.org/docs-2.0/) which might be easier to build on the RPi.

BC
Posts: 9
Joined: Sun Jun 10, 2012 7:47 am
by Arceles » Wed Jun 27, 2012 2:56 pm
Thank you very much for the information, now the problem that is more or less left is how to begin to program in python for the Raspberry Pi device, is there any tutorial available about how to begin in it?
Posts: 12
Joined: Tue Jun 26, 2012 2:56 pm
by walney » Wed Jun 27, 2012 3:03 pm
You could start here for some tutorials:

http://zetcode.com/tutorials/pythontutorial/
User avatar
Posts: 233
Joined: Wed Nov 30, 2011 6:57 pm
by Arceles » Wed Jun 27, 2012 3:15 pm
walney wrote:You could start here for some tutorials:

http://zetcode.com/tutorials/pythontutorial/


And... out of curiosity one for raspberry pi or the debian distribution that it can be put onto the device?
Posts: 12
Joined: Tue Jun 26, 2012 2:56 pm
by Arceles » Wed Jun 27, 2012 7:26 pm
Arceles wrote:
walney wrote:You could start here for some tutorials:

http://zetcode.com/tutorials/pythontutorial/


And... out of curiosity one for raspberry pi or the debian distribution that it can be put onto the device?


Nevermind, I see that is included, thank you a lot guys!
Posts: 12
Joined: Tue Jun 26, 2012 2:56 pm
by joeycmsu » Thu Jun 28, 2012 2:50 pm
I liked the tutorial included with ActiveState's ActivePython software set - you might look into that one for a general introduction to Python.

I also work with PLCs in an industrial automation regard, so keep us updated with what progress you make. I'd like to know what you end up using your RPi for.
Posts: 1
Joined: Wed Jun 27, 2012 3:08 am
by xordiss » Sun Feb 03, 2013 3:30 am
I made a script for changing operation mode(RUN, HALT,MONITOR) for a OMRON CQM PLC using serialpy and pythonCard .
If anyone interested i can search the code and post here .
Posts: 4
Joined: Tue Jan 29, 2013 12:55 am
by zabec » Mon Feb 17, 2014 5:44 pm
xordiss wrote:I made a script for changing operation mode(RUN, HALT,MONITOR) for a OMRON CQM PLC using serialpy and pythonCard .
If anyone interested i can search the code and post here .


Hi! I'm interested in this script. Can you share it with us?

Thanks.
Posts: 1
Joined: Wed Jul 18, 2012 6:15 am