Shuttle and plane

2018-12-11  本文已影响0人  星际飙车王

Reproduce the aviation miracle in human history.

shuttle & plane

Team members


Description

We are trying to make the interactive model of two aircrafts: Blizzard space shuttle, the only space shuttle that’s not made in US and Antonov 225 carrier, the biggest airplane human ever filed into the sky. Our target users are parents searching for cool toys for their children. This set of aircrafts is the perfect Christmas present for your kids.
The An-225 carrier was designed to carry the space shuttle around. That’s where the interaction will happen. The light animation will change when the two air crafts are separate or connected. All the ports will be hidden in the flipping head of both crafts. That’s how An-225 opens its cargo space. There will be one button hidden on the back of each aircraft.


System Diagram


an225
shuttle

Implementation

(See details in section “Software” and “Video”)

An225

Connection changes animation mode


We used analog signal to detect connection status. If the connection status is changed, the voltage on the analog input pin will change. In the main loop, we will measure the voltage to determine if the two parts are connected or not. If the two parts are connected, the Neopixels will work in flow animation mode. If they are not connected, the Neopixels will fade together.
Button changes color

The button for an225 works in blocking mode. We will monitor the button status in the main loop. If a push is detected, a handler function will change the color of the Neopixels. Those colors are coded into the chip.

Shuttle


Connection changes led frequency
While connected, the frequency of the led (no matter blink or fade) will double. It will go back to normal speed after departure.
Button changes animation mode
The button for shuttle works in interrupt mode. While the button is pushed, an external interrupt will be triggered. A handler function will process the button push and change the parameter that controls the animation mode between blink and fade.

Schematics Layouts

schematic.png

Software

Connector

We used the slide connectors in our project. It’s a two-pin connection. To achieve the bi-directional communication only using two pins, we decided to use analog signal instead of digital signal. That’s because analog signal has more than 2 states in one pin. We connected one digital output GPIO and one analog input GPIO together through a 470Ohm resister. And use one pin of the connector to build the common grand. And use the other pin to connect the two analog input pins. We will analyze this connection method according to the three connection states.

System clock

The main loop for feather board is running at 50Hz precisely since I used the Timer to generate a 50Hz interrupt. And I can not find the handbook showing Timer usage for the CPX board. So, the main loop for the CPX board is running a little bit under 50Hz because I put a 20ms delay in the end of the loop. For the feather board’s main loop, the tasks are detecting connection using the analog pin and changing the led brightness using two PWM pin. The button is running on interrupt mode too. For the CPX board’s main loop, monitoring the button is one of the tasks too.

Button

We used D6 on CPX and D2 on feather as button pins. Both the button pins are set to Input_Pullup mode. An external interrupt is attached to the D2 pin to monitor the falling edge. I used the main clock of Arduino to avoid voltage shaking of the button pin. The program will only accept the falling edge happened 25ms after the last one. The button will change the mode parameter for the LEDs. The D6 pin on CPX is monitored in the main loop directly. Since the gap between two cycles is more than 20ms, I did not apply any anti-shake method for this one. This button will change the color of the Neopixels.

Neopixel

The Neopixels are connected to D8 according to the instruction. And I used the adafriutNeopixel library to drive those dots. While not connected, the dots will fade together. While connected, the dots will fade in sequence to create a flow animation. The colors of those dots are saved in a long int array. And pushing the button will change the color.

LED

I used the led connected to the serial chip in this project since the led connected with D13 is in the corner and hard to reach. I cut the copper connecting the serial chip and the LEDs, and the copper connecting the 5V net and the LED positives. I flied the 3V3 onto the positives and D9, D10 onto the negatives instead. Those two pins can be multiplexed as PWM output pins and will not conflict with the Timer2 running the main loop. The connection will change the frequency of those LEDs. And the button will change the mode between blink and fade.

Code for an225

//Library for the NeoPixels
#include <Adafruit_NeoPixel.h>

//Colors in RGB format
long int colors[7] = {0xf44336, 0x9c27b0, 0x3f51b5, 0x00bcd4, 0x4caf50, 0xffeb3b, 0xff5722};
long int ledColor = colors[0];
int colorIndex = 0;

/*
buttonHandler
Change the led color while push the button
*/
void buttonHandler()
{
  colorIndex++;
  if (colorIndex >= 7)
  {
    colorIndex = 0;
  }
  ledColor = colors[colorIndex];
}

/*
setColor
parameters:
long int color: Color value storaged in RGB format
int mode: Fade mode or animation mode
int ledCounter: the progress of the animation
This function changes the color of the NeoPixels
*/
Adafruit_NeoPixel strip = Adafruit_NeoPixel(10, 8, NEO_GRB + NEO_KHZ800);
void setColor(long int color, int mode, int ledCounter)
{
  //Get the RGB value of the color
  int colorR = (color & 0x00FF0000) >> 16;
  int colorG = (color & 0x0000FF00) >> 8;
  int colorB = (color & 0x000000FF);
  //Calculates the brightness under fade mode and change the color.
  if (mode == 1)
  {
    int fade = abs(100 - ledCounter);
    colorR = colorR * fade / 100;
    colorG = colorG * fade / 100;
    colorB = colorB * fade / 100;
    int i = 0;
    for (i = 0; i != 10; i++)
    {
      strip.setPixelColor(i, strip.Color(colorR, colorG, colorB));
    }
  }
  //Calculaes the brightness under animation mode and change the color
  else
  {
    int i = 0;

    for (i = 0; i != 5; i++)
    {
      int fade = abs(100 - (ledCounter + 40 * i) % 200);
      int colorRtemp = colorR * fade / 100;
      int colorGtemp = colorG * fade / 100;
      int colorBtemp = colorB * fade / 100;
      strip.setPixelColor(i, strip.Color(colorRtemp, colorGtemp, colorBtemp));
      strip.setPixelColor(9 - i, strip.Color(colorRtemp, colorGtemp, colorBtemp));
    }
  }
  //display
  strip.show();
}

//Setup
#define button 6
void setup()
{
  Serial.begin(115200);
  pinMode(button, INPUT_PULLUP);
  pinMode(10, OUTPUT);
  digitalWrite(10, LOW);
  strip.begin();
  strip.show();
}

int ledCounter = 0;
int previewsButton = 1;
#define Connected 1
#define DisConnected 0
int connectStatus = DisConnected;

/*
main loop
*/
void loop()
{
  //Change the led counter.
  ledCounter += 4;
  if (ledCounter >= 200)
  {
    ledCounter = 0;
  }
  //Monitor the button
  if ((previewsButton == 1) & (digitalRead(button) == 0))
  {
    buttonHandler();
  }
  previewsButton = digitalRead(button);
  //Monitor the connector
  int adcValue = analogRead(A2);
  if (adcValue > 100)
  {
    connectStatus = DisConnected;
  }
  else
  {
    connectStatus = Connected;
  }
  //Setup the color accordingly
  setColor(ledColor, connectStatus, ledCounter);
  //delay 20ms
  delay(20);
}

Code for shuttle

//The Timer library for generating the 50Hz intterrupt for mian loop
#include <MsTimer2.h>

//define Pins for ports
#define LED1 9
#define LED2 10
#define button 2
#define connector 7

//LED opration mode
#define blinkMode 0
#define fadeMode 1
int ledMode = blinkMode;

//parameters for fading 
int ledCounter = 0;
int ledDirection = 0;

//LED operation speed
#define speedFast 2
#define speedSlow 1
int ledSpeed = speedSlow;

/*Button handler
Use the main clock (millis()) to avoid button shaking
Only accepts falling edge happens more than 25ms after the last one.
Use 1ms delay to avoid button shaking while release the button.
*/
unsigned long previousMillis = 0;
void buttonHandler()
{
  unsigned long currentMillis = millis();
  if ((currentMillis - previousMillis) > 25)
  {
    delay(1);
    if (digitalRead(button) == 0)
    {
      Serial.println("button pushed");
      ledMode = !ledMode;
    }
  }
  previousMillis = currentMillis;
}

/*
Mainloop function
This function is the handler for the 50Hz timer interrupt.
Use adc to determine if the two parts are connected or not.
Than change the opration mode and speed accordingly.
Finnaly change the brightness of both LEDs.
*/
void mainTask()
{
  //Get the connnection status
  int adcValue = analogRead(A0);
  if (adcValue > 900)
  {
    ledSpeed = speedSlow;
  }
  else
  {
    ledSpeed = speedFast;
  }
  //Calculate fade value
  if (ledDirection == 0)
  {
    ledCounter += ledSpeed;
    if (ledCounter >= 50)
    {
      ledDirection = 1;
    }
  }
  else
  {
    ledCounter -= ledSpeed;
    if (ledCounter <= 0)
    {
      ledDirection = 0;
    }
  }
  //Change the brightness according to the opration mode.
  if (ledMode == blinkMode)
  {
    if (ledCounter >= 25)
    {
      analogWrite(LED1, 255);
      analogWrite(LED2, 255);
    }
    else
    {
      analogWrite(LED1, 0);
      analogWrite(LED2, 0);
    }
  }
  else
  {
    int fadeValue = ledCounter * 4 + 5;
    analogWrite(LED1, fadeValue);
    analogWrite(LED2, fadeValue);
  }
}

/*
Set up
*/
void setup()
{
  //Set pin mode for leds and buttons
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(connector, OUTPUT);
  pinMode(button, INPUT_PULLUP);
  //Attach external interrupt for the button
  attachInterrupt(digitalPinToInterrupt(button), buttonHandler, FALLING);
  digitalWrite(connector, HIGH);
  //Set up timer interrupt
  MsTimer2::set(20, mainTask);
  MsTimer2::start();
}

//No need for the blocked main loop
void loop()
{
}


Gallery


Video

Youtube
优酷


Process

Iteration 1: Finding out the scope of our project.

From the beginning, we know that our big plane is going to be huge. We need to figure out how big it should be. So, we used foam to cut out the first iteration of our project. The limitation are the circuit boards and the scaling relation between the two aircrafts. We want to make the plane as small as possible while the whole thing is not ugly. The scale is defined by the feather board. From the feather board, we get the minimum size of our space shuttle. And according to the scale, we get the minimum size of our big plane. Those foam prototypes helped a lot in the future modeling work.

Iteration 2.1: Test the tolerance of F170


We decided to use slide connectors to connect the two parts. Since our plane is going to be huge and the 3D printing resource is limited, we printed out all the connectors first to test the tolerance. We also printed out the head with a clip on the bottom side to test if it would work. The results are really helpful. The slide connectors succeeded the first time. We used the same design for the last version. However, we find out that the bottom clip can not work because that structure requires a large deformation to work and the material is not resilient enough.

Iteration 2.2: Light guide test


None of us has used light guide before. There were a lot to learn. We used acrylic to cut out our light guides for its high transparency. We tested two things here: 1) Is the lens structure helpful for collecting the light? 2) What’s the minimum diameter of the arc on the light guide that’s acceptable. We printed out several lightguides shown in the picture and tested them using the NeoPixels on the CPX board. Turned out the lens do help, and the minimum diameter is around 10 mm. Those details are integrated into our final design to make it better.



To hold the light guides properly insight the body. We designed a set of light guide holder. We used cardboard to do that because carboards are more flexible. It will deform under tight fit and can hold itself and the light guides in position.

Iteration 3: Test prints for the space shuttle

The first print

We modeled the space shuttle first to further test our designs. Though the two aircrafts vary a lot in shape and scale, they have the same design details. And it is easier to test those details on the smaller one. F170 went into some trouble during the first print and the print was not finished. However, those unfinished parts were still helpful to us. We made sure the switch would fit. And we changed the position for the circuit board. The second test print also did not go well due to changing the material on half. The separate lines for those two materials were fragile. We managed to change the design details and modeled both the aircrafts in the end.

Iteration 4: Final print


Thanks to all the test prints and all the experience we got, the final print succeeded for the first time. Almost all the details worked well except for one of the clips on the big plane. But that one is trivial. One funny thing is that since the parts are too large and there is too much support material, our parts were in the wash tank for too long. And water got into every corner of the infill. We shake those parts crazy for hours to get the water out.


Post-process & painting:



We finished the print job early. So, we decided to make the aircrafts look better.

上一篇 下一篇

猜你喜欢

热点阅读