Iron Man Faceplate system wiring help needed

Greetings all,

First time poster here in dire need of some experienced advice if there’s somebody with enough time to spare to lend it.

I am motorizing the Iron Man helmet faceplate using the following components: Freetronics Magnetic Hall effect sensor, Arduino compatible pro micro and Hitec HS-125MG servo. Sorry I can’t upload pictures of these from my phone I havnt figured that out yet.

Before I destroy these components guessing if someone could help me out with a basic wiring diagram id feel much more at easy having a go at this. I need the sensor to operate the servo when activated by a magnetic field to open and close the faceplate. Also do I connect my 4xAA battery pack to RAW and GND or VCC and GND ?

Any help will be very much appreciated

Thanks guys

See if these help …

http://www.freetronics.com/pages/hall-e … _89lmM0_iU

https://www.sparkfun.com/tutorials/283

I would connect the servo power lead as directly to the battery pack as possible. Don’t run it off of the Arduino’s regulated 5V output.

As for power to the Arduino … it depends on what voltage the Arduino takes (5V vs 3.3V), what the clock speed is (16 MHz vs 8 MHz) and what type batteries (alkaline vs rechargable NiMH). Alkaline batteries are 1.5+V when new and 4 in series gives you 6+V when new. That’s too high for even a 5V Arduino and so it has to go into the RAW input. NiMH start at perhaps 1.35+V when fully charged and rapidly go to 1.25V and then less as they are used. So when fully charged they are right at the limit (5.5V) for most “5V” parts To get the longest runtime you could run the battery pack into the Vcc pin (assuming a 5V Arduino). To be safe run it into the RAW input (this is required for a 3.3V Arduino). If you do this the voltage at a 5V Arduino’s MCU “brain” will be lower than the desired 5V after a short runtime and it may start to malfunction. Or it may not. Slower clock speed Arduinos require less voltage to run stably. But you may get lucky and have a 5V 16 MHz Arduino that will happpily run at even 4V. So my advice would be try the RAW first and see if you have enough runtime and open/close cycles. If you provide a link to the clone used, I can figure out how much voltage will be lost by the voltage regulator when the battery voltage goes too low.

The battery ground and sensor ground and servo ground and Arduino ground should be all tied together. Your Arduino may have multiple ground pins to make this easy.

ps - you can use any of the digital pins for the sensor and servo but it’s wise not to use pins 0 and 1, as they are generally used by the Arduino itself for communications to/from the USB connector.

Thankyou for all the information and advice Mee_n_Mac I really appreciate such a quick helpful response, it’s obvious I’ve come to the right place for my nubile questions.

https://www.sparkfun.com/products/12640

The above link is the board I am using, I’m a little unsure of the terminology concerning the pins you mentioned in regards to the digital I / O’s ( would I be correct assuming that means In’s and Out’s ?)

Thankyou again for your help

NoTech:
I’m a little unsure of the terminology concerning the pins you mentioned in regards to the digital I / O’s ( would I be correct assuming that means In’s and Out’s ?)

Correct !

You’re using SF’s Pro Micro and it’s has a very low drop-out voltage regulator. That means it’ll stay in operation, making 5V output, so long as the input voltage is > 5.1V - 5.2V. Once the input goes below that, the output voltage should only be 0.1V - 0.2V below the input voltage. Since you’re loosing so little voltage in this condition, I would run the battery pack into the RAW input.

Thanks again for the great info Mee_n_Mac you’ve been very helpful.

My understanding now is my layout should be as follows:

RAW - Battery +ve

GND - Battery -ve

GND - Servo -ve

GND - Sensor -ve

Battery +ve - Servo +ve

Battery +ve - Sensor +ve

Servo Control Wire - Terminal 3 ( or 4, is PWM necessary for the servo ? I’m vague on the details but is it used for motors ?)

Arduino OUT - Terminal 7

Here’s hoping my shot in the dark isn’t embarassingly wrong but before i solder anything i’ll wait and see if i stand to be corrected.

Thanks again !!

If all goes well i’ll post my project and WIP

NoTech:
Servo Control Wire - Terminal 3 ( or 4, is PWM necessary for the servo ? I’m vague on the details but is it used for motors ?)

If you use the Arduino Servo library, it can be any pin.

http://arduino.cc/en/reference/servo

PWM, when used w/motors, is for speed control.

ps - I think the Hall sensor also needs a battery + connection.

The only reason I thought to use a PWM pin for the servo was, from some quick research I read it was for speed control, I’m hoping through programming I could slow the servo speed near full open or close positions to prevent it from slamming and damaging the helmet or hinge system.

With the sensor I was going to connect it’s VIN direct to Battery +ve.

Is the programming simple enough for a first timer like me ? Very keen to have a go myself

NoTech:
The only reason I thought to use a PWM pin for the servo was, from some quick research I read it was for speed control, I’m hoping through programming I could slow the servo speed near full open or close positions to prevent it from slamming and damaging the helmet or hinge system.

Yeah ... that's the problem w/hobby servos. You give them a position command and then it's totally up to the servo as to how fast it get's to that position and well as any overshoot, oscillations, etc. The thing you can do is command steps to what you can reasonably expect is the final position(s). The command smaller and smaller steps in position, using your timing to avoid slamming "home". I believe that's what done "behind the curtains" when you use the VarSpeedServo library. You can Google it to find it's latest incarnation. That library allows you to specify a speed for the servo motion. I pointed another poster to it and it apparently worked.

NoTech:
Is the programming simple enough for a first timer like me ? Very keen to have a go myself

I think so. Start w/o the above library and just get things to work. Then add the "fine tuning". One thing I'm curious about ... presumably the helmet has an open and a close position. Do you have 2 magnets or 2 sensors to find each position ?

I’ll also add since you have a servo and it goes to whatever position you command … you really don’t need the end position sensor(s). Just fine tune (start short of the desired position and increase it until it’s just right) the servo command. Alternately you could use a basic DC motor and add an H bridge driver and command it to go “that a-way” until the sensor says “Whoa, stop”. What I’m saying is you don’t need the sensor other than as a backup for a failed servo. In which case you’ve got other problems. When designing things try to adhere to the KISS principle.

Well i’m sat here in front of the laptop looking at my blinking orange and solid red led on the Arduino board and poring through a lot of code and do not know where to start this is inane !

I’ve seen some examples on another forum and it seems just to move a servo requires a lot of typing, i hate to think how much more there is when i ask it to be activated by the sensor.

Am i totally lost or just overwhelmed ?

I cant even figure out how to trial the code i have found

Requesting a rescuing please

I take my hat off to the people here that are fluent in this code i am humbled by its apparent difficulty i’m sure there’s a knack to it once i get my head around it

First … I have to assume there’s a switch or button to be pressed to tell the visor to open and/or to close. If so read these tutorials on how to read a switch and how to slowly command a servo.

http://arduino.cc/en/Tutorial/InputPullupSerial

http://arduino.cc/en/Tutorial/Sweep

Then I want to you to look over the code I wrote that’s basically a mash-up of those 2 above. Depending on the visor movement and servo mounting and the pins used, it might be a good starting point.

#include <Servo.h>                   //Library to be used for servo

//declare the constants to be used
const int LEDPIN = 13;               //pin attached to led
const int servoPIN = 3;              //Servo control line (orange) to be connected to this pin
const int SWitchPIN = 2;             //input from N.O. momentary switch

const int posOpenCMD = 90;           //command in deg to servo to open the visor
const int posCloseCMD = 45;          //command in deg to servo to close the visor
const unsigned long slowDlay = 100;  //delay btw 1 degree steps in position commands

//declare the variables used
boolean visorOPEN = true;    //desired door state set to open
int posCMD;                  //servo position command in degrees
int halfWayCMD;              //a position halfway btw open and closed

Servo myServo;               //create a servo object

void setup() {
  //set the pins to be ins or outs
  pinMode(LEDPIN, OUTPUT);
  digitalWrite(LEDPIN, LOW);         //turn LED off
  pinMode(servoPIN, OUTPUT);
  pinMode(SWitchPIN, INPUT_PULLUP);  //Also enable the internal pull-up resistor
  myServo.attach(servoPIN);          //Tell the servo library which pin to use
  //compute a position halfway btw open and closed
  halfWayCMD = abs(posOpenCMD - posCloseCMD) / 2 + min(posOpenCMD, posCloseCMD);
  digitalWrite(LEDPIN, HIGH);        //turn LED on
  //now send the visor to it's open position, slowly, starting from halfway
  for (posCMD = halfWayCMD; posCMD <= posOpenCMD; posCMD += 1) //goes from halfway to open
  {
    myServo.write(posCMD);            //tell servo to go to position in variable 'posCMD'
    delay(max(20, slowDlay));         //waits some ms for the servo to reach the position
  }
  digitalWrite(LEDPIN, LOW);          //turn LED off
}

void loop() {
  //read the switch if the door is not moving
  if (digitalRead(SWitchPIN) == LOW) { //see if switch is being pushed
    visorOPEN = ~visorOPEN;            //reverse desired visor state when sewitch is pushed
    digitalWrite(LEDPIN, HIGH);        //turn LED on
    //now compute servo command based on desired door state
    if (visorOPEN == true) {
      //visor is starting from open postion so close it, 1 deg at a time
      for (posCMD = posOpenCMD; posCMD <= posCloseCMD; posCMD -= 1)  // goes from open to closed
      {
        myServo.write(posCMD);          //tell servo to go to position in variable 'posCMD'
        delay(max(20, slowDlay));       //waits min of 20 ms for the servo to go 1 degree
      }
    } else {
      //visor is starting from closed postion so open it, 1 deg at a time
      for (posCMD = posCloseCMD; posCMD >= posOpenCMD; posCMD += 1) //goes from open to closed
      {
        myServo.write(posCMD);          //tell servo to go to position in variable 'posCMD'
        delay(max(20, slowDlay));       //waits some ms for the servo to reach the position
      }
    }
  }
  digitalWrite(LEDPIN, LOW);            //turn LED off
}

After perusing the above, we can figure out what may need changing for your situation (pin numbers, open and closed positions, etc). Then, when it’s working, it can be expanded on to make it better. But let’s start simple.

EDIT: fixed the above code

Again Mac im in your debt that is impressive and i cant wait to test it tonight, there is the hall effect sensor to act as my button.

I read through a fair bit of the code on the arduino site and just couldnt get my head around it, id really like to learn how to do this, might look for courses in sydney if theres such a thing.

The only other issue i had was uploading to the board, i can post the error message i get later.

Thsnkyou again

After a brief look at the InputPullupSerial code made a bit of sense to me and the // info is very helpful explaining what each line is doing

NoTech:
there is the hall effect sensor to act as my button.

Can you explain how you envision that working ? You wave a magnet at the sensor or ???

Also I don’t know how you have the servo mounted and so I don’t know if an opening servo command is more … or less … degrees than a closing servo command. The code could be backwards in that way

EDIT : Here’s a revised version of the above code that fixes a couple of goofups I found.

#include <Servo.h>                   //Library to be used for servo

//declare the constants to be used
const int LEDPIN = 13;               //pin attached to led
const int servoPIN = 3;              //Servo control line (orange) to be connected to this pin
const int SWitchPIN = 2;             //input from N.O. momentary switch

const int posOpenCMD = 90;           //command in deg to servo to open the visor
const int posCloseCMD = 45;          //command in deg to servo to close the visor
const unsigned long slowDlay = 100;  //delay btw 1 degree steps in position commands

//declare the variables used
boolean visorOPEN = true;    //desired door state set to open
int posCMD;                  //servo position command in degrees
int halfWayCMD;              //a position halfway btw open and closed

Servo myServo;               //create a servo object

void setup() {
  //set the pins to be ins or outs
  pinMode(LEDPIN, OUTPUT);
  digitalWrite(LEDPIN, LOW);         //turn LED off
  pinMode(servoPIN, OUTPUT);
  pinMode(SWitchPIN, INPUT_PULLUP);  //Also enable the internal pull-up resistor
  myServo.attach(servoPIN);          //Tell the servo library which pin to use
  //compute a position halfway btw open and closed
  halfWayCMD = abs(posOpenCMD - posCloseCMD) / 2 + min(posOpenCMD, posCloseCMD);
  digitalWrite(LEDPIN, HIGH);        //turn LED on
  //now send the visor to it's open position, slowly, starting from halfway
  for (posCMD = halfWayCMD; posCMD <= posOpenCMD; posCMD += 1) //goes from halfway to open
  {
    myServo.write(posCMD);            //tell servo to go to position in variable 'posCMD'
    delay(max(20, slowDlay));         //waits some ms for the servo to reach the position
  }
  digitalWrite(LEDPIN, LOW);          //turn LED off
}

void loop() {
  //read the switch if the door is not moving
  if (digitalRead(SWitchPIN) == LOW) { //see if switch is being pushed
    visorOPEN = ~visorOPEN;            //reverse desired visor state when sewitch is pushed
    digitalWrite(LEDPIN, HIGH);        //turn LED on
    //now compute servo command based on desired door state
    if (visorOPEN == true) {
      //visor is starting from open postion so close it, 1 deg at a time
      for (posCMD = posOpenCMD; posCMD <= posCloseCMD; posCMD -= 1)  // goes from open to closed
      {
        myServo.write(posCMD);          //tell servo to go to position in variable 'posCMD'
        delay(max(20, slowDlay));       //waits min of 20 ms for the servo to go 1 degree
      }
    } else {
      //visor is starting from closed postion so open it, 1 deg at a time
      for (posCMD = posCloseCMD; posCMD >= posOpenCMD; posCMD += 1) //goes from open to closed
      {
        myServo.write(posCMD);          //tell servo to go to position in variable 'posCMD'
        delay(max(20, slowDlay));       //waits some ms for the servo to reach the position
      }
    }
  }
  digitalWrite(LEDPIN, LOW);            //turn LED off
}

I’ll post a photo as best i can tonight as the servo isnt mounted as such but has been installed into the moving hinge mechanism, i didnt want it flying open and damaging the helmet if i had made an error.

The magnetic hall effect sensor is located near my temple inside the helmet and the idea is when i wave my hand past its location ( there’ll be a magnet attached to a finger of my glove ) it will activate the servo to open and the next wave of my hand will activate the servo to close.

NoTech:
The magnetic hall effect sensor is located near my temple inside the helmet and the idea is when i wave my hand past its location ( there’ll be a magnet attached to a finger of my glove ) it will activate the servo to open and the next wave of my hand will activate the servo to close.

OK, that makes sense. As it happens the Hall sensor output is also an active low so the code above will work with the sensor just as well as with the switch as described in the tutorial.

From the Freetronics URL above …

OUTPUT: Active LOW. Normally HIGH, goes LOW in the presence of a magnetic field.

Perhaps the INPUT_PULLUP could be just INPUT but that’s no big deal.

Hi Mac

As promised although a little late here are some photos of the helmet with the faceplate open, closed and a close up of the hinge itself.

I read through the code you compiled and am not sure where to make the adjustments to degrees of open and close positions but am i right in saying that in the pictures the servo is, with faceplate closed set at either 0 or 180 degrees and when open will obviously be the opposite. how do i know where the servo is sitting now before running the code, im not explaining this very well i know.

I have wound the servo gear all the way in one direction in order to install it into the hinge system, problem is i dont know if ive wound it to 0 or 180 so i assume if when tried one way the code doesnt work we can just swap the 0 and 180 and that will fix the problem of knowing if open is 0 or 180 degrees and visa versa for closed ?

Good news is i got the Hall Effect sensor to light up and acknowledge the magnetic field i waved past it but not a lot of movement on the servo hopefully the pictures are of some help to my dilemma

NoTech:
Good news is i got the Hall Effect sensor to light up and acknowledge the magnetic field i waved past it but not a lot of movement on the servo hopefully the pictures are of some help to my dilemma

I looked at the pics above and conclude that the range of visor motion is perhaps ~ 60 deg. I also re-looked at the code and found a couple of mistakes. So I've corrected them and accounted for the Hall sensor and this version is now what you should try.
#include <Servo.h>                   //Library to be used for servo

//declare the constants to be used
const int LEDPIN = 13;               //pin attached to led
const int servoPIN = 3;              //Servo control line (orange) to be connected to this pin
const int sensorPIN = 2;             //input from Hall effect sensor

const int posOpenCMD = 45;           //command in deg to servo to open the visor
const int posCloseCMD = 15;          //command in deg to servo to close the visor
const unsigned long slowDlay = 100;  //delay btw 1 degree steps in position commands

//declare the variables used
boolean visorOPEN = true;            //desired door state set to open
int posCMD;                          //servo position command in degrees
int halfWayCMD;                      //a position halfway btw open and closed

Servo myServo;                       //create a servo object

void setup() {
  //set the pins to be ins or outs
  pinMode(LEDPIN, OUTPUT);
  digitalWrite(LEDPIN, LOW);         //turn LED off
  pinMode(servoPIN, OUTPUT);
  pinMode(sensorPIN, INPUT);
  
  myServo.attach(servoPIN);          //Tell the servo library which pin to use
  
  //compute a position halfway btw open and closed
  halfWayCMD = abs(posOpenCMD - posCloseCMD) / 2 + min(posOpenCMD, posCloseCMD);
  digitalWrite(LEDPIN, HIGH);        //turn LED on when visor is in motion
  //now send the visor to it's open position, slowly, starting from halfway
  for (posCMD = halfWayCMD; posCMD < posOpenCMD; posCMD += 1) //goes from halfway to open
  {
    myServo.write(posCMD);            //tell servo to go to position in variable 'posCMD'
    delay(max(20, slowDlay));         //waits some ms for the servo to reach the position
  }
  
  digitalWrite(LEDPIN, LOW);          //turn LED off
}

void loop() {
  //read the switch if the door is not moving
  if (digitalRead(sensorPIN) == LOW) { //see if magnet is being detected
    digitalWrite(LEDPIN, HIGH);        //turn LED on to indicate motion
    //now compute servo command based on desired door state
    if (visorOPEN == true) {
      //visor is starting from open postion so close it, 1 deg at a time
      for (posCMD = posOpenCMD; posCMD > posCloseCMD; posCMD -= 1)  // goes from open to closed
      {
        myServo.write(posCMD);          //tell servo to go to position in variable 'posCMD'
        delay(max(20, slowDlay));       //waits min of 20 ms for the servo to go 1 degree
      }
    } else {
      //visor is starting from closed postion so open it, 1 deg at a time
      for (posCMD = posCloseCMD; posCMD < posOpenCMD; posCMD += 1) //goes from open to closed
      {
        myServo.write(posCMD);          //tell servo to go to position in variable 'posCMD'
        delay(max(20, slowDlay));       //waits some ms for the servo to reach the position
      }
    }
  }
  //motion is now completed
  digitalWrite(LEDPIN, LOW);            //turn LED off
  visorOPEN = ~visorOPEN;               //reverse visor state when motion is done
}

Meanwhile let me answer some questions. The final position commands, for open and close, are contained in these to constants.

const int posOpenCMD = 45;           //command in deg to servo to open the visor
const int posCloseCMD = 15;          //command in deg to servo to close the visor

My assumption in the above is that a fully closed position is 0 deg and a fully open one is ~60 deg. So I set them a bit inside of any hard mechanical stops so as to avoid hitting said stops and breaking something. IF I’ve got the “polarity” of open/close correct, I would advise you to increase one constant and then decrease the other until you’ve got the visor moving to fully open and to fully closed. Even better would be to disconnect the visor from the servo arm and verify it moves in the correct direction and at about to the right places before doing the above. Note that after power on or reset and before detecting any magnet, the visor is commanded to the open position. It should sit there until the Hall sensor indicates a magnet is present.

If I’ve got the “polarity” reversed then some changes will need to happen. You’ll need to change the constants and then the >, < and the -= and += in the for() loops. But first let’s see what happens w/the corrected code above. Alas I don’t know of anyway to tell you what the servo positions or polarity should be, other than by test.