NXC: faulty SENSOR_TYPE_CUSTOM ?

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXC: faulty SENSOR_TYPE_CUSTOM ?

Post 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).
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: faulty SENSOR_TYPE_CUSTOM ?

Post 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.
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXC: faulty SENSOR_TYPE_CUSTOM ?

Post 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.
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: faulty SENSOR_TYPE_CUSTOM ?

Post 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.
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: NXC: faulty SENSOR_TYPE_CUSTOM ?

Post by muntoo »

doc-helmut wrote:thanks Matt, but I want to hear it from John
Does this mean the rest of us are idiots? Image :mrgreen:
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
mightor
Site Admin
Posts: 1079
Joined: 25 Sep 2010, 15:02
Location: Rotterdam, Netherlands
Contact:

Re: NXC: faulty SENSOR_TYPE_CUSTOM ?

Post 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
| 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: faulty SENSOR_TYPE_CUSTOM ?

Post 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.
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXC: faulty SENSOR_TYPE_CUSTOM ?

Post 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
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: NXC: faulty SENSOR_TYPE_CUSTOM ?

Post 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 ;) )
Post Reply

Who is online

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