Subject:
|
Re: temperature sensor problem
|
Newsgroups:
|
lugnet.robotics.rcx.nqc
|
Date:
|
Mon, 3 Jul 2000 16:51:39 GMT
|
Viewed:
|
1743 times
|
| |
| |
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:
Message is in Reply To:
| | temperature sensor problem
|
| 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 (...) (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
|
|
|
|