Building THE MIC ROLLER

606

2

About: I studied electronics at school and in the last years I have become passionate about sevel tech subjects: - mechanical desing - Arduino and its IDE - Raspberry Pi + LAMP server and Python - Stepper motors - ...

Hello,

My aim was to build a Bluetooth controlled robot for a friend to move a microphone in front of a guitar/bass amp. This robot is used by sound engineers to perfectly place the mic in the right spot in front of the speaker to experiment sounds and finally get the best tone.

I knew I also needed to design and code an APP with a captivating user interface to be used on any Android smartphone to move the robot.

The project divides in 4 main sections:

- Electronics hardware

- Mechanics elements

- Firmware programming

- APP development

This is a very versatile project as it can be adapted to move automatically and remotely other things, such as a tiny projector, a lamp or a camera placed on the ceiling of a room.

I apologize for the pictures, as I was so keen on building the robot that I did not take satisfactory ones.

Feel free to write to me for any further explanation and comment.

Have fun!!

Disclosure: I have enjoyed doing this project and it worked well for me but I am not responsible for any damage that could happen to you. Working with electricity people could get hurt. All the hardware of this project is working in very low voltage (12V) so this is unlikely to happen, but in electronics components could always overheat and burn. Also it is very important to be very careful when building a mechanical moving robot such as this one as your hand could end up trapped in the moving parts and you could end up injured. I recommend this project for people that know electronics, mechanics and electrical engineering at least at an intermediate level.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Electronic "Ingredients"

As a chef that prepare a recipe we have to pick the right "ingredients" for our tech project.

Hardware:

- 1 Arduino UNO (always better to go for the original one)

- 1 HC-06 Bluetooth module

- 1 CNC shield

- 3 A4988 drivers with 1A of current (or DRV8825 with 2A of current)

- 3 NEMA 17 stepper motor (with good torque) for example this ones or this ones

- 2 micro-switches

- 1 power supply driver 12V 60W for example I took this

- 1 EU connector (example)

- Additional 4 poles cables

- Arduino jumpers, we will use maily male-male jumpers

Step 2: Mechanical Parts

Most of the mechanical elements for the project can easily be found online. However the plastic supports for the motor have been projected and made with a 3D printer by a friend of mine, another friend with his CNC milled the aluminum support for the central motor (Z axis).

You can see the final assembly (in step 4) and make these parts at your linking using your favorite 3D design CAM software and send the files to your local Fablab. You can find your local Fablab at this site. They will help you to make your 3D printed and CNC milling parts.

Mechanical stuff:

- 2 pieces of 60cm each of aluminum extrusion of 35mmx35mm for linear guides (you can find them online)

- 8 bearings (make sure those are like the ones in the picture. which are suitable with the aluminum linear guide)

- 1 3D printer belt

- 2 pulleys (see the picture)

- 2 3D printed mechanical supports for the motors, these parts are fixed to the aluminium guide with screws

- CNC milled aluminum support for central motor (Z axis). Design it and have your local Fablab make it!

- Any cable chain or flexible cable tubes, you can find two examples in the pictures

- Electric Box to fit the hardware

Step 3: Electronics Assembly

Now we just have to wire our hardware together.

1) place the shield on top of Arduino

2) connect your HC-06 Bluetooth Module to the pins on top of the shield.

BE CAREFUL! Look at the picture 2, as you can see:

  • TX of the HC-06 is going to the RX of the Arduino
  • RX of the HC-06 is going to the TX of the Arduino

3) Wire the micro-switches, or limit switches. As you can see from the code below the normally open contacts of the micro-switch have to be connected between pin 9 and GND for limiting the X axis and between pin 10 and GND for lilmiting the Y axis. You will not need external pull-up or push-down resistors because we will use internal pull-up resistor built-in Arduino. Further info about this subject can be found here.

pinMode(9, INPUT_PULLUP);  
pinMode(10, INPUT_PULLUP); 

4) connect the stepper motors to the shield but pay attention, as you can see a stepper motor is represented as two inductors, follow the order of the shield pins to connect the right pole of the inductor to the right pin. Nothing serious happens if you mess up, but if you do, either the motors won't be moving or will be rattling and shaking!

For the motor I have used the cables colors are the following:

A+ Black

A- Green

B+ Red

B- Blue

I have attached the stepper motor datasheet, in there you will find all the technical information, as you can see these stepper motors accept up to 2A of current per phase. Even if the nominal voltage is 2.2V it is not a problem to drive them with a voltage of 12V, like in our case.

BE CAREFUL! If the motors heat up too much, reduce the current or insert a step-down to lower the voltage!

This settings allow you to use the full power of the motors, you can see that these steppers have a nice torque curve. Even if the rpm (revolutions per minute) increase, they maintain the torque of 30Ncm. 30Ncm means that at the distance of 1cm from their center they can rotate around 3kg of weight. Quite impressive for such small motors!

5) on top of the driver there is a little screw to limit the amount of current that is going to the motors. If you are using the A4988 (the red ones) you can keep the amount of current untouched, usually 1A. Or use a bigger heatsink on top of them and increase it to also 1.5A.

In case you use DRV8825 (the purple ones) you can drive the motors at 2A. To measure the current you will need a digital multimeter placed in series or a desk power supply.

Sometimes if can happen that the motors issue a little annoying buzz, you have to regulate the current until the buzz goes away, it is caused by parasitic frequencies.

6) If you want you can place the EU connector for the the power supply in a pre-made hole in the box and do some soldering to reach the Vin pins of Arduino. The 12V line is also meant to be connected to the blue connector on the shield, this is the main line that will give power to the stepper motors and finally move your axis.

BE CAREFUL! if you invert the positive and negative pole on the motor shield you will burn it and make it unusable. Always measure with your multimeter the polarity of the wires that goes from the power supply to the EU connector and then to the shield power connector .

7) Place all the electronics in the box, make sure you have drilled holes in the box to allow for the cables to come out. I have placed some nice silver PG7 that come out of the box.

Congratulations the messy wiry bit is accomplished!!

Step 4: The Mechanical Assembly

Feel free to experiment with your own creativity to connect the bearings with the support part that join together the two axis made of aluminum extrusions.

Also sprout your creativity into designing the support for the stepper motors. NEMA 17 is a standard, have a look at the motor mechanical specifications in the datasheet and just make sure you design a nice support and fix it to them with the right bolts.

You can design the support and have it 3D printed, such as the first picture or you can make a support in aluminum. You will need some help from someone that has a CNC milling machinery to do so.

You will need to be quite precise and use wisely your caliper to design these parts.

LITTLE HINT: when you are designing two parts that are joining together I suggest you always leave a tolerance of 0.2mm or 0.1mm between the two parts.

Get the main idea from the pictures and make your own design with your favorite CAM software, once you have the 3D model email it to your local Fablab and they will be more than happy to make it turn a reality.

You can find your local Fablab at this site.

Step 5: APP Development With APP Inventor

I have designed the app with the great online builder called App Inventor.

You can find the app at this link. (You can log in with your google account)

Or you can download the .aia file here below and import it in App Inventor.

I will explain the app a bit:

1) The important initial bit is connecting the app via Bluetooth to the robot.

There is a list-picker with the Bluetooth logo. When the the user clicks on it, the available Bluetooth list appears and the user can connect to the Bluetooth client that is actually the Bluetooth network from the HC-06.

A message telling that the connection has happened is displayed with a following message telling the user to turn the motor on to give power to the system.

2) Another bit that I would like to comment concerns the commands.

- The APP will send different single characters via Bluetooth to the Arduino.

- I have used simple capital letters: for example letter 'D' is the command to move the X axis backward. In conjunction this command also move backward of 4 pixels the small microphone icon (ImageSprite1) on the APP.

- Some commands are:

'A' → Y axis forward and Mic icon 4 px forward

'O' → home

'G' → save in slot 1 the current X and Y position

'H' → load from slot 1 X and Y positions and move the motor and mic icon there

3) The user can drag the small mic icon on a 250px x 250px canvas to move the motors without using the arrows. This is an interested feature and it is done by a long logic block called imageSprite1.Dragged.

- it gets the pixel position where the image has been dragged on the canvas.

- a linear proportion is made where the maximum value of 250px corresponds to 62 movement of a motor of 72° to reach the end of the aluminum linear guide. This proportion allows Arduino to know the number of times the motors has to spin forward/backward to reach the corresponding position where the icon has been dragged.

- For example if the system is initially in the home position the icon is at X=0px and Y=0px

- The user drags the icon at postion X=70px and Y=100px

- After the proportion the motor movements are X1=17 and Y1=24

- A command string like ".17,24*;" is sent to the HC-06

- Arduino firmware will then parse this string and move the motors accordingly. This means that the X axis motor will spin forward 17 times of 72° and the Y axis motor will spin forward 24 times of 72°.

BE CAREFUL! To avoid bouncing when dragging the image and assure than the right command will be executed when actually the user release the icon from dragging I had to insert also the block ImageSprite1.TouchUp

- In this block a simple 'U' character is sent so it make sure that when Arduino finds the 'U' character it will execute the previous final command string but ignore the previous bouncing ones:

Example: ".12,19*;.14,22*;.17,24*;U" The right command to be execute is the one previous to the 'U', that's to say ".17,24*", before there are two bouncing touches. I had to inset this to avoid bouncing touches that were messing up everything.

I hope that with this explanation you will look more clearly at the logic blocks in the app. However feel free to study it as long as you like. You find the .aia file down here. Or just install it and play around with it downloading the .apk file.

Step 6: Arduino Firmware

Here comes the section for all C programming lovers out there. Feel free to download the Arduino code, some section could be modified and simplified as you may notice but it is working well anyway.

The most important library used in this code is the Stepper Driver library by Laurb9 that you can find on Github at the following link

https://github.com/laurb9/StepperDriver

We use this library initially to define the stepper motors and then to rotate them.

Another important library is the EEPROM library of Arduino Uno, which is used to save the positions of X, Y and Z axis.

I have done my best in trying to quote the code as much as possible giving all the possible explanations of each bit. However here below I will also comment some bits a little further.

1) In the void setup() section the code is executed only once. In the following part of the Arduino code checks if there is serial communication and until the user send the ON command nothing happens. Once the user has pressed ON then the next command which is waited is either:

'O' → home command

'Z' → OFF command

do    //this cycle waits until someone click the ON button on the app
{
  if(Serial.available()>0)
    {
     state=Serial.read(); 
     Serial.println(readString); //prints string to serial port out    
    }
  }
while(state!='V'); //system ON command
digitalWrite(8, LOW); 
do //this cycle waits that the user push either Home Button or OFF button
  {
  if(Serial.available()>0)
    {
     state=Serial.read(); 
     Serial.println(readString); //prints string to serial port out    
    }
  } while((state!='O')&&(state!='Z'));

2)

- do you remember that in the APP we used to send a command 'D' to send the motor backwards?

- do you remember that we connected the Y limit switches to the built-in pull-up resistor between pin 10 and
GND?

Initially we check if the Y motor can physically go backward: if the limit switch is pushed on pin 10 Arduino will read GND and even if on the APP we push the Backward Button nothing will happen.

If the limit switch is not pressed we simply rotate of 72° the motor with the simple command stepperY.rotate(72) and we decrease of 1 the Y variable.

if(limitYstate==HIGH)    
{ 
if(c == 'B')   //Y motor backward
      {  
      stepperY.rotate(72); //the value is not negative because I mounted the motors upside-down in my assembly, sorry
      delay(5);
      Y--;
      Serial.println("Y value, "); 
      Serial.println(Y); 
      Serial.println("Y motor backward");
      readString="";     
      }
    }

3)

This is the hard bit, basically here we are capturing the string sent when the users drag the mic icon on the APP and then we parse those data. For example, that is to say that we convert into integers the substrings :

X="17" become Xm=17

Y="24" become Ym=24

In the process we load each string in a buffer array and then finally we use the atoi() command to get our integer values.

Do you remember the bouncing problem in the APP when dragging the mic logo?

Well, the motors will not move until the character 'U' is read on the serial and only then the motors will spin according to the last Xm and Ym values.

if (c == ';')     // character ; means that the user has dragged the microphone icon on the app     
{
            Serial.println();
            Serial.print("captured String is : "); //we have captured the string with the X Y Z values, now we need to parse it and elaborate it, the following commands are for parsing 
            Serial.println(readString); //prints string to serial port out, used for debugging      
            ind1 = readString.indexOf('.');  //finds location of .
            ind2 = readString.indexOf(',');  //finds location of ,
            XString = readString.substring(ind1+1, ind2);   //captures the string between charactes . and ,
            ind3 = readString.indexOf('*');   //find location of * which delimits the end string
            YString = readString.substring(ind2+1, ind3);   //captures the string between charactes , and *
            char buf1[XString.length()+1];     //create a characters array long as substring X
            XString.toCharArray(buf1, XString.length()+1);   //load string X in the array buf1
            char buf2[YString.length()+1];  //create a characters array long as substring Y
            YString.toCharArray(buf2, YString.length()+1);    //load the string Y in array buf2
            Xm = atoi(buf1); //convert the string in arra buf 1, which is a character with the value of X in an integer
            Ym = atoi(buf2); //convert the string in arra buf 2, which is a character with the value of Y in an integer
            readString="";      //clears variables for new input            
            XString="";
            YString="";  
            Serial.print("X = "); //we print everything on the serial monitor for debugging
            Serial.println(X); 
            Serial.print("Y = ");
            Serial.println(Y);
            Serial.print("Xm = ");
            Serial.println(Xm); 
            Serial.print("Ym = ");
            Serial.println(Ym);
       }  
         
 if (c == 'U')  //move the motors in the position of the X Y values read from the app movement
       {
            Serial.print("X = ");
            Serial.println(X); 
            Serial.print("Y = ");
            Serial.println(Y);
            Serial.print("final Xm = ");
            Serial.println(Xm); 
            Serial.print("final Ym = ");
            Serial.println(Ym);
            stepperX.rotate(-72*(Xm-X));
            delay(5);            
            stepperY.rotate(-72*(Ym-Y));
            delay(5);
            X=Xm;
            Y=Ym;
            readString="";
       }

Step 7: The End

Congratulations! You can give yourself a good pat on the shoulder if you have arrived here.

If you are a sound engineer or a musician you might also have saved a bit of money as a Bluetooth controlled mic placement robot can be quite costly.

I hope that this project will spur you into making many similar others or upgrading this one.

Thank you for sticking around!

Bye

Pietro

Be the First to Share

    Recommendations

    • CNC Contest

      CNC Contest
    • Make it Move

      Make it Move
    • Teacher Contest

      Teacher Contest

    Discussions