Page 2 of 7
Re: NXC: can't read Dexter pressure sensor values
Posted: 26 Feb 2011, 18:15
by mightor
Then just stick to TOUCH. I doubt John will change this behaviour as it would make sensor readings in the EFW incompatible with the standard one. It would be better to create a new sensor type that doesn't cook the results.
- Xander
Re: NXC: can't read Dexter pressure sensor values
Posted: 26 Feb 2011, 18:25
by HaWe
TOUCH is not good:
1st, it's other way round as LIGHT_INACTIVE
2nd, more important: it produces only raw values between 40 and 18 (in the range of 0-1023).
I actually doubt that these are the correct values, chiefly because _LIGHT or _LIGHT_INACTIVE give constant 0 or 1023 (while the sound sensor in both cases gives correct values)
Have you got the same 40 to 18 range with your own driver?
Re: NXC: can't read Dexter pressure sensor values
Posted: 26 Feb 2011, 20:48
by mightor
You should be using SensorRaw if you want the proper values. I was getting values in the 400 range at normal pressure in NXC.
- Xander
Re: NXC: can't read Dexter pressure sensor values
Posted: 26 Feb 2011, 21:25
by HaWe
what is SENSOR_RAW? a sensor type?
as a mode I'm alread using
SetSensorMode(S2, SENSOR_MODE_RAW);
I tried now
SensorRaw(1);
instead of
SetSensorMode(S2, SENSOR_MODE_RAW);
but I'm getting only constantly 0.
But also attaching a sounssensor instead I only get constantly 0 with this.
(@John: rather weird those sensor readings , types and modes in NXC. Please make it better and more logical!)
Re: NXC: can't read Dexter pressure sensor values
Posted: 26 Feb 2011, 21:35
by HaWe
ps now I think I got it:
SetSensorType(1, SENSOR_TYPE_TOUCH);
SetSensorMode(1, SENSOR_MODE_RAW);
value=SensorRaw(1);
But in this case I only get values from 40...18
([Goodness], what a mess those NXC sensor readings! If once configured as SENSOR_MODE_RAW: why then not read as SensorValue but SensorRaw???
)
Re: NXC: can't read Dexter pressure sensor values
Posted: 26 Feb 2011, 21:36
by mightor
The firmware design is LEGO's, not John's
So blame them for the messed up sensor modes.
Did you try the program I pasted? It works for me with my DI pressure sensor. I have the 35PSI version.
- Xander
Re: NXC: can't read Dexter pressure sensor values
Posted: 26 Feb 2011, 21:37
by HaWe
OK: sorry: what a mess with those Lego sensor readings!
Let NXC become better!
(I got the 70 psi version)
What posted code?
Re: NXC: can't read Dexter pressure sensor values
Posted: 26 Feb 2011, 21:40
by HaWe
do you mean this:
Code: Select all
int val;
float pressure;
task main(){
//SetSensorType(S2, SENSOR_TYPE_TOUCH);
SetSensorType(S2, SENSOR_TYPE_LIGHT);
//SetSensorType(S2, SENSOR_TYPE_LIGHT_ACTIVE);
SetSensorMode(S2, SENSOR_MODE_RAW);
while(true) {
val = SensorRaw(S2);
pressure = ((val / 1023) - 0.04) / 0.0018; // Vout = ((val * DPRESS_VREF) / 1023);
printf("raw=%5d", val);
//printf("hPa=%5.1f", pressure); // alrenatively show raw or pressure
Wait(10);
}
}
with this I get constantly 233-234
Re: NXC: can't read Dexter pressure sensor values
Posted: 26 Feb 2011, 21:42
by mightor
And with the sensor configured as a TOUCH sensor?
- Xander
Re: NXC: can't read Dexter pressure sensor values
Posted: 26 Feb 2011, 21:43
by HaWe
46...18