problem regarding sensor circuit !!!!!!!!!!

Go To Last Post
17 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I made my first sensor circuit using the LM358 OPAMP based on the circuit attached (IR SENSOR CIRCUIT DETECTING WHITE SURFACE).

I then connected the output of the sensor circuit to the development board by giving a 12V-500mA supply (in common) to both (i am using 7805 voltage regulators in both the sensor and devt board).
this is the code i was workin upon:

#include
#include

int main()
{
	DDRA=0x00; //PORT A as input from sensor
	DDRB=0xFF; //PORT B as output to LEDs
	
	while(1)
	{
		if(PORTA & 0b00000001 == 0b00000001)
		{
			PORTB=0b10101010;//LED blinking
			_delay_ms(50);
			PORTB=0b01010101;//LED blinking
			_delay_ms(50);
		}
		else
		{
			PORTB=0b00000000;//no LED blinking
		}
	}
	return 0;
}

At first the output of the sensor circuit (when not connected to the devt board) showed 4.18V(tested using multimeter). Even on connecting to the devt board the output remains the same 4.18V on bringing a white surface near it but however the LEDs do not blink.

Moreover is it OK giving a 12V-500mA supply common to both the sensor and devt board....or we have to provide supply separately.........

Kindly help me out.........i m totally confused....!!!!!!!!!!

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
if(PORTA & 0b00000001 == 0b00000001)

You probably should be looking at PINA, not PORTA.

Chuck Baird

"I wish I were dumber so I could be more certain about my opinions. It looks fun." -- Scott Adams

http://www.cbaird.org

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

zbaird wrote:
Quote:
if(PORTA & 0b00000001 == 0b00000001)

You probably should be looking at PINA, not PORTA.

@zbaird: yes........its PINA actually........i jst copied the wrong code.....bt even though the same problem arises !!!!!!!!!!!!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But does he get some points for finding an error in the wrong code you posted anyway?

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As long as the voltage going into the AVR VCC is +5V and voltage going into the input port pin (the voltage on the wiper of VR2) is not above the AVR's VCC then the AVR will not be damaged.

*** If the VCC of the opamp is higher than +5V then VR2 should be connected between pin 7 and ground!
It should be adjusted so that the maximum voltage on the wiper is +5V. In its current configuration, the voltage on the VR2 wiper will ALWAYs be above +5V when pin 7 is outputting the VCC of the op-amp.

This is a comparator circuit. If I'm not mistaken, normally the IR receiver resistance is very high. The voltage divider of R2 and IR detector puts out a voltage that is higher than that on pin 3 of the LM358. This makes the output of the LM358 be 0V (VEE being Ground). When infrared light hits the IR detector, the resistance of the detector goes very low and the voltage in the non-inverting input of the LM358 is higher than the voltage on the inverting input. Then the LM358 output goes high, which lights the LED.
When you put your finger over the IR receiver, does the voltage at pin 2 of the LM358 go to the op amp's VCC?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@bobgardner: that was a mistake on my part and i am regretful towards it.........
@Simonetta: the OPAMP's VCC was 4.84V and the Voltage at PIN2 comes to around 4.18V when i put the finger on top of it.........the AVR VCC however gets 4.93V.......

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you adjust VR1? You need to do that, VR1 can be used to finetune the sensitivity (light level at which the circuit triggers).

Also, there can be plenty of IR light in daylight or even artificial light, possibly enough to trigger your circuit.

Oh and the LM358 is not suited that well for single supply 5V operation, but I guess it should work OK for this circuit... Most op-amps can not put out the same voltage range as you supply it with, the 358 is not an exception; I think they only promise something like 0-3.5V with a 0-5V supply! So I guess the 4.18V you measure is because the op-amp can't drive the voltage higher, but like I said, it should still be OK for this.

- Brian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Until the external circuit changes voltage levels in response to a reflective ( white ) surface, what chance does the uC have? The circuit should, indeed, work ( after a fashion ) if the variable resistor is properly adjusted. Try testing only the sensor circuit. As Geronimo says, IR in daylight could be enough to trigger the circuit... place the sensor - without the IR LED - in a dark place ( like a box ) and check if you can get the output to go to ground... adjust the variable resistor if necessary. Then test it in normal illumination... repeat adjustment. This should give you some idea of the adjustment range you have. If you cannot get a low level in normal illumination, this circuit is not going to work. Something like a modulated IR sensor with automatic gain might be required... or an op-amp that will work with an input closer to ground, though that would lead to a very sensitive setup which might not be very useful.

Martin Jay McKee

As with most things in engineering, the answer is an unabashed, "It depends."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I was pondering yesterday on the optimum number of exclamation marks(or points in US English).
I believe that most style guides urge economy of use in formal writing.
My thoughts were that, in a relaxed, semi-literate forum, anything more than !!! is overkill - the law of diminishing returns kicks in like a cliff-edge at four.

Googling, I found that Terry Pratchet considers that the number of ! used is in inverse proportion to the sanity of the writer, which has the ring of truth to it.

I have to say that Terry Pratchet, for me at any rate, shares that property with the exclamation mark. I found the first one I read very entertaining, the second was OK, but I never managed to finish a third. By the same token, I think it's a reasonable assumption that there is an inverse relationship between sanity and the number of TP books consumed.

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@Geronimo & @mckeemj: thanks for ur replies........but i tried something the other way round.........i gave separate supplies each of 12V to the devt board and the sensor circuit........and voila....it worked......i then checked the outputs and found that the devt board got 5.13V and the output of LM358 showed 5.01V......most probably what i feel is dat due to the common supply dat i was giving.....the voltage drop remained the same but the current was getting divided(as it was connected in parallel).......so the desired output was getting hampered.........any explanation on ur part guys ????????

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

.........any explanation on ur part guys ????????

Did you read John's treatise on the use of '!'? I wonder what the implications are for the use of '?'?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@clawson:
yeah i read it.however its common these days. the original english grammer has lost its state and now is the era of abbreviated form of the english.u see its spontaneous on the part of the writer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

the original english grammer has lost its state and now is the era of abbreviated form of the english

For moronic cretins?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For what it's worth, here's my 10 cents worth.
Your sensor circuit is indeed a basic comparator with no hysteresis. The LM358 with all it's limitations should be up to the job I would have thought.
Assuming your potentiometer is adjusted somewhere mid way the comparator will attempt to change state when the inverting input is close to mid rail. The gain is completely undefined and is the open loop gain of the LM358. Additionally, any noise superimposed on your sensor signal from either IR from mains operated lighting or supply noise will cause the op-amp to change state. It is very unlikely to be a nice clean transition and you may even see oscillation.

Also, beware of placing your finger over the IR sensor to block it. It won't. Fingers are IR transparent to a degree - a fact utilized by many medical sensors.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

chinmay_90 wrote:
@clawson:
yeah i read it.however its common these days. the original english grammer has lost its state and now is the era of abbreviated form of the english.u see its spontaneous on the part of the writer.

yeah like whatever!!!!!!!!!!!!!
:D :D :D

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am glad to hear you got it to work... but think a bit about your solution; there is nothing different about the two functionally unless the original single supply was insufficient. I never like using a solution that does not make sense; and this solution does not make sense. One think to try would be to try again with the single supply and test the source voltage ( 12v rail ) while it is running.


On a different subject...

chinmay_90 wrote:
the original english grammer has lost its state and now is the era of abbreviated form of the english.u see its spontaneous on the part of the writer.

I believe that this is an argument you will be hard pressed to defend here or anywhere. Perhaps I can use my own posts as an example. Doubtless my writing style is less formal here on these forums, I am less strict about many things, but that does not mean that I ignore the rules of grammar. Abbreviation and "code" ( u, gr8, l33t, etc. ) are fine in the realm of personal texts and social networking sites, but in the "real world" communication is still communication. To convince people to help they have to feel they are not being inconvenienced - that is the whole point of grammar; it is a "standard" way of using the language that the greatest number of people understand easily. Note, by the way, that I quoted the word standard. In French and a number of other languages there really is a standards organization that codifies the structure and usage of the language - this does not exist for English. That does not, however, mean that there is no standard usage or grammar. It only means that these standards are in the form of agreed-upon best standards.

I am currently editing a new grammar text for an English Professor friend of mine... I hope for his sake that grammar is not dead; in that case his sales could be truly abysmal.

... Okay, I feel better now.

Martin Jay McKee

As with most things in engineering, the answer is an unabashed, "It depends."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Okay, I feel better now.

I believe that's supposed to be
Quote:
Okay, I feel better now!!!!!!!!!!!!

Chuck Baird

"I wish I were dumber so I could be more certain about my opinions. It looks fun." -- Scott Adams

http://www.cbaird.org