|
Does anyone have expierence using the active multiplexor sold by
www.mindsensors.com with legOS? If you are not farmiluar with this multiplexor
it is really cool as it lets you multiplex three active sensors on one port.
You tell the mux which "sub" sensor you wish to read from by pulsing the power
to the port, 1,2, or 3 pules with 10ms timing. I've been unable to get it to
reliably switch between "sub" ports on LegOS. After spending a few hours
trying to get it working on LegOS I redownloaded the standard firmware and used
the creators NQC example which worked fine.
I then translated the NQC code basically line for line into LegOS compatible
code makeing the following substitutions.
Wait(1) -> msleep(10)
SetSensorType(SENSOR_2,SENSOR_TYPE_TOUCH) -> ds_passive(&SENSOR_2)
SetSensorType(SENSOR_2,SENSOR_TYPE_LIGHT) -> ds_active(&SENSOR_2)
for the hardware side of the test I hooked up a light sensor to each of the mux
ports. In the NQC example I could see the red light on each of the light
sensors go on and off in series. On the LegOS example the first light tends to
stay on and pule off for extrememly short durations, basically a flicker, and
the other two lights remain off always.
I've tried varying the pulse length from 1-50ms on legOS with no success. In
NQC I was able to get it to switch with pulse lengths from 10 to 50ms.
I've got no idea if I'm doing something wrong or if NQC and LegOS somehow power
the sensors differently.
any thoughts would be appreciated.
thanks,
mark
Here are the NQC and LegOS code
/*******************/
/*start NQC example*/
/*******************/
task main() {
while(1) {
Ch1();
Wait(100);
Ch2();
Wait(100);
Ch3();
Wait(100);
}
}
#define WIDTH 1
sub Ch1() {
SetSensorType(SENSOR_2,SENSOR_TYPE_TOUCH);
Wait(WIDTH);
SetSensorType(SENSOR_2,SENSOR_TYPE_LIGHT);
}
sub Ch2() {
SetSensorType(SENSOR_2,SENSOR_TYPE_TOUCH);
//Wait(WIDTH);
SetSensorType(SENSOR_2,SENSOR_TYPE_LIGHT);
Wait(WIDTH);
SetSensorType(SENSOR_2,SENSOR_TYPE_TOUCH);
Wait(WIDTH);
SetSensorType(SENSOR_2,SENSOR_TYPE_LIGHT);
}
sub Ch3() {
SetSensorType(SENSOR_2,SENSOR_TYPE_TOUCH);
Wait(WIDTH);
SetSensorType(SENSOR_2,SENSOR_TYPE_LIGHT);
Wait(WIDTH);
SetSensorType(SENSOR_2,SENSOR_TYPE_TOUCH);
Wait(WIDTH);
SetSensorType(SENSOR_2,SENSOR_TYPE_LIGHT);
Wait(WIDTH);
SetSensorType(SENSOR_2,SENSOR_TYPE_TOUCH);
Wait(WIDTH);
SetSensorType(SENSOR_2,SENSOR_TYPE_LIGHT);
}
/*********************/
/** end NQC example **/
/*********************/
/*************************/
/** start LegOS example **/
/*************************/
#define WIDTH 10
int main(int argc, char **argv) {
ds_active(&SENSOR_2);
msleep(1000);
while(1) {
//1
ds_passive(&SENSOR_2);
msleep(WIDTH);
ds_active(&SENSOR_2);
msleep(1 000);
//2
ds_passive(&SENSOR_2);
//msleep(WIDTH);
ds_active(&SENSOR_2);
msleep(WIDTH);
ds_passive(&SENSOR_2);
msleep(WIDTH);
ds_active(&SENSOR_2);
msleep(1000);
//3
ds_passive(&SENSOR_2);
msleep(WIDTH);
ds_active(&SENSOR_2);
msleep(WIDTH);
ds_passive(&SENSOR_2);
msleep(WIDTH);
ds_active(&SENSOR_2);
msleep(WIDTH);
ds_passive(&SENSOR_2);
msleep(WIDTH);
ds_active(&SENSOR_2);
msleep(1000);
}
return 0;
}
|
|
Message has 1 Reply: | | Re: multiplexor and legOS
|
| well anyone who looked at the code I attached may have notcied that I had one of the msleeps commented out. Oops, with this now uncommented I at least see the second and third light sensors pulse on, but only for an extremely short time. Suring the (...) (23 years ago, 3-Feb-02, to lugnet.robotics.rcx.legos)
|
19 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|