Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

Assembly code for switching led using comparator

Status
Not open for further replies.

giordano

Newbie level 5
Newbie level 5
Joined
Nov 28, 2012
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Indonesia
Visit site
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
 

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 think u should use the push button in parallel with capacitor in reset circuit, so that reset can occur and starts executing properly.........
 

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
 

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
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.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top