Page 4 of 7
Re: NXC: can't read Dexter pressure sensor values
Posted: 27 Feb 2011, 17:08
by HaWe
I don't want to start a flame war, so just this:
My "feeling" that something is faulty is because of the following:
1) the "normal range" of analog sensors attached to the NXT is usually something between the full range of 0...1023 (Sound, Light, even Touch (raw), somehow also the HTGyro). In case of my DxPS it's far less (approx. 40-100)
2) the result I'm getting using your formula is something in between -3 and 40. 100 kPa = 1 bar, so 40 = 40kPa = 0.4 bar. But my preesure sensor should show at full pressure about 2-3 bar = 200-300 kPa. That's far more than it actually does. So either the raw values are faulty or the calculating formula or the sensor. And already -3 as calculated for "real pressure"=0 is not quite what I "feel" what I should have expected.
Re: NXC: can't read Dexter pressure sensor values
Posted: 27 Feb 2011, 17:29
by mightor
You need to use the right conversion formula for
your sensor though. I think I was using the 250 kPa sensor formula in my test program (since that is what I have). If you have the 500kPa sensor then you need to use that one. I pasted both the 250 and 500 kPa functions in an earlier post. It's ROBOTC code, but I am sure you will manage, it's all math
- Xander
Re: NXC: can't read Dexter pressure sensor values
Posted: 27 Feb 2011, 17:31
by HaWe
As I posted above, I already used the 500kPa code where I got
raw: 40...100
kPa:-3 ... 40
Re: NXC: can't read Dexter pressure sensor values
Posted: 27 Feb 2011, 17:32
by mattallen37
Well, you could try measuring the analog line with a voltage meter, and see if it corresponds to the RAW ADC value the NXT reads. Or, you could completely do away with the NXT, and just power the sensor as the NXT would (don't forget the 10k pullup), and read it with a volt meter. See what voltage range you get. That should at least point to the problem.
Re: NXC: can't read Dexter pressure sensor values
Posted: 27 Feb 2011, 17:35
by HaWe
I don't have a voltage meter and I dont have the electronic equipment for putting something in between in a line.
I first only need a reliable raw sensor type/mode configuring system.
TOUCH is not reliable, because SENSOR_TYPE_LIGHT or SENSOR_TYPE_SOUND_DBA or SENSOR_TYPE_LIGHT_INACTIVE or SENSOR_TYPE_CUSTOM all give readings of constantly 0.
The point is actually now only the RAW value itself.
1) A range only from about 40 to 100 seems faulty to me. - Do you have a wider range with your equipment?
2) Having to use SENSOR_TYPE_TOUCH seems weird and unlogic to me: it's upside down compared to other analog raw inputs (1023...0 instead of 0...1023) - so why use Touch?
3) why doesn't it work if I'm using SENSOR_TYPE_LIGHT_INACTIVE or SENSOR_TYPE_LIGHT or SENSOR_TYPE_CUSTOM? Why isn't there sth like SENSOR_TYPE_ANALOG_STANDARD or however an unfaked "analog standard sensor" may be called by NXC?
So how actually is the correct Sensor Type? Touch intuitively seems to me that it may be the wrong approach...
Re: NXC: can't read Dexter pressure sensor values
Posted: 27 Feb 2011, 17:54
by mattallen37
Well, I would suggest investing in a volt meter. I don't know how much they cost in Germany, but here, you can get cheap digital multimeters for $2 each. Add the price of a single NXT wire (to cut), and wire strippers, that is only like $5 (based on prices here). It should help you know if it is a SW or HW problem.
As far as tried and proven working code for reading RAW values, I know for a fact that the following has worked properly for me.
Code: Select all
task main()
{
SetSensorTouch(S1);
SetSensorMode(S1, IN_MODE_RAW);
while (true)
{
ClearScreen();
NumOut(0,LCD_LINE1,SENSOR_1);
Wait(50);
}
}
I used a 10k pull down, to make a 1:1 voltage divider, and the result was 507. The pull down resistor is rated for 5% tolerance, and the calculated value is 512 (for exactly half voltage). I would say that is pretty good, and proves no "cooking" of RAW values took place in the program.
Re: NXC: can't read Dexter pressure sensor values
Posted: 27 Feb 2011, 18:04
by HaWe
but TOUCH (actually the same as I used by Xander's code) shows 1023 for "infinite resistance" and 183 for "pressed" (low resistance).
Usually all other analog raw values have readings of 0 for for "infinite resistance" and 1023 for "zero resistance".
I'm curious on which kind of readings the DxPS is calibrated.
Isn't there a reliable "uncooked" standard analog type available in NXC?
(And no, I won't start tinkering with electronic stuff like resistors or lead or experimental boards anymore. I'm only using "ready finished" equipment ;) )
Re: NXC: can't read Dexter pressure sensor values
Posted: 27 Feb 2011, 18:08
by nxtreme
mattallen37 wrote:...wire strippers...
Wire strippers?
Wire strippers!?!?! Come on! Use your teeth (don't let your dentist know I said that) or a good sharp knife. I used my knife for a good year before I bought wire strippers. I wasted a good 25 cents on a garage sale pair, shoulda bought a stick of gum instead...
Re: NXC: can't read Dexter pressure sensor values
Posted: 27 Feb 2011, 18:17
by HaWe
please let's not becoming OT... ;)
Re: NXC: can't read Dexter pressure sensor values
Posted: 27 Feb 2011, 18:25
by nxtreme
Yes, yes, very true, very sorry. Couldn't resist
.