View unanswered posts | View active topics It is currently Wed Sep 23, 2020 4:17 pm






Reply to topic  [ 5 posts ] 
NXT Touch sensors raw value 
Author Message
Rookie

Joined: Sun Dec 27, 2009 5:46 am
Posts: 10
Post NXT Touch sensors raw value
Hi all,

Are the NXT touch sensors purely binary or not. If not, is it possible to read them as analog inputs.
I tried to use SensorRaw[], but instead of getting 0 or 1, I simply get 180 or 1023. I tried to suppress the #pragma line added to robot C and simply read the S2 raw value, with the same result, so it does not look very promising.
Still, I remember reading this sensor with the MatlabNXT toolbox and not getting binary values, like in this code (OK, it's not RobotC, but this is to illustrate).

Code:
disp('Press contact sensor to start the robot.');
set(nxt.Port1, 'type', 'touch');
% Wait until the user presses the sensor
while getdata(nxt.Port1) > 40
end
playSoundFile(nxti, '! Attention.rso', 1);
% Wait until the user releases the sensor.
while getdata(nxt.Port1) <= 60
end


Anyone knows how to obtain a similar result with RobotC ?
Thanks for any input.

G.G.


Sun Jan 10, 2010 11:04 am
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: NXT Touch sensors raw value
Just configure the sensor port as a touch sensor and you'll get your binary values if and only if you use the SensorValue and not SensorRaw

Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sun Jan 10, 2010 11:11 am
Profile WWW
Rookie

Joined: Sun Dec 27, 2009 5:46 am
Posts: 10
Post Re: NXT Touch sensors raw value
Sorry, I was not clear in my post I think: I would like to know whether it is possible to read non binary values, i.e. obtain values in the full range (which seems to be 180 - 1023 with my sensor).

The reason is I would like to use a touche sensor as an "accelerator": the sensor is pressed by the user, and the robot speed is set proportional to the value read.

G.G.


Sun Jan 10, 2010 12:01 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: NXT Touch sensors raw value
No, the touch sensor does not allow this. It's either really low, around 0 or really high around 1000.

Regards,
Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sun Jan 10, 2010 12:48 pm
Profile WWW
Rookie

Joined: Sun Dec 27, 2009 5:46 am
Posts: 10
Post Re: NXT Touch sensors raw value
:( Sad news, but that's life !


Sun Jan 10, 2010 2:58 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.