Академический Документы
Профессиональный Документы
Культура Документы
Introduction
In verification & Validation projects, test scripts are primarily used to provide inputs to test system/target. The advantage with these scripts are that they can be batched together in order to execute different scenarios. There are some scenarios those that require the target to be reset/restarted. This How To details how such scenarios can be automated using simple programs. Environment Required The following step of toggling voltage source of 5V was carried out in this regard. Concept works on the principle of Open collector Output on ICs. The interface chosen for this is a PS/2 port available in computers. Usually this port is used for connecting Keyboard/Mouse. To control PS/2 port the following are required: Driver for the port. Program that uses the driver to control the port Multimeter to check the voltage across data and ground pins.
PS/2 controller port mapping and Pin out diagrams are needed to develop this program, that can control the voltage outputs are the pin outs of the PS/2 ports. Knowledge of Open Collector output would be an added advantage.
The open lines of PS/2 correspond to +5V(HIGH) and program sets the data line LOW(0V) by writing a value of 1 in the output port(0x60). Before using setting the data line to LOW, driver needs to be initialized with DeviceIoControl calls to grant the program to take control of the PS/2 ports. Once the above step is successful then interrupts needs to disabled for that port and then data can be send on the data line of the PS/2 port. Provide delay of few hundred milliseconds before pulling the line LOW. Address If we write to Port 0x60 it is termed as data byte which can be measured across Pins 1 and 3. Assumptions On a PC with keyboard/Mouse connected on PS/2 while this program executes causes the devices to become non as we do not wait for the input buffer(0x64) to clear before setting data byte to 1. System needs to be restarted for the devices to work again.
Snippet of the program _outp(0x60 + 0x402, 1<<5);// Disables the interrupt _outp(0x60 , 1); // Sets the line to 0V The above line of code brings down the voltage to 0V which otherwise is at +5V.
Conclusion
This method can be used to toggle the power output ON/OFF(HIGH/LOW) with the help of program. This program would turn the PS/2 port into electronic relay unit.
References
http://www.beyondlogic.org/porttalk/porttalk.htm http://en.wikipedia.org/wiki/Open_collector http://wiki.osdev.org/PS2_Keyboard http://www.win.tue.nl/~aeb/linux/kbd/scancodes-11.html#outputport