Infantry power pack Final Report May 13

37
Infantry power pack; Final Report Mike Sassoon, Gabriel Koretz, Alex Schechter, May 2015 Executive Summary The system is designed to generate Hydrogen on Demand for powering a fuel cell in the field. The objective is to replace batteries (currently standard equipment) in view of the large potential weight savings. After a number of different experimental approaches, a workable design has crystallized which appears capable of achieving and even exceeding the target objectives by a considerable margin. The design is based on the powder to water approach, whereby powder is fed from an upper chamber into liquid reactant below, via a rubber diaphragm with apertures which are opened and closed periodically. Most of the design aims have been demonstrated in short term experiments but the system requires further optimization in order to demonstrate reliable long term capability. Design objectives and achievements; Objectives; 300 ml/min, 72 hr operation. Achieved; up to 1500 ml/min, 24 hr operation at the close of the research program Objective; Supply Hydrogen to Fuel Cell at correct pressure (0.5 bar max, humidified). Demonstrated. Control according to power demand; Demonstrated Safety; pressure relief, upside down operation; mechanical pressure relief not yet incorporated, upside down operation demonstrated briefly. Low thermal signature; not yet started but considered achievable. Low parasitic power consumption (target <1W). Actual power consumption <0.6W Self-starting (i.e. no need for auxiliary battery). Not a must but “nice to have”. Considered achievable if upgrade to motor were undertaken.

Transcript of Infantry power pack Final Report May 13

Page 1: Infantry power pack Final Report May 13

Infantry power pack; Final Report

Mike Sassoon, Gabriel Koretz, Alex Schechter, May 2015

Executive Summary

The system is designed to generate Hydrogen on Demand for powering a fuel cell in the field. The objective is to replace batteries (currently standard equipment) in view of the large potential weight savings.

After a number of different experimental approaches, a workable design has crystallized which appears capable of achieving and even exceeding the target objectives by a considerable margin. The design is based on the powder to water approach, whereby powder is fed from an upper chamber into liquid reactant below, via a rubber diaphragm with apertures which are opened and closed periodically. Most of the design aims have been demonstrated in short term experiments but the system requires further optimization in order to demonstrate reliable long term capability.

Design objectives and achievements;

Objectives; 300 ml/min, 72 hr operation. Achieved; up to 1500 ml/min, 24 hr operation at the close of the research program

Objective; Supply Hydrogen to Fuel Cell at correct pressure (0.5 bar max, humidified). Demonstrated.

Control according to power demand; Demonstrated Safety; pressure relief, upside down operation; mechanical pressure relief not yet

incorporated, upside down operation demonstrated briefly. Low thermal signature; not yet started but considered achievable. Low parasitic power consumption (target <1W). Actual power consumption <0.6W Self-starting (i.e. no need for auxiliary battery). Not a must but “nice to have”. Considered

achievable if upgrade to motor were undertaken. Minimum weight and size (target weight<500g for the generator). Not started but appears

possible using plastic instead of metal.

Design Philosophy

Conceptual design; the addition of powder to water instead of the other way round is intrinsically desirable from a reaction kinetics point of view. This is due to the thermal buffer role of the water surrounding each particle of powder, the elimination of “product skin” by dissolution in the surrounding water and the ease with which rapid and uniform mixing can be performed. Rapid reaction is essential for good control.

The reaction only occurs under low pH (i.e. acidic) conditions or with the aid of a catalyst. Although pH was used for development purposes, it is intended to use catalyst in finely divided form in the reaction space by plating onto porous metal substrate. The substrate will be in the form of mixing

Page 2: Infantry power pack Final Report May 13

paddles to optimize reaction conditions. Therefore it is envisaged that there will be no need for pre-treatment of reactants (i.e. no acidification, palletisation etc.).

Notes on other approaches

Water to powder appears attractive due to ease of handling liquid (pumping, metering, spreading etc.). The approach was tried in the early stages but was seen to be unworkable due to the creation of a “cocoon” of products which slowed down further reaction by preventing contact between water and fresh SBH. As more and more water was added, the cocoon broke down and the reaction suddenly proceeded at a rapid uncontrollable rate (“runaway”).

Dissolved SBH in water followed by injection into porous catalytic reactor; A common approach used by other researchers is to pre-dissolve the SBH powder in water and pump the solution through a catalyst coated porous matrix. However this approach can be problematic due to the need for a high flowrate of solution to “wash off” the product which would otherwise form a coating on the catalyst and inhibit further reaction. Constraining the flowrate in this way brings further problems in it’s train since it removes a degree of freedom (impacts negatively on temperature control and overall reaction control). In addition there is the mechanical and weight penalty of a second “solution tank” to be considered.

The powder to water approach evolved through a number of different feed mechanisms which have been detailed in previous reports. The main findings and issues that arose are listed below in “Development History”

Development history

It became apparent at an early stage that the following features/phenomena impact on the design.

Wide range of powder condition during the dispensing cycle (from dry free running powder, lumps and “boulders” through to sticky paste and eventually slurry. This created challenges due to “stickiness”, pastiness, boulders, need to clean up previous batch completely before adding fresh SBH etc.

Need to ensure fast chemical kinetics to ensure good control. This is complicated since the reaction rate is influenced by pH which changes throughout the cycle. (i.e. the products are alkaline which raises the pH and reduces reactivity).

Build-up of reactants which sequesters water (hydration) and also results in crystallization which can interfere with mechanical operation.

Good ergonomic design; (simple and rapid powder recharging, simple discharge of reactants and spent liquor, self-starting, safety in case of “upside down” , low thermal signature

Temperature control (reaction rate seen to be strong function of temp)

Page 3: Infantry power pack Final Report May 13

Corrosion (mainly due to acidification of water but also likely caused by alkalinity of product)

Leakage of Hydrogen Bearing/seal issues (wear) Ability to operate at pressure to provide buffer capability (discontinuous feed plus

load changes) Low parasitic power consumption

The design evolved from the above considerations. The current version is shown in Figs 1 and 2: The animation below illustrates the basic principle of operation.

Page 4: Infantry power pack Final Report May 13

link to animation

Short description of latest version of test rig:

Figure 1

Figure 3

Figure 2

Page 5: Infantry power pack Final Report May 13

1. Top compartment

2. Upper gasket

3. Diaphragm (St/St)

4. Membrane with slits (Silicone)

5. Bottom compartment

1. Slit opener paddle

2. Lower arm for preload

3. Preloaded slit opener

4. Silicone O-ring elastic band

Figure 4

Page 6: Infantry power pack Final Report May 13

5. Shaft

6. Locating screws for upper and lower arms

7. Mixer paddle

1. Plate for compressing O-rings

2. Lower bearing (brass bushing)

3. O-ring seals

4. Base

5. O-ring

6. M3 screw X3 for adjusting O ring preload

Main design highlights

Cylindrical shape; Good geometry for operation at pressure (later change to dome top and bottom instead of “ flat “ for even better pressure capability.

Shaft/seal/bearing; Shaft is supported by bottom brass bearing (lubricated by water) and supported at top by hole in diaphragm plate. This minimizes eccentric motion (which leads to wear and leakage). Drive enters at bottom so seal is submerged under liquid- easier to seal against water than Hydrogen gas. Seals are Silicone O rings under slight compression.

Reactor;

Figure 5

Page 7: Infantry power pack Final Report May 13

o Bottom compartment. Equipped with mixer paddles to maintain fluidity of water/reaction products as much as possible. High head room to facilitate vapour liquid separation. Mixer paddles intended as substrate for catalyst

o Top compartment for powder dispensing; large diameter plug for charging with fresh powder. Wiper paddles driven by shaft. Paddles made from thin sheet st/steel with bonded on silicone rubber “lips” to “wipe” powder (which could be dry, pasty or slurry) into the aperture formed by the opening of the slits. The rubber lips minimize mechanical “tearing” of the slit edge.

o Diaphragm; Elastic silicone sheet supported on thin stainless steel “shim” which has apertures sized and shaped to enable reliable slit opening with minimum tearing stress and repeatable aperture size

o “Wiper paddles”; spring loaded paddles with rubber edges to sweep a wide variety of powder forms (dry, lumps, pasty etc.) into the slit apertures.

Throttling valve; several functions; a) Maintain reactor at pressure range 1-2 bar (increased storage/buffer capacity). b) Variable orifice to enable adjustment to suitable flow-deltaP range (typically 0- 1000 cc/min at 0-2 bar deltaP. c) Reduce pressure to suitable range for FC (0.5 bar max).

Control; The system is designed to do the following;1. Measure pressure, temperature and current demand. Pressure and temperature

are used for control purposes. Motor current to identify shaft seizure.2. Calculate Flow (hot wet gas conditions) from flow pressure calibration3. Emergency stop 4. Log temp, pressure, motor current

The overall scheme is shown in Fig 6, a picture of the actual unit is given in Fig 7:

Illustration of overall system showing main components

Page 8: Infantry power pack Final Report May 13

The pressure and temperature in the reactor volume are continuously monitored by sensors which relay the information to a microprocessor (Arduino). The microprocessor checks for overpressure, over temperature and calculates flow and generates the appropriate signal to the paddle motor (i.e. motor RPM). Thus the rate of powder dispensing is controlled to hold the flow at the desired level. Motor current is also monitored to detect jamming or other paddle malfunction. The Arduino software outputs temperature, pressure, motor current and flow data to an on board data logger (SD card) and display. The code is given in Appendix 1.

Current performance/results

1. The dispensing mechanism has demonstrated ability to cope with all forms of SBH feed from dry powder to slurry. The powder chamber is seen to be almost wiped clean of SBH at the end of each run. This enables addition of fresh charges of powder without the need for clean-up.

2. Powder dispensing rates up to X5 design rate have been seen in short term operation (0-4 hrs typically)

3. Operation at up to 2 bar reactor pressure has been demonstrated.4. Motor control by feedback from the reactor pressure has been demonstrated (proportional

control of RPM according to user defined set point). On board display of instantaneous flow also demonstrated.

5. Longer term operation is a “work in progress”. The main issues have been mechanical due mainly to jamming of the metal paddle springs from reaction debris. However these appear to have been largely overcome by switching to silicone rubber springs (see below).

6. Operation with sea water (simulated by 3-4% salt solution) has been demonstrated.7. Operation at temperatures up to 85C has been demonstrated.

Figure 6

Figure 7

Page 9: Infantry power pack Final Report May 13

8. Operation with Ruthenium catalyst powder mixed with water has been demonstrated.9. A rough estimate of cumulative hours we have run: 24hrs. 10. Note: best powder to water ratio was achieved at 50 °C . 200ml water+0.2gr

ruthenium+50gr SBH.

The following graphs illustrate performance highlights of the generator;

Figure 8

Illustration of controlled operation at set point (300 ml/min) 31.3.15 100 ml H2SO4, 15gr SBH, initial PH-0, final PH-10

Figure 9Illustration of controlled operation at set point (300 ml/min) 31.3.15

under varying temperature conditions100 ml H2SO4, 15gr SBH, initial PH-0, final PH-10

Page 10: Infantry power pack Final Report May 13

Figure 10Illustration of control by ON/OFF operation of paddle motor(with

proportional speed at nr set point conditions). Note low duty cycle, hence wide margin to enable higher inputs

31.3.15 under varying temperature conditions

100 ml H2SO4, 15gr SBH, initial PH-0, final PH-10

Page 11: Infantry power pack Final Report May 13

Issues tackled in the last 3 months

Ongoing paddle development to obtain

smooth, low friction long life operation under operating conditions of heat, moisture and chemical debris. Jamming due to ingress of material into the spring mechanism was an issue. A number of metallic spring configurations were tried but in order to reach a reliable solution a high level of manufacturing precision is required. This is beyond the resources of the lab so a switch was made to springs from silicone “elastic bands” and Teflon slit openers. The elastic band approach appears to be a practical solution and the Teflon substitution is in progress at the time of writing.

Control; the control system is designed to do the following;o Read pressure and temperatureo Stop the motor if pressure goes above a predefined safety limito Identify shaft seizure by motor current demand and shut down if neededo Convert pressure into flow and control the RPM to maintain a (user defined)

pressure (and therefore flow) level

Figure 11aIllustration of operation with ruthenium catalyst(pdr suspended in

water) instead of acidified water 5.5.15200ml water 0.2gr ruthenium 200gr SBH

Figure 11bMKS digital flow meter used to monitor flow. Note correlation between flow and

pressure. Total volume calaulated from t=0 until t=9(hr) is approximately 170 liters

Page 12: Infantry power pack Final Report May 13

o Monitor pressure, temperature and motor current demand. Download the data onto an on-board SD card for later retrieval and onto an on-board display.

o Autonomous operation

The controller is built on an Arduino platform with suitable interfaces and sensors for reading pressure, temperature and current. It is powered by 9V battery therefore can be operated remote from the laptop. Set points can be adjusted via an on board display. See Figure 12 for a view of the controller:

For

development purposes, online flow measurement is required. This is complicated by the need to measure a hot Hydrogen/water vapour mix of unknown composition, with the possibility of liquid entrainment which can cause blockage. Initially an off the shelf needle valve was used but this had poor resolution and was prone to blockage. Therefore a new needle valve was built to operate in the desired flow-pressure regime and give good repeatability after resetting (if cleaning is required). Initial calibrations were done using clean, cool dry bottled Hydrogen and water displacement to measure flow. Fig 13 shows a typical correlation between flow and pressure. This demonstrates the viability of using the pressure drop approach as a simple and reliable flow indicator.

Figure 12

Page 13: Infantry power pack Final Report May 13

The calibration is currently being upgraded to measure flow using actual Hydrogen/water vapour at various temperatures from the generator itself. The conversion algorithm in the Arduino code will be upgraded accordingly.

Operation with salt water. The system was operated in “back to back” mode with

salt water and tap water. As figure 14 shows, the system response is essentially similar:

Recommended future enhancements

Reactor body; currently from st/st and aluminium which are too heavy for operational use. It is intended to change to polycarbonate with domed top and bottom (light, impact resistance, easy to form to domed shape, corrosion resistant)

Customize the motor (currently off the shelf automotive item) to reduce weight, add position sensoring to be able to park the paddles in a “slit closed” position. Add a clutch to enable manual turning of the shaft for self-starting

Install mechanical relief valve to vent excess pressure in an emergency Modify the throttle valve to manually enable “quick release” in case of blockage Develop shaft seal/bearing further. The system appears to work reasonably well with low

friction (0.5W) but requires long term proving to demonstrate reliability and reduce wear (eg may improve by more precise compression and move to Viton).

Plate catalyst onto lower mixing paddles and develop operation with non-acidified water

Figure 13

Figure 14

0 5 10 15 20 25 30 350

50100150200250300350400450500

tap water vs salt water

salt water

tap water

t(min)

flow

(ml/

min

)

Page 14: Infantry power pack Final Report May 13

APPENDIX 1

Arduino code:

/////////////////////////////////////// For use with SD card /////////////////////////////

#include <SD.h>

File myFile;

///////////////////// For use with the Adafruit_INA219 current sensor /////////////////////////////

//#include <Adafruit_INA219.h>

//Adafruit_INA219 ina219;

///////////////////////////// For use with the DFrobot LCD Shield /////////////////////////////

#include <LiquidCrystal.h>

#include <DFR_Key.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7); //Pin assignments for DFRobot LCD Keypad Shield

DFR_Key keypad;

Page 15: Infantry power pack Final Report May 13

int localKey = 0;

String keyString = "";

int lcd_key = 0;

int adc_key_in = 0;

#define btnRIGHT 0 // define some values used by the panel and buttons

#define btnUP 1

#define btnDOWN 2

#define btnLEFT 3

#define btnSELECT 4

#define btnNONE 5

int buttonPushCounter = 0; // counter for the number of button presses

int buttonState = 0; // current state of the button

int lastButtonState = 0; // previous state of the button

int stuck=0;

int running=0;

////////////////////////////// For use with the Adafruit Motor Shield v2 /////////////////////////////

#include <Wire.h>

#include <Adafruit_MotorShield.h>

#include "utility/Adafruit_PWMServoDriver.h"

// Create the motor shield object with the default I2C address

Adafruit_MotorShield AFMS = Adafruit_MotorShield();

Adafruit_DCMotor *myMotor = AFMS.getMotor(1);

Page 16: Infantry power pack Final Report May 13

////////////////////////////////////////// veriables //////////////////////////////////////////////

unsigned long time;

int cnt=0; // just a counter

float Pressure;

//float flow;

float SetPoint=1; // Desired pressure in bar set by user

float PB = 0.1 * SetPoint; // proportional band

float error;

//int current_mA = 0;

//int flow =0;

int Temperature;

int lastTime=0;

int Toggle=0;

int Dutytime=10;

int Resttime=60;

int MotorGo=1;

/////////////////////////////// setup /////////////////////////////////////////////

void setup()

{

lcd.begin(16, 2);

lcd.clear();

lcd.setCursor(0, 0);

Page 17: Infantry power pack Final Report May 13

Serial.begin(9600); // initialize serial communications at 9600 bps

Serial.print("Initializing SD card...");

pinMode(10, OUTPUT);

if (!SD.begin(3))

{

Serial.println("SD initialization failed!");

lcd.print("SD failed!");

lcd.setCursor(4, 1);

lcd.print(":-(");

delay(2000);

lcd.clear();

}

else

{

Serial.println("SD initialization done.");

lcd.print("SD initialized");

lcd.setCursor(4, 1);

lcd.print(":-D");

delay(2000);

}

Serial.println(); Serial.println();

Serial.println(" time (s) Pressure (BAR) Temperature (C) running (ON/OFF) ");

Page 18: Infantry power pack Final Report May 13

//////////////////// For use with the Adafruit_INA219 current sensor /////////////////////////////

// uint32_t currentFrequency;

// ina219.begin();

/////////////////////////////// For use with the Adafruit Motor Shield v2 /////////////////////////////

AFMS.begin();

myMotor->setSpeed(204);

myMotor->run(FORWARD);

myMotor->run(RELEASE);

//////////////////////////////// For use with the DFrobot LCD Shield /////////////////////////////

lcd.begin(16, 2);

lcd.clear();

lcd.setCursor(0, 0);

delay(1000);

keypad.setRate(10);

int buttonPushCounter = 0; // counter for the number of button presses

int buttonState = 0; // current state of the button

int lastButtonState = 0; // previous state of the button

}

///////////////////////////////// main program /////////////////////////////////////

void loop()

Page 19: Infantry power pack Final Report May 13

{

//////////////////////// print the results to the serial monitor: ///////////////////////////////

lastTime = time;

time = millis()/1000; // prints time since program started

if (time > lastTime) // sample and serial print every 1 second

{

cnt++;

if (cnt>Resttime)

cnt=0;

if (cnt>Dutytime)

MotorGo=0;

else

MotorGo=1;

Pressure = (52.77 * analogRead(A1)* 5.0/1023.0 - 10.554)/101; // from datasheet MPX4250

//flow = (analogRead(A3)*22.22222222*5/1025-4.44444444)*100*2.71; // from datasheet MPX5100 and calibration // not sure about that

Temperature = ( analogRead(A2)*5.0/1023.0 - 1.225 ) * 200 ;

// current_mA = ina219.getCurrent_mA();

String dataString = "";

dataString = String(time) + "," + String(Pressure)+ ","+ String(Temperature) + "," + String(running) ;

File dataFile = SD.open("datalog.csv", FILE_WRITE);

if (dataFile) {

Page 20: Infantry power pack Final Report May 13

dataFile.println(dataString);

dataFile.close();

}

Serial.print(" ");

Serial.print(time);

Serial.print(" , ");

Serial.print(Pressure);

Serial.print(" , ");

//Serial.print(flow);

// Serial.print(" , ");

Serial.print(Temperature);

Serial.print(" , ");

Serial.print(running);

Serial.println();

}

////////////////////////// print the results to the LCD: /////////////////////////////////////////

localKey = keypad.getKey();

lcd.setCursor(0,1); // move to the beginning of the second line

lcd_key = read_LCD_buttons(); // read the buttons

switch (lcd_key) // depending on which button was pushed, we perform an action

{ ////////////// pressing RIGHT button ///////////////////

Page 21: Infantry power pack Final Report May 13

case btnRIGHT:

{

buttonState = HIGH;

if (buttonState != lastButtonState) {

if (buttonState == HIGH){

lcd.clear();

buttonPushCounter++; }}

lastButtonState = buttonState;

break;

}

////////////// pressing LEFT button ///////////////////

case btnLEFT:

{

buttonState = HIGH;

if (buttonState != lastButtonState) {

if (buttonState == HIGH){

buttonPushCounter--;

lcd.clear();}}

lastButtonState = buttonState;

break;

}

////////////// pressing SELECT button ///////////////////

case btnSELECT:

{

buttonState = HIGH;

if (buttonState != lastButtonState) {

if (buttonState == HIGH){

Page 22: Infantry power pack Final Report May 13

Toggle++;

lcd.clear(); }}

lastButtonState = buttonState;

break;

}

}

if (!Toggle) /////////////////////////////////// Data Screen //////////////////////////////////

{

if (buttonPushCounter==0)

{

lcd.setCursor(0, 0);

lcd.print("P(bar):");

lcd.setCursor(0, 1);

lcd.print(Pressure);

lcd.print(" ");

lcd.setCursor(12, 1);

/* if(Pressure<SetPoint)

lcd.print("ON ");

else

lcd.print("OFF");

lcd.setCursor(8, 0); */

}

Page 23: Infantry power pack Final Report May 13

if (buttonPushCounter==1)

{

lcd.setCursor(0, 0);

lcd.print("Flow not available");

lcd.setCursor(0, 1);

//lcd.print(flow);

lcd.print(" ");

lcd.setCursor(12, 1);

/*if(Pressure<SetPoint)

lcd.print("ON ");

else

lcd.print("OFF");*/

}

if (buttonPushCounter==2)

{

lcd.setCursor(0, 0);

lcd.print("T(C):");

lcd.setCursor(0, 1);

lcd.print(Temperature);

lcd.print(" ");

lcd.setCursor(12, 1);

/*if(Pressure<SetPoint)

lcd.print("ON ");

else

lcd.print("OFF");*/

}

Page 24: Infantry power pack Final Report May 13

if (buttonPushCounter==3)

{

lcd.setCursor(0, 0);

lcd.print("Motor state:");

lcd.setCursor(0, 1);

lcd.print(running);

lcd.print(" ");

lcd.setCursor(12, 1);

/*if(Pressure<SetPoint)

lcd.print("ON ");

else

lcd.print("OFF");*/

}

if (buttonPushCounter==4) // all in one screen

{

lcd.setCursor(0, 0);

lcd.print("P:");

lcd.setCursor(2, 0);

lcd.print(Pressure);

lcd.print(" ");

lcd.setCursor(6, 0);

lcd.print(" ");

lcd.setCursor(8, 0);

//lcd.print(" Q:");

Page 25: Infantry power pack Final Report May 13

lcd.setCursor(12, 0);

//lcd.print(flow);

lcd.print(" ");

lcd.setCursor(0, 1);

lcd.print("T:");

lcd.setCursor(2, 1);

lcd.print(Temperature);

lcd.print(" ");

lcd.setCursor(6, 1);

lcd.print("Motor:");

lcd.setCursor(12, 1);

lcd.print(running);

lcd.print(" ");

}

}

if (Toggle==1)

{

switch (lcd_key)

{

////////////// pressing UP button ///////////////////

case btnUP:

{

Page 26: Infantry power pack Final Report May 13

buttonState = HIGH;

if (buttonState != lastButtonState) {

if (buttonState == HIGH){

lcd.clear();

SetPoint += 0.1; }}

lastButtonState = buttonState;

break;

}

////////////// pressing DOWM button ///////////////////

case btnDOWN:

{

buttonState = HIGH;

if (buttonState != lastButtonState) {

if (buttonState == HIGH){

lcd.clear();

SetPoint -= 0.1; }}

lastButtonState = buttonState;

break;

}

}

lcd.setCursor(0, 0);

lcd.print("P Setpoint:");

lcd.setCursor(0, 1);

lcd.print(SetPoint);

lcd.print(" bar");

Page 27: Infantry power pack Final Report May 13

}

if (Toggle==2)

{

switch (lcd_key)

{

////////////// pressing UP button ///////////////////

case btnUP:

{

buttonState = HIGH;

if (buttonState != lastButtonState) {

if (buttonState == HIGH){

lcd.clear();

Dutytime += 1; }}

lastButtonState = buttonState;

break;

}

////////////// pressing DOWM button ///////////////////

case btnDOWN:

{

buttonState = HIGH;

if (buttonState != lastButtonState) {

if (buttonState == HIGH){

lcd.clear();

Page 28: Infantry power pack Final Report May 13

Dutytime -= 1; }}

lastButtonState = buttonState;

break;

}

}

lcd.setCursor(0, 0);

lcd.print("Dutytime");

lcd.setCursor(0, 1);

lcd.print(Dutytime);

lcd.print(" seconds");

}

if (Toggle==3)

{

switch (lcd_key)

{

////////////// pressing UP button ///////////////////

case btnUP:

{

buttonState = HIGH;

if (buttonState != lastButtonState) {

if (buttonState == HIGH){

lcd.clear();

Resttime += 1; }}

lastButtonState = buttonState;

Page 29: Infantry power pack Final Report May 13

break;

}

////////////// pressing DOWM button ///////////////////

case btnDOWN:

{

buttonState = HIGH;

if (buttonState != lastButtonState) {

if (buttonState == HIGH){

lcd.clear();

Resttime -= 1; }}

lastButtonState = buttonState;

break;

}

}

lcd.setCursor(0, 0);

lcd.print("Resttime");

lcd.setCursor(0, 1);

lcd.print(Resttime);

lcd.print(" seconds");

}

/////////////////////////////////////////// LCD variables ///////////////////////////////////////

if (buttonPushCounter==5)

buttonPushCounter=0;

if (buttonPushCounter<0)

Page 30: Infantry power pack Final Report May 13

buttonPushCounter=4;

lastButtonState=0;

if (Toggle==4)

{

Toggle=0;

lcd.clear();

}

////////////////////////////////////////// motor control ///////////////////////////////////////

if(Pressure > SetPoint || MotorGo==0 )

{

myMotor->run(RELEASE);

running=0;

}

else

{

myMotor->run(FORWARD) ;

running=1;

}

/*if(current_mA > 200)

{

stuck = time;

}

while( time - stuck < 2)

Page 31: Infantry power pack Final Report May 13

{ myMotor->setSpeed(255);

myMotor->run(FORWARD);

running=1;}*/

myMotor->setSpeed(255);

//////////////////////////////////////////////////////////////////////////////////////////////////////////

delay(120);

}

////////////////////////////////// functions ////////////////////////////////////////

// read the buttons

int read_LCD_buttons()

{

adc_key_in = analogRead(0); // read the value from the sensor

// my buttons when read are centred at these values: 0, 144, 329, 504, 741

// we add approx. 50 to those values and check to see if we are close

if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result

// For V1.1 us this threshold

if (adc_key_in < 50) return btnRIGHT;

if (adc_key_in < 250) return btnUP;

if (adc_key_in < 450) return btnDOWN;

if (adc_key_in < 650) return btnLEFT;

if (adc_key_in < 850) return btnSELECT;

Page 32: Infantry power pack Final Report May 13

return btnNONE; // when all others fail, return this...

}