0
\$\begingroup\$

I am using ParallelPort to do communicate with One Electric Device.

My Task on ParallelPort is to just start and stop device. For that I have write up following code: [My Code is written in C#.Net]

One static Class ParellelPort which contain Method static extern void Output(int address, int value).

public static class ParellelPort
    {
        [DllImport("inpout32.dll",EntryPoint = "Out32")]
        public static extern void Output(int address, int value);
    }

Using that method

I do write something on ParallelPort in my case just writing 1 and 0.

For starting and stopping Device. i using following Code.

private const int PORT_ADDRESS = 0x0378;
int startMachine = 1;
int stopMachine = 0;

ParellelPort.Output(PORT_ADDRESS, startMachine); //For starting Device.

ParellelPort.Output(PORT_ADDRESS, stopMachine);//For Stoping Device.

Now my PROBLEM IS,

Whenever i am starting CPU it cause start Device automatically as CPU writing on Parallel

Port each time it starts.

So starting of CPU start my DEVICE I need to get rid of it.

Is there any way to disable ParallelPort or way something like this to get rid of it.

NOTE:

I am using PIN-2 for Communicate with my device.

Each time I write value=1 on ParallelPort 5 volt is available at PIN-2 and

When write value=0 on on ParallelPort 0 volt is available at PIN-2 (this cause stops my Device).

And whenever CPU start 5 volt is available on each DataPort Pin from PIN-2 to PIN-9.

Thanks.....

\$\endgroup\$
1
  • \$\begingroup\$ This seems more like a superuser question to me (dealing with PC hardware and software) \$\endgroup\$ Commented Jul 28, 2011 at 18:31

3 Answers 3

1
\$\begingroup\$

The simplest way would be to look at two parallel port pins and use a small amount of logic.

If you look at both pins 2 and 3, for example you can do the following:

  • If both pin 2 and 3 are off, the device should be off.
  • If pin 2 is on but pin 3 is off, the device should be on.
  • If both pin 2 and 3 are on, the device should be off

This is called "Exclusive Or" or XOR and the truth table is as follows:

A   B   OUT
0   0   0
0   1   1
1   0   1
1   1   0

There are many ways of implementing this in hardware - the simplest is probably to use the 74xx86 (eg 74ls86 or 74hc86) logic chip. This contains 4 XOR gates which each has 2 inputs to it (you can get other input quantities, and chip densities).

For example:

XOR Circuit

Which could be turned into a circuit as such:

XOR PCB

\$\endgroup\$
7
  • \$\begingroup\$ Thank you so much for answering.... i don't know anything about electronics ,,,,,BTW,,does it require external power connection to operate with or using 74xx86 (eg 74ls86 or 74hc86) logic chip.. \$\endgroup\$ Commented Jul 28, 2011 at 8:39
  • \$\begingroup\$ Yes, it does. The 'LS' series run from 5V. \$\endgroup\$
    – Majenko
    Commented Jul 28, 2011 at 10:04
  • \$\begingroup\$ Is there any Component which can directly connect to say PIN-2 and PIN-3 and exactly work as XOR gate and don't requires external power or say Volt? Thank you so much for answering \$\endgroup\$ Commented Jul 28, 2011 at 10:27
  • \$\begingroup\$ I am not aware of one. 5V can be easily obtained from the computer itself - for instance from a nearby USB port (pin 1 is +5V, pin 4 is GND). \$\endgroup\$
    – Majenko
    Commented Jul 28, 2011 at 10:37
  • \$\begingroup\$ A slightly "Heath Robinson" solution. NPN transistor. Resistor R2from collector to V+. Resistor R1 from Pin 2 to base. \$\endgroup\$
    – Russell McMahon
    Commented Jul 28, 2011 at 10:40
0
\$\begingroup\$

If spurious operation of your device is potentially a problem, you should either disconnect it or keep it powered down except when your software is running, or make the turn on scheme more complicated. For example, you could use a microcontroller or a CPLD to require that a sequence of values be sent to "unlock" the device - the longer the sequence, the less likely it is to be accidentally activated.

Don't forget that the computer could randomly crash and reboot.

Lots of parallel-port motion control stuff may have been able to get around worrying that much about this if stepper motors are used; there it takes quite a number of pulses to move the motors any substantial distance - but if you are turning a motor on or off, you have a system that can easily run away if the software or operating system does the slightest thing unexpected. Where motors are involved, a big easily reached "Emergency Stop" button that electrically bypasses the software is not only a good idea, in many cases it may be a regulatory requirement.

Given that bit-addressable parallel ports are becoming hard to find, a microcontroller solution could also give you additional interface options - serial, or usb (either native or as a usb-serial converter).

\$\endgroup\$
0
\$\begingroup\$

These are simple alternatives to the better but more complex hardware answer from Matt. They may or may not work. If they do you have a simple solution BUT one which could stop working in future. Understanding why it is doing what it does is a first step to fixing things. See Matt & Chris's answers for this.

Possible fixes:

  • Consider writing a STOP command as soon as your program gains control. This won't stop the startup "glitch" but MAY make it insignificant. (Long ago I had a system that used to despool reel to reel data tape onto the floor for the same reason :-) ).

  • Consider trying inverted logic with high = stop and low = go. This may or may not work depending on other factors.


A slightly "Heath Robinson" no-power solution related to the XOR gate solution.

NO power supply required, very compact.

This implements

  • (Pin2 AND NOT(PIN3)). ie

  • It raises output only when Pin2 = high and Pin3 = low.

enter image description here

So: "Device will be high (V+) only when P2p3 = hI/lO.

"Device" will remain low for hi/hi, lo/hi, lo/lo.


Re your question: "i think i just have to put NOT gate...at my input.....Isn't it?"

Answer: Maybe!

As I said - this MAY work, depending on other factors. If the line is lowered and raised several times during setup it may fail.

For a certain result see Matt's reply or my transistor only gate above.

If relying on a "gate" solution, you need a solution where the output is active only when one input is high and one is low. Matt does this with an XOR. My transistor is effectively an AND in which one input MUST be inverted. Out = (A and /B) where / = inversion.

\$\endgroup\$
4
  • \$\begingroup\$ ya this is also a good solution.....thank you so much for replying....... \$\endgroup\$ Commented Jul 28, 2011 at 10:14
  • \$\begingroup\$ i think i just have to put NOT gate...at my input.....Isn't it? \$\endgroup\$ Commented Jul 28, 2011 at 10:15
  • \$\begingroup\$ MaMahon, thank you so much for your valuable suggestion...now i will try it....and feeling sad that i can't up vote your answer(require 15 reputation). \$\endgroup\$ Commented Jul 29, 2011 at 5:34
  • \$\begingroup\$ Try it first - be happy only if it works for you :-). Note that the load current to drive output "Device" is provided by pin 2, which needs to be able to supply the current - should be OK if it's treated as a signal output ajd not expected to supply substantial current. Resistor to base can be say 1k to 10k (maybe much higher but that provides lots of drive which reduces transistor saturation voltage. The voltage on "Device" will be slightly lower than on pin 2 due to transistor saturation voltage. Usually this will be OK. \$\endgroup\$
    – Russell McMahon
    Commented Jul 29, 2011 at 5:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.