LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Serial/Parallel/Game Port Interfacing (https://www.linuxquestions.org/questions/programming-9/serial-parallel-game-port-interfacing-457665/)

sparkyssb 06-23-2006 03:39 PM

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! :cool:

Eric Lucas

indienick 06-23-2006 04:19 PM

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.

:D

jlinkels 06-24-2006 09:13 AM

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

sparkyssb 06-28-2006 02:19 PM

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.

FLLinux 06-28-2006 02:32 PM

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.

theNbomr 06-28-2006 05:28 PM

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.

indienick 06-28-2006 08:47 PM

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.

sparkyssb 06-29-2006 12:46 PM

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?

davcefai 06-29-2006 01:41 PM

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.


All times are GMT -5. The time now is 01:14 AM.