7 segment rolling display using PC

 It is very interesting and convenient to be able to control everything while sitting at your PC terminal. Here, a simple hardware circuit and software is used to interface a 7-segment based rolling display. The printer port of a PC provides a set of points with some acting as input lines and some others as output lines. Some lines are open collector type which can be used as input lines. The circuit given here can be used for interfacing with any type of PC�s printer port. The 25-pin parallel port connector at the back of a PC is a combination of three ports. The address varies from 378H-37AH. The 7 lines of port 378H (pins 2 through 8) are used in this circuit to output the code for segment display through IC1. The remaining one line of port 378H (pin 9) and four lines of port 37AH (pins 1, 14, 16, 17) are used to enable the display digits (one a time) through IC2. The bits D0, D1 and D3 of port 37AH connected to pins 1, 14 and 17 of �D� connector are inverted by the computer before application to the pins while data bit D2 is not inverted. Therefore to get a logic high at any of former three pins, we must send logic 0 output to the corresponding pin of port 37AH. Another important concept illustrated by the project is the time division multiplexing. Note that all the five 7-segment displays share a common data bus. The PC places the 7-segment code for the first digit/character on the data bus and enables only the first 7-segment display. After delay of a few milliseconds, the 7-segment code for the digit/character is replaced by that of the next charter/digit, but this time only second display digit is enabled. After the display of all characters/digits in this way, the cycle repeats itself over and over again. Because of this repetition at a fairly high rate, there is an illusion that all the digits/characters are continuously being displayed. DISP1 is to be physically placed as the least significant digit. IC1 (74LS244) is an octal buffer which is primarily used to increase the driving capability. It has two groups of four buffers with non-inverted tri-state outputs. The buffer is controlled by two active low enable lines. IC2 (75492) can drive a maximum of six 7-segment displays. (For driving up to seven common-cathode displays one may use ULN2003 described elsewhere in this section.) The program for rolling display is given in the listing DISP.C above. Whatever the message/characters to be displayed (here five characters have been displayed), these are separated and stored in an array. Then these are decoded. Decoding software is very simple. Just replace the desired character with the binary equivalent of the display code. The display code is a byte that has the appropriate bits turned on. For example, to display character �L�, the segments to be turned on are f, e and d. This is equivalent to 111000 binary or 38 hex. Please note that only limited characters can be formed using 7-segment display. Characters such as M, N and K cannot be formed properly.


PC based Frequency Meter

Here is a simple technique for measuring frequencies over quite a wide frequency range and with acceptable accuracy limits using a PC. It follows the basic technique of measuring low frequencies, i.e. at low frequency, period is measured for a complete wave and frequency is calculated from the measured time-period. Cascaded binary counters are used for converting the high-frequency signals into low-frequency signals. The parallel port of a computer is used for data input from binary counters. This data is used for measuring time and calculating the frequency of the signal. The block diagram shows the basic connections of the counters and parallel port pin numbers on 25-pin �D� connector of a PC (control register 379 Hex is used for input). External hardware is used only for converting the higher frequency signals into low frequency signals. Thus, the major role in frequency-measurement is played by the software. The PC generates a time-interrupt at a frequency of 18.21 Hz, i.e. after every 54.92 millisecond. Software uses this time-interrupt as a time-reference. The control register of the PC�s parallel port is read and the data is stored continuously in an array for approximately 54.9 ms using a loop. This stored data is then analysed bit-wise. Initially, the higher-order bit (MSB or the seventh-bit) of every array element is scanned for the presence of a complete square wave. If it is found, its time period is measured and if not then the second-highest order bit (sixth bit) is scanned. This operation is performed till the third bit and if no full square wave is still found, an error message is generated which indicates that either there is an error in reading or the frequency signal is lower than 19 Hz. Lower three bits of the control register are not used. When a wave is found, along with its time-period and frequency components, its measurement precision in percentage is also calculated and displayed. Number of data taken in 54.9 ms is also displayed. As stated above, the lower starting range is about 19 Hz. Data is read for approximately 54.9 ms. Thus, the lowest possible frequency that can be measured is 1/.0549 Hz. Lower range depends only on the sampling time and is practically fixed at 19 Hz (18.2 Hz, to be precise). Upper range depends on factors such as value of the MOD counter used and the operating frequency range of the counter IC. If MOD-N counter is used (where N is an integer), upper limit (UL) of frequency is given by UL=19xN5 Hz. Thus for MOD 16 counters UL@20 MHz, and for MOD 10 counters UL@1.9 MHz. Care should be taken to ensure that this upper limit is within the operating frequency range of counter IC used. Precision of measurement is a machine-dependent parameter. High-speed machines will have better precision compared to others. Basically, precision depends directly upon the number of data read in a standard time. Precision of measurement varies inversely as the value of MOD counter used. Precision is high when MOD 10 counters are used in place of MOD 16 counters, but this will restrict the upper limit of frequency measurement and vice-versa.


Simple Analog to Digital Converter

Normally analogue-to-digital con-verter (ADC) needs interfacing through a microprocessor to convert analogue data into digital format. This requires hardware and necessary software, resulting in increased complexity and hence the total cost.
The circuit of A-to-D converter shown here is configured around ADC 0808, avoiding the use of a microprocessor. The ADC 0808 is an 8-bit A-to-D converter, having data lines D0-D7. It works on the principle of successive approximation. It has a total of eight analogue input channels, out of which any one can be selected using address lines A, B and C. Here, in this case, input channel IN0 is selected by grounding A, B and C address lines.
Usually the control signals EOC (end of conversion), SC (start conversion), ALE (address latch enable) and OE (output enable) are interfaced by means of a microprocessor. However, the circuit shown here is built to operate in its continuous mode without using any microprocessor. Therefore the input control signals ALE and OE, being active-high, are tied to Vcc (+5 volts). The input control signal SC, being active-low, initiates start of conversion at falling edge of the pulse, whereas the output signal EOC becomes high after completion of digitisation. This EOC output is coupled to SC input, where falling edge of EOC output acts as SC input to direct the ADC to start the conversion.
As the conversion starts, EOC signal goes high. At next clock pulse EOC output again goes low, and hence SC is enabled to start the next conversion. Thus, it provides continuous 8-bit digital output corresponding to instantaneous value of analogue input. The maximum level of analogue input voltage should be appropriately scaled down below positive reference (+5V) level.
The ADC 0808 IC requires clock signal of typically 550 kHz, which can be easily derived from an astable multivibrator constructed using 7404 inverter gates. In order to visualise the digital output, the row of eight LEDs (LED1 through LED8) have been used, wherein each LED is connected to respective data lines D0 through D7. Since ADC works in the continuous mode, it displays digital output as soon as analogue input is applied. The decimal equivalent digital output value D for a given analogue input voltage Vin can be calculated from the relationship

Control electrical appliances using PC

Here is a circuit for using the printer port of a PC, for control application using software and some interface hardware. The interface circuit along with the given software can be used with the printer port of any PC for controlling up to eight equipment .
The interface circuit shown in the figure is drawn for only one device, being controlled by D0 bit at pin 2 of the 25-pin parallel port. Identical circuits for the remaining data bits D1 through D7 (available at pins 3 through 9) have to be similarly wired. The use of opto-coupler ensures complete isolation of the PC from the relay driver circuitry.
Lots of ways to control the hardware can be implemented using software. In C/C++  one can use the outportb(portno,value) function where portno is the parallel port address (usually 378hex for LPT1) and 'value' is the data that is to be sent to the port. For a value=0 all the outputs (D0-D7) are off. For value=1 D0 is ON, value=2 D1 is ON, value=4, D2 is ON and so on. eg. If value=29(decimal) =   00011101(binary)  ->D0,D2,D3,D4 are ON and the rest are OFF.                       

Code Software in C :


/*program to control devices using PC parallel port
The devices are controlled by pressing the keys 1-8
that corresponds to each of the 8 possible devices
*/

#include<dos.h>
#include<stdio.h>
#include<conio.h>
#define PORT 0x378 /* This is the parallel port address */

main()
{
char val=0,key=0;
char str1[]="ON ";
char str2[]="OFF";
char *str;
clrscr();
printf("Press the approriate number key to turn on/off devices:\n\n");
printf("Here Device1 is connected to D0 of parallel port and so on\n\n");
printf("Press \"x\" to quit\n\n");
gotoxy(1,8);
printf("Device1:OFF Device2:OFF Device3:OFF Device4:OFF\n");
printf("Device5:OFF Device6:OFF Device7:OFF Device8:OFF");

while(key!='x' && key!='X')
{
gotoxy(1,12);
printf("Value in hex sent to the port:");
key=getch();
switch(key){

case '1':

    gotoxy(9,8);
    val=(val&0x01)?(val&(~0x01)):val|0x01;
    str=(val&0x01)?str1:str2;
    printf("%s",str);
    outportb(PORT,val);
    gotoxy(1,13);
    printf("%x",val);
    break;

case '2':

    gotoxy(21,8);
    val=(val&0x02)?(val&(~0x02)):val|0x02;
    str=(val&0x02)?str1:str2;
    printf("%s",str);
    outportb(PORT,val);
    gotoxy(1,13);
    printf("%x",val);
    break;

case '3':

    gotoxy(33,8);
    val=(val&0x04)?(val&(~0x04)):val|0x04;
    str=(val&0x04)?str1:str2;
    printf("%s",str);
    outportb(PORT,val);
    gotoxy(1,13);
    printf("%x",val);
    break;

case '4':

    gotoxy(45,8);
    val=(val&0x08)?(val&(~0x08)):val|0x08;
    str=(val&0x08)?str1:str2;
    printf("%s",str);
    outportb(PORT,val);
    gotoxy(1,13);
    printf("%x",val);
    break;

case '5':

    gotoxy(9,9);
    val=(val&0x10)?(val&(~0x10)):val|0x10;
    str=(val&0x10)?str1:str2;
    printf("%s",str);
    outportb(PORT,val);
    gotoxy(1,13);
    printf("%x",val);
    break;

case '6':

    gotoxy(21,9);
    val=(val&0x20)?(val&(~0x20)):val|0x20;
    str=(val&0x20)?str1:str2;
    printf("%s",str);
    outportb(PORT,val);
    gotoxy(1,13);
    printf("%x",val);
    break;

case '7':

    gotoxy(33,9);
    val=(val&0x40)?(val&(~0x40)):val|0x40;
    str=(val&0x40)?str1:str2;
    printf("%s",str);
    outportb(PORT,val);
    gotoxy(1,13);
    printf("%x",val);
    break;

case '8':
    gotoxy(45,9);
    val=(val&0x80)?(val&(~0x80)):val|0x80;
    str=(val&0x80)?str1:str2;
    printf("%s",str);
    outportb(PORT,val);
    gotoxy(1,13);
    printf("%x",(unsigned char)val);
    break;

    }

}


}

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | cheap international calls