My plan, right now, is to make use of the display's capabilities and "backdrop" the primary data with colors, warning of an issue.
Black = no detected issue
Yellow = Caution
Red/Flashing = Critical
The "combat" display would only have a couple of key pieces of information. Shots (user selectable shots fired versus mag count), battery condition, firing mode, Feet Per Second (FPS).
If the gun detects that the shots caution threshold has been crossed, it now displays the number of shots in a black text on yellow backdrop. If the system detects that the critical threshold has been crossed, it changes the color to red. If the system detects a dry fire (gearbox cycling, but with no rounds coming out), then the WHOLE screen will strobe red.
This way, tactically relevant information is pushed as hard as it needs to be pushed (if that makes sense). In your example of popping out to engage 6 targets, a glance at my screen will immediately tell me if this is OK. I don't need to know the number (It takes some time to actually process that information). Instead, I just need to know "Black, Yellow, Red". If I see any red on the display, I definitely don't need to jump out.
Magazines... I've given a ton of thought to the magazines. Any solution for the magazines needs to be cheap and easy to implement. I've gone into games with over a dozen mags. I've also gone into games with 4 different "forms" of magazines.
If I enable a "smart mag", I'm going to first look at the P-90. The P-90 has a semi-enclosed magazine mounted on top of the AEG. There are several places that I could place Hall Sensors to "check" the magazine type. If I just use three Hall Sensors, I can detect 7 different types of magazines (3 bits, two states, MINUS one state as a "mag check"). If I use an analog pin and some resistors, I should be able to scan all the Hall Sensors off of one pin.
I'm leaning towards this method for a couple of reasons:
The maximum cost to modify the magazine is equal to the cost of three miniature neodymium magnets.
There are two primary types of magazines. A linear spring "Low Cap", which typically holds less than 100 rounds. A box spring or clockwork "High Cap", which can hold 200+ rounds. Their mechanisms are different and messing with them can really impact reliability. Detecting the exact number of rounds in a Low-Cap is probably feasible. Detecting the exact number of rounds in a High-Cap is a nightmare (unless you want to count them yourself).
Most AEG's do not feed the complete magazine to the gearbox. When they're "Empty", there are still a few rounds left. This means that an "empty mag" still has some wiggle room.
On the P-90, there are plenty of locations to mount the magnets and detecting Hall Sensors.
The computer is going to track when the gearbox cycles, and if a shot is fired with that cycle. We'll know when a round leaves the AEG, and we can decrement the counter then.
I can't have the AEG go into a low-power mode upon dropping the magazine. One of our big safety procedures at the end of a game, is to drop the mag, fire 2-3 shots on single shot, to relax the spring and make sure the system is clear. Simply dropping the mag doesn't clear the mechanism.
You folks were absolutely right about the 2N2222 transistor. I've got a bunch of 2N4401's lying around, that seem to be working. The display is resetting when I ask it nicely.
However, now I'm at the icky portion of the programming. I need to get two different processors to talk using a common language.
Code: Select all/* AirsoftComputerDisplay3-1-12
SS denotes Software Serial
Arduino Display (uOLED 160)
Pin 2 (SS RX) Pin 3 (TX)
Pin 4 (SS TX) Pin 5 (RX)
Pin 4 Pin 9 (Reset)
5v Pin 1 (Vcc)
GND Pin 7 (GND)
Arduino
* LED on board at pin 13
* Motor control on pin 10 (PWM pin)
* pushbutton attached to pin 7 from +5V
* 10K resistor attached to pin 7 from ground
* ADC on analog pin 0
* ---------------Important-------------------
* Hall Effect Sensor not used in this sketch!
* Hall Effect Sensor on pin 8 (Honeywell SS451A)
Hall Effect Vin (5v) has a 1k resistor to Hall Effect Output
* Note: on most Arduinos there is already an LED on the board
attached to pin 13.
* 30amp Current Sensor between battery plug and MOSFET board.
* Current sensor output wired to Analog 3
*/
#include <SoftwareSerial.h>
const int buttonPin = 7; //Trigger switch attached to digital pin 7
const int ledPin = 13; //onboard LED on pin 13
const int MotorPin = 10; //Motor drive pin (on MOSFET) connected to PWM pin at pin 3
const int VoltageMain = 3; //Voltage Divider connected to Analog 3
const int Hall = 8;
const int CurrentSensor = 0; //Current flow sensor attached to Analog 0
const int MotorSpeed = 255; //PWM value for motor, max 255
const int LowAmpTrigger = 770; //Amp level direct from ADC, signaling end of cycle ~680 for G36
const int DisplayReset = 4; //Display Reset Pin
int VMain = 0;
float ADCRead =0;
int buttonState = 0;
int HallState = 0;
int IMain = 0;
float IRead = 0;
int DebounceDelay = 50; //Button debounce delay in milliseconds
int SensorDelay = 1; //Sensor Read Delay in MICROSECONDS
byte DisplayIncoming; //The incoming message from the display
byte Test = 'Y'; //The reply to the display
SoftwareSerial mySerial(2,3); //Software Serial is going to be used to
//communicate with the display, leaving the
//basic serial port unencumbered
void setup(){
digitalWrite(DisplayReset, HIGH); //
delay(10); //
digitalWrite(DisplayReset, LOW); // This is the code to reset the uOLED display
mySerial.begin(115200);
Serial.begin(115200);
delay(500); // Startup both serial ports, so the computer's termnial window can be used for checking
DisplayIncoming = mySerial.read();
Serial.print("From Display ");
Serial.println(DisplayIncoming);
if (DisplayIncoming != 5){ // This is arbitrary right now, I just want the display to think everything is AOK
mySerial.print(Test, HEX);
Serial.print("Sending ");
Serial.println(Test, HEX);
}
}
void loop(){
}
I have the display set up to look for a hex 'Y' over the serial line.
Here's the display code. It's very simple, BUT THIS IS NOT ARDUINO CODE!!!! Please don't try to load this into your Arduino.
Code: Select all#platform "GOLDELOX-GFX2"
/*DET5 Labs Visual Display Module for the P-90 Smartgun Mod 0
*/
#inherit "4DGL_16bitColours.fnc"
var combuf[1]; //24 variables = 48 bytes
var Test := 0x54; //Hex for T
func main()
gfx_Cls();
txt_Set(FONT_ID, 0);
txt_MoveCursor(0,1);
print("DET5 Labs \nP90 Smartgun Mod 0\n");
print("\n");
print("Comms Check\n");
setbaud(BAUD_115200);
com_Init(combuf, 2, 0); //Serial Buffer
serout(Test); //Send the contents of "Test" out over the serial line
pause(5000); //Wait 5 seconds
Test := serin(); //Put the contents of the Serial Line into Test
//print(Test);
if (Test == 0x59) //Hex for Y
print("Successful\n");
else
print("Error\n");
print(Test);
endif
pause(5000);
endfunc
Right now, I think it's a timing issue that I need to resolve. I spent the morning playing with the transistor issue, making sure that I had that correct (I was making it too complicated again).
The code is just to make sure I have the concept of communications between the Arduino and the uOLED down. I can get the uOLED to behave correctly by manually sending communications over the terminal display. I can't get it to work when the Arduino sends those same commands. I'm trying different formatting (Hex, Dec, etc), but not getting anywhere. I'm a little fried right now, so I'm taking a break for the day.