Page 7 of 7
Re: NXC: can't read Dexter pressure sensor values
Posted: 01 Mar 2011, 22:08
by mattallen37
mightor wrote:You still never eliminated the one common thing: the firmware.
- Xander
Actually, we did. He tested it with a touch sensor, and got the expected readings, so that proves it isn't the FW.
Re: NXC: can't read Dexter pressure sensor values
Posted: 01 Mar 2011, 22:10
by mightor
No, it just means that the TOUCH sensor works fine.
- Xander
Re: NXC: can't read Dexter pressure sensor values
Posted: 01 Mar 2011, 22:17
by HaWe
You forgot: I tried also the sound sensor, it was also fine with all settings, as I wrote before.
Re: NXC: can't read Dexter pressure sensor values
Posted: 01 Mar 2011, 22:25
by mattallen37
mightor wrote:No, it just means that the TOUCH sensor works fine.
- Xander
He tested it in RAW mode, and it gave the proper readings of ~184 and 1023. That means that he was indeed seeing RAW values, and that the FW wasn't messing around. You're right, it does prove that the touch sensor works fine, but since he replaced it with the pressure sensor, and that DIDN'T behave like it should have, it seems pretty obvious that the sensor itself is the issue.
Re: NXC: can't read Dexter pressure sensor values
Posted: 01 Mar 2011, 22:26
by HaWe
You forgot: I tried also the sound sensor, it was also fine with all settings, as I wrote before.
hi,
indeed, that's really odd:
In the test program I'm reading "raw" values in both cases from sound sensors,
S1 configured as: SetSensorType(S1, SENSOR_TYPE_SOUND_DBA); SetSensorMode(S1, SENSOR_MODE_RAW); val1 = SensorValue(S1);
S2 configured as: SetSensor(S2, SENSOR_SOUND); val2 = SensorRaw(S2);
attaching the sound sensor:
S1 shows (quiet) 13 ->->-> (loud) 1023
S2 shows (quiet) 988 ->->-> (loud) 263
taking touch sensors instead:
S1 shows (released) 0 -> -> -> (pressed) 999
S2 shows (released) 1023->->-> (pressed) 186
What the hell did the Lego people think when they established (at least) 2 completely different inverse "raw" measuring results for one and the same single sensor ?!?
Code: Select all
#define printf1( _x, _y, _format1, _value1) { \
string sval1 = FormatNum(_format1, _value1); \
TextOut(_x, _y, sval1); \
}
int val1, val2;
task main(){
SetSensorType(S1, SENSOR_TYPE_SOUND_DBA);
SetSensorMode(S1, SENSOR_MODE_RAW);
SetSensor(S2, SENSOR_SOUND);
while(true) {
val1 = SensorValue(S1);
val2 = SensorRaw(S2);
printf1(0, LCD_LINE1, "%5d", val1);
printf1(0, LCD_LINE2, "%5d", val2);
Wait(10);
}
}
Re: NXC: can't read Dexter pressure sensor values
Posted: 22 Mar 2011, 21:07
by HaWe
hi,
got a new pressure sensor (500 psi), now it works.
Xander, I could simplify your formula very much - the trick was to change int val into float val
(no Vout, no other buffer):
pressure = (((val / 1023) ) - 0.04) *556;
Code: Select all
#define printf1( _x, _y, _format1, _value1) { \
string sval1 = FormatNum(_format1, _value1); \
TextOut(_x, _y, sval1); \
}
float val;
float pressure;
task main(){
SetSensorType(S1, SENSOR_TYPE_TOUCH);
SetSensorMode(S1, SENSOR_MODE_RAW);
while(true) {
val = SensorRaw(S1);
pressure = (((val / 1023) ) - 0.04) *556;
printf1(0, LCD_LINE1, "%5.0f", val);
printf1(0, LCD_LINE2, "%5.1f", pressure);
if (pressure<150) OnFwd(OUT_A,100);
else
if (pressure>175) Off(OUT_A);
Wait(10);
}
}
Re: NXC: can't read Dexter pressure sensor values
Posted: 22 Mar 2011, 21:23
by mightor
I'll update my drivers to use the same formula. Thanks!
- Xander