ROBOTC.net forums
http://www.robotc.net/forums/

[Help] My sensors don't work
http://www.robotc.net/forums/viewtopic.php?f=1&t=1011
Page 1 of 1

Author:  Crocopep [ Sat Dec 06, 2008 6:48 am ]
Post subject:  [Help] My sensors don't work

Solved
It was something with Moter & Sensor Setup, the problem is solved now :)



Hey all,

I'm new here. Yesterday I downloaded the robotc 31 day trial for my lego NXT.

The problem is that my sensors don't work. When I go on my NXT to 'view', the sensors don't work, ultrasonic is stuck at 253 and the other sensors are stuck at 0.

But... When I go to 'try me' they work fine.

Also the sensors don't work in a program:
Code:
task main ()
{
   while(SensorValue[S1] == 0) //S1 is the touch sensor
   {
      motor[motorA] = -75;
      motor[motorC] = -75;
   }
}


The robot doesn't do anything when I run this program.

Please help me.

Pepijn

Author:  gspence [ Sat Jan 03, 2009 5:08 pm ]
Post subject:  Re: [Help] My sensors don't work

I'm having the exact same problem. Trying to use the Ultrasonic(SONAR) sensor and its not reading any values. I reverted to the original firmware from LEGO and it worked fine in the demo. I've re-downloaded the RobotC firmware and I'm getting no readings or very intermittent readings. The motors are working fine. Help!

Author:  Ford Prefect [ Sat Jan 03, 2009 6:36 pm ]
Post subject:  Re: [Help] My sensors don't work

hi,
what if the sensor value is unequal to 0 from the beginning?
the program will never enter the while loop...
is this what you intended?

if not, maybe try this:

Code:
task main ()
{
  while (true)
  { 
    if (SensorValue[S1] == 0) //S1 is the touch sensor
    {
        motor[motorA] = -75;
        motor[motorC] = -75;
    }
    else
    {
       // if !=0 maybe do the following or anything else
        motor[motorA] = 0;
        motor[motorC] = 0;
    }
  }
}

Author:  arcana666 [ Sat Jan 31, 2009 9:49 am ]
Post subject:  Re: [Help] My sensors don't work

gspence wrote:
I'm having the exact same problem. Trying to use the Ultrasonic(SONAR) sensor and its not reading any values. I reverted to the original firmware from LEGO and it worked fine in the demo. I've re-downloaded the RobotC firmware and I'm getting no readings or very intermittent readings. The motors are working fine. Help!


I had exactly the same problem. There is definitely something glitchy about the NXT ultrasonic sensor and RobotC. It's like RobotC forgets what sort of sensor it is. I managed to get around the problem by explicitly redefining the sensor type in an initialization function like this:

void Initialize()
{
SensorType[S4] = sensorSONAR;
}

Then I check the raw values of the sensor with SensorRaw[S4]

Again, it all works fine on the standard lego firmware.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/