Iron man motorised faceplate electronics tutorial!!!

Hey, I modified the circuit to power the servos with a 6V.

Ground of the arduino is still connected.

Still doesn't work. Don't know what to do now :wacko
 

Attachments

  • montage3.jpg
    montage3.jpg
    703.1 KB · Views: 277
  • montage4.jpg
    montage4.jpg
    517.1 KB · Views: 287
  • montage5.jpg
    montage5.jpg
    685.6 KB · Views: 278
Is the polarity of that led right? bigger led = positive side, small leg = negative side, test all the circuit for short circuits or lose connections, test the push button it self to see if it is working properly, use a multimeter on the continuity function.

Seem fine to me on the pictures.

I'm also using the code of the 1st page and it is working like a charm!
 
Yeah, I don't understand why the only servo that works is the crappy one from arduino kit.

I could run the two emax servo from the external power supply with the SWEEP sketch, they ran normally back and forth between 0 and 180° (more or less). But if I try with the led and button, the emax refuse to work. Sometimes they're buzzing for a few seconds then stop (and may heat a bit).

If I only try the button and the led, that works like a charm. The led flickers then fade in. If I try the button, the led and the Tower Pro, also works like a charm. I push the button, the servo activates, the led flickers and fade in. I click a second time, the led shuts down and the servo activates in the opposite way.

So, the code is good (no doubt on that), the button works, the led works and the Tower Pro servo works. But, despite the emax servos work individually or two at a time with the sweep function, they don't work with this circuit. Can't find out why.
 
link to those servos?

do they have different power requirements than the other?

what battery pack are you using? (to power the servo(s))?.. are you still powering the Arduino from the USB? or is that too connected/being powered by the same pack as the servos?
 
Tower Pro SG92R Datasheet

Emax ES08D datasheet

They are similar servos. I guess the Tower Pro isn't digital but as previously said, that should make no difference.

They need 4.8V to operate. I use 4 AA alkaline batteries. I tested them and they gave me 6V for a bit more than 5A. The arduino is still powered from the USB. The ground of servos/arduino/button and led are on the blue rail, same for the battery pack.
 
Hey guys, I was playing around tonight with my new ardunio board and I uploaded the library or example of sevo Sweeping and all it is doing is going from 0-180 and then buzzing really loud. It's trying to keep rotating and I'm not sure why at all. sevo is HS645-mg and I have a 82mg as well



EDIT figured out why...needed to ground the battery source to the board too..Don't understand why but it worked.

Also my servos are not rotation a true 180 degrees..more like 170 ish. Anyway to fix this? Up the 180 value to 190 or something like that in the code below?

// Sweep
// by BARRAGAN <http://barraganstudio.com>
// This example code is in the public domain.


#include <Servo.h>

Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created

int pos = 0; // variable to store the servo position

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}


void loop()
{
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}

I have the power coming from 4 AA batteries and yellow wire to pin 9
 
Last edited:
My problem is solved after making some tests on the servo thanks to Zoomkat on arduino forum (see test code below).

In fact, the emax servos couldn't make a full 180°. More a 5 -> 165° run. I modified the code to keep that in mind and everything work fine (with or without external power supply, but yeah, I won't power the servo with the arduino...promise :))

So with the following code, you can input millisecond or angle value through serial monitor (for exemple, to force the 4 servos to go to position 50°: 50a,50b,50c,50d, ).

So for people who may have problems with servos doing nothing, use this test to know the limitations of the servos you use! The Tower Pro servo seem to have no problem to make a full half-circle.

Code:
//zoomkat 11-22-12 simple delimited ',' string parse 
//from serial port input (via serial monitor)
//and print result out serial port
//multi servos added 

String readString;
#include <Servo.h> 
Servo myservoa, myservob, myservoc, myservod;  // create servo object to control a servo 

void setup() {
  Serial.begin(9600);

  //myservoa.writeMicroseconds(1500); //set initial servo position if desired

  myservoa.attach(6);  //the pin for the servoa control
  myservob.attach(7);  //the pin for the servob control
  myservoc.attach(8);  //the pin for the servoc control
  myservod.attach(9);  //the pin for the servod control 
  Serial.println("multi-servo-delimit-test-dual-input-11-22-12"); // so I can keep track of what is loaded
}

void loop() {

  //expect single strings like 700a, or 1500c, or 2000d,
  //or like 30c, or 90a, or 180d,
  //or combined like 30c,180b,70a,120d,

  if (Serial.available())  {
    char c = Serial.read();  //gets one byte from serial buffer
    if (c == ',') {
      if (readString.length() >1) {
        Serial.println(readString); //prints string to serial port out

        int n = readString.toInt();  //convert readString into a number

        // auto select appropriate value, copied from someone elses code.
        if(n >= 500)
        {
          Serial.print("writing Microseconds: ");
          Serial.println(n);
          if(readString.indexOf('a') >0) myservoa.writeMicroseconds(n);
          if(readString.indexOf('b') >0) myservob.writeMicroseconds(n);
          if(readString.indexOf('c') >0) myservoc.writeMicroseconds(n);
          if(readString.indexOf('d') >0) myservod.writeMicroseconds(n);
        }
        else
        {   
          Serial.print("writing Angle: ");
          Serial.println(n);
          if(readString.indexOf('a') >0) myservoa.write(n);
          if(readString.indexOf('b') >0) myservob.write(n);
          if(readString.indexOf('c') >0) myservoc.write(n);
          if(readString.indexOf('d') >0) myservod.write(n);
        }
         readString=""; //clears variable for new input
      }
    }  
    else {     
      readString += c; //makes the string readString
    }
  }
}
 
DevilFlash & Djstorm100

this has been posted many (many) times.. did you miss it? (ie: grounds & 180 movement)

1.) connect grounds
2.) stop making FULL 180 sweeps/turns.. you WONT get a full 180 degrees!!!
3.) If you wanted more movement you should have bought a modified 360 servo.. or mod'd one yourself.


you could have saved yourself a TON of trouble (and time) by reading!,...following the advice given here... (and been up and running faster)



glad you got it all working..


matthewr7935 ?? it would just be the same thing.. add another servo.



also DevilFlash


you'll have to change the code from Zoomkat

that only works from a serial input... (which is find for testing from the serial monitor)..

however you'll need to convert the code to use a button...etc..etc.. blink the leds..etc..etc..



glad you guys got it all working!
 
Last edited by a moderator:
@DevilFlash & @Djstorm100

this has been posted many (many) times.. did you miss it? (ie: grounds & 180 movement)

1.) connect grounds
2.) stop making FULL 180 sweeps/turns.. you WONT get a full 180 degrees!!!
3.) If you wanted more movement you should have bought a modified 360 servo.. or mod'd one yourself.


you could have saved yourself a TON of trouble (and time) by reading!,...following the advice given here... (and been up and running faster)



glad you got it all working..


@matthewr7935 ?? it would just be the same thing.. add another servo.



also @DevilFlash


you'll have to change the code from Zoomkat

that only works from a serial input... (which is find for testing from the serial monitor)..

however you'll need to convert the code to use a button...etc..etc.. blink the leds..etc..etc..



glad you guys got it all working!

Thanks for the info but given that there are 27 pages I didn't have time to search. I would rather understand WHY you have to ground the servo to arduino. Thanks again!


Look through most of the this thread but how are you guys making secure connections for when you put it in the helmet?
 
Last edited by a moderator:
2.) stop making FULL 180 sweeps/turns.. you WONT get a full 180 degrees!!!

you could have saved yourself a TON of trouble (and time) by reading!,...following the advice given here... (and been up and running faster)

I read most of the thread and never read that it wouldn't work if the servos don't do a full 180 degrees. I know this is utopic to think a servo will go from 0 to 180 but I naively thought that make the connections and copy/paste the code would work.

The Tower Pro servo worked without any problem with the code. I couldn't imagine (yeah, electronic newbie here,...) that if the code give a position that a servo can't reach...the servo wouldn't do ANYTHING. I thought the servo would buzz trying to reach the position, but at least move.

Or here, the servo didn't even move.

Ok I haven't read the whole thread. I read about the servos buzzing after being moved. Sorry not to have made the link with my problem.

For the code from Zoomkat, I only used it to check the servos. It's not meant to replace the code on the first page but to find where the servos can go and where they can't. And with that information, I could modify the code in the first page to finally make the servo work.

So, I'm sorry to have made you lose some time. I don't think I lost mine in trying. I learned much thanks to those mistakes (first problem I had was to put the button on analogic 2 pin in place of digital 2 pin).

I apologize if I seem to have a grudge agains you xl97 cuz it's really not the case. Your message seemed a bit harsh but I understand it's not easy to answer some question that may sound obvious for you but you have to know I usually take time to test and check things, so yeah, relation between full 180° and no move was not clear in my mind :)
 
Last edited:
Im not mad or upset AT ALL... :)

just saying.. the answers were there/given ;)

If you found out the solutions on your own through trial and error or another means... great!.. in the end you learned and it works. (just could have saved yourself some possible frustration/time)


Im only here trying to post help... on OTHER PEOPLES code..

not the code "I" posted..(nobody seems to be using it...haha)

and the answers are not easy/obvious to me.. I had/have to work through the same things you do..

the point was/is that some of us had already went through the same things here.. and posted the problems & solutions is all. :)


IMHO.. there are two people here in this thread.

1.) the ones that could care less.. and want a solution provided for them from beginning to end. (those are the people who "I" think should read, read and read some more here then.. the answers are here) and then follow what answers are given..

2.) people are are interested and want to learn, and expand their skills and be able to apply this stuff to other aspect of their projects..
(these people will try NEW things on their own.. seeks answers elsewhere when not available here.. (ie: not wait to be spoon fed),, have the drive/motivation..)

In the end.. there are MANY people here..giving MANY different/alternate (possible) solutions..

depending on the person you are above.. you can either pick the approach you are most comfortable with.. and hope the solution is complete.. and/or contact that person who posted that path).. or read it ALL understand what is going on from the solutions provided and make your own based on what you have learned. :)

I personally dont care who comes here and for what 'agenda'.. (we all like props and should have fun)... and I post/comment when I can (seems valid)

however its hard to understand what a certain person didnt pick-up or read when most of the problems and solutions have been posted.

ie: if people are saying over & over again to connect all GNDs.. (how are we suppose to know you arent doing that when you post more problems?)

ie: if people are saying try to reduce the movement to under 160 and see if the buzz stops? (ow are we suppose to know you arent doing that when you post more problems?)



common problems:

*connect all GND together (said many times.. hard to know if someone ISNT doing since its been mentioned so much ...ya know?) :)
*powering components from a battery pack NOT Arduino (not enough current to drive a component)
*power regulation (ensuring each components has to correct voltage(s) to run properly
*using resistors (common/best practice is to always use a resistor <--- something a very smart EE tries to teach everyone that has been burned into my brain) :)


some of things you would NEVER know (learn) until you tried and failed.. LOL.. like the servo.. why wouldnt you think you'd get 180 degree of movement from a 180 degree servo! its mis-leading..

only after buying, playing, reading and asking, did I myself learn the same way you did..(we got our results and posted for others to learn from is all)
together we make it all better..
 
@DevilFlash & @Djstorm100

this has been posted many (many) times.. did you miss it? (ie: grounds & 180 movement)

1.) connect grounds
2.) stop making FULL 180 sweeps/turns.. you WONT get a full 180 degrees!!!
3.) If you wanted more movement you should have bought a modified 360 servo.. or mod'd one yourself.


you could have saved yourself a TON of trouble (and time) by reading!,...following the advice given here... (and been up and running faster)



glad you got it all working..


@matthewr7935 ?? it would just be the same thing.. add another servo.



also @DevilFlash


you'll have to change the code from Zoomkat

that only works from a serial input... (which is find for testing from the serial monitor)..

however you'll need to convert the code to use a button...etc..etc.. blink the leds..etc..etc..



glad you guys got it all working!

If I understand right, zoomkat's code is using serial communication to the Sergio? If so what's the purpose of this vs digital? I'm a newbe like devil.
 
Last edited by a moderator:
Sergio? (did you mean Arduino?) :)

But yes.. Zoomkats code IS using serial interface to communicate/send data to the Arduino..

The purpose has nothign to do with this project.. but it was used so the OP could test his servo's..

it allows him to send custom values for either milliseconds or angle/degree to send to the servo..

I believe he sought out this 'side code' to test his servos for functionality..and to ultimately pin-point/fine tune his full range of servo motion/movement..

(and hence finding out the servo while stated to be 180 degree will never really reach that destination/angle)

in the end (unless he wants to add more cool features/effects).. the serial stuff is JUST for testing his components and getting a better understanding of them /how they work...etc before he implements them into his IM faceplate project..
 
It's, indeed, what I did with Zoomkat's code. Only for testing purpose. Absolutely not IM-faceplate related :D

All you said is valid XL, and I'm more of the second type of person you described. This is why I sought on different forum, youtube, tutorial arduino website, the answer. I indeed went really slowly but now I understand. My problem is I can be hasty sometimes ^^

BTW, thank you for taking time to answer. I really appreciate!
 
no problem! we all learn together.. and we all bring different skill sets to the table. :)


lots of info in here and lots of opinions as well different 'paths' to take.. to a newer person it can be overwhelming Id imagine.. :)
 
sup ppl,

i finished my blueprint of the LED's PCB, its not fancy like xl97 made but it will work with the components i have here!

circuitov1_zps671aac9a.jpg


and thanks xl97 for the ITEAD tip, i will send it to them for production :)


also for the ones who want it, i cleaned a lil bit the code that 7sinnz wrote, removed some things and added others, messed a lil bit with the delays:

IronMan Code V1 - Download - 4shared

Without fade effect:
Code:
//Iron Man - sequence code:
//Made by: 7sinnz
//Mod by: memebr
//The RPF thread:
//http://www.therpf.com/f24/iron-man-motorised-faceplate-electronics-tutorial-170853/
//-----------------------------------------------------------------------------------




#include <Servo.h>

Servo myservo; // Cria um objeto de controle para o servo 1
Servo myservo1; // Cria um objeto de controle pro servo 2
const int pinobotao = 2; // Designa o pino 2 ao botão
const int pinoled = 5; // Designa o pino 5 ao led
int estadobotao = 0; // Estado atual do botão
int ultimoEstadobotao = 0; // estado anterior do botão
int estadoled = 0; // Lembra o atado atual do led
int pos = 0; // Variável para armazenar a posiçao do braço do servo
int pos1 = 180; //Variável para armazenar a posiçao do braço do servo

void setup()
{
myservo.attach(9); // Designa o pino 9 para controle do servo
myservo1.attach(10); // Designa o pino 10 para controle do servo
pinMode(pinobotao, INPUT); // Inicializa o botão como entrada
pinMode(pinoled, OUTPUT); // Inicializa o led como saida
}

void loop()
{
estadobotao = digitalRead(pinobotao); // Faz a leitura do pino do botão
  if (estadobotao != ultimoEstadobotao) // Compara o atual estado do botão com o estado anterior
  {
    if (estadobotao == 1) // se o estado do botão for alto
    {
      if(estadoled == 1) // e se o estado do led for alto
      {
      delay(30); estadoled = 0; //atrasa 30ms e inicia a sequencia

       for(pos = 0; pos <= 180; pos += 10) // faz o servo1 ir de 0º a 180º em passos de 10º
       { 
       myservo.write(pos); // armazena o valor de pos na variavel do servo1
       }
         for(pos1 = 180; pos1 >= 0; pos1 -= 10) // faz o servo2 ir de 180º a 0º em passos de -10º
         {
         myservo1.write(pos1); // armazena o valor de pos1 na variavel do servo2
         }
      delay(15); // Atrasa em 15ms depois que o servo atingir a posição final
      }
      else
      {
      delay(30); //atraso de 30ms
      estadoled = 1; // manda um valor alto para a variavel estadoled
        for(pos = 180; pos >= 0; pos -= 10) // faz o servo1 ir de 180º a 0º em passos de 10º
        {
        myservo.write(pos); // armazena o valor de pos na variavel do servo1
        }
          for(pos1 = 0; pos1 <= 180; pos1 += 10) // faz o servo2 ir de 0º a 180º em passos de 10º
          {
          myservo1.write(pos1); // armazena o valor de pos1 na variavel do servo2
          }
       delay(1000); //Atraso de 1000ms
       }
    }

  ultimoEstadobotao = estadobotao; // Lembra o atual estado do botão e Liga o led se estadoled =1 ou desliga se estadoled = 0
  }
digitalWrite(pinoled, estadoled); //atribui o valor de pinoled ao estadoled
myservo.write(pos); // vai de 0º a 180º
myservo1.write(pos1); // vai de 180º a 0º

delay(20); // Atraso de 20ms
}



With fade effect:
Code:
//Iron Man - Flicker Eyes sequence code:
//Made by: 7sinnz, guitarakizta
//mod by: memebr
//The RPF thread:
//http://www.therpf.com/f24/iron-man-motorised-faceplate-electronics-tutorial-170853/
//-----------------------------------------------------------------------------------


#include <Servo.h> //Biblioteca de servos
Servo myservo; // Cria um objeto de servo
Servo myservo1; // Cria um objeto de servo
int val; // variavel para ler o estado do pino
int val2; // variavel para ler o novo estado do pino
int estadobotao; // variavel de estado do botão
int servostatus = 0; // variavel de estado do servo
int botao = 2; // Atraca o botão ao pino 2
int led = 5; // atraca o led ao pino 5



void setup() 
{
myservo.attach(9); //servo 1
myservo1.attach(10); //servo 2
pinMode(botao, INPUT); // Coloca o pino do botão como entrada
pinMode(led, OUTPUT); // Coloca o pino do led como saida
estadobotao = digitalRead(botao); // faz a leitura do estado do botão
myservo.write(0); // seta o servo 1 para 0º
myservo1.write(170); // seta o servo 2 para 170º
}

void loop() 

{
val = digitalRead(botao); // faz a leitura da entrada e armazena na variavel
delay(10); // atraso de 10ms
val2 = digitalRead(botao); // refaz a leitura para verificar se não há erros
  if (val == val2) 
  { // certifica que temos uma leitura certa
    if (val != estadobotao) 
    { // compara o estado do botão
      if (val == LOW) 
      { // se a variavel do botão for baixa
        if (servostatus == 0) { //se o servo1 estiver em 0º e o servo2 em 170º
                              servostatus = 1; // atribui um valor alto para a variavel de servos e manda o servo1 para 170º e servo 2 para 0º e inicia a sequencia de fade


                              //efeito de fade
                              myservo.write(0);
                              myservo1.write(170);
                              delay(1200);
                              digitalWrite(led, HIGH);
                              delay(200);
                              digitalWrite(led, LOW);
                              delay(25);
                              digitalWrite(led, HIGH);
                              delay(200);
                              digitalWrite(led, LOW);
                              delay(25);

                                             for(int fade = 0 ; fade <= 255; fade +=10) 
                                             {
                                           
                              // defina o valor que quiser (de 0 ate 255) e a velocidade do efeito mudando o valor 10 para qualquer outro valor que quiser:

                                             analogWrite(led, fade); // atribui a variavel fade com o mesmo valor da variavel led
                                             delay(30); // atraso de 30ms
                                             }

                                } 

  else 
       {
       servostatus = 0; // seta o estatus do servo para 0º
       digitalWrite(led, LOW); //desliga os leds quando o servo chega a 0º
       delay(15); // atraso de 15ms
       myservo.write(170); // seta o servo 1 para 170º
       myservo1.write(0); // seta o servo 2 para 0º
       }
      }
    }
    estadobotao = val; // salva o novo estado do botao na variavel
  }
}
 
Last edited:
Looks great member!


Looking at the diagram on the first post....why is there a resistor on connecting D2 switch to ground? Resistors aren't one way (diodes are from what I understand) can someone clear this up for me please?
 
Resistors goes both ways, they are not like diodes.

the resistor is used to pull the pin down, micro controllers don't like to have any active pin floating, so you have to attach it to ground or to VCC

the Arduino already have internal resistors that you can activate via code, but just to be cautious it is good to use another pull down
 
Back
Top