Go Down

Topic: How can I fix this unstable condition? (Read 519 times) previous topic - next topic

May 03, 2013, 10:02 am Last Edit: May 03, 2013, 03:07 pm by orchestraj Reason: 1


hi

I'm using GP2D12 Infrared sensors to control an electric lift.

I followed the recommendation which is adding a capacitor to the sensor.

But I'm having a problem that the sensor's input is extremly unstable.

I will appreciate for any comments. Thank you.

The following is the code.

Code: [Select]
#define Lift0 A3
#define Lift1 A4
#define Lift2 A5
#define front 6
#define top 7
#define Relay0 5
#define Relay1 4
int LiftValue0=0,LiftValue1=0,LiftValue2=0;
int frontValue=0,topValue=0;
int a=0,b=0,c=0;

void setup(){
 Serial.begin(9600);

 pinMode(Relay0,OUTPUT);
 pinMode(Relay1,OUTPUT);
 }
void loop()
{
LiftValue0=analogRead(Lift0);
LiftValue1=analogRead(Lift1);
LiftValue2=analogRead(Lift2);
frontValue=digitalRead(front);
topValue=digitalRead(top);

if(LiftValue0>300){
   a=1;}
 else{
   a=0;}
 if(LiftValue1>300){
   b=1;}
 else{
   b=0;}
 if(LiftValue2>300){
   c=1;}
  else{
    c=0;}

if((frontValue==0)||(topValue==0)){
  if(topValue==0){
        digitalWrite(Relay1,HIGH);
        delay(500);
        digitalWrite(Relay1,LOW);}
   if(frontValue==0){
         digitalWrite(Relay1,HIGH);
         delay(500);
         digitalWrite(Relay1,LOW);}
    }
   if((topValue==1)&&(frontValue==1)){
         if((a==1)||(b==1)||(c==1)){
             digitalWrite(Relay0,HIGH);
             delay(500);
             digitalWrite(Relay0,LOW);}
            }
    }

RReguera

Hi,

Try to add a low pass filter. Maybe that helps

Regards


Hi,

Try to add a low pass filter. Maybe that helps

Regards


I will try it!

Thank you very much  :)

MarkT

How long are the cables to the sensor?  Are they shielded?  Are they running alongside high current wiring?
Is there a source of electrical noise nearby?  What kind of optical target material are you using for the sensor?
[ I won't respond to messages, use the forum please ]

el_supremo

What exactly is the problem that needs to be fixed?
Quote
the sensor's input is extremly unstable

That's about as vague a statement as you could have possibly made. How do you know the sensor is unstable?
What are the symptoms of the problem and where's your measurements/debugging of the problem?

Pete


How long are the cables to the sensor?  Are they shielded?  Are they running alongside high current wiring?
Is there a source of electrical noise nearby?  What kind of optical target material are you using for the sensor?


How long are the cables to the sensor?
-Approximately 90~100cm

Are they shielded?
-No they aren't

Are they running alongside high current wiring?
-Only 5V

Is there a source of electrical noise nearby?
-Probably..... wires from 3 sensors are inside of 17?-pipe

What kind of optical target material are you using for the sensor?
-Human bodies.


:)


What exactly is the problem that needs to be fixed?
Quote
the sensor's input is extremly unstable

That's about as vague a statement as you could have possibly made. How do you know the sensor is unstable?
What are the symptoms of the problem and where's your measurements/debugging of the problem?

Pete


When I ran the code that I attached above, I could see the following symptoms.

1. The lift(What I need to control) went up even though there weren't any targets in the range of the sensor.
2. The lift didn't go up as against it went up (There were targets in the range)

My English is not so good to explain exactly what I'm going through  =(


Go Up