23
DATA LOGGER WITH HIGH SPEED PC INTERFACE ATHARVA INAMDAR CANDIDATE NO# 0088 CENTRE NO# 52103 AYLESBURY GRAMMAR SCHOOL

Data Logger with high speed PC interface

Embed Size (px)

DESCRIPTION

This was my A level electronics project report. This includes a detailed designs and source code for building a datalogger using microprocessor for only PC comms everything else is done using discrete components. I received an A* grade for this.Please respect my hard work and do NOT copy anything. If you require information, please view the sources or contact me. thank you

Citation preview

Page 1: Data Logger with high speed PC interface

DATA LOGGER WITH HIGH SPEED PC

INTERFACE

A T H A R V A I N A M D A R

C A N D I D A T E N O # 0 0 8 8

C E N T R E N O # 5 2 1 0 3

A Y L E S B U R Y G R A M M A R S C H O O L

Page 2: Data Logger with high speed PC interface

2

Atharva Inamdar Candidate no# 0088 Centre no# 52103 Unit 2531

TABLE OF CONTENTS

SUMMARY .................................................................................................................................................................... 3

BRIEF ............................................................................................................................................................................. 4

SPECIFICATION .......................................................................................................................................................... 4

BLOCK DIAGRAM....................................................................................................................................................... 4

EQUIPMENT ................................................................................................................................................................. 5

SYSTEMS ....................................................................................................................................................................... 6

ANALOGUE-TO-DIGITAL CONVERTER (ADC) ................................................................................................................. 6 Subsystem 1: Clock ................................................................................................................................................... 6 Subsystem 2: Counter ............................................................................................................................................... 8 Subsystem 3: Digital-to-Analogue converter (dac) ................................................................................................. 10

PARALLEL-TO-SERIAL CONVERTER ............................................................................................................................. 12 subsystem 4: Parallel-to-serial converter (piso) ..................................................................................................... 12

DATA STORAGE AND TRANSMISSION........................................................................................................................... 14 subsystem 5: Sensor Data storage and transmission .............................................................................................. 14

DATA OUTPUT ............................................................................................................................................................ 16 subsystem 6: user interface ..................................................................................................................................... 16

END RESULT .............................................................................................................................................................. 18

CIRCUIT DIAGRAM ...................................................................................................................................................... 18 FULLY FUNCTIONAL BREADBOARD PHOTO: ................................................................................................................ 19

REVIEW AND EVALUATION .................................................................................................................................. 20

BIBLIOGRAPHY ........................................................................................................................................................ 21

ACKNOWLEDGEMENTS ......................................................................................................................................... 21

APPENDIX I................................................................................................................................................................. 22

APPENDIX 2: ............................................................................................................................................................... 23

Page 3: Data Logger with high speed PC interface

3

Atharva Inamdar Candidate no# 0088 Centre no# 52103 Unit 2531

SUMMARY

I set out to design and build a data logging system for an analogue input. This system would consist of an analogue to digital converter and a microprocessor to store data on an EEPROM and communicate with a PC. At the end of this project, I have achieved all of the above. However, the data stored is raw data and is not calibrated. It is intended that the user calibrated this data logger to their specific sensor. I have successfully met all the specification points.

Page 4: Data Logger with high speed PC interface

4

Atharva Inamdar Candidate no# 0088 Centre no# 52103 Unit 2531

BRIEF

In schools sometimes it is necessary for pupils to record data at specific intervals for a long period of time such as, in a Physics experiment recording the time. I will be developing a Data logger, which will be able to communicate with a PC using a high-speed interface.

SPECIFICATION

Data Logger o One Analogue input

E.g. Thermistor

8-bit resolution o Store data for Analogue input o Display data stored in PIC memory (buffer) or an EEPROM depending on user‟s need of data retention

Data from PIC memory buffer will be transmitted in real-time to the PC o Record data at a frequency of 1Hz

PC interface o Serial interface with PC o Transmit data stored in the EEPROM using Serial or USB connection

To be used with applications such as HyperTerminal

Communication uses 4800bits/s with no parity and 1 stop bit

BLOCK DIAGRAM

Page 5: Data Logger with high speed PC interface

5

Atharva Inamdar Candidate no# 0088 Centre no# 52103 Unit 2531

EQUIPMENT

Multimeter

PC with RS232 port

Set of coloured wires o Red: positive power supply o Green: 8 bit data connection o Yellow: Interconnect subsystems o Blue: Serial Comms with PC o Brown: Clock o Orange: general connections

Page 6: Data Logger with high speed PC interface

6

Atharva Inamdar Candidate no# 0088 Centre no# 52103 Unit 2531

SY STEMS

ANALOGUE-TO-DIGITAL CONVERTER (ADC)

SUBSYSTEM 1: CLOCK

Specifications: To produce a stable and clean square waveform of 4kHz.

Alternative-1: Crystal Oscillator Alternative-2: Relaxation Oscillator (selected)

Advantages Disadvantages

Crystal Oscillator Accurate, clean and stable waveform

Difficult to buy a 4kHz crystal.

Relaxation Oscillator Accurate, clean and stable waveform

Cheap components such as resistors and capacitors are needed

Reliability of operation depends on tolerance of resistors and capacitors being used.

Accurate waveform of certain frequency is achieved by trial and improvement method

A relaxation oscillator is sufficient for the needs of this data-logger. It is a cheap solution which has no major disadvantages over a Crystal oscillator.

Circuit Diagram:

Component Values:

Capacitor: 1nF; Resistor: 35k How Relaxation Oscillators work: The output depends on the state of the input. However, the state of the input is determined by the state of the output due to the use of a feedback resistor. When the input of the Schmitt trigger is below +2.2V (lower trip point) then the output saturates to +5V. The current in feedback resistor charges the capacitor raising the voltage at the input to above +2.8V. This will saturate the output to 0V.

Page 7: Data Logger with high speed PC interface

7

Atharva Inamdar Candidate no# 0088 Centre no# 52103 Unit 2531

Testing: Testing was conducted using a frequency meter. The output was a stable frequency of 4kHz. Photos:

Variable resistor

35k

1nF ceramic capacitor

40106B Hex Schmitt Trigger

Page 8: Data Logger with high speed PC interface

8

Atharva Inamdar Candidate no# 0088 Centre no# 52103 Unit 2531

SUBSYSTEM 2: COUNTER

Specifications: Count up 255stages in binary outputting 8-bit parallel word

Alternative-1: 4029B configurable counter (selected) Alternative-2: S-R Flip Flop

Advantages Disadvantages

4029B counter Dedicated counter IC

Configurable – 4-bit parallel output

Can carry count to additional counter ICs with synchronized clock

Small footprint

Two separate ICs are needed

S-R Flip Flop (setup as T-type) Are building blocks of a digital binary counter

No advantage over using 4029B IC

Footprint is extremely large for consideration of practical or even prototype application (Eight ICs needed)

4029B is a dedicated counter IC and is the best solution for a data-logger. Using S-R flip-flops set up as T-Type increases the footprint and performs the same function.

Circuit Diagram:

Page 9: Data Logger with high speed PC interface

9

Atharva Inamdar Candidate no# 0088 Centre no# 52103 Unit 2531

Component Values: P1-P4, LD, EN are all connected to 0V. Clock for both counters is connected to the output of subsystem 1. U/D AND B/D is connected to +5V to count UP. Carry from counter #1 is connected to Enable of counter #2. How 4029B counter Works: On power up the output is the same as inputs P1-P4 and C is high. On the rising edge of the clock, the output increases by 1 in binary. On the 15th rising edge Carry (on the 1st counter) is switched low. This enables the 2nd counter. On the 16th pulse one is counted up on the 2nd counter and all bits on 1st counter are switched low. After 255 counts both counters are reset and their outputs are low. Testing: Testing was done using 8 LEDs connected to the outputs. The clock pulses were provided by using a push-to-make switch connected between the clock pin and +5V rail. The order of LEDs lighting up was checked. (see photo below showing 153rd stage 10011001). Photos:

4029B Binary up counter

Red LEDs for 2nd counter IC

Green LEDs for 1st counter IC

Page 10: Data Logger with high speed PC interface

10

Atharva Inamdar Candidate no# 0088 Centre no# 52103 Unit 2531

SUBSYSTEM 3: DIGITAL-TO-ANALOGUE CONVERTER (DAC)

Specifications: Convert a 8-bit parallel word into and analogue output of corresponding value in real time

Alternative-1: Summing Amplifier (selected) Alternative-2: PICAXE-28X

Advantages Disadvantages

Summing Amplifier Fast and real-time conversion of digital input

Max output voltage range is large 26V (-13V to +13V)

Output voltage range can be controlled by altering the gain

8 resistor array is needed

Variable resistors need to be used to achieve accurate values

Large footprint

PICAXE-28X Integrated DAC function Expensive solution for the problem and the accuracy needed

Real-time conversion not available as processing time is taken into account with large binary numbers.

A summing Amplifier was chosen as it can provide a large voltage output range and can be controlled. The output provided is an accurate representation of the Digital 8-bit word. PICAXE-28X is too expensive for such an application.

Circuit Diagram:

Page 11: Data Logger with high speed PC interface

11

Atharva Inamdar Candidate no# 0088 Centre no# 52103 Unit 2531

Component Values:

Input Resistors: 1kΩ, 2kΩ, 4kΩ, 8kΩ, 16kΩ, 32kΩ, 64kΩ. 128kΩ o These values are chosen to keep the current drawn minimal

Op-amp(summing amp): feedback resistor: 502 , input resistance = 1.5T , output resistance = 60

Inverting amplifier: gain = -1, input resistor = 1k , feedback resistor = 1 , input resistance = 1.5T , output

resistance = 60 How a Summing Amplifier works: The summing amplifier adds the voltages of the inputs together considering the input resistances. The effect of the voltage

added depends on the weighting of the inputs. Thus the least significant bit has input resistance of 1k and the most

significant bit (8th bit) will have input resistance of 128k , thus when the 8th bit is high the voltage increase will be much greater than the voltage increase by the 1st bit. As the counter counts up, the output of the summing amplifier increases in

steps of 0.05V ( 13V/256). The inverting amplifier is present to invert the voltage output of the summing amp to give a true value instead of the inverted value. Testing: This was tested using a voltmeter on the output of the Summing amplifier. As the counter counted up the voltage was seen to rise steadily Problems:

Summing amplifier was saturating to 13V. the gain was decreased by using a 502 feedback resistor Photos:

CA3140E

Feedback resistors

Resistor array for Summing amplifier.

1k fixed resistor was used and all other values were achieved with variable resistors

Page 12: Data Logger with high speed PC interface

12

Atharva Inamdar Candidate no# 0088 Centre no# 52103 Unit 2531

PARALLEL-TO-SERIAL CONVERTER

SUBSYSTEM 4: PARALLEL-TO-SERIAL CONVERTER (PISO)

Specifications: To convert a 8-bit parallel word to a serial stream including 1 start and 1 stop bit

Alternative-1: 4014B 8 stage Shift Register Alternative-2: PICAXE-28A (selected)

Advantages Disadvantages

4014B 8 stage Shift Register Dedicated shift register for conversion of a 8-bit parallel word to a serial stream

Can output as 6/7/8 bits serially

Start and stop bits are not included in the serial data stream

Very difficult to add a start/stop bit to the stream

PICAXE-28A 8 inputs which can be read simultaneously

Serial data output stream adds start and stop bits automatically.

Reliable operation with minimalist program

Large footprint compared to 4014B

More expensive

PICAXE-28A was the only alternative, which can add a start and stop bit to a data stream while acting as an 8-stage shift register. The dedicated 4014B shift Register was not able to add start and stop bits to the data stream.

Circuit Diagram:

Page 13: Data Logger with high speed PC interface

13

Atharva Inamdar Candidate no# 0088 Centre no# 52103 Unit 2531

Component Values:

8bit inputs are connected directly to the inputs of the PICAXE-28X

4k7 pull up resistor is used for the reset pin

Impedance (PIC):

o Input: 2M minimum at 4.5V VCC.

o Output: 233 when Output state = 1; 71 when output state = 0 How a PICAXE-28A is used as a PISO shift register : A Binary number (8-bit) is stored in 1 variable (b0). Each bit of b0 stores 1 or 0 depending on the input state of each input

(07). This is then transmitted using the „sertxd‟ command using the „serout‟ pin. PIC program is shown in appendix 2. Testing: By programming a PICAXE-18X to display the value of the serial number on a LCD. The input to the PICAXE-28X was manually held high or low and the output was compared with the input. This functioned as desired. Photos:

4k7 pull-up reset resistor

PICAXE-28A

Page 14: Data Logger with high speed PC interface

14

Atharva Inamdar Candidate no# 0088 Centre no# 52103 Unit 2531

DATA STORAGE AND TRANSMISSION

SUBSYSTEM 5: SENSOR DATA STORAGE AND TRANSMISSION

Specifications: To write a 8-bit word into EEPROM and read data to transmit to PC using a serial link of the following format: 4800-8-n-1

Alternative-1: PICAXE with I2C EEPROM (selected) Alternative-2: PICAXE with I2C RAM

Advantages Disadvantages

I2C EEPROM (24C64WP) Permanent data storage Slow read and write times

I2C RAM Fast read and write times Only temporary data storage

Data lost on power down

EEPROM was selected due to its ability of retaining the data on power down and thus is useful in the situation of remote data collection.

Circuit Diagram:

Component Values:

4k7 pulled resistor for the reset pin on the PICAXE

Clock and data are synchronised through SLA and SDC pins on the PICAXE with same pins on the RAM. o Pull-up resistors (10kΩ) on SDA & SCL

Connection from PICAXE-28A is direct without any need for discrete components.

EEPROM write control impedance > 500kΩ o SDA & SCL i/p, o/p impedance = 4k7Ω (set by pull up resistors on line

Impedance (PIC):

o Input: 2M minimum at 4.5V VCC.

o Output: 233 when Output state = 1; 71 when output state = 0

Page 15: Data Logger with high speed PC interface

15

Atharva Inamdar Candidate no# 0088 Centre no# 52103 Unit 2531

How a PICAXE-18X is used to store data in I2C EEPROM and transmit it to the PC: A digital number transmitted by the shift register serially is read by the PICAXE. This is stored in the accumulator and using the I2C protocol transferred to the RAM. The RAM stores this raw number (in binary) starting from its first memory location (00h). Program attached in Appendix 1. Testing: A program was written in PIC BASIC and was simulated. The simulation was successful on a PC and was then tested using PICAXE-18X on a breadboard. The display was first tested by severing the input and connections with the EEPROM. As the photo below shows the display was functioning as desired. Problems: During the first testing stage with a PICAXE it was found that whenever a command to write to the LCD was sent the previous display was not cleared, thus ghosting was occurring for unused matrices at the end of the string. This was

corrected by a simple clear screen command (serout 7,N2400,(254,1)). Initially, 100 F capacitor was used for decoupling; it was found that the charge up and down times were too long so a 1nF capacitor was used. Photos:

LCD Display 16x2

PCAXE-18X

Decoupling Capacitor 1nF

I2C EEPROM 64Kbits

Write Control

SDA/SCL

Page 16: Data Logger with high speed PC interface

16

Atharva Inamdar Candidate no# 0088 Centre no# 52103 Unit 2531

DATA OUTPUT

SUBSYSTEM 6: USER INTERFACE

Specifications: to display a menu and current task being carried out. If data is being recorded, the raw data value should also be displayed.

Alternative-1: LCD screen (selected) Alternative-2: LED matrix

Advantages Disadvantages

LCD screen Serial communications with PICAXE-18X

Low power consumption

Low resolution

Each character space is made of a crystal matrix

Only 2 rows available

Low visibility in high and (near) zero luminous conditions

LED matrix Can customise to any matrix size possible

Range of colours for LEDs

Need a custom driver board

Extremely low resolution

Extremely high power consumption

Extremely large footprint for any application

LCD screen is the only practical alternative as it is dedicated display unit with built in driver circuit.

Component Values:

Impedance:

o Input: 2M minimum at 4.5V VCC.

o Output: 233 when Output state = 1; 71 when output state = 0

How a LCD screen is used as a user interface: A serial byte transmitted by the PICAXE is received. This is interpreted by an Onboard driver IC which displays the information. The protocol used is serial communications with baud rate of 2400bit/s, no parity, 8 bits and 1 stop bit. Testing: A simple program was written to display the message “Hello World!” and tested. ******** pause 10 main: serout 7,N2400, (254,128,”Hello World!”) serout 7, N2400, (254,192, “Hello World!”)

Page 17: Data Logger with high speed PC interface

17

Atharva Inamdar Candidate no# 0088 Centre no# 52103 Unit 2531

goto main ******** This program functioned as desired and the LCD was displaying all the characters correctly. Photos: (see previous subsystem photo)

Page 18: Data Logger with high speed PC interface

18

Atharva Inamdar Candidate no# 0088 Centre no# 52103 Unit 2531

END RESULT

CIRCUIT DIAGRAM

Page 19: Data Logger with high speed PC interface

19

Atharva Inamdar Candidate no# 0088 Centre no# 52103 Unit 2531

FULLY FUNCTIONAL BREADBOARD PHOTO:

Page 20: Data Logger with high speed PC interface

20

Atharva Inamdar Candidate no# 0088 Centre no# 52103 Unit 2531

REVIEW AND EVALUATIO N

Data logger at the start displays first message after the delay of the one-second. This delay is may be due to initial charging of the coupling capacitors, which are across the LCD power supply. “GO” switch is to initiate the analogue to digital conversion. At the press of “Go” 8bit digital signal is converted into serial stream with start and stop bits. When "Record" is toggled, the current data point and its value, which is being stored in EEPROM is displayed and the data is also sent to PC at the same time. The display returns to menu again on toggling “Record”. Pressing "Send to PC", transmitted data from EEPROM to the PC. During this function data is read from location 0 till the last point it was recorded. On the press of ERASE EEPROM, data values at all location are be replaced by zero. The following shows the results recorded by the PC: Data received by PC during „Recording‟ and „Send to PC‟:

No# Data 0 0 1 0 2 204 3 204 4 204 5 206 6 0 7 204 8 204 9 204 10 206 11 206 12 204 13 204 14 204 15 206 16 204 17 204 18 0 19 206 20 0 21 0 22 204 23 0 24 0 25 206 26 206 27 202 28 0

29 206 30 0 31 206 32 0 33 204 34 0 35 204 36 0 37 206 38 0 39 204 40 206 Recieving Data... No# Data 0 0 1 0 2 204 3 204 4 204 5 206 6 0 7 204 8 204 9 204 10 206 11 206 12 204 13 204 14 204

15 206 16 204 17 204 18 0 19 206 20 0 21 0 22 204 23 0 24 0 25 206 26 206 27 202 28 0 29 206 30 0 31 206 32 0 33 204 34 0 35 204 36 0 37 206 38 0 39 204 40 206 Data Received

Successfully

Photos: The following shows photos of me operating the Data logger: Recording Data: Erase EEPROM: Data sent to PC:

Page 21: Data Logger with high speed PC interface

21

Atharva Inamdar Candidate no# 0088 Centre no# 52103 Unit 2531

BIBLIOGRAPHY

CMOS Cookbook – Don Lancaster

Microchip.com – technical support

Electronics Explained – M. W. Brimicombe

ACKNOWLEDGEMENTS

Mr. M Harvey

PICAXE.com forum members

Page 22: Data Logger with high speed PC interface

22

Atharva Inamdar Candidate no# 0088 Centre no# 52103 Unit 2531

APPENDIX I

'Start 'pin2 = input 'pin0 = record 'pin1 = erase mem 'pin7 = serial send data to PC 'pin6 = read from mem button 'output 0 = record for tristate (write-protect) 'serout for LCD and PC 'b2 = erase ram flag 'b3 = data to send to PC pause 50 init: let b0 =0 high 0 serout 7, N2400, (254,1) main: serout 7, N2400, (254,128,"Record Data? ") serout 7, N2400, (254,192,"Send to PC? ") if pin0 = 1 then record if pin7 = 1 then mem_PC if pin1 = 1 then erase_mem goto main clr_scn: serout 7, N2400, (254,1) return record: if b0 = 185 then let b0 = 0 endif gosub clr_scn low 0 sertxd ("No# Data", 13,10) for b0 = b0 to 185 step 1 if pin0 = 1 then if b0 = 185 then mem_error 'let b1 = pin2 i2cslave %10100001, i2cfast8, i2cword serin 2,4800,b1 serout 7, N2400, (254,128,#b0,"= ", #b1, " ") serout 7, N2400, (254,192,"Recording... ") writei2c b0, (b1) sertxd (#b0, " ", #b1,13,10) pause 990 elseif pin0 = 0 then high 0 goto main endif next b0 goto main mem_error:

low 0 gosub clr_scn serout 7, N2400, (254,128, " MEMORY FULL! ") serout 7, N2400, (254,192, " :( ") wait 5 gosub clr_scn goto main „read from mem mem_pc: gosub clr_scn serout 7, N2400, (254,128, "Send data to PC?") serout 7, N2400, (254,192, " ") if pin7 = 1 then sertxd (13,10,"Recieving Data...",13,10, "No# Data",13,10) serout 7, N2400, (254,128, "Sending Data") serout 7, N2400, (254,192, "Do NOT Disconnect") for b0 = 0 to 184 step 1 i2cslave %10100001, i2cfast8, i2cword readi2c b0,(b3) sertxd (#b0, " ", #b3,13,10) next b0 sertxd ("Data Recieved Successfully") elseif pin7=0 then goto mem_pc endif gosub clr_scn serout 7, N2400, (254,128, "Data sent!") serout 7, N2400, (254,192, " ") wait 1 goto main erase_mem: serout 7, N2400, (254,128,"Mem Full! DEL?") serout 7, N2400, (254,192,"Press Record") pause 2000 gosub clr_scn if pin1 = 1 then low 0 b1 = 0 for b0 = 0 to 185 step 1 serout 7,N2400,(254,128,"Erasing MEM") serout 7, N2400, (254,192, "Do NOT Power Off") writei2c b0, (0) next b0 let b0 = 0 Endif

Page 23: Data Logger with high speed PC interface

23

Atharva Inamdar Candidate no# 0088 Centre no# 52103 Unit 2531

high 0 goto main 'End Program written to erase EEPROM 'Start pause 10 init:serout 7, N2400, (254,1)

for b0 = 0 to 185 i2cslave %10100001, i2cfast8, i2cword let b1 = 0 serout 7, N2400, (254,128,#b0) serout 7, N2400, (254,192,"Erasing..... ") writei2c b0, (b1) next b0 'End

APPENDIX 2 :

'Start of program pause 10 main: 'collect each bit in seperate variables let b0 = pins & %1111111 'shift each bit through serout pin 4800-8-n-1 with start and stop bits sertxd (b0) wait 1 goto main 'loop 'End of program