Gp2d12
Hi,
I am trying to connect the GP2D12 to the javelin board demo. But i do not anderstand everythings.
http://document.sharpsma.com/files/GP2D12-DATA-SHEET.PDF
The GP2D12 got 3 cables 2) to the groud· 1) output voltage and 3)input voltage
So, i should need to connect :
2) to the·Vss
1) to pinX1
3) to pinX2
To start the mesure i must telle the PinX2(input voltage) to send electricity to the GP2D12 and analyse the voltage on PinX1. So i anderstoud that i must use DAC class like this :
static ADC GP2D12 = new ADC(CPU.pinX2(input voltage), CPU.pinX1(output voltage));
so, i should use DAC.start to activate the GP2D12 and then DAC.Stop to stop it. And in between read the Dac.value();
so, the code shoulb be :
GP2D12.start();
GP2D12.value();
GP2D12.stop();
is that rigth or am i completly out ?
thanks
·
I am trying to connect the GP2D12 to the javelin board demo. But i do not anderstand everythings.
http://document.sharpsma.com/files/GP2D12-DATA-SHEET.PDF
The GP2D12 got 3 cables 2) to the groud· 1) output voltage and 3)input voltage
So, i should need to connect :
2) to the·Vss
1) to pinX1
3) to pinX2
To start the mesure i must telle the PinX2(input voltage) to send electricity to the GP2D12 and analyse the voltage on PinX1. So i anderstoud that i must use DAC class like this :
static ADC GP2D12 = new ADC(CPU.pinX2(input voltage), CPU.pinX1(output voltage));
so, i should use DAC.start to activate the GP2D12 and then DAC.Stop to stop it. And in between read the Dac.value();
so, the code shoulb be :
GP2D12.start();
GP2D12.value();
GP2D12.stop();
is that rigth or am i completly out ?
thanks
·
Comments
GP2D12-pin2 = GND
GP2D12-pin3 = VDD (5V), use the VDD on connector X3 (top right on javelin board)
GP2D12-pin1 = Vo (analog voltage), connects to analog input of ADC.
The schematic for the ADC can be found at page 159 of the javelin manual.
For convenience I attached the manual and the board schematic.
regards peter
If i connect to GP2D12-pin3 = VDD (5V), use the VDD on connector X3 (top right on javelin board).
the GP2D12 will be working all the time.
I would like to be able to start the mesure when i need to do it. So i would like to tell the GP2D12 to start mesuring and then to get the result.
1) start the mesure
2) get result
3) stop the GP2D12
how can i do this ?
Your code communicates via the ADC object.
static ADC myAdc = new ADC(CPU.pin0,CPU.pin1);
Anytime you need a sample of the sensor, you use
· value = myAdc.value(); //this returns the latest analogue voltage measured
The value has range 0-255, which you must convert to
whatever unit you would like to use.
regards peter
i have done what you said and i got alway 0 as result ?
By the way what it is used for the ADC.outpin ?
(section constructor) ADC(int inPin, int outPin)
Have you connected pin1 of the GP2D12 to the analog input of figure 9.1 on page 159?
Post your complete code.
regards peter
I have tried many thing. like removing to resistor between analog input and pin inPin. And i alway get the same result value, around 100 and 105.
if i remove the resistor connected to the outPin i got around 90.
???
by the way i found this doing a search :
http://forums.parallax.com/forums/default.aspx?f=8&m=171163&g=172221#m172221
It look like the condo must be 0.1 and not 1.0 as said in the documentation page 160.
what is the rigth solution. in connect the condo i got with the javelin edu pack so (1 for 25v)
What do i by as condo ? 0.1 with 2.5 v
The ADC will keep the voltage across the capacitor at 2.5V
You may need to check the GP2D12 datasheet, to find out what
voltage range is outputted. The ADC delivers values 0-255 for
a 0-5V input. If your sensor only outputs 1-2V, then the
range of ADC values will be limited.
You may also need to check wether a 10k resistor is not too much load
for the sensor output (because that would lower the sensor output voltage).
If it is, try using two 100k resistors.
regards peter
Good value for between 5 and 10 cm. But it is sold for 10 to 80 cm.
I will try with 100 k tomorow. I let you know
thanhk for the help.
If find the solution with the GP2D12 and ADC. infact there is two solution :
1) i can get the correct value for distance using 100k resistor and 1uf condo
2) if i remove the condo and keep the 2 resistror i got result 128(2.5v) when an object is on the axe of the GP2D12 and this for any distance from 1cm to 80cm.
the second solution is very intersting.
But i got one question :
it is possible that you explain to me how the ADC work.
it look like the output pin send constantly energie to the systeme. Because when i remove he analog input i alway got 128 which is the 2.5 volt that is use to keep the condo full.
So in the second case where i got 128 when object is detected. This should means that the GP2D12 send 0 volt. But when there is nothing in front of the GP2D12 i alway got value between 13 and 35 (average 25). It is because the ADC counter reset to 0 after counting to 128 ? so the value a got are just parasite voltage send by GP2D12 ?
Without any analog input voltage, the ADC outpin toggles every loop (dutycycle 50%),
and so the ADC input sees an equal number of 1's and 0's, so the average
is 128 over 256 loops. dutycycle = (number of 1's / 256)*100%
regards peter
(number of 1's / 256)*100%
the number of 1's are 128. those are send to inpin by the outpin
how it is possible to multiple by 100% ?
regards peter