Reflective sensor and distance detector problem when connected together

Hi everybody,

I’m using the FEZ Mini Robot kit with two reflective sensors connected on it.
I had the idea to add two Sharp GP2D120 distance detectors on it.
But when i run the robot with my reflective sensors and without using the distance detector in the code they are juste declared in it as shown below.
It seems that the distance detector are “connected” together with the reflective sensor ?!? The distance detectors are reacting like the refelective sensor, but they are not used in the code…
It there any hardware limitation, maybe?

    static FEZ_Components.DistanceDetector LeftDetector = new FEZ_Components.DistanceDetector(FEZ_Pin.AnalogIn.An6, FEZ_Components.DistanceDetector.SharpSensorType.GP2D120);
    static FEZ_Components.DistanceDetector RightDetector = new FEZ_Components.DistanceDetector(FEZ_Pin.AnalogIn.An7, FEZ_Components.DistanceDetector.SharpSensorType.GP2D120);
    static FEZ_Components.ReflectiveSensor LeftSensor = new FEZ_Components.ReflectiveSensor(FEZ_Pin.AnalogIn.An1, 50);
    static FEZ_Components.ReflectiveSensor RightSensor = new FEZ_Components.ReflectiveSensor(FEZ_Pin.AnalogIn.An2, 50);

Thanks for helping me and have a nice day,

Marco

Hey there Marco, welcome to the forum!

I can’t quite figure out what your fault may be. Can you step through this again?

You have two reflective sensors that you’re not currently trying to use, but you have them defined in the code. Are they still physically connected?

You have two Sharp GP2D120 IR sensors (Datasheet http://www.robot-electronics.co.uk/datasheets/gp2d120.pdf )

The Sharp sensors are analog sensors, so your definitions look right. Can you confirm how your sensors are connected?

One thing I note in the output characteristics of those sensors is that they can output up to VCC +0.3v, so if you’re powering it with 5v, you can easily hit 5v output. Now the Fez Analog inputs can only handle 3.3v maximum. My suggestion is that you should only supply 3v3 maximum to the sensors, and even then you may still saturate the Fez analog input circuit.

Last question for the moment; can you describe the actual behaviour? Does your code actually use the LeftSensor RightSensor, or the LeftDetector RightDetector?

@ Brett - I have that same sensor (GP2D120) sitting on my desk and have just wacked a volt meter across it.

5v max output 2.93v
3.3v max output 2.34v

Recommended VCC is 5v

Cool, that’s a good test; but the data sheet states (in hte absolute max table) the Output Terminal Voltage, Vo, is -0.3 to vcc+0.3. Not saying you’re not right, but I’d be worried about damaging the ADC multiplexer if the sensor did as it says it can.

It definetely does say that you should run it with 4v5 to 5v5.

I don’t quite get it either but the graphs further down display a Max of around 3v ouput

quit yappin and connect to a Fez and run the code and see what it does for you :wink: How do you expect to top 10k ?!!

@ Brett - good points :smiley:

Hi,

Thank you for trying to solve my problem.

Yes the two sensors and the two detectors are physically connected on the board.

I tested actually the two distance detectors they are working very well, but when i’m trying to connect the two reflective sensors one of them mostly the first declared in the code is like connected to the distance detectors, but when i connect and declare only one reflective sensor it’s working but with two of them not…

And all four sensors are connected like declared in the code.

@ Dragonsshout - just to get my head around things…

 
            // GP2D120 working ok and giving good results?
            FEZ_Components.DistanceDetector LeftDetector = new FEZ_Components.DistanceDetector(FEZ_Pin.AnalogIn.An6, FEZ_Components.DistanceDetector.SharpSensorType.GP2D120);
            FEZ_Components.DistanceDetector RightDetector = new FEZ_Components.DistanceDetector(FEZ_Pin.AnalogIn.An7, FEZ_Components.DistanceDetector.SharpSensorType.GP2D120);

            // what are these? 
            FEZ_Components.ReflectiveSensor LeftSensor = new FEZ_Components.ReflectiveSensor(FEZ_Pin.AnalogIn.An1, 50);
            FEZ_Components.ReflectiveSensor RightSensor = new FEZ_Components.ReflectiveSensor(FEZ_Pin.AnalogIn.An2, 50);

Do you have a link to the code you are running?

@ Justin- Yes i get good result , the robot works very well with detecting walls for example.

The reflective sensor is given with the robot kit :

http://www.google.ch/url?sa=t&source=web&cd=2&ved=0CCoQFjAB&url=http%3A%2F%2Fwww.ghielectronics.com%2Fdownloads%2FFEZ%2FComponent%2FBroch_ReflectiveSensor.pdf&ei=MExgUJqhKM3DtAbrroHoBQ&usg=AFQjCNGmjKdN_Bp6HdcKZfHoOW_rikSiFg&sig2=D_ghMuOeOISr3ZAb-PCmmg

I will upload the code as soon as i can.

You can download my entire solution at this link: no-more-existing

Thanks for helping

@ Dragonsshout - Hiya, sorry for the delay has been one of those weeks already…

Anywho…

In your code you are only using the GP2D120’s LeftDetector and RightDetector and the ReflectiveSensors LeftSensor and RightSensor are declared but not used in the code.

Does it work ok like this?

How are you using the ReflectiveSensors?

@ Justin - Don’t worry for that… Thanks for your help by the way.

Yes, the ReflectiveSensors LeftSensor and RightSensor are not used in the code, but only declared.

It doesn’t work like that.
It’s like i connected physically the first sensor declared in the code (the LeftSensor in this case) with the two detectors. It very weird…
The LeftSensor react with the two detectors, i don’t understand that… Maybe it’s a hardware limitation?

But if i delete one of the to sensor, like the RightSensor, the problem has gone and the LeftSensor don’t react anymore with the two detectors.
I tried other same detectors, sensors and boards but it’s always the same problem so the hardware is not defect.

In the example picture the ReflectiveSensors are hooked up to A6 and A7 but you are using A1 and A2.
Try changing the ReflectiveSensors to A6 and A7 like in the pic and connect the GP2D120’s to A1 and A2.

        static FEZ_Components.DistanceDetector LeftDetector = new FEZ_Components.DistanceDetector(FEZ_Pin.AnalogIn.An1, FEZ_Components.DistanceDetector.SharpSensorType.GP2D120);
        static FEZ_Components.DistanceDetector RightDetector = new FEZ_Components.DistanceDetector(FEZ_Pin.AnalogIn.An2, FEZ_Components.DistanceDetector.SharpSensorType.GP2D120);
        static FEZ_Components.ReflectiveSensor LeftSensor = new FEZ_Components.ReflectiveSensor(FEZ_Pin.AnalogIn.An6, 50);
        static FEZ_Components.ReflectiveSensor RightSensor = new FEZ_Components.ReflectiveSensor(FEZ_Pin.AnalogIn.An7, 50);

Does this help any?

Also forgot to ask, what is the actual strange behaviour?

I tried to invert the the ReflectiveSensors on A6 and A7 and the GP2D120 on A1 and A2. But it change nothing.
Where did you find this picture?

The actual strange behaviour is when the reflective sensor detects a white line acts like the distance dector detect a wall.
So it puts the input to “1” but i’m not sure about this…

i found the same problem in this thread: http://www.tinyclr.com/forum/search?q=user:2242
i have to read it…

Ok I found the solution!
The ZX-03 Reflective sensor was saturating the Fez analog input circuit. Because the output of the sensor was 0-5V and the analog input is max 3,3V as Breth says…
I added a 3,3K Ohm resistance between the sensor output and the cable connector and changed the 10k Ohm resistor with a 5,6k Ohm to have max 3,2V output and it work great!

Thanks you very much guys for your great help!!!

PS: But why are designed so? Is there not a design problem? Maybe we have to tell GHI about this issue?

@ Dragonsshout - Glad you got it working :slight_smile:

@ Justin - Yes i’m happy about it :smiley:
Thank you for your help and ideas :wink: