martes, 14 de junio de 2011

Comberter Dijital Analogic

Using the converter PCF8591, create a digital-analog converter.

The converter is 8 bits resolution and communicate with a high-end PIC (18F4550) via I2C.
To schedule use code language 'C ' (SCCS Compiler) and its simulation using Proteus.
The conversion will be displayed with the virtual oscilloscope Proteus.


Now that we are clear about the content of the exercise we will set the converter to work with him. The first thing to know is that it is a converter

that can work in analog-digital or digital-analog.
In addition we also know that the line of communication with the PIC will be the I2C bus.
Now we will configure it as simply indicates the 
PDF,to work with him.


After reviewing the PDF see the need to send 2 bytes ('ADDRESSING'and 'Control ') to work with the PCF8591.


The first byte ('ADDRESSING') after the start we send I2C communication (i2c_start ();). As we can see, the byte consists of a fixed and a programmable part.
The fixed part contains the four bit more weight ('1001').
The programmable part contains the four least significant bits. The first three (A2, A1 and A0) are the analog inputs and the least significant bit, read or write data as configured.

This part will be in 'OOOO', and we will not use any analog input and also it's in 'Writing'.





SECOND BYTE ('Control'), configure the device to work on digital-analog converter mode, besides indicating that the output will show the conversion (A OUT).

To use it as only 'A OUT', the byte will be '01000000 '. The 'msb' first bit ('O ') is fixed, the '1' indicates that we use the output 'A OUT' and the others left to 'O' because we do not use.








Finally here I leave the code, as you see all I do is increase or decrease the variable 'analogue' as it is. That is, if you're in 'OO' the incrementaré and if it gets to 'FF ' the decrementaré.

The variable ranges between these two values ​​because being an 8-bit converter, the accuracy of this is 2 ^ 8 = 256 (256 different values ​​are those that can take the converter).

Therefore, the oscillation between 'OO' and 'FF ' (from O to 255).





Dowload exercices:

No hay comentarios:

Publicar un comentario