Jump to content


Galorin

Member Since 10 Dec 2015
Offline Last Active Feb 12 2016 10:58 AM

Topics I've Started

New modder, partially working RapidStrike Electronics, no photos (yet)

30 December 2015 - 08:26 PM

I promise to add photos later, but I was inspired by the TR-27 Gryphon to do my own take on it.

 

My key points

 

* dart ready detection

* variable flywheel and pusher speeds, in software.

* multi-mode select

 

I got a 128/64 LCD screen and the MOSFETs a couple days ago, no silly 7 segment displays, and they really are compact when used with an Arduino Nano.  Putting my code as-is here for reference. Will either keep it updated or make a link to Github.
 
My camera is on the fritz, unfortunately, so I can't show you what it currently looks like or does... but there's a big breadboard... and I have no idea how to make that Fritzing software work to show my schematics.  Can't find my particular LCD screen,
 
Suffices to say, I have one potentiometer hooked up to the Analog input, and a SSD1306-powered white-only OLED screen hooked up via Serial, using the Adafruit libraries.  I may have to strip the libs down for use later though.  Just not that much RAM on the Nano, and I'm not doing things like bitmaps, just letters, numbers and lines.
 
The code below has a few hooks for things I don't have the hardware for yet, like the dart detector. It basically will blink a warning when no dart is detected, but that's not hooked up to anything just yet.  The blinking works if I change a bool.
 
The bit that works, reads the potentiometer, converts it to a percent, and I round it to the nearest 10 percent, then display the number on-screen.  I may do just a cell phone signal-type bar display if I want to go all fancy, this is just easier.
 
I will have two pots, one for pusher motor speed, and one for flywheel speed.  haven't got a way to actually measure those speeds yet, but it'll probably be something like 5v-9v ish through the MOSFET for each. As I'm powering from a 11.1V LIPO on stock motors (right now at least) I don't want to burn them out.
 
What I want to do down the line is a mode select, so I can do 3 dart burst per trigger pull, single dart per pull, and full auto.  First target though is full auto as it's the easiest to implement.
 
If anyone else has either suggestions for improving the below code or wants a more thorough explanation, please speak up.
 
-----------------------------------------
 
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
 
// If using software SPI (the default case):
#define OLED_MOSI   9
#define OLED_CLK   10
#define OLED_DC    11
#define OLED_CS    12
#define OLED_RESET 13
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
 
 
 
#define PUSH_POT 0
bool blinkOn = true;
bool fDartSeen = true;
 
int flyPercent = 0;
int pushPercent = 0;
 
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
 
void setup()   {                
  Serial.begin(9600);
  
  // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
  display.begin(SSD1306_SWITCHCAPVCC);
  // init done  
  display.clearDisplay();
}
 
void loop() {
 
  display.clearDisplay();
  
  display.fillRect(0, 0, display.width(), display.height(), WHITE);
  display.fillRect(2, 2, display.width()-4, display.height()-4, BLACK);
  display.drawLine(61, 0, 61, 40, WHITE);
  display.drawLine(62, 0, 62, 40, WHITE);
  display.drawLine(0,40,127,40,WHITE);
 
  display.drawLine(0,28,127,28,WHITE);
 
//display flywheel percent
  display.setCursor(7,8);
  display.setTextSize(2);
  display.print(flyPercent);
  display.println("%");  
  
  display.setCursor(7,31);
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.println("Flywheel");
 
// display pusher percent  
  display.setCursor(68,8);
  display.setTextSize(2);
  int percent = map(analogRead(PUSH_POT),0,1023,0,100);
  int newPer = round(percent / 10) * 10;
  display.print(newPer);
  display.println("%");
 
  display.setCursor(68,31);
  display.setTextSize(1);
  display.println("Pusher");
 
if (fDartSeen)
{
  display.setCursor(5,44);
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.println("DART READY");
}
else
{
  if (blinkOn)
  {
  display.setCursor(20,44);
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.println("NO DART");
  blinkOn = false;
  }
  else
  {
    blinkOn = true;
  }
}
 
  display.display();
  delay(50);  
}
 
-----------------------------------------