NXC: can't read Dexter pressure sensor values

Discussion specific to the intelligent brick, sensors, motors, and more.
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

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

Post by mattallen37 »

doc-helmut wrote: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 ;) )
No, setting the sensor type to touch, and then RAW does NOT only allow for the values of 1023 and 183. Those two values are the only values that the NXT touch sensor returns, but those are not the only possibilities (actually, I think when pressed, it is more like 184).

A real, uncooked RAW value (of a 100% ideal ADC), does the equivalent of the following. ADC_Value=(mv*Max_ADC_Value)/Reference_mv. For NXT specs, that would look like this. ADC_Value=Pin1_Voltage*1024)/5000 (or whatever the sensor supply voltage really is, in mv, probably more like 4300-4700).

Because of this, any type or mode that follows this "Usually all other analog raw values have readings of 0 for for "infinite resistance" and 1023 for "zero resistance"." is not uncooked. It is inverted, if nothing more.

With nothing connected, the RAW value should be 1023 (because of the pullup). With no resistance, the RAW value should be 0, despite the 10k pullup.

Believe me, I just tested this, and it DOES WORK.

Code: Select all

task main()
{
  SetSensorTouch(S1);
  SetSensorMode(S1, IN_MODE_RAW);
  while (true)
  {
    ClearScreen();
    NumOut(0,LCD_LINE1,SENSOR_1);
    Wait(50);
  }
}
Connect a touch sensor, and you should get the values of 184 (ish) and 1023. If you get those values, then the code IS WORKING PROPERLY!

OT, but just a little tip. The NXT has a 10k pullup, so to calculate ohms, you can use this: OHMs = (10000 * SENSOR_1) / ( 1023 - SENSOR_1 );
nxtreme wrote:
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, should bought a stick of gum instead...
LOL, I remember using a knife as well, and oh what a relief to get my first set of wire strippers. I paid $2 for them, and they are still my primary set ;) .
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

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

Post by HaWe »

the value of 183 was only related for the touch sensor pressed.
I certailny know that other analog sensors used by this TOUCH-pseudo-analog-driver may go down to completely 0.
Bot it should demonstrate that is goes from 1023 to 0 (descending pressed -> unpressed) although a touch sensor configured as an analog type gos from 0 to 1023 (ascending pressed -> unpressed). So again:
How is the DxPS configured? 0 to 1023 or 1023 to 0 for ascending pressures?
What raw range SHOULD it have?
Is the maximum kPa value really 40 for about 3 bar = 300 kPa?
what exactly is faulty?
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...
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

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

Post by HaWe »

Xander,
I read through both of your postet pdf's but I still can't find anything about the range of raw values of the pressure sensor (for pressures 0...500kPa) if configured as a standard analog sensor. So what raw range do you get with your 250kPa sensor?
Anyone else who got one of those sensors and can test the raw value range by NXC?
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 range -is- there, it's expressed in volts, not 0-1023. It's not rocket surgery to convert the voltage range to a 0-1023 range when you use 4.85V as your reference voltage (as in my drivers).

- 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 »

thx, I admit that this whole load of English-language electronic information was not easy to read.
Though the voltage of 4,85 V I found, I still have no idea how is this voltage calculated into an expectable range of raw value?
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 data sheet says the output voltage range is 0.2 to 4.7V. So if the 0-1023 spans a voltage range from 0-4.85V, then 0.2 to 4.7V is....

about 40 to 990 if there's no interference from the firmware internals.

Also the datasheet assumes Vref is 5, which is not the case with the NXT, so your results may be somewhat different from the theoretical.

- 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 »

thanks - that's what I have been afraid of.
my ranges are going just from about (drifting) 35(40) up to 100 (110), that's far too little.

So now either the NXC analog raw driver is faulty or the sensor itself is defective.

It would help if you could confirm that raw value range up to 900 (or whatever) with your equipment and your posted NXC driver (using TYPE_TOUCH ).
If the 250kPa sensor has got this raw range approximately, than my sensor definitively is broken (and the software driver is ok).
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 »

...or you could get over your issues with ROBOTC and try it with my test program and driver. Make sure you modify it to call the 500kPa sensor functions.

I have other things on my plate today that have a much higher priority (personal stuff).

You have options, utilise them.

- 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 »

I didn't give you orders to do it here and now, and if you don't want to do it some day no one can force you to do that.

On the other hand I had asked if other people may have this sensor to test it.

So please stop offending me.
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

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

Post by mattallen37 »

I am sure that Xander doesn't mean to offend you.

If, using SensorRaw, the value range is still 40-100, for 0-70 psi (or the other way around), then I would say the sensor is defective.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests