Subject:
|
Re: More light sensors in legOS
|
Newsgroups:
|
lugnet.robotics.rcx.legos
|
Date:
|
Thu, 3 Feb 2000 21:07:09 GMT
|
Viewed:
|
2341 times
|
| |
| |
> I did not get any answers for my previous question about this, and I am still
> puzzled as for why light sensor readings for a dark background have 0x1F0 added
> to them once in a while (more often than not, actually)
I'm working on similar measuring too. I'm getting quite stabile values, but
quite noisy too... I don't know if it's the same problem (I'm reading the
values in decimal). I've just converted "0x1F0" to dec... Too much, I've not
the same problem.
How are you reading the values? I'm using a code like this:
--- Cut
/* readlight.c */
/* P.M. 2000 */
#include <conio.h>
#include <dsensor.h>
#include <dsound.h>
#include <unistd.h>
#include <rom/system.h>
int elapsed(int iDelay) {
static long StopWatch;
if (iDelay==0) {
return (StopWatch=sys_time);
} else {
return (sys_time >= StopWatch + iDelay);
}
}
int main(int argc, char **argv) {
unsigned noise, minlight, maxlight, light;
dsound_system(DSOUND_BEEP);
ds_active(&SENSOR_2);
dsound_system(DSOUND_BEEP);
cputs("rdy");
getchar();
cls();
cputs("scan");
elapsed(0);
noise = maxlight = minlight = ds_scale(SENSOR_2);
while (!elapsed(2000)) {
light = ds_scale(SENSOR_2) ;
if (light < minlight) minlight=light;
if (light > maxlight) maxlight=light;
}
noise = maxlight-minlight;
dsound_system(DSOUND_BEEP);
lcd_int(noise);
getchar();
lcd_int(minlight);
getchar();
lcd_int(maxlight);
getchar();
cls();
ds_passive(&SENSOR_2);
}
--- Cut
Actually I get values with a noise bewtween 25 and 55 units with the sensor
firmly positioned over a black or white color (different center values, but
same noise on reading).
> any ideas for what might be the reason and possible solutions?
No idea (for my problem(?) too).
Bye,
Paolo.
---
Knight's Law: Life is what happens to you while you are making other plans.
|
|
Message is in Reply To:
| | More light sensors in legOS
|
| Hi again! I did not get any answers for my previous question about this, and I am still puzzled as for why light sensor readings for a dark background have 0x1F0 added to them once in a while (more often than not, actually) any ideas for what might (...) (25 years ago, 3-Feb-00, to lugnet.robotics.rcx.legos)
|
2 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|