Categories
Raspberry Pi

Pipboy 3000

OVERVIEW

My daughter wanted to cosplay as a character from Fallout 3 for Awesomecon 2018 in Washington D.C. We found Noe and Pedro Ruiz’s design on learn.adafruit.com 1 and decided to build it. She decided do this cosplay a few days before the event so it was going to be a challenge to complete it in time but we did it.

I thought getting the electronics in time was going to be the biggest challenge but the biggest challenge was reducing the time for the 3D prints. We started on Sunday and did not finish until Wednesday afternoon. (We did not print continuously so the overall print time was less but not by much.) Noe and Pedro have some tips on reducing print time and they worked in combination with tweaking the infill and layer height.

3D PRINTING

My 3D printer is the XYZprinting daVinci 1.0. The printer is a few years old now and is not the best 3D printer by far but it does a fair job. The printer only supports ABS fulfillment and XYZprinting filament cartridges. I have yet to take time to change the head to support PLA or hack the firmware so I can use other filaments. This limits me to the colors of filament that I may use in the printer. We looked for a brown or green filament to use for the Pipboy but did not find any to my daughter’s liking. We decided to print it in white and spray paint it. We found some metallic paint which seemed to work well. Additionally, we printed the screen visor in black and the LED diffuser in natural.

As a side note, I started using Simplify3D Slicing Software with the printer and it has made a world of difference with the print quality and control of the printer. The prints come out much closer to the designed measurements than the XYZprinting software could accomplish. The software gives more options than the XYZprinting software which really came in handy for this project. Noe and Pedro recommend removing some of the supports for the armband and base-main pieces. The XYZprinting software is all or nothing regarding supports but the Simplify3D software allowed me to remove some supports while leaving others in place.

HARDWARE

Noe and Pedro do a good job in the write-up but as with most build instructions, a few things are left out or are not clear. Here are a few notes that I made along the way but it is not a complete list as we were under a very restrict time constraint to get this project done. Unfortunately that means take notes and documenting issues was not a priority.

Additional Materials needed but not listed in the materials list in the overview.

  • Electronic Parts & Components
  • Tools & Supplies
    • (Optional) Hot Glue and Hot Glue Gun
    • Adhesive foam such as weatherstripping for doors and windows

Below are the connections to the 3.5″ LCD Shield that were used in our build.

PypBoy Function Pin Pin Function PypBoy
LED + 3V3 1 2 5V  
ENC A GPIO2 3 4 5V PB 1000C +
ENC B GPIO3 5 6 GND PB 1000C –
ROT 1 GPIO4 7 8 GPIO14 ENC SW
LED – GND 9 10 GPIO15  
ROT 2 GPIO17 11 12 GPIO18  
ROT 3 GPIO27 13 14 GND ROT –
ROT 4 GPIO22 15 16 GPIO23 ROT 5
  3V3 17 18 GPIO24  
  GPIO10 19 20 GND  
  GPIO9 21 22 GPIO25  
  GPIO11 23 24 GPIO8  
ENC – GND 25 26 GPIO7  

SOFTWARE

We made a few tweaks to the software but they were to change the map and display some different text on some screens and adding some missing code to change other displayed text. I plan to post those minor changes in a future post. The more major changes implemented were to get the pypboy program to launch on start and wire up the rotary encoder so we can safely shutdown the Raspberry Pi.

The shutdown code was modified from Inderpreet Singh’s code on Element14’s website2.

REFERENCES

  1. Noe and Pedro’s writeup on learn.adafruit.com: https://learn.adafruit.com/raspberry-pi-pipboy-3000
  2. Inderpreet Singh’s Shutdown Code on Element14’s site: https://www.element14.com/community/docs/DOC-78055/l/adding-a-shutdown-button-to-the-raspberry-pi-b
Categories
Arduino

Arduino delay(), millis(), etc. cause execution to halt in a library

I ran into an interesting issue yesterday while rewriting some Arduino code into a library. I figure out what was the issue but I’m not sure as to why. If someone reads this and can point me to the reason why this was an issue, please comment on this post. I would appreciate it.

PROBLEM STATEMENT (Observation): Adding any timing function in my library file would halt the execution. The time functions includes delay(), delayMicroseconds(), micros(), and millis().

ROOT CAUSE: The time function was being called in the constructor of the class. If the time function was moved to another method and called separately, the time function would work.

RESOLUTION: Modified the code to create the object, then make a call to a public method of the class. I used begin() as I have seen in other classes.

Problem code demonstrating the issue

sample.ino

#include "mylib.h"

mylib myObject = mylib();

const int ledPin =  LED_BUILTIN;
unsigned long previousMillis = 0;
const long interval = 1000;

void setup() {
   pinMode(ledPin, OUTPUT);
}

void loop() {
  unsigned long currentMillis = millis();
  
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    digitalWrite(ledPin, !digitalRead(13));
  }
}

mylib.h

#if defined(ARDUINO) && ARDUINO >= 100
  #include "Arduino.h"
#else
  #include "WProgram.h"
#endif

class mylib {
  public:
    // Constructors
    mylib();

  private:
    void initialize();
};

mylib.cpp

#include "mylib.h"

mylib::mylib() {
  initialize();
}

mylib::initialize() {
  delay(100);
}

Working code demonstrating the solution

sample.ino

#include "mylib.h"

mylib myObject = mylib();

const int ledPin =  LED_BUILTIN;
unsigned long previousMillis = 0;
const long interval = 1000;

void setup() {
  pinMode(ledPin, OUTPUT);
  myObject.begin();
}

void loop() {
  unsigned long currentMillis = millis();
  
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
}

mylib.h

#if defined(ARDUINO) && ARDUINO >= 100
  #include "Arduino.h"
#else
  #include "WProgram.h"
#endif

class mylib {
  public:
    // Constructors
    mylib();

    void begin();

  private:
    void initialize();
};

mylib.cpp

#include "mylib.h"

mylib::mylib() {
  
}

mylib::begin() {
  initialize();
}

mylib::initialize() {
  delay(100);
}