Page 3 of 3
Re: NXC: faulty SENSOR_TYPE_CUSTOM ?
Posted: 01 Mar 2011, 22:19
by mattallen37
afanofosc wrote:What I was trying to say is that the input module code does not bother to populate the ADRaw field in the input module IOMap from the AVR data if you use one of the sensor types that I did not list. So you can't get it period. If it was in the IOMap you could get it via SensorRaw(). I could change this in the enhanced firmware but at the moment it acts just like the standard firmware does.
John Hansen
Ok, I understand now. Thanks for the explanation. I only have one project in mind that would benefit from you changing it in the enhanced FW, so if you want, you could go ahead (if it isn't too much hassle).
Re: NXC: faulty SENSOR_TYPE_CUSTOM ?
Posted: 01 Mar 2011, 22:22
by HaWe
???
@John:
I need(ed) uncorrupted raw data - is it too much to ask for a programming language? Please tell me what I have to do.
You can't read raw AVR AD values when you configure the port as any of these types: SENSOR_TYPE_LOWSPEED, SENSOR_TYPE_LOWSPEED_9V, or SENSOR_TYPE_HIGHSPEED.
does the following what I need - read unfaked uncorrupted raw values -
Code: Select all
SetSensorType(S1, SENSOR_TYPE_TOUCH);
SetSensorMode(S1, SENSOR_MODE_RAW);
Wait(20); // as per John's instructions
int val = SensorRaw(S1);
@John: Just say yes or no.
Re: NXC: faulty SENSOR_TYPE_CUSTOM ?
Posted: 01 Mar 2011, 22:29
by mattallen37
I am not John, but if it gives a reading of ~184 when an NXT touch sensor is pressed, then YES IT IS TRUE RAW. I can back that statement up with math.
Re: NXC: faulty SENSOR_TYPE_CUSTOM ?
Posted: 01 Mar 2011, 22:31
by HaWe
thanks Matt, but I want to hear it from John:
doc-helmut wrote:???
@John:
I need(ed) uncorrupted raw data - is it too much to ask for a programming language? Please tell me what I have to do.
You can't read raw AVR AD values when you configure the port as any of these types: SENSOR_TYPE_LOWSPEED, SENSOR_TYPE_LOWSPEED_9V, or SENSOR_TYPE_HIGHSPEED.
does the following what I need - read unfaked uncorrupted raw values -
Code: Select all
SetSensorType(S1, SENSOR_TYPE_TOUCH);
SetSensorMode(S1, SENSOR_MODE_RAW);
Wait(20); // as per John's instructions
int val = SensorRaw(S1);
:?:
@John: Just say yes or no.
Re: NXC: faulty SENSOR_TYPE_CUSTOM ?
Posted: 02 Mar 2011, 01:41
by muntoo
doc-helmut wrote:thanks Matt, but I want to hear it from John
Does this mean the rest of us are idiots?
Re: NXC: faulty SENSOR_TYPE_CUSTOM ?
Posted: 02 Mar 2011, 07:42
by mightor
Does this mean the rest of us are idiots?
Nah, the rest of us understood what John said without having to have it repeated three times
- Xander
Re: NXC: faulty SENSOR_TYPE_CUSTOM ?
Posted: 02 Mar 2011, 07:57
by HaWe
doc-helmut wrote:???
@John:
I need(ed) uncorrupted raw data - is it too much to ask for a programming language? Please tell me what I have to do.
You can't read raw AVR AD values when you configure the port as any of these types: SENSOR_TYPE_LOWSPEED, SENSOR_TYPE_LOWSPEED_9V, or SENSOR_TYPE_HIGHSPEED.
does the following what I need - read unfaked uncorrupted raw values -
Code: Select all
SetSensorType(S1, SENSOR_TYPE_TOUCH);
SetSensorMode(S1, SENSOR_MODE_RAW);
Wait(20); // as per John's instructions
int val = SensorRaw(S1);
@John: Just say yes or no.
no you're not idiots, you're English or American or English-speaking Dutch...
I'm not speaking English (ok, enough English to order a burger and a Coke at McDonald's) , I have to use GoogleTranslate or Babelfish and some posts contain so many words and so many things that I don't need to know for the moment and so many fw stuff or NBC code that I don't understand at all that the translations to German gives me only trash.
And e.g. I read things which I never had asked before, e.g.I have no idea why John started talking about i2c drivers - I never asked a single question about i2c in my TO question.
A simple definite answer containing just "yes" or "no" or only the code that I need to know was all I had ever requested.
Re: NXC: faulty SENSOR_TYPE_CUSTOM ?
Posted: 02 Mar 2011, 19:56
by afanofosc
yes? If the value you get from the AVR in what it calls the ADValue (see below) can be called an unfaked uncorrupted raw value then if I understand the firmware source code I think that the answer might be yes.
If you can write pseudo recursive chess playing programs translated from obfuscated C code then you can understand the firmware source code at least as well as I can.
Code: Select all
#define INPUTGetVal(pValues, No) *pValues = (UWORD)IoFromAvr.AdValue[No]; \
*pValues &= 0x03FF
void dInputGetRawAd(UWORD *pValues, UBYTE No)
{
INPUTGetVal(pValues, No);
}
case SWITCH:
{
UWORD InputVal;
dInputGetRawAd(&InputVal, No);
IOMapInput.Inputs[No].ADRaw = InputVal;
These snippets seem to prove that if you set the sensor as a SWITCH or SENSOR_TYPE_TOUCH (same value as SWITCH) then the ADRaw field of the Input module IOMap is set to the value that is read from the AVR chip and only "corrupted" by ANDing it with 0x03FF. The mode does not matter. The type can be any of the other types I previously mentioned but NOT the types that I mentioned that you can't use. Just read the unfaked uncorrupted RAW value using SensorRaw rather than SENSOR_n or Sensor or SensorValue.
John Hansen
Re: NXC: faulty SENSOR_TYPE_CUSTOM ?
Posted: 02 Mar 2011, 20:13
by HaWe
sorry, John, I really honestly understand no single word of the NBC or C++ or firmware code or what this language ever is or does.
But the answer that it is the one and only real raw value I get is all I wanted to know, thanks!
(but I never succeeded recursive chess programs because NXC unfortunately don't has recursions ;) )