xl97's Iron Man motorized face plate tutorial

*Update:

opk I see the GND wire now..

but youre saying that adding breaks everything?

(but if you remove it works fine again?)

And when I remove the GND wire, it looks like its working. The first video is how it looks like if I don't add the GND wire.
 
How do I find what kind of transistor I need sory if theres is only one kind ahah

Envoyé de mon SM-G530W en utilisant Tapatalk
 
Dio

I'm not sure why your getting jitter then.

If it were me.. I'd remove everything except the servos.. work on getting those stable..

at the very least.. just use 1 led (no transistors).. and a resistor to just the output pin on the Arduino..


tijojo98 -

You can use an NPN resistor..

the brand and pinout may differ.. (read the datasheets)

but this may vary on each persons set-up..

battery source
how many leds
forward current of these leds..etc

but more or less..

or if can handle the load (current) you need to supply to the LEDS (in total).. any NPN transistor should be fine.
 
Last edited by a moderator:
  • Like
Reactions: Dio
@Dio

I'm not sure why your getting jitter then.

If it were me.. I'd remove everything except the servos.. work on getting those stable..

at the very least.. just use 1 led (no transistors).. and a resistor to just the output pin on the Arduino..


@tijojo98 -

You can use an NPN resistor..

the brand and pinout may differ.. (read the datasheets)

but this may vary on each persons set-up..

battery source
how many leds
forward current of these leds..etc

but more or less..

or if can handle the load (current) you need to supply to the LEDS (in total).. any NPN transistor should be fine.

Hi xl97,

Will try that now and keep you posted.

Dio
 
Do a search on the Arduino.cc forums.. (you'll find everything you need there)..

For the most part.. I have either used a transistor to control high powered leds.. or made a constant current driver..



re: the hinge system..

looks good if you want to go the route where you have the 'slots' for the hinge arms to go..(in the helmet)

so go that route.. some dont.



@Leylander


What diagram are you 'cleaning up'?

I dont think its get any more direct than this:

http://dmstudios.net/misc/IronMan_circuitLayout_xl97.jpg

The one you made on 123D circuits. See your post on p2. It had green wires going straight to the connections. I just colorized and repositioned the wires so it's visible where they are going. It's practically the same, yes. But I like to haven editable version to play around with
 
Hi xl97,

Will try that now and keep you posted.

Dio

Hi xl97,

I'm still working on it. But I do have some questions.

since the wire and servo wire head looks like this:

wire.jpg

How should I connect them when I finally wire them up? Should I cut the head off then wire them? It easy for jumper wire.

On your diagram, I didn't see there is a wire linked to GND on the uno r3 board. I only see the wire back to negative to the battery. May I ask why I should do additional wire to the GND pin on UNO r3 board?

Thanks

Dio
 
It is. (Look again)..

I just have the GNDs connected coming after the vRegulator..

Your diagram doesnt.. so a quick 'fix' is add the jumper.

I'm not really sure why this seems like such a big deal? Just try it.. if its not working.. (or actually breaking things).. then you have something else going on. (which is why I suggested you strip everything down and implement 1 component at a time to find out whats going on)

You connect all GROUNDS together.. so all logic/voltage levels know about each other and can communicate with each other more or less


As far as wiring goes..thats up to you and your projects..

cut and splice together.. cut both ends and get new matching connectors (so you can remove things and trouble shoot if ever the need)

solder directly the board your using..

(I do NOT recommend using an UNO for your final project... I recommend replacing it with a Arduino Pro-Mini). <-- you'll need to order a FTDI/CP210X programmer with this as well.. (cost roughly $2.00 USD)
 
It is. (Look again)..

I just have the GNDs connected coming after the vRegulator..

Your diagram doesnt.. so a quick 'fix' is add the jumper.

I'm not really sure why this seems like such a big deal? Just try it.. if its not working.. (or actually breaking things).. then you have something else going on. (which is why I suggested you strip everything down and implement 1 component at a time to find out whats going on)

You connect all GROUNDS together.. so all logic/voltage levels know about each other and can communicate with each other more or less


As far as wiring goes..thats up to you and your projects..

cut and splice together.. cut both ends and get new matching connectors (so you can remove things and trouble shoot if ever the need)

solder directly the board your using..

(I do NOT recommend using an UNO for your final project... I recommend replacing it with a Arduino Pro-Mini). <-- you'll need to order a FTDI/CP210X programmer with this as well.. (cost roughly $2.00 USD)

Hi xl97,

Thanks for the clarification. I'm working on it one by one now. Now I only have a servo connected. nothing else. But it still moving wired. So once I power it on, it start jitter but seems like it try to find the right position. After a couple minutes, it stopped. Then when push the button it turn 45 degree which is correct. However, when I push the button again, it start jitter again for couple minutes then stop again just like the first time when I power it on.

I'm try different approach see where the problem is. Will keep you posted.

For the final project, I'm planning to use the nano board 328. Will this ok?

Thanks

Dio
 
This is the code I'm using:

// IronMan Helmet: eye blink sequence_v1.0
// created by: xl97




//import servo lib
#include <Servo.h>


//servo object names
Servo myservo; // create servo object to control a servo
Servo myservo1;


const int buttonPin = 2; // the pin that the pushbutton is attached to
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button




// led control pins (need to be PWM enabled pins for fading)
const int leftEye = 6; // the number of the left eye/pcb LEDs
const int rightEye = 3; // the number of the right eye/pcb LEDs


unsigned long fadeDelay = .5; //speed of the eye 'fade'
unsigned long callDelay = 700; //length to wait to start eye flicker after face plate comes down
unsigned long blinkSpeed = 100; //delay between init blink on/off
unsigned long currentPWM = 0;
boolean isOpen = true;
//
int openAngle = 90;
int closeAngle = 0;
//


#define S_IDLE 1
#define S_LEDON 2
#define S_WAITON 3
#define S_LEDOFF 4
#define S_WAITOFF 5
#define S_INITON 6
#define S_INITWAIT 7
#define S_BLINKON 8
#define S_SERVOUP 9
#define S_SERVODOWN 0
#define S_SERVOWAIT 10






//FSM init vars
static int state = S_IDLE; // initial state is 1, the "idle" state.
static unsigned long lastTime; // To store the "current" time in for delays.




void setup() {
// Set up serial port
Serial.begin(9600);
//start it off
//state = S_BLINKON;
Serial.print("INTIT STATE: ");
Serial.println(state);


myservo.attach(9); // attaches the servo on pin 9 to the servo object
myservo1.attach(10); // attaches the servo on pin 10 to the servo object


pinMode(buttonPin, INPUT); // initialize the button pin as a input
digitalWrite(buttonPin, HIGH); //use interal pull up resistors
}


void loop() {
switch(state)
{
case S_IDLE:
// We don't need to do anything here, waiting for a forced state change...like button press.
//check mian button state
buttonState = digitalRead(buttonPin);


// compare buttonState to previous state
if (buttonState != lastButtonState) {
//if button pressed/down
if (buttonState == LOW){
//ie: pressed
if(isOpen == true){
Serial.print("CLOSING FACE PLATE: ");
Serial.println(isOpen, DEC);
state = S_SERVODOWN;
}
else{
Serial.print("OPENING FACE PLATE: ");
Serial.println(isOpen, DEC);
//state = S_SERVOUP;
state = S_LEDOFF;
}
isOpen = !isOpen;
}
else{
//went from ON/HIGH to LOW/OFF..ie: released
//Serial.print("RELEASE: ");
//Serial.println(isOpen, DEC);
}
}
// save the current state for next loop
lastButtonState = buttonState;
break;


case S_BLINKON:
Serial.println("init blink.........");
//do blink routine here
//one blink
analogWrite(leftEye, 155);
analogWrite(rightEye, 155);
delay(blinkSpeed);
analogWrite(leftEye, 0);
analogWrite(rightEye, 0);
delay(10);
//two blinks
/*
analogWrite(leftEye, 155);
analogWrite(rightEye, 155);
delay(blinkSpeed);
analogWrite(leftEye, 0);
analogWrite(rightEye, 0);
delay(10);
*/
state = S_LEDON;
break;


case S_LEDON:
Serial.println("increase........");
lastTime = millis(); // Remember the current time
analogWrite(leftEye, currentPWM);
analogWrite(rightEye, currentPWM);
state = S_WAITON; // Move to the next state
break;


case S_WAITON:
// If one second has passed, then move on to the next state.
if(millis() > (lastTime + fadeDelay)){
if(currentPWM < 255){
currentPWM += 5;
state = S_LEDON;
}
else{
Serial.println("@ 255 done........");
state = S_IDLE;
//state = S_LEDOFF; //no auto turn off.. set to idle state
}
}
break;


case S_LEDOFF:
Serial.println("........decrease");
lastTime = millis(); // Remember the current time
analogWrite(leftEye, currentPWM);
analogWrite(rightEye, currentPWM);
state = S_WAITOFF;
break;


case S_WAITOFF:
// If one second has passed, then move on to the next state.
if(millis() > (lastTime + fadeDelay)){
if(currentPWM > 0){ //change 0 to higher number to init face 'up' function sooner.
currentPWM -= 5;
state = S_LEDOFF;
}
else{
Serial.println("@ 0 done........");
state = S_SERVOUP; //leds off..raise faceplate
}
}
break;


case S_SERVOUP:
Serial.println("servo up.........");
myservo.write(100);
myservo1.write(100);
state = S_IDLE;
break;


case S_SERVODOWN:
lastTime = millis(); // Remember the current time
Serial.println("servo down.........");
myservo.write(0);
myservo1.write(0);
state = S_SERVOWAIT;
break;


case S_SERVOWAIT:
// If enough time has passed, call the eye flicker routine
if(millis() > (lastTime + callDelay)){
Serial.println("start eye flicker routine");
state = S_BLINKON;
}
else{
Serial.println("waiting........");
}
break;


default:
state = S_IDLE;
break;
}
}

I only add the part in red to control the moving degree. It is correct?
 
Last edited by a moderator:
as mentioned before.. try to change the RANGE to be something like 30 & 90

not 0 & 90

A Nano should work just as well..

(and you dont need a programmer as I believe it has USB built in).. a little bigger than a Pro-Mini.. but whatever works for your project.
 
as mentioned before.. try to change the RANGE to be something like 30 & 90

not 0 & 90

A Nano should work just as well..

(and you dont need a programmer as I believe it has USB built in).. a little bigger than a Pro-Mini.. but whatever works for your project.

Thanks will make change now. Really appreciate your help and patience:D

Really hope it will work this time:)

Dio
 
good luck..

as a last ditch effort....
may
be try another micro servo of some other type.. to rule out that type/brand..etc


but usually having a correct range... (as not all servos an actually move 0-180... more like 20-160 or so.. as a max.)...

and connecting all grounds together should work.
 
good luck..

as a last ditch effort....
may
be try another micro servo of some other type.. to rule out that type/brand..etc


but usually having a correct range... (as not all servos an actually move 0-180... more like 20-160 or so.. as a max.)...

and connecting all grounds together should work.

Hi xl97,

I think I find out why servo is jitter. Remember I was mentioned when there is power to the servo the voltage has dropped from 4.89 to 2.83? I think the 6V power source is kind of weak so cannot constant support 6v all the time. Since I don't have a 7V power source, what I did is add another 4xAA battery pack then I have a 12V power supply. And I did test it when there is a power to the servo it stay between 4.96-4.97V. No there is no more jitter.:D

However, next issue come out. It won't move to the right angle range. No matter what's my input (I have tried 0-180,30-90,30-60,30-120,0-120, etc) One of them always move about 10 degree and the other one always move about 5 degree. Not only that once they moved like that, they will also move back without me push the button.

Below is the diagram how I wire them.

Test 9.jpg

Here is the video how it looks like when power on.


May I ask is there anything I did wrong?

Thanks

Dio
 
Last edited by a moderator:
Another thing, I connect the R3 board to my computer using usd cable, and wire from pin 5v and GND from the board to servo. I assume this should work since the power source is my computer. However, see what happened after I plug it to the computer:


The beep sound from my computer is because the connection keep dropping. Not only the jitter but also unstable voltage (see the meter reader)

I see a lot of people use computer as power source for testing and have no problem at all. Not sure what's going on. Could there be something wrong with my R3 board? (I hope not)

Dio
 
Last edited by a moderator:
Could be..

but you are NOT supposed to try and power any devices/components from the Arduino that needs more that roughly 20mA per pin.. and I think maybe 150mA total per board..

I dont think most computer USB hubs/ports provide more than 200-500mA either.. and a servo can take more than 1Amp per servo.

(so external power source with all grounds connected is usually the suggested approach)

maybe your servo needs more or less voltage/current? what are the specs for it?
 
Could be..

but you are NOT supposed to try and power any devices/components from the Arduino that needs more that roughly 20mA per pin.. and I think maybe 150mA total per board..

I dont think most computer USB hubs/ports provide more than 200-500mA either.. and a servo can take more than 1Amp per servo.

(so external power source with all grounds connected is usually the suggested approach)

maybe your servo needs more or less voltage/current? what are the specs for it?

Hi xl97,

Thanks for the explanation. Now I understand better.

Here is the datasheet for the servo I'm using.

https://www.pololu.com/file/download/HD-1501MG.pdf?file_id=0J729

It says the range is between 4.8V - 6V. It also showing three different range for current. Not sure why (really wish I have taken some physics course when I was in school :()


I choose this servo was due to it was referred by a lot of people on the web. And showing what will happen if use the small and plastic servo. However the small plastic servo will work if the helmet/faceplate is pure plastic or 3d printed due to the lightness. I'm using the traditional version which is 110lb paper template->hot glue->resin->fiberglass->resin->body filter(multiple times) so it is pretty heavy.

I also notice that when I power it on for a while say 5-10mins with the 12V power source (2 4xAA battery pack), my 5v module become a bit hot. I know its input range is between 6-12V. Is that normal to be a bit hot? Will that be a issue since I'm at the max input range?

Here is what the 5v module looks like:

5v1.jpg

I do have a backup 5v module. The input range is 7.5v-20v.

5v2.jpg

The problem is for this one, I'm not sure how to connect it. It looks like I can wire input on one side ( the one side with screw) and output on the other side (the other side with screw. However, I notice that the is a yellow select which have 5+ and 5-. Now I'm confused. Also since originally I only have 1 4xAA battery pack for the power source. So I used the first one. The second one need min 7.5V input. And the first one is only the half the size of the second one.

Not sure what happened with my nano board. After the first time I load the code to it, I couldn't rewrite it anymore. And showing this message (stk500_recv(): programmer is not responding) I have tried different computer, press the reset button. Nothing works. Not sure whether this means the nano board it dead or not..................................

Thanks

Dio
 
Last edited:
.........May I ask is there a way to fix it or I have to buy a new one? (hopefully I don't have to buy a new one)
 
You have an UNO as well...correct?

Then you can re-flash bootloader..etc

hard to tell.. with it not in front of me.

Arduino.cc forum will yield TONS of help/things to try/do
 
Back
Top