Tampilkan postingan dengan label microcontroller. Tampilkan semua postingan
Tampilkan postingan dengan label microcontroller. Tampilkan semua postingan

Senin, 29 September 2008

Build Digital to Analog Converter Using 0808


The first task this week is to build a simple D/A convertor and evaluate its performance. You will be using a DAC0808 (DAC0808 datasheet).Your design should take 8 bits from the microcontroller (use the 8 8bits on Port 0 of the AT89s51 as the input to the D/A convertor). The D/A output should range from 0 to 5 volts. The lower 8 bits from the AT89s51 should go into the 8 bits from the DAC0808. Note: I expect you to try to get the device to work by reading the datasheet and trying to understand it, if you have trouble you should come see me, but I expect you to have fairly specific questions that indicate you have put some thought into the problem.

Things to consider with the this design:

Figure 2.6.1 from page 4 of the DAC0808 datasheet is a good place to start your design.
The pins are labeled A1 through A8, but note that A1 is the Most Significant Bit, and A8 is the Least Significant Bit (the opposite of the normal convention). Ground the two least significant bits.
The D/A convertor has an output current, instead of an output voltage. The output pin should stay at about 0 volts. The op-amp on the "Typical Application" on the datasheet converts the current to a voltage. How does it do this?
The output current from pin 4 ranges between 0 (when the inputs are all 0) to Imax*255/256 when all the inputs are 1. The current, Imax, is determined by the current into pin 14 (which is at 0 volts). Note: Since we are using 8 bits, the maximum value is Imax*255/256.
You'll need to modify the circuit given in the datasheet to get a full scale range of 0 to 5 volts. Again, our output will be just under 5 volts. The output of the D/A convertor takes some time to settle. You may need to take this in consideration when planning the timing of the A/D conversion in later sections of this lab. Check the DAC0808 datasheet for specs. The code below shows an easy way to send 8 bits to the output of the microcontrollerr. You should probably test your code without the D/A convertor separately to ensure that the microcontroller is behaving as you expect

K E Y P A D 4 x 4 (2)


Keypads are often used as a primary input device for embedded microcontrollers. The keypads actually consist of a number of switches, connected in a row/column arrangement as shown in Fig 2.8.1.

In order for the microcontroller to scan the keypad, it outputs a nibble to force one (only one) of the columns low and then reads the rows to see if any buttons in that column have been pressed. The rows are pulled up by the internal weak pull-ups in the 8051 ports. Consequently, as long as no buttons are pressed, the microcontroller sees a logic high on each of the pins attached to the keypad rows. The nibble driven onto the columns always contains only a single 0. The only way the microcontroller can find a 0 on any row pin is for the keypad button to be pressed that connects the column set to 0 to a row. The controller knows which column is at a 0-level and which row reads 0, allowing it to determine which key is pressed. For the keypad, the pins from left to right are: R1, R2, R3, R4, C1, C2, C3, C4

The Algorithm

Matrix-type keypads consist of a rectangular array of momentary push button. Each row and each column of push buttons is connected to a common rail. Suppose a four by four array of push button are used. A four by four array is often used to input hexadecimal numbers. There are four comun rails and four row rails. Each pushbutton has two terminals, one connected to its column rail and the other to its row rail. The row and column rails are connected to the microcontroller ports. The columns are driven low by output port. The rows are then read into the input ports. If no key is pressed, the rows read 1. When a row is detected to be 0, it indicates that a key in that row is pressed. the task now is to detect which key of the row is actually pressed. The microcontroller loops through each column, driving only one column low at a time as it inspects the row.The microcontroller needs to poll the rows to see if a key is pressed. Only when the column in which the pressed key resides is driven low is the row rail grounded, and thus the voltage is low. The rows and columns are interchangeable, that is, the rows may be driven low as the columns are read by the input ports.