Presentation is loading. Please wait.

Presentation is loading. Please wait.

Department of Electronic & Electrical Engineering Further work? Simple Voltmeter. ● Analogue to Digital converter (MCP3001 SPI ) ● Analogue → 10bit binary.

Similar presentations


Presentation on theme: "Department of Electronic & Electrical Engineering Further work? Simple Voltmeter. ● Analogue to Digital converter (MCP3001 SPI ) ● Analogue → 10bit binary."— Presentation transcript:

1 Department of Electronic & Electrical Engineering Further work? Simple Voltmeter. ● Analogue to Digital converter (MCP3001 SPI ) ● Analogue → 10bit binary ● Convert the 10 bit binary into a BCD ● Use bsd.asm (in my resources) ● Display value on the LCD display ● Modify your Hello World code

2 Department of Electronic & Electrical Engineering MCP3001 SPI Analogue To Digital Converter Features 10-bit resolution SPI™ serial interface Single supply operation: 2.7V - 5.5V 200 ksps sampling rate at 5V Applications Sensor Interface Process Control Data Acquisition Battery Operated Systems

3 Department of Electronic & Electrical Engineering Functional Block Diagram

4 Department of Electronic & Electrical Engineering MCP3001 Pins

5 Department of Electronic & Electrical Engineering MCP3001 operation ( see data sheet for details) IN+ positive analogue input (IN- can be connected to ground) /CS initiate communication by pulling low CLK initiate conversion and clock for each bit of data DOUT output data appears on the falling edge of the clock.

6 Department of Electronic & Electrical Engineering Reading a sample (see section 5.0) The device will begin to sample the analog input on the first rising edge after CS goes low. The sample period will end in the falling edge of the second clock, at which time the device will output a low null bit. The next 10 clocks will output the result of the conversion with MSB first, as shown in Figure 5-1. Data is always output from the device on the falling edge of the clock.

7 Department of Electronic & Electrical Engineering Sequence for operation. (fig 5.2)

8 Department of Electronic & Electrical Engineering Digital Output

9 Department of Electronic & Electrical Engineering Your first task ? Don't try to do everything at first. Break the exercise down into smaller easier tasks. Connection to the PIC (see eeprom ex.)? Your first program ? Display the voltage of a 4 bit number. Just stop reading after 4 bits! The MCP3001 is similar to the serial EEPROM (but no SI or instructions!) If you really understand the serial EEPROM code it should be easy!

10 Department of Electronic & Electrical Engineering Converting 10bits into decimal characters. e.g. 1101010111 → '8' '5' '5' The bcd.asm code will make this job easier ! The code has a routine which takes a 16bit binary number (in 2 registers). NumH:NumL It returns 4 registers which have the Binary Coded Decimal values TenK:Thou:Hund:Ones

11 Department of Electronic & Electrical Engineering Binary-to-BCD. Written by John Payson #define NumH 0x10 ; registers used by Convert #define NumL 0x11 #define TenK 0x12 #define Thou 0x13 #define Hund 0x14 #define Tens 0x15 #define Ones 0x16........... ; PJL test code try it out with 0x03FF --> 1023 movlw 0x03 movwf NumH movlw 0xFF movwf NumL call Convert ; now TenK=1 Thou=0 Hund=2 Ones=3..... Convert: ; Takes number in NumH:NumL ; Returns decimal in TenK:Thou:Hund:Tens:Ones ; snip.....

12 Department of Electronic & Electrical Engineering Displaying the voltage from the ADC ➔ Read 10 bit value into 2 registers. NumH NumL 000000XX YYYYYYYY ➔ Call BCD conversion ➔ Display TenK Thou Hund Ones + Some details that are left as an exercise for you ! !

13 Department of Electronic & Electrical Engineering Hints: Avoid nasty sums The PIC16F84 was not designed for arithmetic. You can make life a lot easier by: ➢ Choosing a appropriate Vref (e.g. MCP1541) ➢ Only use simple arithmetic ( X2 X4 X8 etc)

14 Department of Electronic & Electrical Engineering Further Work Add any features that you think would be cool !


Download ppt "Department of Electronic & Electrical Engineering Further work? Simple Voltmeter. ● Analogue to Digital converter (MCP3001 SPI ) ● Analogue → 10bit binary."

Similar presentations


Ads by Google