Linux based analog to digital converter

What is an ADC, and why do we need one?

In our daily life, anything we deal like sound, pressure, voltage or any measurable quantity, are usually in analog form so what if we want to interface any analog sensor with our digital controllers? There must be something that translates the analog inputs to digital output, and so analog to digital convertors come to play. Let's start with a simple example: suppose we had an outdoor unit where we wanted to monitor the sound, pressure, voltage or any measurable quantity on a regular basis. Obviously, we would put a circuit inside the unit and walk out to read the measurement. We wanted to know the value. This could obviously become a hassle, especially during inclement weather. To make it more convenient, we could put a remote readout inside our home. In order for the remote readout to work, though, we need to convert the measurement reading into an electrical signal that can be read by the remote readout. Usually we call them ADC (Analog to digital convertor). Before going to learn how to interface an ADC with a controller we first take a look at basic methods of analog to digital conversion.
This is a sample of the large number of analog-to-digital conversion methods. The basic principle of operation is to use the comparator principle to determine whether or not to turn on a particular bit of the binary number output. It is typical for an ADC to use a digital-to-analog converter (DAC) to determine one of the inputs to the comparator. So how does a device like the remote readout work?
The answer is actually quite simple. It works on the principle of changing electrical currents and voltages. Some specialized electronics components change the currents or voltages in a circuit with a change in measurement. We simply use these components in a circuit that outputs a voltage that is proportional to a changing measurement. Then we use our ADC to change the voltage (an analog signal) into a digital signal. A device such as the remote readout is programmed to display different values for a given digital signal. Although we've skipped over a lot of the finer details, we can now at least understand the concepts behind analog to digital conversion and why it is necessary.

Instructions for making an ADC

To build the ADC that we used for our project, it is necessary to have some basic knowledge of circuit diagrams and soldering. If you have no prior experience with these items, you may find a basic "do-it-yourself" manual for electric circuitry to be of some assistance.
The first thing you need to do in order to build the circuit is to obtain the necessary electronics components. Most of these components can be obtained from a similar electronics supply store, with the exception of the IC chips, which is also the company that supplied the circuit design. Be sure to read the notes below the parts list regarding some purchasing issues.

Tips on Circuit Construction

1) First and foremost, try to have a layout of how you want to place all the components on the PC board before you begin soldering. Taking this extra step can eliminate a lot of confusion and unnecessary wiring during assembly.
2) If you purchased the PC board from the parts list, use one (or both if you connect them) of the solid strips that runs around the perimeter of the board in order to make all your ground connections. It is much easier to do this than to run an individual ground wire for every ground connection.
3) make sure to orient the diodes correctly in the circuit. The whole point of a diode is to only let current flow one way (like a check valve), so if you get the two ends switched, the circuit will not function because current will not flow through the diode.
4) Also be sure to take note of the proper pin numbering on the IC chips. The circuit diagram has the connections to the chips laid out by pin number, not by visual position. The proper IC chip orientation and pin numbering is as follows:
Note that the semicircle at the "top" of the chip indicates the position of Pin 1. If there is no semicircle, then Pin 1 will be indicated by a dot as shown in the diagrams. Regardless of how Pin 1 is indicated, the numbering remains the same.
5) Be sure to orient the electrolytic capacitors in the proper direction, as they are polar (unless otherwise noted). The negative lead is always the shorter lead and will be indicated by a series of minus symbols on the corresponding side of the capacitor.
6) The numbers for the parallel port terminals are written on the connector itself right next to the pins. The numbers are rather small, so be careful not to confuse them, as the connections to the parallel connector are indicated by pin number on the circuit diagram.
7) The ground connections on the circuit diagram are indicated by a symbol that looks like this: .
8) Any IC pins marked "N.C." are not connected to anything else in the circuit.
9) For the input wires (shown in the lower right-hand corner of the diagram), the positive wire is connected to the resistor "R5", and the negative wire is connected to ground.

Testing the ADC

Once the circuit is built, it can be tested using the program found in ADC circuit description. You simply connect the circuit to your PC using the parallel port, apply an input voltage to the input wires, and the test program will produce a value for the given voltage. A good test for the circuit is to connect the input wires to a function generator running a sine wave, and verify that the output values reproduce a sine wave when graphed. In order to do this, however, the test source program must be modified. Shown below is the graph that we obtained from the ADC test values:

The digital values are divided by 255 because the signal is a 8-bit signal. Since the signal is binary, 8-bits translates to 2^8, or 255. 1 is subtracted from that value for conversion purposes, making it 255. The values are also multiplied by 4.5 to obtain an approximate magnitude for the signal readings. The signal we used was slightly over 4 Volts, so we used 4.5 just to be safe. Once the digital values are converted using the above formula, they should produce a graph something like the one above when graphed vs. time.

Following steps are involved in the procedure to display ADC output at the terminal using Linux environment. We want to read ADC output from parallel port so first we need permission to access parallel port. After accessing parallel port we initialize

parallel data port D0 to D7 to zero. We now that by default we can write data to parallel port if we need to read data from parallel port we need to send control signal to parallel port to make it ready for reading.
After doing all above step we are able to read parallel port. These all steps belong to our program (software) for reading data.
In this project analog source is variable resistance this resistance is connected on analog input of ADC.ADC convert these analog resistances into digital output these output pins of ADC are connect to data pin of parallel port D0 to D7. We know computer only deal with binary so we must give digital data at parallel port.
When we run code output of ADC will appear on output.
The Parallel Port is the most commonly used port for interfacing. This port includes input of up to 9 bits or the output of 12 bits. The port is composed of 4 control lines (i.e. pins 1, 14, 16, 17), 5 status lines (i.e. pins 10, 11, 12, 13, 15) and 8 data lines (i.e. pins 1, 2, 3, 4, 5, 6, 7, 8, 9). It's found commonly on the back of your PC as a D-Type 25 Pin female connector.

No comments:

Post a Comment