UNIT-5
PIC Interfacing –III
DAC(digital to analog converter) 0808 with Interfacing with PIC
- The digital-to-analog converter (DAC) is a device widely used to convert digital pulses to analog signals.
- The DAC0808 is an 8-bit monolithic digital-to-analog converter (DAC).
- Featuring a full scale output current settling time of 150 ns while dissipating only 33 mW with ±5V supplies.
- No reference current (IREF) trimming is required for most applications since the full scale output current is typically ±1 LSB of 255 IREF/256.
- Relative accuracies of better than ±0.19% assure 8-bit monotonicity and linearity
- while zero level output current of less than 4 µA provides 8-bit zero accuracy for IREF≥2 mA.
- The power supply currents of the DAC0808 are independent of bit codes, and exhibits essentially constant device characteristics over the entire supply voltage range.
- The DAC0808 IC is a monolithic digital to analog converter which takes an 8-bit digital data as an input and sends an analog signal at the output. It has high accuracy and utilizes very low power.
- Electronic devices like music players, televisions, mobiles, CD players gaming systems, etc. use this chip for the conversion of audio signals.
- This article discusses in detail the working, Pinout configuration, Proteus simulation and uses of IC DAC0808.
ADC
- In electronics, an analog-to-digital converter (ADC, A/D, or A-to-D) is a system that converts an analog signal, such as a sound picked up by a microphone or light entering a digital camera, into a digital signal.
- An ADC may also provide an isolated measurement such as an electronic device that converts an input analog voltage or current to a digital number representing the magnitude of the voltage or current.
- Typically, the digital output is a two's complement binary number that is proportional to the input, but there are other possibilities.
- There are several ADC architectures. Due to the complexity and the need for precisely matched components, all but the most specialized ADCs are implemented as integrated circuits (ICs).
- These typically take the form of metal–oxide–semiconductor (MOS) mixed-signal integrated circuit chips that integrate both analog and digital circuits.
Features of ADC
- The PIC18f458 has a 10-bit 8 channel A/D converter.
- The number of analog inputs varies among difference PIC18 devices.
- The A/D converter has the following registers:
- A/D Result High Register (ADRESH)
- A/D Result Low Register (ADRESL)
- A/D Control Register 0 (ADCON0)
- A/D Control Register 1 (ADCON1)
DAC(digital to analog converter) 0808 Interfacing with PIC 18
- The digital-to-analog converter (DAC) is a device widely used to convert digital pulses to analog signals.
- The DAC0808 is an 8-bit monolithic digital-to-analog converter (DAC).
- featuring a full scale output current settling time of 150 ns while dissipating only 33 mW with ±5V supplies.
- No reference current (IREF) trimming is required for most applications since the full
- scale output current is typically ±1 LSB of 255 IREF/256.
- Relative accuracies of better than ±0.19% assure 8-bit monotonicity and linearity
- while zero level output current of less than 4 µA provides 8-bit zero accuracy for IREF≥2 mA.
- The power supply currents of the DAC0808 is independent of bit codes, and exhibits essentially constant device characteristics over the entire supply voltage range.
- Features
- Relative accuracy: ±0.19% error maximum
- Full scale current match: ±1 LSB typ
- Fast settling time: 150 ns typ
- Noninverting digital inputs are TTL and CMOS compatible
- High speed multiplying input slew rate: 8 mA/µs
- Power supply voltage range: ±4.5V to ±18V
- Low power consumption: 33 mW @ ±5V
- Pin diagram of DAC 0808
Fig.1 Pin diagram of DAC 0808
Interfacing of DAC to PIC 18
Fig.2 Interfacing of DAC to PIC 18
Temperature sensor LM35
- The LM35 is an integrated circuit sensor that can be used to measure temperature with an electrical output proportional to the temperature (in oC).
- The LM35 device has an advantage over linear temperature sensors calibrated in Kelvin, as the user is not required to subtract a large constant voltage from the output to obtain convenient Centigrade scaling.
- The LM35 device does not require any external calibration or trimming to provide typical accuracies of ±¼°C at room temperature and ±¾°C over a full−55°C to 150°C temperature range.
- The low-output impedance, linear output, and precise inherent calibration of the LM35 device makes interfacing to readout or control circuitry especially easy.
- The device is used with single power supplies, or with plus and minus supplies.
- As the LM35 device draws only 60 μA from the supply, it has very low selfheating of less than 0.1°C in still air.
- The LM35 device is rated to operate over a −55°C to 150°C temperature range, while the LM35C device is rated for a −40°C to 110°C range (−10° with improved accuracy).
- The LM35-series devices are available packaged in hermetic TO transistor packages, while the LM35C, LM35CA, and LM35D devices are available in the plastic TO-92 transistor package.
- The LM35D device is available in an 8-lead surface-mount small-outline package and a plastic TO-220 package.
- In LM35 circuit, parameter values commonly used are:
- Vc = 4 to 30v
- 5v or 12 v are typical values used.
- Ra = Vc /10-6
- Actually, it can range from 80 KW to 600 KW , but most just use 80 KW.
- Temperature measurement
- Digital display of temperature
- used of microcontroller to measure temperature
- used of microcontroller to Display temperature value on LCD (liquid crystal display)
- The PIC microcontroller measure temperature using LM35 which is an analog temperature sensor every 10 second and compares it with the reference value enters by the user. When the reference value is higher than the measured value, then the heater is turned ON to heat the area.
- The PIC microcontroller measure temperature using LM35 which is an analog temperature sensor every 10 second and compares it with the reference value enters by the user.
- When the reference value is higher than the measured value, then the heater is turned ON to heat the area.
- The heater is switched OFF once the reference temperature is reached. When the measured value is higher than the reference value, then the cooler is switched ON to cool off the area until the required temperature is reached.
- An LCD display shows the measured temperature continuously.
|
Fig.3 Temperature sensor interfacing using ADC and 12C with PIC
- As shown in above figure both temperature sensor and LCD are displaying same values of temperature.
- To ensure protection of LM35 and microcontroller you can connect 80k ohm resistor parallel to output of temperature sensor.
- Before making this project, I recommend you should learn about LCD interfacing with microcontroller especially hardware part. Because I have seen many students struggling with LCD display.
- The heater is switched OFF once the reference temperature is reached.
- When the measured value is higher than the reference value, then the cooler is switched ON to cool off the area until the required temperature is reached.
- An LCD display shows the measured temperature continuously.
- Read date & time by using I2C – RTC in PIC16F/18F Advanced Development Board.
- Wiring up an I2C based RTC to the I2C port is relatively simple.
- The RTC also makes the software easier as it takes care of all calendar functions; accounting for leap years etc.
- The DS1307 (RTC) Real Time Clock IC (an I2C real time clock) is an 8-pin device using an I2C interface.
- In PIC16F/18F Advanced Development Kit, 2 nos. of RTC lines are controlled by I2C Enabled drivers. I2C Lines serial clock of CLK (RC3), serial data of DATA (RC4) connected to the I2C based serial RTC ds1307 IC.
- The date & times are read in PIC16F/18F Advanced Development Kit by using these DATA & CLK I2C lines.
Fig.4 Circuit Diagram to Interface I2C–RTC with PIC
- The Interfacing I2C – RTC with PIC16F877A program is very simple and straight forward that read date & time in RTC by using I2C & the value is displayed in serial port.
- A delay is occurring in every single data read from RTC. The delay depends on compiler how it optimizes the loops as soon as you make changes in the options the delay changes.
SPI:
- Serial Peripheral Interface (SPI) is a synchronous serial data protocol used by microcontrollers for communicating with one or more peripheral devices quickly over short distances.
- It can also be used for communication between two microcontrollers.
- Typically, there are three lines common to all the devices
- Fig. 1 shows how to interface the SPI-DAC to microcontroller.
- With an SPI connection there is always one master device (usually a microcontroller) which controls the peripheral devices.
- Typically, there are three lines common to all the devices.
- Master in Slave Out (MISO) – The Slave line for sending data to the master.
- Master Out Slave In (MOSI) – The Master line for sending data to the peripherals.
- Serial Clock (SCK) – The clock pulses which synchronize data transmission generated by the master.
- Slave Select pin – the pin on each device that the master can use to enable and disable specific devices. When a device’s Slave Select pin is low, it communicates with the master. When it’s high, it ignores the master.
- These allow you to have multiple SPI devices sharing the same MISO, MOSI, and CLK lines.
Fig.5 SPI ethernet to microcontroller and block diagram of DAC
- The controller designed controls the EEPROM device through SPI protocol.
- The SPI Controller here acts as a master device and controls EEPROM which acts as a slave.
- The read-write operations are accomplished by sending a set of control signals including the address and/or data bits.
- The control signals must be accompanied with proper clock signals.
Interfacing SPI – EEPROM with PIC16F877A
- We now want to Read, write and Erase EEPROM by using SPI in PIC16F/18F Development Board.
- Wiring up an SPI based EEPROM to the SPI port is relatively simple.
- The basic operation of the SPI based EEPROM’s is to send a command, such as WRITE, followed by an address and the data.
- In WRITE operation, the EEPROM to store the data.
- In SPI, the clock signal is controlled by the master device PIC16F/18F Development Board, all data is clocked in and out using this pin.
- These lines need to be connected to the relevant pins on the PIC16F/18F Development Board. Any unused GIO pin can be used for CS, instead pull this pin high.
- In PIC16F/18F Development Kit four nos. of EEPROM lines are controlled by SPI Enabled drivers.
- The SPI Lines Chip Select of CS (PORTC.0), serial clock of CLK (PORTC.3), serial input data of MISO (PORTC.4) and serial output data of MOSI (PORTC.5) connected to the SPI based serial EEPROM IC.
- The EEPROM read & write operations are done in PIC16F/18F Development Kit by using these CS, CLK, MOSI, MISO SPI lines.
- The Interfacing SPI – EEPROM with PIC16F877A program is very simple and straight forward .
- Read, write and erase operations in EEPROM by using SPI & the value is displayed in serial port.
- A delay is occurring in every single data read or write in EEPROM.
- The delay depends on compiler how it optimizes the loops as soon as you make changes in the options the delay changes.
ADCON1 register.
- ADCON1 is 8 bit register.
- ADCON1 is Control Register used for setting voltage.
- Bit 7 ADFM: A/D result format select bit
- 0 = left justified. Six least significant bits of ADRESL are 0s.
- 1 = right justified. Most significant bits of ADRESH are 0s.
- Bit 6 ADCS2: A/D conversion clock select.
- This bit along with the ADCS1:ADCS0 bits of ADCON0 are used to select clock source for
- A/D conversion.
Fig.6 ADCON1 register
Key Takeaway:
- The digital-to-analog converter (DAC) is a device widely used to convert digital pulses to analog signals.
- An analog-to-digital converter (ADC, A/D, or A-to-D) is a system that converts an analog signal, such as a sound picked up by a microphone or light entering a digital camera, into a digital signal.
- The PIC microcontroller measure temperature using LM35.
- Serial Peripheral Interface (SPI) is a synchronous serial data protocol used by microcontrollers for communicating with one or more peripheral devices quickly over short distances.
- SPI can also be used for communication between two microcontrollers.
- In SPI, the clock signal is controlled by the master device PIC16F/18F Development Board.
Reference:
1.Peatman, John B, “Design with PIC Microcontroller”, Pearson Education PTE
2.Ramesh Gaonkar, “Fundamentals of Microcontrollers and Applications In Embedded Systems(with the PIC18 Microcontroller Family)”Thomson/Delmar Learning; 1 edition (January 8, 2007), ISBN:978-1401879143
3.Muhammad Ali Mazidi, SarmadNaimi,“ARM Assembly Language Programming & Architecture”