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).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 )
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);
}
}
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 );
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 .nxtreme wrote: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...mattallen37 wrote:...wire strippers...