Вы находитесь на странице: 1из 5

Automatic Power Toggling for Test Systems

Automate Power Toggling for test Machines

Automatic Power Toggling for Test Systems

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.

Automatic Power Toggling for Test Systems

Developing Program for Controlling PS/2


Need for a Driver I/O ports cannot be accessed directly in operating systems Windows NT/XP/2000 without a device driver. PortTalk device driver is chosen for the following reasons: Source Code of the device driver is available. Works for I/O ports like COM and PS/2. Ease of programming with this driver.

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.

PS/2 Port Architecture

Automatic Power Toggling for Test Systems

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.

Steps for writing the program


Initialize the driver and start the service for the driver DeviceIoControl call is used with IOCTL_IOPM_ALLOW_EXCUSIVE_ACCESS parameter for giving access to all ports. DeviceIoControl call is used with IOCTL_ENABLE_IOPM_ON_PROCESSID parameter for giving the executable(program) the access to the ports Disable interrupts for the port address(0x60) Call _outp with value 1 for port address(0x60) to set the data line to 0V.

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.

Automatic Power Toggling for Test Systems

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

Вам также может понравиться