User Tools

Site Tools


making_the_hand_controller

The Packbot Code, Bluetooth, and Hand Controller Build

Author: Michael Salinas Email: Salinm1@UNLV.Nevada.edu
Date: Last modified on <07/25/2016>
Keywords: Lego PackBot, HandController, NXT, BrickxCommander


The Hand Controller uses a second NXT brick, connected via Bluetooth, to act as a controller. I found three really good videos on YouTube that can help you better understand how it works.









I also made the code for the packbot in NXC so it is easier to visualize what is going on.

Since the code for both the controller and the packbot are relatively short, I will leave it here to be copied and pasted or modified as you please.

task main()        //The Controller code, or otherwise known as the "master"
{
 string text1,text2,text3;
 long a, b, c;
 char x;
 text1="Left Speed" ;
 text2= "Right Speed" ;
 text3= "Flip Speed" ;
 while(1)
 {    ClearScreen();
   a = MotorRotationCount(OUT_A);           //Each one of these "Motor Rotation
   b = MotorRotationCount(OUT_B);           //Counts uses the encoders in each
   c = MotorRotationCount(OUT_C);           //motor to obtain their relative
                                            //Position
                                            
   TextOut(0,10,text1,DRAW_OPT_NORMAL);     //Text on the Screen Displaying
   TextOut(0,20,text3,DRAW_OPT_NORMAL);     //Current position values on the
   TextOut(0,30,text2,DRAW_OPT_NORMAL);     //Controller
   NumOut(70,10, -a, DRAW_OPT_NORMAL);
   NumOut(70,20, -b, DRAW_OPT_NORMAL);
   NumOut(70,30, -c, DRAW_OPT_NORMAL);

    x = SendRemoteNumber(CONN_BT1,MAILBOX2,a);   //Each one of these commands
    Wait(10);                                    //Sends the data collected
    x = SendRemoteNumber(CONN_BT1,MAILBOX1,b);   //earlier in the code. each
    Wait(10); //Measured in Milliseconds         // motor has a specific mail-
    x = SendRemoteNumber(CONN_BT1,MAILBOX3,c);   //box that corresponds with
    Wait(10); // A delay between each message  being sent.
                                                 //The PackBot programs'
                                                 //Mailboxes
 }
}
task main()

{                                      //This is the Packbot Code
 long a,b,c,left,right,flip;
 char x;
 
 while(1)   //This Program needs to stay on a continuous loop, so that way it
 {          //never stops receiving the messages sent by the controller.
  Wait(50);      //If it refreshes too fast, the packbot is really jerky
                 //If it refreshes too slow, there will be input lag.
  x = ReceiveRemoteNumber(MAILBOX2, true, a);   //RecieveRemoteNumber waits for
  left = a;                                     //a message to arrive in the
  OnFwd(OUT_A, left);                           //corresponding mailbox.
  x = ReceiveRemoteNumber(MAILBOX1, true, b);
  flip = b;                                     //The message is then paired
  OnFwd(OUT_B, flip);                           //with the corresponding
  x = ReceiveRemoteNumber(MAILBOX3, true, c);   //motor. The values retrieved
  right = c;                                    //are directly converted to
  OnFwd(OUT_C, right);                          //the power value of the
 }                                              //corresponding motor
}

Adjusting wait times within the code can help smooth out the commands given to the packbot. So you can essentially “tune” your controls
You can also have some fun adding sounds when backing up, or possibly adding buttons to the controller that perform other functions.

The Controller Build



Step 1

Step 2

Step 3

Step 4

Step 5

Step 6

Step 7

Step 8

Step 9

Step 10

Step 11

Step 12

Step 13

Step 14

Step 15

Step 16

Step 17

Step 18

Step 19

Step 20

Step 21

Step 22

Step 23

Step 24

Step 25

Step 26

Step 27

Step 28

Step 29

Step 30

Step 31

Step 32

Step 33

Step 34

Step 35

Step 36

Step 37

Step 38

Step 39

Step 40

Step 41

Step 42

Step 43

Step 44

Step 45
I skipped a few tedious parts to this step. Basically you keep staking the 3 beams to connect the two motors. Do this by using the pins used in step 44

Step 46

Step 47

You will actually need to set where the

making_the_hand_controller.txt · Last modified: 2016/07/25 17:01 by salinasmichael