# could someone please check this circuit?

#### efm

Joined Sep 14, 2006
14
hello,

i'm making a data logger that consists of 3 LM35s, one LM324 OpAmp, one ADC0808, one
AT89S51, and a 24LC256 serial eeprom. i've designed the circuit by myself with references from
the net, and i want to know whether the design is correct or not. and i'm open for suggestions of
course.

well, the goal of the circuit is to receive data from the three sensors, and then save it into the
24LC256 memory, and then the computer will download the data through parallel port.

faizal

#### Attachments

• 33.1 KB Views: 60

#### Dave

Joined Nov 17, 2003
6,970
Can you improve the clarity? It is very difficult to read anything on the image.

Dave

#### efm

Joined Sep 14, 2006
14
hello dave,
well, here is the clearer picture...i zipped it,
i hope you would see it and tell me whether the design is correct or not,

faizal

#### Attachments

• 26.8 KB Views: 57

#### hgmjr

Joined Jan 28, 2005
9,029
Greetings efm,

Your circuit looks as though you have everything covered.

You may want to look at replacing the LM324 opamps with a rail-to-rail opamp. This will give a little better linearity on your temp readings at the high end of the temperature range.

I noticed that you chose not to implement a means of connecting to the AT89S51 for the purpose of In-System Programming. I take it that you are planning to socket the AT89S51 and program it off-board.

hgmjr

#### hgmjr

Joined Jan 28, 2005
9,029
I noticed that you have made no provisions for measuring temperatures below 0 degrees Celsius. Is that intentional?

hgmjr

#### hgmjr

Joined Jan 28, 2005
9,029
You may want to consider assigning the EOC signal from the ADC0808 to one of the external interrupt pins on the AT89S51. That way you will not need to use polling to detect when the A-to-D conversion has been completed.

hgmjr

#### efm

Joined Sep 14, 2006
14
hello
thanks for the reply and for the suggestions!!

so, what rail-to-rail opamp do you suggest? i found OPA4344P, is it ok?
and, about the in system programming thing...you're right, i'm planning to program it
off-board, but i think your idea is good...
if i want to add the isp to the circuitry, can i just wire the mosi, miso, and sck (p1.5,
p1.6, p1.7) to the parallel port? or do i have to change the whole circuitry?
and, is it ok if i do the in system programming while the board is powered?

btw, thanks for the suggestion for wiring the eoc to interrupt pin. i think i will
change the design, and i will attach it in my next message.

and...actually, i want to measure below 0 celcius, but i've bought that lm35d. i didn't
know that it only measures 0 to 100 celcius.

well, thanks for all suggestions,
faizal

#### hgmjr

Joined Jan 28, 2005
9,029
efm,

The OPA4344 looks like it should work fine.

As for the ISP hookup, you should be able to consult ATMEL's AT89S51 datasheet for implementations instructions. You will need to take into consideration the requirements of your existing programmer.

The LM35D datasheet shows how it can be connected for -55 to +150 celsius temp range even while powered by a single supply. You will need to configure your op-amps as differential amplifiers instead of the single-ended scheme you are currently using.

hgmjr

#### efm

Joined Sep 14, 2006
14
hello again,

well, according to my previous circuit layout, i made the pcb layout,
umm...would you care too see if it's correct or not?
your help would be greatly appreciated

btw, if i want to connect the board with parallel port, do i have to connect
parallel port's ground (pin 21-25) to the board's ground?

thank you,
faizal

#### Attachments

• 19 KB Views: 27
• 23.9 KB Views: 26

#### efm

Joined Sep 14, 2006
14
hello,

according to my previous schematic, i have written a code for the microcontroller. but i haven't uploaded
it yet, i just scare that it's wrong and will eventually break the microcontroller / memory

here is the code, could someone please tell me whether it will work or not

Rich (BB code):
\$MOD51

DSEG

ORG			30H

BYTSTR:
DS	20H

; ------------------------------------------------
; CONSTANTS
; ------------------------------------------------

; EEPROM EQUATES
WTCMD		EQU	10100000B

CONV_PORT	EQU	P2

; ------------------------------------------------
; START OF PROGRAM
; ------------------------------------------------

CSEG

ORG		0

JMP		START

START:
MOV	P1, #0FFH
CALL	MAIN_ROUTINE
JMP	START

; ------------------------------------------------
; COMPARISON, AND SAVE TO EEPROM
;
; Note: Channel Selection
;	 0	 0	 0	   1
;	 0	 0	 1	   2
;	 0	 1	 0	   3
; ------------------------------------------------

MAIN_ROUTINE:

CALL	START_CONVERSION
MOV	R2, A

CALL	START_CONVERSION
MOV	R3, A

CALL	START_CONVERSION
MOV	R4, A

; COMPARE R2, R3, AND R4
CALL	COMPARE

; DELAY FOR ONE MINUTE

; LOOP
JMP	MAIN_ROUTINE

; ------------------------------------------------
; RESULT COMPARISON
; ------------------------------------------------

COMPARE:
; COMPARES R2 WITH R3
MOV 	A, R2
SUBB	A, R3
JNZ	COMPARE_2		; If R2-R3 <> 0, they're not equal, jump to COMPARE_2
MOV	R1, A			; R2 and R3 is equal, so save R2 in R1...

COMPARE_2:
; COMPARE R2 WITH R4
MOV	A, R2
SUBB	A, R4
JNZ	COMPARE_3		; If R2-R4 <> 0, they're not equal, jump to COMPARE_3
MOV	R1, A			; R2 and R4 is equal, so save R2 in R1...

COMPARE_3:
; COMPARE R3 WITH R4
MOV	A, R3
SUBB	A, R4
JNZ	NO_VOTE			; If R3-R4 <> 0, they're not equal, jump to NO_VOTE
MOV	R1, A			; R3 and R4 is equal, so save R3 in R1...

NO_VOTE:
; NO TWO OUT OF THREE ARE EQUAL
MOV	R1, #0			; If no 2 out of three are equal, set R1 as 0

SAVE_R1:
; SAVE R1 TO EEPROM
CALL TESTWR
RET

; ------------------------------------------------
; ------------------------------------------------

START_CONVERSION:
MOV	CONV_PORT, #0FFH

START_CLK:
MOV	A, CONV_PORT
RET

; ------------------------------------------------
; BELOW IS THE ROUTINE TO WRITE ONE BYTE TO EEPROM
; ------------------------------------------------

TESTWR:
CALL	BYTEW
RET

BYTEW:
MOV	A, #WTCMD
CALL	OUTS
MOV	A, R4
CALL	OUT
MOV	A, R1
CALL	OUT
CALL	STOP
RET

OUTS:
MOV	R2, #8
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP

OTSLP:
RLC	A
JNC	BITLS
JMP	OTSL1

BITLS:

OTSL1:
NOP
NOP
NOP
NOP
NOP
DJNZ	R2, OTSLP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
RET

OUT:
MOV	R2, #8

OTLP:
RLC	A
JNC	BITL
JMP	OTL1

BITL:

OTL1:
NOP
NOP
NOP
NOP
NOP
DJNZ	R2, OTLP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
RET

STOP:
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
RET

END
thank you

#### Dave

Joined Nov 17, 2003
6,970
Your best bet would be to download the programme to the microcontroller, it is very unlikely that you will damage anything as long as you follow the correct download procedure. It would be much easier for you to decifer if the code works by testing on-line, rather than someone reading through the source code here on the forums.

Hope it goes well.

Dave