www.fym.dk - Frank make things
 www.fym.dk Login

Login
News
Activities
Quotes
Tech Notes
Mindstorms
Quadbike
FYM's weblog
GSM Cell ID
Agria fejemaskine
PS2
Links
  BitMax.dk
  hrumpf.dk


3 motor bidirectional control on one RCX.


Special requirements:
- Light sensor
- 2 touch sensors

On Sensor input 1 and 3, put touch sensors. On input 2 put the light sensor.

The light sensor gives different values, according to the color of the LEGO bricks in front of it. Therefore the control is based upon 3 colors, in one line in picture 1.

The control handle:

The base:

The whole before the final completion:

Mounting the handle holder:

Completed:

Mounted on the RCX, including the 2 touch sensors:


NQC code:

task main(){
  SetSensor(SENSOR_1,SENSOR_TOUCH);
  SetSensor(SENSOR_2,SENSOR_LIGHT);
  SetSensor(SENSOR_3,SENSOR_TOUCH);
 
  SetPower(OUT_A, 7);
  SetPower(OUT_B, 2);
  SetPower(OUT_C, 2);
 
  while(true){
    // pos 1 - remember to set the right color values, with an interval
    if ( (SENSOR_2 <= 32) && (SENSOR_2 >= 29) ){
      if (SENSOR_1 == 1){
         SetDirection(OUT_A,OUT_FWD);
         On(OUT_A);
      }
      if (SENSOR_3 == 1){
         SetDirection(OUT_A,OUT_REV);
         On(OUT_A);
      }
    }
  
    // pos 2 - remember to set the right color values, with an interval
    if ( (SENSOR_2 <= 46) && (SENSOR_2 >= 44) ){
      if (SENSOR_1 == 1){
         SetDirection(OUT_B,OUT_FWD);
         On(OUT_B);
      }
      if (SENSOR_3 == 1){
         SetDirection(OUT_B,OUT_REV);
         On(OUT_B);
      }
    }

    // pos 3 - remember to set the right color values, with an interval
    if ( (SENSOR_2 <= 44) && (SENSOR_2 >= 37) ){
      if (SENSOR_1 == 1){
         SetDirection(OUT_C,OUT_FWD);
         On(OUT_C);
      }
      if (SENSOR_3 == 1){
         SetDirection(OUT_C,OUT_REV);
         On(OUT_C);
      }
    }

    if ( (SENSOR_3 == 0) && (SENSOR_1 == 0) ){
      Off(OUT_C);
      Off(OUT_B);
      Off(OUT_A);
    }
  }
}

Motor running:

task main(){

SetSensor(SENSOR_1,SENSOR_TOUCH);

SetSensor(SENSOR_2,SENSOR_TOUCH);

SetSensor(SENSOR_3,SENSOR_TOUCH);

SetPower(OUT_A, 7);

SetPower(OUT_B, 7);

SetPower(OUT_C, 7);

while(true){

if (SENSOR_1 == 1){

SetDirection(OUT_A,OUT_FWD);

On(OUT_A);

}

if (SENSOR_3 == 1){

SetDirection(OUT_A,OUT_REV);

On(OUT_A);

}

if ( (SENSOR_3 == 0) && (SENSOR_1 == 0) ){

Off(OUT_C);

Off(OUT_B);

Off(OUT_A);

}

}

}

 



2003-10-13 17:47:21 / FYM

Powerd by Bitraweb
on www.bitmax.dk