NXC: can't read Dexter pressure sensor values

Discussion specific to the intelligent brick, sensors, motors, and more.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

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

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

As I posted above, I already used the 500kPa code where I got
raw: 40...100
kPa:-3 ... 40
Last edited by HaWe on 27 Feb 2011, 17:32, edited 1 time in total.
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 »

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

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

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

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 ;) )
Last edited by HaWe on 27 Feb 2011, 18:18, edited 1 time in total.
nxtreme
Posts: 246
Joined: 29 Sep 2010, 03:53
Location: 192.168.1.2

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

Post 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...
Last edited by nxtreme on 27 Feb 2011, 18:22, edited 1 time in total.
One King to rule them all, One King to find them,
One King to bring them all and in the darkness bind them
On Earth where Shadows lie.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

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

Post by HaWe »

please let's not becoming OT... ;)
nxtreme
Posts: 246
Joined: 29 Sep 2010, 03:53
Location: 192.168.1.2

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

Post by nxtreme »

Yes, yes, very true, very sorry. Couldn't resist :P.
One King to rule them all, One King to find them,
One King to bring them all and in the darkness bind them
On Earth where Shadows lie.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests