NXC: can't read Dexter pressure sensor values

Discussion specific to the intelligent brick, sensors, motors, and more.
mightor
Site Admin
Posts: 1079
Joined: 25 Sep 2010, 15:02
Location: Rotterdam, Netherlands
Contact:

Re: NXC: can't read Dexter pressure sensor values

Post 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
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: NXC: can't read Dexter pressure sensor values

Post 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?
mightor
Site Admin
Posts: 1079
Joined: 25 Sep 2010, 15:02
Location: Rotterdam, Netherlands
Contact:

Re: NXC: can't read Dexter pressure sensor values

Post 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
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: NXC: can't read Dexter pressure sensor values

Post 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!)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: NXC: can't read Dexter pressure sensor values

Post 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??? :evil: )
Last edited by HaWe on 26 Feb 2011, 21:36, edited 1 time in total.
mightor
Site Admin
Posts: 1079
Joined: 25 Sep 2010, 15:02
Location: Rotterdam, Netherlands
Contact:

Re: NXC: can't read Dexter pressure sensor values

Post 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
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: NXC: can't read Dexter pressure sensor values

Post 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?
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: NXC: can't read Dexter pressure sensor values

Post 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
mightor
Site Admin
Posts: 1079
Joined: 25 Sep 2010, 15:02
Location: Rotterdam, Netherlands
Contact:

Re: NXC: can't read Dexter pressure sensor values

Post by mightor »

And with the sensor configured as a TOUCH sensor?

- Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: NXC: can't read Dexter pressure sensor values

Post by HaWe »

46...18
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 0 guests