Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Assembly code for switching led using comparator

Status
Not open for further replies.

giordano

Newbie level 5
Joined
Nov 28, 2012
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Indonesia
Activity points
1,376
I have build a project using AT89S51 and comparator LM324. The input to uC is from comparator that the inverting input is connected to infrared sensor and the non-inverting input set as the voltage reference (Vr). For certain distance the output voltage from infrared sensor is higher than the Vr so that the output from comparator is low and otherwise. This output is connected to P1.0, and a led is connected to P3.0. My intention is to make the led on when the output from comparator is low and led off when the output from comparator is high. However, when I test it the led is only on or off for once after I power on my uC even I already made loop in source code. Can anybody help me to fix this problem?
The circuit is led_switch.JPG

Code:
	ORG 0H
START:
	MOV A,P1
	CJNE A,#0FEH,LED_OFF
LED_ON:
	CLR P3.0
	SJMP START
LED_OFF:
	SETB P3.0
	SJMP START
	END
 

Joined
Jul 25, 2012
Messages
1,192
Helped
170
Reputation
340
Reaction score
161
Trophy points
1,343
Activity points
0
Where is the infrared input to the comparator?

O/P from comparator is low and led is on. How are you making O/P of comparator high without infrared input.
 

jjeevan007

Full Member level 5
Joined
Apr 13, 2012
Messages
311
Helped
44
Reputation
88
Reaction score
43
Trophy points
1,308
Location
bangalore
Activity points
2,781
i think u should use the push button in parallel with capacitor in reset circuit, so that reset can occur and starts executing properly.........
 

giordano

Newbie level 5
Joined
Nov 28, 2012
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Indonesia
Activity points
1,376
Where is the infrared input to the comparator?

O/P from comparator is low and led is on. How are you making O/P of comparator high without infrared input.
I already show it in the picture, corner left side

- - - Updated - - -

i think u should use the push button in parallel with capacitor in reset circuit, so that reset can occur and starts executing properly.........
It means I have to push the button frequently. I want to reset it only once
 

ark5230

Advanced Member level 3
Joined
Jun 29, 2009
Messages
858
Helped
163
Reputation
324
Reaction score
140
Trophy points
1,323
Location
India
Activity points
6,143
The port pin P1.0 has to be configured as input first. SETB P1.0 will make it high and configure it as input port pin. Try this. This should go in the beginning.
 

    V

    points: 2
    Helpful Answer Positive Rating

giordano

Newbie level 5
Joined
Nov 28, 2012
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Indonesia
Activity points
1,376
Ya, it works after I set P1.0 high in the beginning. Thanks for the suggestions.

- - - Updated - - -

It works when I use power supply as inverting input to comparator. The led is on and off every time I vary the input voltage lower or higher than voltage reference. However, when the inverting input is from infrared sensor the led is always on and never off even though the output voltage from comparator is low. I use infrared sensor from sh*rp.
 

ark5230

Advanced Member level 3
Joined
Jun 29, 2009
Messages
858
Helped
163
Reputation
324
Reaction score
140
Trophy points
1,323
Location
India
Activity points
6,143
Seems like an issue related to IR module
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top