could someone please check this circuit?

Thread Starter

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.

please help,
faizal
 

Attachments

Thread Starter

efm

Joined Sep 14, 2006
14
hello dave,
thanks for the reply,
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

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
 

Thread Starter

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
 

Thread Starter

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

Thread Starter

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
ADDRH		EQU	0
ADDRL		EQU	0
AD_SDA		BIT	P1.0
AD_SCL		BIT	P1.1

; ADC0809 EQUATES
AD_OE		BIT	P1.5
AD_SC		BIT	P1.7
AD_EOC		BIT	P1.4
AD_ALE		BIT	P1.7
AD_CLK		BIT	P1.6
AD0		BIT	P3.2
AD1		BIT	P3.3
AD2		BIT	P3.4
CONV_PORT	EQU	P2

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

CSEG

ORG		0

JMP		START

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

; ------------------------------------------------
; BELOW IS THE ROUTINE TO READ ADC'S OUTPUT,
; COMPARISON, AND SAVE TO EEPROM
;
; Note: Channel Selection
;	AD2	AD1	AD0	CHANNEL
;	 0	 0	 0	   1
;	 0	 0	 1	   2
;	 0	 1	 0	   3
; ------------------------------------------------

MAIN_ROUTINE:

	; INITIALIZE ADC
	CLR	AD_OE
	CLR	AD_ALE
	CLR	AD_CLK

	; READ FROM CHANNEL 0
	CLR	AD0
	CLR	AD1
	CLR	AD2
	CALL	START_CONVERSION
	MOV	R2, A
	
	; READ FROM CHANNEL 1
	SETB	AD0
	CLR	AD1
	CLR	AD2
	CALL	START_CONVERSION
	MOV	R3, A

	; READ FROM CHANNEL 2
	CLR	AD0
	SETB	AD1
	CLR	AD2
	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...
	JMP 	SAVE_R1			; ...and jump to SAVE_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...
	JMP	SAVE_R1			; ...and jump to SAVE_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...
	JMP	SAVE_R1			; ...and jump to SAVE_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

; ------------------------------------------------
; ADC CONVERSION ROUTINE
; ------------------------------------------------

START_CONVERSION:
	MOV	CONV_PORT, #0FFH
	CLR	AD_OE
	SETB	AD_ALE
	CLR	AD_ALE

START_CLK:
	CPL	AD_CLK
	JNB	AD_EOC, START_CLK
	SETB	AD_OE
	MOV	A, CONV_PORT
	CLR	AD_OE
	RET

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

TESTWR:
	MOV	R3, #ADDRH
	MOV	R4, #ADDRL
	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
	SETB	AD_SDA
	SETB	AD_SCL
	NOP
	NOP
	NOP
	NOP
	NOP
	CLR	AD_SDA
	NOP
	NOP
	NOP
	NOP
	NOP
	CLR	AD_SCL

OTSLP:
	RLC	A
	JNC	BITLS
	SETB	AD_SDA
	JMP	OTSL1

BITLS:
	CLR	AD_SDA

OTSL1:
	SETB	AD_SCL
	NOP
	NOP
	NOP
	NOP
	NOP
	CLR	AD_SCL
	DJNZ	R2, OTSLP
	SETB	AD_SDA
	NOP
	NOP
	NOP
	SETB	AD_SCL
	NOP
	NOP
	NOP
	NOP
	NOP
	CLR	AD_SCL
	RET

OUT:
	MOV	R2, #8

OTLP:
	RLC	A
	JNC	BITL
	SETB	AD_SDA
	JMP	OTL1

BITL:
	CLR	AD_SDA

OTL1:
	SETB	AD_SCL
	NOP
	NOP
	NOP
	NOP
	NOP
	CLR	AD_SCL
	DJNZ	R2, OTLP
	SETB	AD_SDA
	NOP
	NOP
	NOP
	SETB	AD_SCL
	NOP
	NOP
	NOP
	NOP
	NOP
	CLR	AD_SCL
	RET
	
STOP:
	CLR	AD_SDA
	NOP
	NOP
	NOP
	NOP
	NOP
	SETB	AD_SCL
	NOP
	NOP
	NOP
	NOP
	NOP
	SETB	AD_SDA
	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
 
Top