ROBOTC

Setting up the Controller

1.)  Before you start using your Matrix controller with ROBOTC™, you will need to make sure that the platform type is set to ‘LEGO NXT + TETRIX/MATRIX’ under the ‘Robot -> Platform Type’ menu.

2.) Next, you will need to ensure that your program is set up to use the MATRIX controller configuration used by your robot. To do this, open the ‘Robot -> Motors and Sensors Setup’ window.

3.) Navigate to the ‘External Controllers’ tab and select the ‘Standard Matrix Configuration. This will set the robot up for one MATRIX controller plugged into Sensor Port 1 of the NXT brick.

4.) If you wish to use a different setup, select the ‘Custom Configuration’ option. This will allow you to manually configure which NXT ports have a Matrix controller attached to them via the drop-down menu options.

Setting up Motors

Once the Matrix controllers are configured in the ‘External Controllers’ section of the Motors and Sensors Setup window, you will next need to configure the individual motors plugged into the MATRIX Controller. This can be done by navigating to the ‘Motors’ tab.

2.) By default, ROBOTC assigns the names “motorA” to the motor plugged into the NXT’s motor A port, “motorB” to the motor plugged into motor port B, and “motorC” to the motor plugged into motor port C. The four MATRIX ports are assigned the names “motorD”, “motorE”, “motorF”, and “motorG” in respect to ports 1, 2, 3, and 4 on the MATRIX controller.

 

3.) To change these names to something that is easier to reference, simply replace the appropriate motor name with your own custom name. In this example, the ‘motorD’ name is replaced with a ‘frontLeftDrive’ motor name. When naming your motors in ROBOTC, make sure to follow these basic naming rules.

 

4.) One or more of the motors may need to be ‘reversed’ if the motor is running opposite of the desired direction. To do this, simply check the ‘reversed’ check box and ROBOTC will make the changes to that motor in your program.

 

5.) The ‘Encoder’ check box should be checked for each motor that has encoders installed, and the PID checkbox should be checked for each motor that will be utilizing PID control.  Each check box will enable its respective features.

Setting up Servos

1.)  The Sensors tab in the Motors and Sensors Setup window can be used to set up and configure individual servos. ROBOTC automatically names the servos  numerically starting at servo port 1(servo1) to the maximum number of servos that are configured (in this example, four servos total are used, with the last servo being ‘servo4′).

 

2.)  If there is more than one Matrix controller set up and in use, the Motors and Sensors setup window will reflect the additional controllers with additional servos (starting at the lowest numbered sensor port being used).

 

3.)  To change the Servo names to something easier to reference, simply replace the appropriate servo name with a custom name. In this example, the ‘servo1’ name is replaced with a ‘wristServo’ servo name. When giving servos custom names in ROBOTC, make sure to follow these basic naming rules. Note that each servo’s type (either the‘Standard Servo’ type or ‘Continuous Rotation’ type) will need to be selected from the drop down list.

Using Motors

Moving Forward

1.) Controlling a robot’s movement with the MATRIX controller is an easy process with ROBOTC. First, make sure the motors are set up appropriately in the Motors and Sensor Setup window; in this example, motor port 1 is named named ‘frontLeftDrive’, port 2 is named ‘frontRightDrive’, port 3 is named ‘rearLeftDrive’, and port 4 is named ‘rearRightDrive’. Note that the left motors (‘frontLeftDrive’ and ‘rearLeftDrive’) are reversed to ensure that positive motor values will turn them in the correct direction.

 

2.)  Now that the MATRIX Controller is set up in ROBOTC, the robot can be programmed to move forward for a specific amount of time. In this example, the robot will first wait for 2 seconds, move forward for 3 seconds, then stop before the program ends.

3.) ROBOTC executes programs from the top of the code to the bottom of the code, left to right (similar to reading a book). Because of this, our first command should be a 2000 millisecond ‘wait1MSec’ command.

4.) The wait1MSec command tells the program to halt at the specified line of code for a specific amount of time. Remember that the Function Library on the left side of ROBOTC  (next to the code section of the IDE) can be used to quickly reference and drag-and-drop different commands. The wait1MSec command can be found under the ‘Timing’ section of the Function library.

 

5.) Next, all of the motors will need to be turned on in the correct direction. Assuming that the motors are setup correctly in the Motors and Sensors Setup window, a positive value should move the motors in the forward direction. In this example, the half-speed forward value of ’50′ is used for each motor. Note that all of the motor power levels should be set to the same value to move the robot straight forward.

6.) The next line of code is another ‘wait1MSec’ command which will tell the robot how long it should move forward for. Since the robot must move forward for 3 seconds, a 3000 millisecond wait command is used.

7.)  Once the robot has moved for the desired amount of time, the motors must be stopped in order to prevent the robot from moving beyond its target. This is done by assigning a motor power level of zero to all of the drive motors.

Let’s take a look at the finished program. This program will wait for 2 seconds, move the robot forward at half speed for 3 seconds, then stop the robot.

 #pragma config(Hubs, S1, MatrxRbtcs, none, none, none)
 #pragma config(Sensor, S1, , sensorI2CMuxController)
 #pragma config(Motor, mtr_Matrix_S1_1, frontLeftDrive, tmotorMatrix, PIDControl, reversed, encoder)
 #pragma config(Motor, mtr_Matrix_S1_2, frontRightDrive, tmotorMatrix, PIDControl, encoder)
 #pragma config(Motor, mtr_Matrix_S1_3, rearLeftDrive, tmotorMatrix, PIDControl, reversed, encoder)
 #pragma config(Motor, mtr_Matrix_S1_4, rearRightDrive, tmotorMatrix, PIDControl, encoder)
 #pragma config(Servo, srvo_Matrix_S1_1, servo1, tServoNone)
 #pragma config(Servo, srvo_Matrix_S1_2, servo2, tServoNone)
 #pragma config(Servo, srvo_Matrix_S1_3, servo3, tServoNone)
 #pragma config(Servo, srvo_Matrix_S1_4, servo4, tServoNone)
 //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()
{
 //Wait for two seconds
 wait1Msec(2000);

//Move forward for three seconds
 motor[frontLeftDrive] = 50;
 motor[frontRightDrive] = 50;
 motor[rearLeftDrive] = 50;
 motor[rearRightDrive] = 50;

 wait1Msec(3000);

//Stop
 motor[frontLeftDrive] = 0;
 motor[frontRightDrive] = 0;
 motor[rearLeftDrive] = 0;
 motor[rearRightDrive] = 0;
}


Moving Backward

 1.) Controlling a robot’s movement with the MATRIX controller is an easy process with ROBOTC. First, make sure the motors are set up appropriately in the Motors and Sensor Setup window; in this example, motor port 1 is named named ‘frontLeftDrive’, port 2 is named ‘frontRightDrive’, port 3 is named ‘rearLeftDrive’, and port 4 is named ‘rearRightDrive’. Note that the left motors (‘frontLeftDrive’ and ‘rearLeftDrive’) are reversed to ensure that negative motor values will turn them in the correct direction.

 

2.) Now that the MATRIX Controller is set up in ROBOTC, the robot can be programmed to move backwards for a specific amount of time. In this example, the robot will first wait for 2 seconds, move the backwards for 3 seconds, then stop before the program ends.

 

3.) ROBOTC executes programs from the top of the code to the bottom of the code, left to right (similar to reading a book). Because of this, the first command should be a 2000 millisecond ‘wait1MSec’ command.

 

4.) The wait1MSec command tells the program to halt at the specified line of code for a specific amount of time. Remember that the Function Library on the left side of ROBOTC  (next to the code section of the IDE) can be used to quickly reference and drag-and-drop different commands. The wait1MSec command can be found under the ‘Timing’ section of the Function library.

 

5.) Next, all of the motors will need to be turned on in the correct direction. Assuming that the motors are setup correctly in the Motors and Sensors Setup window, a positive value should move the motors in the forward direction. In this example, the half-speed forward value of ’50′ is used for each motor. Note that all of the motor power levels should be set to the same value to move the robot straight backwards; in this case, the values are negative to move the motors in the backwards direction.

6.) The next line of code is another ‘wait1MSec’ command which will tell the robot how long it should move backwards for. Since the robot must move backwards for 3 seconds, a 3000 millisecond wait command is used.

 

7.) Once the robot has moved for the desired amount of time, the motors must be stopped in order to prevent the robot from moving beyond its target. This is done by assigning a motor power level of zero to all of the drive motors.

Let’s take a look at the finished program. This program will wait for 2 seconds, move the robot backwards at half speed for 3 seconds, then stop the robot.

#pragma config(Hubs, S1, MatrxRbtcs, none, none, none)
 #pragma config(Sensor, S1, , sensorI2CMuxController)
 #pragma config(Motor, mtr_Matrix_S1_1, frontLeftDrive, tmotorMatrix, PIDControl, reversed, encoder)
 #pragma config(Motor, mtr_Matrix_S1_2, frontRightDrive, tmotorMatrix, PIDControl, encoder)
 #pragma config(Motor, mtr_Matrix_S1_3, rearLeftDrive, tmotorMatrix, PIDControl, reversed, encoder)
 #pragma config(Motor, mtr_Matrix_S1_4, rearRightDrive, tmotorMatrix, PIDControl, encoder)
 #pragma config(Servo, srvo_Matrix_S1_1, servo1, tServoNone)
 #pragma config(Servo, srvo_Matrix_S1_2, servo2, tServoNone)
 #pragma config(Servo, srvo_Matrix_S1_3, servo3, tServoNone)
 #pragma config(Servo, srvo_Matrix_S1_4, servo4, tServoNone)
 //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()
{
 //Wait for two seconds
 wait1Msec(2000);

//Move forward for three seconds
 motor[frontLeftDrive] = -50;
 motor[frontRightDrive] = -50;
 motor[rearLeftDrive] = -50;
 motor[rearRightDrive] = -50;

 wait1Msec(3000);

//Stop
 motor[frontLeftDrive] = 0;
 motor[frontRightDrive] = 0;
 motor[rearLeftDrive] = 0;
 motor[rearRightDrive] = 0;
}

Using Servos

1.) Using a servo with the MATRIX controller is a fairly simple process. First, make sure the servo is set up appropriately in the Motors and Sensor Setup window; in this example, servo port 1 is set up for a ‘Standard Servo’ type named ‘wristServo’.

2.) Servos work differently than motors. Instead of giving a servo a power and a direction, servos are given a location (when using the MATRIX controller with ROBOTC, these locations range from 0 to 255). Once a servo is given a position, it will need time to move to that position; once it reaches the target position, it will ‘hold’ that position until it is told to move to a different position.

3.) In this example, the servo is going to move to 3 different locations (64, 192, and 128). 3 seconds will be given to complete each change in position. In order to assign a servo a position, the ‘servo[]’ command will be used. This command can be found under the ‘Servo’ section of the Function Library.

 

4.) The first position the servo will be moved to is 64. The ‘servo[]’ command is used to define which servo is being controlled (in this example, ‘wristServo’ and the value assigned to it is the position the servo must move to (in this example, 64).

 

5.) After a servo’s position is set, the program must give the servo enough time to reach its target before a new position is assigned. This can be done with the ‘wait1MSec’ command. In this example, a 3 second wait (3000 milliseconds) will be enough time for the servo to reach its target.

6.) To assign a new position to the servo, a new ‘servo[]’ command must be used. Remember, each movement will also need its own separate 3 second wait (using the wait1MSec() command) to allow the servo to move to the target location.

7.) The final movement to position 192 is similar to the previous servo movements, with the value of 192 being assigned to the servo and a 3 second wait to give the servo time to move to the desired position. Unlike the motors, a value of zero should not be assigned to the servos to stop them. A zero value assigned to a servo will instead move the servo to position 0 and cause the servo to ‘hold’ that position until a new value is assigned to it.

Let’s take a look at the finished program.This program will move the ‘wristServo’ on the MATRIX controller’s servo port 1 to position 64, 192, and 128, with a three seconds allotted for each movement.

#pragma config(Hubs, S1, MatrxRbtcs, none, none, none)
 #pragma config(Motor, mtr_Matrix_S1_1, motorD, tmotorMatrix, openLoop)
 #pragma config(Motor, mtr_Matrix_S1_2, motorE, tmotorMatrix, openLoop)
 #pragma config(Motor, mtr_Matrix_S1_3, motorF, tmotorMatrix, openLoop)
 #pragma config(Motor, mtr_Matrix_S1_4, motorG, tmotorMatrix, openLoop)
 #pragma config(Servo, srvo_Matrix_S1_1, wristServo, tServoStandard)
 #pragma config(Servo, srvo_Matrix_S1_2, servo2, tServoNone)
 #pragma config(Servo, srvo_Matrix_S1_3, servo3, tServoNone)
 #pragma config(Servo, srvo_Matrix_S1_4, servo4, tServoNone)
 //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

task main()
{
 //Move the servo to position 64
 //Wait 3 seconds for the servo to move
 servo[wristServo] = 64;
 wait1Msec(3000);

//Move the servo to position 192
//Wait 3 seconds for the servo to move
 servo[wristServo] = 192;
 wait1Msec(3000);

//Move the servo to position 128
//Wait 3 seconds for the servo to move
 servo[wristServo] = 128;
 wait1Msec(3000);
}

adidas yeezy boost v3 shoe adidas yeezy boost v2 shoes adidas yeezy boost 350 v3 shoe adidas yeezy boost 350 v2 shoes adidas yeezy boost 350 v2 black red adidas yeezy boost 350 v2 black white adidas yeezy boost 350 v2 triple white adidas yeezy boost 350 v2 cream white adidas yeezy boost 350 v2 black adidas yeezy boost 350 v3 grey adidas yeezy boost 350 v3 yellow