The discussion of the Alien series of films and the props used in them is the aim, but if it's got Big Bugs and Big Guns, then they are welcome too!





Post new topic Reply to topic  [ 30 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Build your own predator cannon
PostPosted: Fri Sep 01, 2017 3:42 pm 

Country: United States
OK now I have my budget for a predator canon. Here are the sites I am referencing:
https://www.instructables.com/id/Buildi ... r-costume/
https://www.instructables.com/id/Arduin ... ostumes-m/

The parts list takes a lot of the guess work out of things.

https://learn.adafruit.com/adafruit-16- ... s?view=all

The adafruit walkthrough on the shield I am using.

Many of the write-ups are ancient relatively speaking so this will be a fund build out.

_________________
The impossible takes a while longer and goes over budget too...


Last edited by knoxvilles_joker on Fri Sep 01, 2017 6:09 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Build your own predator cannon
PostPosted: Fri Sep 01, 2017 5:55 pm 

Country: United States
OK, I think I have all the parts to at least start on the canon build. I think the total is somewhere around 2 or 3 hundred in parts. This is to also finish out some of the other pieces I am working on.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject: Re: Build your own predator cannon
PostPosted: Sun Sep 03, 2017 1:19 am 

Country: United States
Original post did not apply.

I have posted on Adafruit forums:
https://forums.adafruit.com/viewtopic.php?f=31&t=124714

I am not above groveling to get some help.

It appears all code bases are dated and the newest software version do not play nice with anything I have tried to date.

_________________
The impossible takes a while longer and goes over budget too...


Last edited by knoxvilles_joker on Mon Oct 09, 2017 3:59 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Code updates
PostPosted: Sun Sep 24, 2017 6:05 pm 

Country: United States
Original post no longer applies.

Did more digging and found that I will have to do a major code rewrite.

As stated code has changed loads in a decade along with the hardware.

Let us just say that this will be a test of patience. I will have to get the servos working, and then back track from there.

WiiChuck is now an official Arduino library set. I only found that after tinkering for several hours. I can verify that the nunchuck is communicating and the servos seem to be ok.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject: Re: Build your own predator cannon
PostPosted: Mon Oct 09, 2017 11:21 am 

Country: United States
I think part of the issue is that there are multiple libraries created for the need and you have to write the code differently for each application:

https://github.com/GabrielBianconi/arduino-nunchuk

https://blog.underc0de.org/arduino-wii- ... o-motores/

This was one of the working items that read input from the chuck and displayed it on the serial plotter.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject: Re: Build your own predator cannon
PostPosted: Wed Oct 11, 2017 11:47 am 

Country: United States
OK, it looks like the servo shield is adding a harware layer and would require a complete code rewrite to function properly. I may try purchasing one for one parts in the original write up.

If you look at many of the shields there is an integrated chip on each that helps manage the functions on it. That chip fundamentally alters how you communicate with things. (Basically the commands or program you launch and the arguments or options are completely different depending upon what is used.)

I think the key here is to get it working first then back track with the code and try to port the programming to another platform.

Now in all of this you have to test each individual piece. All of the servos move when run with the pwmtest from adafruit. This told me the programming had to change.

The wii nunchuck communicates as there is a stream of information in the serial plotter when I run a separate example for the nunchuck. I had the wiring reversed initially but many of the kids toys are literally bullet and idiot proof. You will often times find that cheap kids toys make the best sources for parts.

Verify each piece and then get them talking together. The problem I am running into is I have yet to find a code piece that allows this.

As you all saw at the fan boy. I know the hardware pieces inside and out and didn't need to consult anything to troubleshoot the wiring (the smart gun piece I think had a broken connection somewhere when it stopped making sound.) The learning process drills all the information in your mind. I had worked a solid month on that piece getting it perfected. And I had bought several wrong parts trying to get it to work initially.

Also oshpark.com is your friend. If you have a .brd file you found for something you want, they will build it and ship it for a very reasonable price.

alliedelec.com
newark.com
Are very good sources for individual components and can be cheaper than adafruit.com for some parts. I will not knock adafruit as their components are top notch and you do get what you pay for. As my late step father liked to remind me, "La Saluta Non si paga," let the buyer beware. Know what you get or you will get some unused spare parts.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject: Re: Build your own predator cannon
PostPosted: Thu Oct 12, 2017 2:40 am 

Country: United States
OK, without the shield I have had some progress tonight:

https://blog.underc0de.org/arduino-wii- ... o-motores/

This codebase appears to be the only working one. It has the best printout and digital read stream I have found .

I would advise that no matter what country and language you have or encounter you will run into some of the most intelligent and talented people you will ever run into.

The code is very clean and simple.

Looks like there is some line noise. The alternate setup may work better.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject: Re: Build your own predator cannon
PostPosted: Sun Oct 15, 2017 11:42 pm 

Country: United States
Just out of possibilities I have ordered some more servos in the off chance I cooked the ones I have. The servos appear fine but I have suspicions that the control board may be a DOA.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject: Re: Build your own predator cannon
PostPosted: Sat Oct 21, 2017 8:28 pm 

Country: United States
knoxvilles_joker wrote:
Just out of possibilities I have ordered some more servos in the off chance I cooked the ones I have. The servos appear fine but I have suspicions that the control board may be a DOA.


OK received the new servos and it appears I did in fact toast the old units on accident. Did the same thing with a blower fan on my central heat and air once. At least this mistake did not cost me 200 and only 20 this time.

OK, this site's code appears to work fine:
https://blog.underc0de.org/arduino-wii- ... o-motores/

I will have to rehash this code to work with an fx sound board mini in UART mode (sound)
and set fire and laser sequence with button presses. The Serial.print function allows direct output to the board for audio output.

I wil rehash it to only work with the joystick and not tilt functions. I like this code as it outputs useful information to the serial monitor so you can make sure you don't have hardware issues.

I will also rehash things to work with joystick without button presses. I will use the button presses to play sounds and illuminate lights.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject: Re: Build your own predator cannon
PostPosted: Sat Oct 21, 2017 10:06 pm 

Country: United States
OK I did my first round of edits. You will have to include the two bottom libraries to your sketch.

If I did things right I set the unit to respond to analog stick input only ( you could change to tilt and disassemble your controller into your helmet)
c
z
c+z
button presses make different sounds and light up the cannon

The laser initializes as soon as you boot the device.

I added a push button sequence to raise the arm to 170 degrees (straight) and if already there leave it

Code:
/*
 * Example 6
 * Nunchuck control for four servos and two button inputs
 * Honus 2007
 * This allows the use of a Wii nunchuck as an input device and is modified/extended from the original code
 * by Tod E. Kurt and Windmeadow Labs
 *2007 Tod E. Kurt, http://todbot.com/blog/
 *The Wii Nunchuck reading code is taken from Windmeadow Labs, http://www.windmeadow.com/node/42
 */
// www.facebook.com/ArduinoCenter
// https://blog.underc0de.org/arduino-wii-nunchuck-servo-motores/
// Original Code base credited to Undercode
// Code adapted from Sean Maio Crybabyfx setup
//https://github.com/outcry27/crybabyFX
// Updated by knoxvilles_joker 2017
// http://facebook.com/knoxvillesjoker
// more instructions documented at
// http://alienslegacy.com
 

#include "Wire.h" 

#include "ArduinoNunchuk.h"
#include <Servo.h>
// This is imported from the smartgun setup
#include <SoftwareSerial.h>
#include "Adafruit_Soundboard.h"

// pins used for Serial communication with the audio board
// FX board must be grounded on the uart pin.
// I believe these have to be crossed tx on one end and rx
// on the other end.
//

#define SFX_TX 1
#define SFX_RX 0
// initializes the sound board serial connection
SoftwareSerial ss = SoftwareSerial(SFX_TX, SFX_RX);
Adafruit_Soundboard sfx = Adafruit_Soundboard(&ss, NULL, NULL);

//Creates the objects to control the servos
ArduinoNunchuk nunchuk = ArduinoNunchuk();
//  Servo servoPin1;
//  Servo servoPin2;
//  Servo servoPin3;
//  Servo servoPin4;


int ledPin1 = 13;       // Control pin for LED 1
int ledPin2 = 12;       // Control pin for LED 2
 int servoPin1 = 9;      // Control pin for servo motor
 int servoPin2 = 8;      // Control pin for servo motor
 int servoPin3 = 7;      // Control pin for servo motor
 int servoPin4 = 6;      // Control pin for servo motor

 int pulseWidth1 = 0;    // Amount to pulse the servo 1
 int pulseWidth2 = 0;    // Amount to pulse the servo 2
 int pulseWidth3 = 0;    // Amount to pulse the servo 3
 int pulseWidth4 = 0;    // Amount to pulse the servo 4

int refreshTime = 20;  // the time in millisecs needed in between pulses

//Initializes the variables
int xjoystick;
int yjoystick;
int xtilt;
int ytilt;


long lastPulse1;
long lastPulse2;
long lastPulse3;
long lastPulse4;

int minPulse = 700;   // minimum pulse width
int loop_cnt=0;


void setup() {
  // put your setup code here, to run once:
Serial.begin(19200);
  ss.begin(9600);
 Serial.print("loading sound card init\n");
  delay(800); 
  Serial.print("card initialized");
   //give the audio board time to power up.
  // Otherwise bootup sound will be called before audio
  // board is ready.
  // this plays an initialization sound.
  Serial.print("#0\n");
    //Initializes nunchuck ans servos
  nunchuk.init();

// servoPin1.attach(9);
// servoPin2.attach(8);
// servoPin3.attach(7);
// servoPin4.attach(6);
 

  pinMode(servoPin1, OUTPUT);  // Set servo pin as an output pin
  pinMode(servoPin2, OUTPUT);  // Set servo pin as an output pin
  pinMode(servoPin3, OUTPUT);  // Set servo pin as an output pin
  pinMode(servoPin4, OUTPUT);  // Set servo pin as an output pin
 
  pulseWidth1 = minPulse;      // Set the motor position to the minimum
  pulseWidth2 = minPulse;      // Set the motor position to the minimum
  pulseWidth3 = minPulse;      // Set the motor position to the minimum
  pulseWidth4 = minPulse;      // Set the motor position to the minimum
  pinMode(ledPin1, OUTPUT);  // sets the LED pin as output
  pinMode(ledPin2, OUTPUT);
  digitalWrite(ledPin1, LOW); // sets the LED pin LOW (turns it off)
  digitalWrite(ledPin2, LOW);

}

void loop() {
  // put your main code here, to run repeatedly:
  checkNunchuck1();
  updateServo1();   // update servo 1 position
  checkNunchuck2();
  updateServo2();   // update servo 2 position
  checkNunchuck3();
  updateServo3();   // update servo 3 position
  checkNunchuck4();
  updateServo4();   // update servo 4 position
   if(nunchuk.zButton == 1)  {    // light the LED if z button is pressed
    digitalWrite(ledPin1, HIGH);
    Serial.print("#1\n");
   }
  else {
    digitalWrite(ledPin1,LOW);

  }
   
     if(nunchuk.cButton == 1) {     // light the LED if c button is pressed
    digitalWrite(ledPin2, HIGH);
    Serial.print("#2\n");
     }
  else {
    digitalWrite(ledPin2,LOW);
  }

   if(nunchuk.cButton == 1 && nunchuk.zButton == 1) {
      digitalWrite(ledPin2, HIGH);
      digitalWrite(ledPin1, HIGH);
      Serial.print("#3\n");
       }
  else { 
      digitalWrite(ledPin1,LOW);
      digitalWrite(ledPin2,LOW);
          }
   
    delay(1);        // this is here to give a known time per loop

 //Guardamos los valores que nos manda el Nunchuk en las variables
  xjoystick = nunchuk.analogX;
  xjoystick = constrain(xjoystick, 26, 226);
  xjoystick = map(xjoystick, 26, 226, 0, 180);
 
  yjoystick = nunchuk.analogY;
  yjoystick = constrain(yjoystick, 26, 226);
  yjoystick = map(yjoystick, 26, 226, 180, 0);
 
  xtilt = nunchuk.accelX;
  xtilt = constrain(xtilt, 320, 720);
  xtilt = map(xtilt, 320, 720, 180, 0);
 
  ytilt = nunchuk.accelY;
  ytilt = constrain(ytilt, 320, 720);
  ytilt = map(ytilt, 320, 720, 0, 180);
// This prints the serial status of the nunchuck.
  Serial.print ("Joystick X: ");
  Serial.print (xjoystick, DEC);
  Serial.print ("\t");
 
  Serial.print ("Joystick Y: ");
  Serial.print (yjoystick, DEC);
  Serial.print ("\t");
 
  Serial.print ("X: ");
  Serial.print (xtilt, DEC);
  Serial.print ("\t");
 
  Serial.print ("Y: ");
  Serial.print (ytilt, DEC);
  Serial.print ("\t");
 
  nunchuk.update();
 
  if (nunchuk.cButton == 1) {
    Serial.print("--C--  ");
  }
 
  if (nunchuk.zButton == 1) {
    Serial.print("--Z--  ");
  }
 
  if (nunchuk.cButton == 1 && nunchuk.zButton == 1) {
    Serial.print("--Z-C--");
  }


 
  Serial.print ("\r\n");


}

void checkNunchuck1()
{
  if( loop_cnt > 100 ) {  // loop()s is every 1msec, this is every 100msec
   


    float tilt = xjoystick;    // x-axis, in this case ranges from ~70 - ~185
    tilt = (tilt - 70) * 1.5;        // convert to angle in degrees, roughly
    pulseWidth1 = (tilt * 9) + minPulse; // convert angle to microseconds

//   servoPin1.write(xjoystick);
   
    loop_cnt = 0;  // reset for
  }
  loop_cnt++;
 
}

// called every loop().
// uses global variables servoPin, pulsewidth, lastPulse, & refreshTime
void updateServo1()
{
  // pulse the servo again if rhe refresh time (20 ms) have passed:
  if (millis() - lastPulse1 >= refreshTime) {
    digitalWrite(servoPin1, HIGH);    // Turn the motor on
    delayMicroseconds(pulseWidth1);   // Length of the pulse sets the motor position
    digitalWrite(servoPin1, LOW);    // Turn the motor off
    lastPulse1 = millis();            // save the time of the last pulse
  }
}

void checkNunchuck2()
{
  if( loop_cnt > 100 ) {  // loop()s is every 1msec, this is every 100msec
   
//    nunchuck_get_data();
//    nunchuck_print_data();

    float tilt = yjoystick;    // y-axis, in this case ranges from ~70 - ~185
    tilt = (tilt - 70) * 1.5;        // convert to angle in degrees, roughly
    pulseWidth2 = (tilt * 9) + minPulse; // convert angle to microseconds
   
    loop_cnt = 0;  // reset for
  }
  loop_cnt++;
 
}

// called every loop().
// uses global variables servoPin, pulsewidth, lastPulse, & refreshTime
void updateServo2()
{
  // pulse the servo again if rhe refresh time (20 ms) have passed:
  if (millis() - lastPulse2 >= refreshTime) {
    digitalWrite(servoPin2, HIGH);   // Turn the motor on
    delayMicroseconds(pulseWidth2);   // Length of the pulse sets the motor position
    digitalWrite(servoPin2, LOW);    // Turn the motor off
    lastPulse2 = millis();            // save the time of the last pulse
  }
}

void checkNunchuck3()
{
  if( loop_cnt > 100 ) {  // loop()s is every 1msec, this is every 100msec
   
//    nunchuck_get_data();
//    nunchuck_print_data();

    float tilt = xtilt;    // x-axis, in this case ranges from ~70 - ~185
    tilt = (tilt - 70) * 1.5;        // convert to angle in degrees, roughly
    pulseWidth3 = (tilt * 9) + minPulse; // convert angle to microseconds
   
    loop_cnt = 0;  // reset for
  }
  loop_cnt++;
 
}

// called every loop().
// uses global variables servoPin, pulsewidth, lastPulse, & refreshTime
void updateServo3()
{
  // pulse the servo again if rhe refresh time (20 ms) have passed:
  if (millis() - lastPulse3 >= refreshTime) {
    digitalWrite(servoPin3, HIGH);   // Turn the motor on
    delayMicroseconds(pulseWidth3);   // Length of the pulse sets the motor position
    digitalWrite(servoPin3, LOW);    // Turn the motor off
    lastPulse3 = millis();            // save the time of the last pulse
  }
}

void checkNunchuck4()
{
  if( loop_cnt > 100 ) {  // loop()s is every 1msec, this is every 100msec
   
//    nunchuck_get_data();
//    nunchuck_print_data();

    float tilt = ytilt;    // y-axis, in this case ranges from ~70 - ~185
    tilt = (tilt - 70) * 1.5;        // convert to angle in degrees, roughly
    pulseWidth4 = (tilt * 9) + minPulse; // convert angle to microseconds
   
    loop_cnt = 0;  // reset for
  }
  loop_cnt++;
 
}

// called every loop().
// uses global variables servoPin, pulsewidth, lastPulse, & refreshTime
void updateServo4()
{
  // pulse the servo again if rhe refresh time (20 ms) have passed:
  if (millis() - lastPulse4 >= refreshTime) {
    digitalWrite(servoPin4, HIGH);   // Turn the motor on
    delayMicroseconds(pulseWidth4);   // Length of the pulse sets the motor position
    digitalWrite(servoPin4, LOW);    // Turn the motor off
    lastPulse4 = millis();            // save the time of the last pulse
  }
}



Code:
/*
 * ArduinoNunchuk.h - Improved Wii Nunchuk library for Arduino
 *
 * Copyright 2011-2013 Gabriel Bianconi, http://www.gabrielbianconi.com/
 *
 * Project URL: http://www.gabrielbianconi.com/projects/arduinonunchuk/
 *
 * Based on the following resources:
 *   http://www.windmeadow.com/node/42
 *   http://todbot.com/blog/2008/02/18/wiichuck-wii-nunchuck-adapter-available/
 *   http://wiibrew.org/wiki/Wiimote/Extension_Controllers
 *
 */

#ifndef ArduinoNunchuk_H
#define ArduinoNunchuk_H

#include <Arduino.h>

class ArduinoNunchuk
{
  public:
    int analogX;
    int analogY;
    int accelX;
    int accelY;
    int accelZ;
    int zButton;
    int cButton;

    void init();
    void update();

  private:
    void _sendByte(byte data, byte location);
};

#endif


Code:
/*
 * ArduinoNunchuk.cpp - Improved Wii Nunchuk library for Arduino
 *
 * Copyright 2011-2013 Gabriel Bianconi, http://www.gabrielbianconi.com/
 *
 * Project URL: http://www.gabrielbianconi.com/projects/arduinonunchuk/
 *
 * Based on the following resources:
 *   http://www.windmeadow.com/node/42
 *   http://todbot.com/blog/2008/02/18/wiichuck-wii-nunchuck-adapter-available/
 *   http://wiibrew.org/wiki/Wiimote/Extension_Controllers
 *
 */

#include <Arduino.h>
#include <Wire.h>
#include "ArduinoNunchuk.h"

#define ADDRESS 0x52

void ArduinoNunchuk::init()
{
  Wire.begin();

  ArduinoNunchuk::_sendByte(0x55, 0xF0);
  ArduinoNunchuk::_sendByte(0x00, 0xFB);

  ArduinoNunchuk::update();
}

void ArduinoNunchuk::update()
{
  int count = 0;
  int values[6];

  Wire.requestFrom(ADDRESS, 6);

  while(Wire.available())
  {
    values[count] = Wire.read();
    count++;
  }

  ArduinoNunchuk::analogX = values[0];
  ArduinoNunchuk::analogY = values[1];
  ArduinoNunchuk::accelX = (values[2] << 2) | ((values[5] >> 2) & 3);
  ArduinoNunchuk::accelY = (values[3] << 2) | ((values[5] >> 4) & 3);
  ArduinoNunchuk::accelZ = (values[4] << 2) | ((values[5] >> 6) & 3);
  ArduinoNunchuk::zButton = !((values[5] >> 0) & 1);
  ArduinoNunchuk::cButton = !((values[5] >> 1) & 1);

  ArduinoNunchuk::_sendByte(0x00, 0x00);
}

void ArduinoNunchuk::_sendByte(byte data, byte location)
{
  Wire.beginTransmission(ADDRESS);

  Wire.write(location);
  Wire.write(data);

  Wire.endTransmission();

  delay(10);
}

_________________
The impossible takes a while longer and goes over budget too...


Last edited by knoxvilles_joker on Sun Oct 29, 2017 7:01 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Build your own predator cannon
PostPosted: Sat Oct 21, 2017 10:16 pm 

Country: United States
I will have to order the fx soundboard mini, speaker, and class d amp. But this should work in theory...

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject: Re: Build your own predator cannon
PostPosted: Sun Oct 29, 2017 3:41 pm 

Country: United States
OK some progress. I had to make a common ground with the ground bus on the arduino. That fixed the noise issue. Basic electronics rule.

Code:
// Include the Servo library
#include <Servo.h>
// Declare the Servo pin
int servoPin = 3;
// Create a servo object
Servo Servo1;
void setup() {
   // We need to attach the servo to the used pin number
   Servo1.attach(servoPin);
}
void loop(){
   // Make servo go to 0 degrees
   Servo1.attach(servoPin);
   Servo1.write(0); 
   delay(500); //Not sure why I had to add this short delay here, but without it, the servo doesn't move at all
   Servo1.detach();
   delay(900);
   // Make servo go to 180 degrees
   Servo1.attach(servoPin);
   Servo1.write(180);
   delay(500);  //Not sure why I had to add this short delay here, but without it, the servo doesn't move at all
   Servo1.detach();
   delay(900);
}


This is a servo test on pin 3 moving the connected servo 180 degrees and back to zero degrees. the 500ms or half second delay is required to give the servo time to move before detaching the servo.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject: Re: Build your own predator cannon
PostPosted: Sun Oct 29, 2017 3:45 pm 

Country: United States
This writes the servo. It moves it to neutral 0 degree position, moves it 90 and then moves it 180. If you want scripted moves that run in a cycle this example is your best example. I had to bump the delay up to 900ms to allow the servo time to move.

High Torque = slow (kind of like big muscle cars and monster trucks, they take a while to get moving but once they do you can not stop them)

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject: Re: Build your own predator cannon
PostPosted: Sun Oct 29, 2017 3:47 pm 

Country: United States
This code scans your I2C (serial control) bus. It will show the address of anything on that bus. This is good to use to make sure you have the wii nunchuck wired up properly (I accidentally reversed the tx/rx lines initially.)

Code:
 // --------------------------------------
// i2c_scanner
//
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    http://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
// Version 6, November 27, 2015.
//    Added waiting for the Leonardo serial communication.
//
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//

#include <Wire.h>


void setup()
{
  Wire.begin();

  Serial.begin(9600);
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");
}


void loop()
{
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknown error at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.println(address,HEX);
    }   
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");

  delay(5000);           // wait 5 seconds for next scan
}

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject: Re: Build your own predator cannon
PostPosted: Sun Oct 29, 2017 5:36 pm 

Country: United States
PWM test code. I had to increment the delay and add that. This gives the motor enough time to run. You use this code to calibrate your minimum pulseWidth value. Every servo is unique...

Code:
//https://www.arduino.cc/en/Reference/ServoWriteMicroseconds
// courtesy of above range is 700 to 2300.  1000 is zero,
// 1500 is 90 and 2000 is 180 degrees typically.
// The standard is not defacto or dejure as of yet so
// your results will vary.
// La Saluta Non Si Paga as my late step-father would say.
// You get what you pay for.

#include <Servo.h>

Servo myservo;

void setup()
{
  myservo.attach(9);
//  myservo.writeMicroseconds(2000); // set servo to mid-point
  delay (150);
//  myservo.writeMicroseconds(700);

}


void loop() {
  myservo.writeMicroseconds(2300); // set servo to mid-point
  delay (1000);
  myservo.writeMicroseconds(700);
  delay (1000);
  myservo.writeMicroseconds(1500);
  delay (1000);
  }

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject: Re: Build your own predator cannon
PostPosted: Sun Oct 29, 2017 6:11 pm 

Country: United States
OK, I think I found the issue with the Honus code base the PWM pulse width calculations are off. As in the above to get a full 180 degree rotation you have to have a pulse write of 2300 milliseconds.

The calculation is as follows:
Variable (say 180 in this case)
minus 70 (in our example 110)
times 1.5 ( 165 in this case)
plus minPulse (700) (865 in our case)
So, the math is off.

we need to pulse width of 2300 for 180 degrees.

The one thing you will find in robotics and science is that math is EVERYTHING.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject: Re: Build your own predator cannon
PostPosted: Sun Oct 29, 2017 6:25 pm 

Country: United States
knoxvilles_joker wrote:
OK, I think I found the issue with the Honus code base the PWM pulse width calculations are off. As in the above to get a full 180 degree rotation you have to have a pulse write of 2300 milliseconds.

The calculation is as follows:
Variable (say 180 in this case)
minus 70 (in our example 110)
times 1.5 ( 165 in this case)
plus minPulse (700) (865 in our case)
So, the math is off.

we need to pulse width of 2300 for 180 degrees.

The one thing you will find in robotics and science is that math is EVERYTHING.


OK, I messed up in the calculation. In the floating integer tilt after multiplying times 1.5 I did not notice that I had to multiply it times 9. IN the calculation here that get it to 2185. For PWM modulation that should be close enough.

I would also add if you dig into things and hook up an oscilloscope you will have some minor variance on some pins. You are talking about a few milliseconds difference and for the negligible difference in degrees that sort of minor variance should be fine.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject: Re: Build your own predator cannon
PostPosted: Sun Oct 29, 2017 7:04 pm 

Country: United States
Success. I have more servos on the way. I have updated the first post with the working code piece.

I can get the fx sound board mini, load some sounds, a speaker and then test there.

The other 200 in parts have been ordered. That should cover everything for the other props for Greg and Paul to have demo units I will gussy up for the conventions including Dragoncon for Next year.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject: Re: Build your own predator cannon
PostPosted: Mon Oct 30, 2017 10:58 am 

Country: United States
OK, Carl J Toti is no longer in business. I am having difficulty laying hands on a reproduction bracket. If I can get the 3-d files I can send them to a printer to get some aluminum or titanium printed parts.

So far this is the best I can find:

http://www.robotshop.com/en/lynxmotion- ... t_EALw_wcB

I can just fabricate the arm pice, but that would work and would more or less be self contained.

If anyone has anything I am all ears.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject: Re: Build your own predator cannon
PostPosted: Sat Nov 04, 2017 12:32 pm 

Country: United States
On a somewhat related note looks like I found a chinese supplier with 2 inch by 1 inch 14 segment led displays:

http://www.betlux.com/led/SEVEN-SEGMENT ... -LED-1.htm

That only took a couple weeks of off and on searching with google to find.

That size is important as I have figured out how to use a 14 segment led display to display the yautja alphabet. More specifically a much easier LED backpack setup.

I have resigned to buying at least one unit from Pelleta on predatorium as her unit is the best, but I still think the community needs a good freely available arduino circuit program and layout along with 3-d printed design specs.

As I get better with the programming part I think that a more expensive DIY would be in the community's best interest.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject: Re: Build your own predator cannon
PostPosted: Sun Nov 05, 2017 10:41 pm 

Country: United States
https://www.youtube.com/watch?v=C1gIQ_7b3lU

first ok video posted to youtube.

I will have more results once I get a couple of pan tilt rigs.

I had to do a minor code update as for the sounds to work you have to add sound pins.

I think I have some noise from the servos and I may have to address that but I need to get things together a little bit more.

Predator 1 appears to use just a 2 servo setup. knowing that this code can easily run two cannons.

Going through the pins I am honestly running out of pins on this one. I could halve the ppm calculations and limit the travel on some of the lift of the unit and split that between two servos.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject: Re: Build your own predator cannon
PostPosted: Mon Nov 06, 2017 2:14 am 

Country: United States
OK I am working out some bugs in the code regarding playing of sounds. The serial control is very picky as to what button and what number you print to get the desired sound to play.

Right now I have it set to play a sound track at boot and then play clacks which works. I am trying to get the other button to play fire sounds.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject: Re: Build your own predator cannon
PostPosted: Tue Nov 07, 2017 12:56 am 

Country: United States
Next time I will order the larger fxsoundboard. The mini one I ordered had fewer pins and I think there are some hardware/code changes internally on the unit giving me fits. This one supports 80 sounds versus the 110 on the other board I have.

The board only supports OGG and WAV files and they have to be formatted at 44000kbps and lower bit rates.

I can get it to play firing on one pin, and sounds on another pin.

I will only add that audacity is your friend and that anything you find online is questionable as things are very difficult to make work.

I am going to say that things are complete unless I can source some more cannon sounds.

I will work on the transistor board by Honus as it appears I need transistors to help with some of the motor noise.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject: Re: Build your own predator cannon
PostPosted: Wed Nov 08, 2017 2:27 am 

Country: United States
OK it looks like my long term issues are using UART mode.

I will have to use GPIO mode.

This means I would Have to take physical pins 3,4,7,11 to 4 gpio pins on the fx sound board.

Then use digital write to the pins on the arduino board.

The code example here is what I would have to adapt:
https://www.arduino.cc/reference/en/lan ... italwrite/
Code:
void setup()
{
  pinMode(11, OUTPUT);          // sets the digital pin 13 as output
}

void loop()
{
  digitalWrite(11, HIGH);       // sets the digital pin 13 on
  delay(1000);                  // waits for a second
  digitalWrite(11, LOW);        // sets the digital pin 13 off
  delay(1000);                  // waits for a second
}

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
 Post subject: Re: Build your own predator cannon
PostPosted: Fri Nov 10, 2017 2:56 am 

Country: United States
GPIO mode appears to work. I am hashing out some delay and playback issues, but it does appear to be working nicely now.

_________________
The impossible takes a while longer and goes over budget too...


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 30 posts ]  Go to page 1, 2  Next



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: