xl97's Iron Man motorized face plate tutorial

HI

Thanks for the quick reply.

PMOS is showing as "pMOS Transistor (MOSFET)" on the 123D website (https://123d.circuits.io).

I did add two capacitors just like your instruction. The problem is in your instruction I see the power source is linked at the top left comer as below (I circled blue) :

View attachment 591122

However, on the 123D website they don't have this option. So I linked positive to 5v and negative on the GND both on tthe POWER section showing on the UNO R3 board.

The reason why I use 123D is they have the start simulation function so after I link all the parts together and upload the code, it can virtually show how the result looks like.

I tried to find some other virtual simulation software but they are not free such as VBB. I also tried Fritzing but it is for schematic only, no simulation.

If you know any other good simulation software, could you let me know?

I redid another screenshot. hoe this looks better:

View attachment 591126

I connect both led to the 0.1 uf Capacitor.

I don't know if you have a schematic with the breadboard? I saw your comments saying that the Jump Wire can be used for temporary test due to their voltage limitation is not suggested for a long run.

I have order the package on amazon but since it come from china the ETA showing as begin or middle of March. So I thought I may play around with the virtual simulation to be prepared. Just want to make sure I don't burn any of the actual parts. If I do, it will take another 1 and half month for the new one arrive:cry

Really hope I can get it work.

Thanks

Dio



couple of things..

1.) You need a voltage regulator.. MOSFET is not the same thing.
2.) You are NOT using a regulated +5v power source.. so you should be connecting to VIN on the Arduino.. not +5v..

Maybe try using a regulated +5v (maybe the PSU component in 123D?).. if it can be set to a steady voltage.. (not sure how)..

then you can connect to the Arduino +5v pin.. as well as remove the MOSFET and caps.. and run the simulation.. although this wont be the final design you need to implement into the helmet.. but if you want to try and simulate.. that might get you closer to a working circuit.
 
Ideally you wanna have your servos connected to a 5v regulator because if not, there is going to be alot "noise". This is going to lead to random servo movement when you don't want it, not moving at all, or even moving really slow. A common 5v regulator that I use is the L7805- it outputs 5v at 1.5 amps I believe. http://www.mouser.com/ProductDetail/STMicroelectronics/L7805ACV-DG/?qs=UOUhb9503hEO7qX1qhGGyg==

- - - Updated - - -

Is this compatible with led sheets ? :)

EL sheets usually have their own inverters which means most of the time they can't be integrated into different circuits.
 
I didnt see one in the app/simulator he wants to use (is using).. (a voltage regulator)
 
Hi xl97,

Thanks for the suggestion. Here is what I did.

I did follow your second suggestion and it start working. I also find that the simulation software set the power source default to 5v. So I removed MOSFET and 0.33uf capacitor (I assume this is for the LM7805 (MOSFET in my case) only)

After that this is how it looks like when I power it on:

Test 3.jpg

However after I push the pushbutton it looks like this:

Test 4.jpg

As you can see the good thing is the lights are turned on. But the servo turned downward instead of back up.

May I ask how should I fix this issue?

Seems like I'm really close:)

Thanks

Dio
 
@Dio-

I tried the 123D circuits thing.... seems to be working for me.

open the serial monitor and watching the output..

and shouldnt the faceplate (servos) be down when the lights are on? and off. when the face plate is up? (seems correct to me)..

when you power it on for the first time.. it opens the face plate up.. so you can see..get your head in..etc.. initial button press closes it.. and starts eye sequence.


simulation text:
https://123d.circuits.io/circuits/1601796-arduino-motorized-iron-man-faceplate-simulation



you can play with the servo open/close angles.... but really that wont matter too much until you get to installign things.. and how you mount the servo..and what angles you'll need to adjust to for your own setup
 
Last edited:
  • Like
Reactions: Dio
How do we take a circuit from the arduino uno and plug it on a mini ?

Envoyé de mon SM-G530W en utilisant Tapatalk
 
Hi Xl97,

Thanks for the explanation. Now I'm just waiting my shipment and try it in real:D

About the 0.33uf and 0.1uf polarized capacitors. They are to ensure the stability of the circuit, right?

By the way do you know any good source about the hinge system?

Thanks

Dio
 
How do we take a circuit from the arduino uno and plug it on a mini ?

Envoyé de mon SM-G530W en utilisant Tapatalk

Its no different..

Min just doesnt have barrel jack.. on-board USB..etc..

all the same pins match up..

- - - Updated - - -

Hi Xl97,

Thanks for the explanation. Now I'm just waiting my shipment and try it in real:D

About the 0.33uf and 0.1uf polarized capacitors. They are to ensure the stability of the circuit, right?

By the way do you know any good source about the hinge system?

Thanks

Dio

Yes.. the caps are for the voltage regulator.. to smooth things out.. (decoupling it is referred to as)

I would suggest using them.. some regulators may not even work without them.


As far as the hinge stuff goes.. I do not. As every helmet is unique and the place is unique.. I find its always a custom job.. not real one size fits all.. (unless it made for a specific run of casts..etc)

but there have been so many good ideas.. Im sure one will suit your needs.
 
Hi xl97,

Thanks for all your help. Will keep you posted once I received my electric parts:)

Have a good day.

Dio
 
Hi xl97,

Sorry to bother you again. I have another question. If I want to replace the button to an IR sensor, which part of your code need to be change? I just realize the UNO starter kit that I bought has IR sensor and IR remote. If there is a way I can replace the button to the IR senser then I can control the helmet remotely, right?

Thanks

Dio
 
should be a simple drop in replacement? I think pin....2? is the button? I'd have to look at the code.. how many wires are on the PIR sensor? link to part?
 
Hi xl97,

Sorry about the late reply. It looks like this:

IR Sensor.jpg

It also come with a IR Remote. Looks like this:

IR Remote.jpg

You are right, pin 2 is for the button. What I have heard is that it also need to program the remote to control the sensor. Since I have no background, not sure what to do next.

Dio
 
not sure about the remote part...

but when sending a signal/command to the sensor.. what does it send out from the 'out' pin?

I think there are some basic IR tuts out there...

looks like its a bit more involved than a reed switch:

https://www.youtube.com/watch?v=iFpAqG90zY0

I'm sure it can be done.. but the code above wont work as is.
 
Last edited:
I have no idea about the out pin. I just find out that the UNO starter kit I bought include these two parts. So I thought this is may be a good idea to remote control the helmet:D

The 123D site has these parts as well.
 
from what I saw in the vid.. looks like it spits out some hex code (or something).. matching whatever button was pressed.
 
This is what I find on the web for turn on and off led code for IR sensor:



#include <IRremote.h>


int RECV_PIN = 11;
int LED = 10;
IRrecv irrecv(RECV_PIN);
decode_results results;


void irdisplay(unsigned long value)
{
switch(value){
case 0xFFA25D:
digitalWrite(LED, LOW);
break;
case 0xFFE21D:
digitalWrite(LED, HIGH);
break;
}
}


void setup()
{
pinMode(LED,OUTPUT);
Serial.begin(9600);
irrecv.enableIRIn();
}


void loop() {
if (irrecv.decode(&results))
{
irdisplay(results.value);
irrecv.resume();
}
}

Just wonder how should I apply this code into your code.
 
Hi xl97,

I think I figure it out. I tired the modified code on 123D and it seems working.

Here is the code:



//import servo lib
#include <Servo.h>
#include <IRremote.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 = 1; //delay between init blink on/off
unsigned long currentPWM = 0;
boolean isOpen = true;
int openAngle = 180;
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.


//New
int RECV_PIN =2; // 红外线接收器OUTPUT端接在pin 2
IRrecv irrecv(RECV_PIN); // 定义IRrecv 对象来接收红外线信号
decode_results results; //解码结果放在decode_results构造的对象results里


void irdisplay(unsigned long value) // 按下按键后,显示本遥控对应的按键
{
switch(value){ //判定按下的是哪个按键,串口显示按钮名称
case 0xFD00FF:
digitalWrite(RECV_PIN, LOW); //电源键按下,执行关闭LED灯
break;
}
}
//New End


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(openAngle);
myservo1.write(openAngle);
state = S_IDLE;
break;


case S_SERVODOWN:
lastTime = millis(); // Remember the current time
Serial.println("servo down.........");
myservo.write(closeAngle);
myservo1.write(closeAngle);
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;
}
}

The color in red is what I added on your code. For the IR sensor, I connect the gnd pin to gnd, vcc pin to 5v and out pin to 2 on the R3 board.

Could you help me check it out? I just want to make sure there is no mistake.

Thanks

Dio
 
Last edited by a moderator:
Hi xl97,

I think I figure it out. I tired the modified code on 123D and it seems working.

Here is the code:



//import servo lib
#include <Servo.h>
#include <IRremote.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 = 1; //delay between init blink on/off
unsigned long currentPWM = 0;
boolean isOpen = true;
int openAngle = 180;
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.


//New
int RECV_PIN =2; // 红外线接收器OUTPUT端接在pin 2
IRrecv irrecv(RECV_PIN); // 定义IRrecv 对象来接收红外线信号
decode_results results; //解码结果放在decode_results构造的对象results里


void irdisplay(unsigned long value) // 按下按键后,显示本遥控对应的按键
{
switch(value){ //判定按下的是哪个按键,串口显示按钮名称
case 0xFD00FF:
digitalWrite(RECV_PIN, LOW); //电源键按下,执行关闭LED灯
break;
}
}
//New End


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(openAngle);
myservo1.write(openAngle);
state = S_IDLE;
break;


case S_SERVODOWN:
lastTime = millis(); // Remember the current time
Serial.println("servo down.........");
myservo.write(closeAngle);
myservo1.write(closeAngle);
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;
}
}

The color in red is what I added on your code. For the IR sensor, I connect the gnd pin to gnd, vcc pin to 5v and out pin to 2 on the R3 board.

Could you help me check it out? I just want to make sure there is no mistake.

Thanks

Dio
How do we put text in the code editor please when I open it i cant add text is it normal ? :)

Envoyé de mon SM-G530W en utilisant Tapatalk
 
Last edited by a moderator:
Back
Top