LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-23-2006, 03:39 PM   #1
sparkyssb
LQ Newbie
 
Registered: Jun 2006
Posts: 3

Rep: Reputation: 0
Serial/Parallel/Game Port Interfacing


Hello,

I am looking to hook my security system into my linux server so that when the security system triggers a relay or drops a voltage, it can be detected by the server so that it can do a command/run a script.

I have been reading about how to make your own circuit to interface with either serial/parallel/or game port however I don't really want to design this if I don't have to. I am doing this for a company so money is not really an object. I was wondering if anybody premade these type of interfaces? I would also like some direction on software to use or code examples that can trigger the commands. If I have to design the interface myself, how complex is it and can you possibly give me a parts list?

Thank you for your time and I hope you can help!

Eric Lucas
 
Old 06-23-2006, 04:19 PM   #2
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
I'm not sure if some one's pre-made any general application to interface with security systems, but if you know BASIC (to some extent) I know Gambas has some pretty slick serial interfacing features.

I hope that helps.

 
Old 06-24-2006, 09:13 AM   #3
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Lenny/Squeeze/Wheezy/Sid
Posts: 4,087

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
If this is a professional application, I can recommend you to buy a simple I/O card. Use it either directly or with a relay interface to the outside world.

Cyberresearch.com stocks every conceivable I/O you might need.

Then (and this is the answer to your question) use the Comedi library to interface to the hardware. I don't know the URL, but google for it, and you'll find it. Extremely versatile, portable and reliable. I have used it in various projects.

jlinkels
 
Old 06-28-2006, 02:19 PM   #4
sparkyssb
LQ Newbie
 
Registered: Jun 2006
Posts: 3

Original Poster
Rep: Reputation: 0
Thank you for your answers guys/gals! However, I only need 1 input and not multiple which it looks like Cyberresearch.com has. Also, it requires a lot to make the stuff work. All I need is a simple interface to drop a votage on a pin so a program can run a command. Anybody else have any ideas?

Thanks again.
 
Old 06-28-2006, 02:32 PM   #5
FLLinux
Member
 
Registered: Jul 2004
Location: USA
Distribution: Fedora 9, LFS 6.3, Unbuntu 8.04, Slax 6.0.7
Posts: 145

Rep: Reputation: 15
If you wanted something quick and dirty like that you can use a serial port and have your script watch for the ring line on the RS-232 connection to go high. I think you have to pull it high with like 5 or 12 volts (can't remember off the top of my head) to get the script to see it, but it is easy to do and does not require much in the way of hardware. At one point i had a script around here that ran in the back ground and just watched for the ring line on the port 1 to go high and then it ran a program or what not.

Hope that helps.
 
Old 06-28-2006, 05:28 PM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
I don't recommend using RS-232 inputs, since the voltage levels output by your transducer is unlikely to be compatible with RS-232. RS-232 uses bipolar voltages levels, +/- 12V, and -3V to +3V at an input pin is considered to be invalid, and results in undefined behavior.

If you have a relay contact closure to work with, you can drive a TTL input on a parallel port with it. Connect 2 or more of the output data port pins together, drive them all to a high (nominal +5V) level, and couple that back through the relay contact closure to one of the parallel port inputs pins. Place a high value resistor, say 1Megohm, between the input pin and ground. The whole business can be wired inside the hood of the parallel port connector. You may need to guard against contact bounce using this method. While a relay seems to make and break cleanly, in reality each closure is a series of rapid make-break events that a fast computer will be able to detect discretely.

If you have a TTL level output from your transducer, just drive an input pin on the parllel port with it. Don't forget to wire the ground connection between the transducer and the PC.

THere is plenty of online information on programming the PC parallel port, both in generic terms, and Linux-specificly.

Hope this helps.

--- rod.

Last edited by theNbomr; 06-28-2006 at 05:29 PM.
 
Old 06-28-2006, 08:47 PM   #7
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
I'm glad you guys/gals understand chip circuitry (ie. transducers) and such.

For the programming aspect of it, there are two methods to take:
1) ASM
This will undoubetly prove to be the most time-consuming, and archaic method of programming a chip. However, it is also the most supported due to the fact that you can completely control the flow. If this is the direction you want to head in, check out MPLAB (Microchip IDE). This requires a hefty knowledge of ASM (assembler) and C, and is made with highest support for the Microchip PIC processors.

2) Gambas
This is an easier, slightly more elegant, but less-powerful method of serial port-interfacing. The previous suggestion was for programming chips, and I realize that, but a chip that interfaces with a serial port may be your solution. Using Gambas is very much akin to learning BASIC-based electronics/robotics programming. I know for a fact that Gambas has, not only support, but detailed tutorials on how to interface with a serial port. I, personally use Gambas for everything under the sun - what I lack in C/C++ knowledge, I make up for in BASIC knowledge.

While the other people in this discussion can offer valuable insight towards the hardware and circuitry, I can offer a helping hand in the software and interfacing.



I hope this has at least some value.
 
Old 06-29-2006, 12:46 PM   #8
sparkyssb
LQ Newbie
 
Registered: Jun 2006
Posts: 3

Original Poster
Rep: Reputation: 0
Thank you all.

Has anybody ever used parapin? Take a look at it: parapin.sourceforge.net

I think that is exactly what I'll use along with the suggestion from theNbomr above.

Anybody disapprove?
 
Old 06-29-2006, 01:41 PM   #9
davcefai
Member
 
Registered: Dec 2004
Location: Malta
Distribution: Debian Sid
Posts: 764

Rep: Reputation: 32
A couple of years ago I was asked to set up a data logging system (temperature recording and alarm) for the cold stores of a subsidiary.

I found a neat little data logging system which was in fact overkill but very convenient. This thing has modules for recording all sorts of things into RAM and can then download the data to a PC via a serial port.

For this project you'd use the door microswitch module and poll the logger every few seconds.

I forget even the name of the logger - it's that good that I haven't been called out for several months.

OK you're talking about, say Ä500-600 but you could "justify" it by doing more with it. You can even control an aquarium with it. I can give you sample code (VB, sorry) which you could adapt to whatever language you want to use.

If interested post a reply & I'll dig out the details tomorrow at work.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
serial and parallel port with DMESG command froglinux Linux - Hardware 1 06-16-2006 08:51 PM
interfacing using parallel port divu Programming 1 04-13-2006 08:39 AM
Parallel port/i2c interfacing question Mike Davies Linux - Hardware 0 10-01-2005 08:45 AM
interfacing using perl(parallel port) teao Programming 1 07-29-2003 03:47 AM
serial/parallel port marco_aq Linux - Networking 1 10-12-2001 02:44 PM


All times are GMT -5. The time now is 07:10 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration