To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.nqcOpen lugnet.robotics.rcx.nqc in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / NQC / 676
675  |  677
Subject: 
Re: temperature sensor problem
Newsgroups: 
lugnet.robotics.rcx.nqc
Date: 
Mon, 3 Jul 2000 19:53:07 GMT
Viewed: 
1724 times
  
ahhh... there it is.  page 312.  thanks. :)  i think i saw that 3-digit stuff
before and i forgot about it.

and thanks for the idea about the until.

-ben


In lugnet.robotics.rcx.nqc, Dave Baum writes:
Ben,

Internally, the RCX only works with integers, but .1 degree resolution was
desired for temperature sensors, so the sensor values are actually measured in
.1 degree increments.  A reading of 70 degrees F is stored as 700, not 70.  If
you change the value in the 'if' statement to 700 things should start working.

An aside - your program repeatedly calls On() or Off() even when no state
change is required.  Its really a matter of style (and efficiency), but I
prefer to only call functions such as On() or Off() when a state has changed.
You could do something like:

#define CUTOFF 700

while(true)
{
// off state...wait until too hot, then turn on
until(SENSOR_1 >= CUTOFF);
On(OUT_A + OUT_C);

// on state...wait until too cold, then turn off
until(SENSOR_1 < CUTOFF);
Off(OUT_A + OUT_C);
}

It turns out that these until loops are much tighter than the while/if/On/Off
loop you wrote, so the response time would be faster.  Not really a big deal
considering the slowness of the temp sensor.  As I said, its mostly a matter • of
style.

Also, you can take the SetSensorMode() back out.  The call to SetSensor() will
set both the type and mode correctly.

Dave

In lugnet.robotics.rcx.nqc, Ben Erwin writes:

It's probably something simple and i'm about to embarrass myself, but
I'm trying to write the equivalent of an RCX Code temperature sensor watcher
with NQC.  The motors don't seem to shut off, even when the temperature gets
less than 70... (I added the SetSensorMode in after it didn't work the first
time)

-Ben

// BubbleTemp

task main()
{
SetSensor(SENSOR_1, SENSOR_FAHRENHEIT);
SetSensorMode(SENSOR_1, SENSOR_MODE_FAHRENHEIT);

while(true)
{
if (SENSOR_1 < 70)
{
Off(OUT_A + OUT_C);
}
else
{
On(OUT_A + OUT_C);




Message has 1 Reply:
  Re: temperature sensor problem
 
(...) No problem. Most of the other environments hide this sort of thing programmer, but this relies on the fact that the programming environment knows how each sensor is going to be used. I didn't think this fit with the C philosophy*, so (...) (24 years ago, 4-Jul-00, to lugnet.robotics.rcx.nqc)

Message is in Reply To:
  Re: temperature sensor problem
 
Ben, Internally, the RCX only works with integers, but .1 degree resolution was desired for temperature sensors, so the sensor values are actually measured in .1 degree increments. A reading of 70 degrees F is stored as 700, not 70. If you change (...) (24 years ago, 3-Jul-00, to lugnet.robotics.rcx.nqc)

4 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR