My P1 Themed Predator Costume with Electronics and Sounds. (Pic Heavy)

Man hopefully you do video sooner than later! Right now I'm just three printing as much as I can and following moe's pictures and what I can gather from this forum.
 
Man hopefully you do video sooner than later! Right now I'm just three printing as much as I can and following moe's pictures and what I can gather from this forum.
Check out my youtube which linked on that video. I have other videos there already so you might get what you are looking for.
 
I’m working on the electrical part of my build currently. Have the board connected to cannon and servos. My issue is it’s fine turning head left and right but when i tilt head down gun goes up and when head up gun goes down. Any ideas how to fix this? Or what code part to edit to reverse the signal for #6 servo connection?
 
I’m working on the electrical part of my build currently. Have the board connected to cannon and servos. My issue is it’s fine turning head left and right but when i tilt head down gun goes up and when head up gun goes down. Any ideas how to fix this? Or what code part to edit to reverse the signal for #6 servo connection?
What you need to do is do a remap routine.

For arduino you use the map function

for python I documented how I used a value remap here:
The basic remap formula is: new value = ((old value - old min)/(old max - old min))*(new max-new min) + new min
 
What you need to do is do a remap routine.

For arduino you use the map function

for python I documented how I used a value remap here:
The basic remap formula is: new value = ((old value - old min)/(old max - old min))*(new max-new min) + new min
Forgot to mention I have 0 knowledge with using arduino. I got the code on following simple copy and paste.
Happen to know of a copy paste kind of code with the channel 6 already reversed?
 
Forgot to mention I have 0 knowledge with using arduino. I got the code on following simple copy and paste.
Happen to know of a copy paste kind of code with the channel 6 already reversed?
no not really. Your other option is to flip the servo install location by 180 degrees...
 
For python something like this might work:

For arduino just use the map command?
map(input, old min, old max, new min, new max)
in your case to reverse it would be
map(input, old min, old max, new max, new min)
 
Ok I worked on it a little bit more. So, PWM signal range is 0-2300 typically. It varies based on many factors.
So i thought why not an if and elseif statement:
if (val > max/2)
val1 = max - val
elseif(val< max/2)
val1 = max - val

So this yielded that the simple solution was to do a recalibration of:
value1 = maxiumum value - original value

So using that equation should be simple to flip things.

For example
0 950 1150 1350 2300
value of 950 remaps to 1350 by taking 2300 - 950 = 1350
and conversely value of 1350 remaps to 950 by taking 2300 - 1350 = 950

Now the kicker is if your end value ends up being out of range you may need to adjust the numbers used.
 
Ok I worked on it a little bit more. So, PWM signal range is 0-2300 typically. It varies based on many factors.
So i thought why not an if and elseif statement:
if (val > max/2)
val1 = max - val
elseif(val< max/2)
val1 = max - val

So this yielded that the simple solution was to do a recalibration of:
value1 = maxiumum value - original value

So using that equation should be simple to flip things.

For example
0 950 1150 1350 2300
value of 950 remaps to 1350 by taking 2300 - 950 = 1350
and conversely value of 1350 remaps to 950 by taking 2300 - 1350 = 950

Now the kicker is if your end value ends up being out of range you may need to adjust the numbers used.
Swapping the servo motor wires and the potentiometer +- wires was way faster and easier for me and now works.
 
Sorry for the last responses, work has me busier than a bee.

No sir, I meant the piece that holds the plasma cannon. The piece that makes the cannon move all directions.
moe, Could you post a picture of how you mounted the second servo at the base? I think that is the only real outstanding question that is not sufficiently covered with documentation or pictures.

Here are some 3D pics of the servos. The servos are MG996.
1673453159030.png


1673453368707.png


1673453508919.png


1673453570716.png

That looks awesome but I'm really new to this and I don't really see how the flashlight is actually wired in? I see it looks like you took out the bulb and just stuck it in there and what looks like on moe's picture a double a battery in some sort of a holder. But how is the back of it actually activated? And connected to I suppose you Arduino or your wrist computer? Thank you again!

The flashlight is hard wired from the canon to a cat 6 that connects to the gauntlet to 2 switches. One is a double momentary switch (pictured below) that hits 2 buttons at once (one to flash the light, one to make the plasma sound):

1673453830847.png


I also have a seperate power supply going to the flashlight controlled by a latching switch. That's the large one on the right. The latching bypasses the momentary button and sends juice seperately to the flashlight.

1673454096153.png



Excellent I got it to work! I just tried different pins for the pwm I'm not quite sure where they were labeled in the code but they actually work out! Thank you all!
Below is my Arduino ini. Compare it to yours and you may see the issue.
#include<Wire.h>
#include<Servo.h>

const int MPU_addr=0x68; // I2C address of the MPU-6050
int16_t GyX,GyY,GyZ,AcX,AcY,AcZ,Tmp;

int xOffset = 0;
int yOffset = 0;
int zOffset = 0;

int i = 0;

long X = 0;
long Y = 0;
long Z = 0;

unsigned long previousMillis = 0;
unsigned long currentMillis = millis();
const long interval = 10;

unsigned long TIMERpreviousMillis = 0;
unsigned long TIMERcurrentMillis = millis();
const long TIMERinterval = 1;

int resetButtonPin = 12;

int horizontalPosition = 90;
int verticalPosition = 90;
int sideTiltPosition = 90;

int buttonCurrent = 0;
int buttonPrevious = 0;
unsigned char buttonHistory = 0;

int test = 0;

Servo horizontalServo;
Servo verticalServo;
Servo sideTiltServo;


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

void loop()
{
headTracking();
}



void GetCalibrationData()
{
int i = 0;
long xCal = 0;
long yCal = 0;
long zCal = 0;

Serial.println("Calculating Gyro Offset Values...");

while(i < 1000)
{
Wire.beginTransmission(MPU_addr);
Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H)
Wire.endTransmission(false);
Wire.requestFrom(MPU_addr,14,true); // request a total of 14 registers
AcX=Wire.read()<<8|Wire.read(); // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)
AcY=Wire.read()<<8|Wire.read(); // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
AcZ=Wire.read()<<8|Wire.read(); // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
Tmp=Wire.read()<<8|Wire.read(); // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
GyX=Wire.read()<<8|Wire.read(); // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
GyY=Wire.read()<<8|Wire.read(); // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
GyZ=Wire.read()<<8|Wire.read(); // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)

xCal = xCal + GyX;
yCal = yCal + GyY;
zCal = zCal + GyZ;

i = i + 1;
}

xOffset = xCal/1000;
yOffset = yCal/1000;
zOffset = zCal/1000;

Serial.print("X Offset: ");
Serial.println(xOffset);

Serial.print("Y Offset: ");
Serial.println(yOffset);

Serial.print("Z Offset: ");
Serial.println(zOffset);

Serial.println("--------------------");
Serial.println();

delay(2500);

Serial.println("Ready");

digitalWrite(13,HIGH);

return;
}



void gyroSetup()
{
pinMode(resetButtonPin,INPUT);
pinMode(13,OUTPUT);
digitalWrite(13,LOW);

horizontalServo.attach(7);
horizontalServo.write(horizontalPosition);
delay(15);
verticalServo.attach(6);
verticalServo.write(verticalPosition);
delay(15);
sideTiltServo.attach(5);
sideTiltServo.write(sideTiltPosition);
delay(15);

Serial.println("Initializing Gyroscope...");

Wire.begin();
Wire.beginTransmission(MPU_addr);
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU-6050)
Wire.endTransmission(true);

Serial.println("Initialization Complete");

GetCalibrationData();

return;
}



void headTracking()
{
TIMERcurrentMillis = millis();
if (TIMERcurrentMillis - TIMERpreviousMillis >= TIMERinterval)
{
//reset timer
TIMERpreviousMillis = TIMERcurrentMillis;

buttonPrevious = buttonCurrent;
if(digitalRead(resetButtonPin) == HIGH)
{
buttonCurrent = 1;
}
else
{
buttonCurrent = 0;
}
buttonHistory = (buttonHistory << 1) | buttonCurrent;

if((buttonPrevious == 0)&&(buttonCurrent == 1))
{
test = 0;
}
}

if(test == 0)
{
if(buttonHistory == 0x0)
{
test = 1;

sideTiltPosition = 90;
sideTiltServo.write(sideTiltPosition);
verticalPosition = 90;
verticalServo.write(verticalPosition);
horizontalPosition = 90;
horizontalServo.write(horizontalPosition);
}
}

Wire.beginTransmission(MPU_addr);
Wire.write(0x43); // starting with register 0x43 (GYRO_XOUT_H)
Wire.endTransmission(false);
Wire.requestFrom(MPU_addr,14,true); // request a total of 6 registers

GyX=Wire.read()<<8|Wire.read(); // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
GyY=Wire.read()<<8|Wire.read(); // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
GyZ=Wire.read()<<8|Wire.read(); // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)

GyX=(GyX-xOffset)/131;
GyY=(GyY-yOffset)/131;
GyZ=(GyZ-zOffset)/131;

X = X + GyX;
Y = Y + GyY;
Z = Z + GyZ;

i = i + 1;

currentMillis = millis();
if (currentMillis - previousMillis >= interval)
{
//take average
X = X/i;
Y = -Y/i;
Z = Z/i;

//multiply by 0.01 (ten milliseconds)
X = X*0.02;
Y = Y*0.02;
Z = Z*0.02;

//reset i
i = 0;

//reset timer
previousMillis = currentMillis;



//-------------------------------------------------------------------------------------
sideTiltPosition = sideTiltPosition + X;

if((sideTiltPosition <= 60) && (sideTiltPosition >= 0))
{
sideTiltServo.write(sideTiltPosition);
}
else if(sideTiltPosition > 60)
{
sideTiltPosition = 60;
}
else if(horizontalPosition < 0)
{
sideTiltPosition = 0;
}
//-------------------------------------------------------------------------------------


//-------------------------------------------------------------------------------------
verticalPosition = verticalPosition + Y;

if((verticalPosition <= 60) && (verticalPosition >= 0))
{
verticalServo.write(verticalPosition);
}
else if(verticalPosition > 60)
{
verticalPosition = 60;
}
else if(verticalPosition < 0)
{
verticalPosition = 0;
}
//-------------------------------------------------------------------------------------


//-------------------------------------------------------------------------------------
horizontalPosition = horizontalPosition + Z;

if((horizontalPosition <= 60) && (horizontalPosition >= 0))
{
horizontalServo.write(horizontalPosition);
}
else if(horizontalPosition > 60)
{
horizontalPosition = 60;
}
else if(horizontalPosition < 0)
{
horizontalPosition = 0;
}
//-------------------------------------------------------------------------------------



//reset averages
X = 0;
Y = 0;
Z = 0;
}

return;
}
 
So how did you actually wire in power in ground the two wires for the flashlight toggle and the two wires to turn on the cannon laser lights? Do you have some sort of schematic again I need all this. I did get the head tracker to work though! Additionally how did you actually put in the flashlight and connect it inside the gun? Do you have a picture of that exact setup? Thank you again!
I don't have a sketch board to draw on easily so I'll try to describe what to do for the Flashlight only:

Step 1) Solder directly to the terminals on the flashlight. Now you have one red wire (Flashlight Positive) and one black wire (ground).
Step 2) Ground the flashlight in the backpack where the battery pack is.
Step 3) FOR FLASHLIGHT ONLY, you need to run 2 wires from the backpack to the gauntlet (5V Power and flashlight positive). There will be other wires for powering the servos, reset button, etc but that is seperate for now.
Step 4) In the gauntlet: From the power in, wire one 5v Power to the double momentary switch (one button only)
Step 5) In the gauntlet: From the power in, wire one 5v Power to the latching switch.
Step 6) From the double momentary, wire the other side of the one button to the Flashlight positive.
Step 7) From the Latching switch, wire the other side of the switch to the Flashlight positive.

Let me know if that is clear. If someone has a easy sketch program to use I will download it and use that to illistrate my point.
 
I don't have a sketch board to draw on easily so I'll try to describe what to do for the Flashlight only:

Step 1) Solder directly to the terminals on the flashlight. Now you have one red wire (Flashlight Positive) and one black wire (ground).
Step 2) Ground the flashlight in the backpack where the battery pack is.
Step 3) FOR FLASHLIGHT ONLY, you need to run 2 wires from the backpack to the gauntlet (5V Power and flashlight positive). There will be other wires for powering the servos, reset button, etc but that is seperate for now.
Step 4) In the gauntlet: From the power in, wire one 5v Power to the double momentary switch (one button only)
Step 5) In the gauntlet: From the power in, wire one 5v Power to the latching switch.
Step 6) From the double momentary, wire the other side of the one button to the Flashlight positive.
Step 7) From the Latching switch, wire the other side of the switch to the Flashlight positive.

Let me know if that is clear. If someone has a easy sketch program to use I will download it and use that to illistrate my point.
What model flashlight did you use?
 
I don't have a sketch board to draw on easily so I'll try to describe what to do for the Flashlight only:

Step 1) Solder directly to the terminals on the flashlight. Now you have one red wire (Flashlight Positive) and one black wire (ground).
Step 2) Ground the flashlight in the backpack where the battery pack is.
Step 3) FOR FLASHLIGHT ONLY, you need to run 2 wires from the backpack to the gauntlet (5V Power and flashlight positive). There will be other wires for powering the servos, reset button, etc but that is seperate for now.
Step 4) In the gauntlet: From the power in, wire one 5v Power to the double momentary switch (one button only)
Step 5) In the gauntlet: From the power in, wire one 5v Power to the latching switch.
Step 6) From the double momentary, wire the other side of the one button to the Flashlight positive.
Step 7) From the Latching switch, wire the other side of the switch to the Flashlight positive.

Let me know if that is clear. If someone has a easy sketch program to use I will download it and use that to illistrate my point.
Excellent Moe thank you very much!!! I'll give this a shot, I'll let you know when I'm able to accomplish this I'm still 3d printing out a lot of the stuff and find time to do this in between taking care of the household.
 
Next question how did you wire that battery pack through the usb? In the picture it looks like you just stuck two wires in there or is there some sort of an adapter? Thank you

Some options that could work for you:




 

Some options that could work for you:




Excellent ksj!!! Thx for taking the time to answer! I appreciate it
 

Your message may be considered spam for the following reasons:

If you wish to reply despite these issues, check the box below before replying.
Be aware that malicious compliance may result in more severe penalties.
Back
Top