Pages: [1]   Go Down
Author Topic: How can I fix this unstable condition?  (Read 494 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset



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:
#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);}
             }
     }
« Last Edit: May 03, 2013, 08:07:28 am by orchestraj » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Try to add a low pass filter. Maybe that helps

Regards
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Try to add a low pass filter. Maybe that helps

Regards

I will try it!

Thank you very much  smiley
Logged

0
Offline Offline
Shannon Member
****
Karma: 222
Posts: 12725
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Edison Member
*
Karma: 50
Posts: 1702
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.


 smiley
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-cry

Logged

Pages: [1]   Go Up
Jump to: