mirror of
https://github.com/caperren/school_archives.git
synced 2025-11-09 13:41:13 +00:00
Added old firmware and pcb design files
These are all design documents that I thought I had lost. It's may make me cringe, but it's still cool to use it to see how far I've come.
This commit is contained in:
@@ -0,0 +1,829 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//Includes, Defines, Instantiations, and Global Variables//////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//Includes
|
||||
#include "DualVNH5019MotorShield.h" //Library for the motor driver shield
|
||||
#include <EEPROM.h> //EEPROM Storage Library for storing config changes
|
||||
#include <SoftwareSerial.h> //Software Serial Library needed for lcd communications
|
||||
#include <StopWatch.h> //Stopwatch library for timing purposes
|
||||
#include <avr/pgmspace.h> //PROGMEM library for storage of config
|
||||
#include <String.h>
|
||||
|
||||
//Pin Definitions (Arduino Suggested Method)
|
||||
const unsigned char LcdTX = 5; //Pin connected to LCD RX Line
|
||||
|
||||
const unsigned char StartSwitch = 11; //Pin connected to start switch
|
||||
const unsigned char StopSwitch = 13; //Pin connected to stop switch
|
||||
|
||||
const unsigned char EncoderLed = A2; //Pin connected to rotary encoder led
|
||||
const unsigned char EncoderButton = A3; //Pin connected to rotary encoder led
|
||||
const unsigned char EncoderChannelB = A4; //Pin connected to channel A of the rotary encoder
|
||||
const unsigned char EncoderChannelA = A5; //Pin connected to channel B of the rotary encoder
|
||||
|
||||
//Instantiations
|
||||
SoftwareSerial LcdSerial(3, LcdTX); //Software Serial Instantiation with Pin 3 as dummy for RX
|
||||
DualVNH5019MotorShield MotorDriver; //Motor Driver Library Instantiation
|
||||
StopWatch MyStopWatch(StopWatch::SECONDS); //StopWatch Instantiation for measuring time
|
||||
|
||||
enum ArduinoPrograms{ //Enumeration for defining the arduino program states
|
||||
StandardDechorionation = 0, //This is the standard Dechorianation Program
|
||||
TwoFourDechorionation = 1, //Used for embryo's 24 hours old
|
||||
PronaseAndRinse = 2, //This is an alternating pronase and rinse cycle
|
||||
RinseOnly = 3, //This only does the rinse cycle
|
||||
SDConfig = 4, //Config page for the standard dechorionation
|
||||
TFConfig = 5, //Config page for the 24 hour
|
||||
PnRConfig = 6, //Config page for Pronase and Rinse
|
||||
ROConfig = 7, //Config page for Rinse Only
|
||||
ProgramSelection = 8 //Presents a program selection screen
|
||||
} ArduinoProgram = ProgramSelection; //This selects the arduino program to run
|
||||
|
||||
//Global Variables and Constants and Configs
|
||||
const unsigned char TitleTimeout = 2; //Time in seconds to display the main device title
|
||||
const unsigned char LcdPageDelay = 3; //Seconds to wait before the lcd changes pages.
|
||||
const unsigned char ConfigPageTimeout = 5; //Time in seconds to wait before dropping the user back to the program selection screen
|
||||
const unsigned int DebounceTimeout = 300; //Timeout in milliseconds of the button debounce delay
|
||||
|
||||
unsigned char DoneOnce = 0; //Variable to store whether something has happened or not.
|
||||
unsigned char EStop = 0; //Variable to store the status of the system's estop button
|
||||
unsigned char CycleSkip = 0; //Variable to store whether the user wants to skip the current cycle of a program.
|
||||
|
||||
signed char SelectedProgram = 0; //Holds the current program selection. This is not the currently active program.
|
||||
signed char SelectedConfig = 0; //Hold the current config selection.
|
||||
unsigned char PreviousConfig = 0; //A value to hold the previous config value. Used for smoothing the rotary encoder reading.
|
||||
|
||||
unsigned char EncoderChannelALastValue = LOW; //This variable stores the previous state of channel a on the rotary encoder. This is needed to determine direction.
|
||||
unsigned char EncoderReferenceVariable = LOW; //This is a dummy varaible for direction determination on for the rotary encoder.
|
||||
|
||||
String ConfigVal; //This is used to store the value returned from PROGMEM and converting it to a char array.
|
||||
int NewVal; //This holds the new value
|
||||
int PrevVal; //This holds the previous value when changing configs
|
||||
|
||||
const unsigned int MaxDriveSpeed = 400; //Max drive speed value given by the motor driver library
|
||||
const unsigned int RotationMinDriveSpeed = 75; //Minimum value to get the motor to turn
|
||||
const unsigned int PumpMinDriveSpeed = 75; //Minimum value to get the motor to turn
|
||||
const unsigned int PumpMaxDriveSpeed = 180;
|
||||
unsigned int MaxRampValue = 300; //The maximum reasonable value used when ramping the motors
|
||||
unsigned int MaxPumpRampValue = 150;
|
||||
unsigned int MinRampValue = 1; //The minimum reasonable value used when ramping the motors
|
||||
unsigned int CycleSeconds; //Stores the seconds that each cycle should run for.
|
||||
unsigned int DriveLoop; //Looping variable for driving motors
|
||||
|
||||
|
||||
//| Program List Top | Program List Bottom |
|
||||
PROGMEM prog_char* ProgramNames[][2] = { //Strings for program names shown on the LCD
|
||||
{"1: Standard ", " Dechorionation"},
|
||||
{"2: 24 Hour Old ", " Dechorionation"},
|
||||
{"3: 6 Hour HPF ", " Dechorionation"}, //Note that "Pronase and Rinse" has been changed to this.
|
||||
{"4: Rinse Cycle ", " Only "}
|
||||
};
|
||||
|
||||
// | Main Page Top | Main Page Bottom | Adjust Page Top | Max Value | EEPROM Address |
|
||||
PROGMEM const prog_char* StandardDechorionationConfig[][5] = {
|
||||
{"Pronase Cycle 1 ", " Minutes ", " Minutes ", (const prog_char*)256, (const prog_char*)0},
|
||||
{"Pronase Cycle 1 ", " Seconds ", " Seconds ", (const prog_char*)60, (const prog_char*)1},
|
||||
{" Rinse Cycle ", " Minutes ", " Minutes ", (const prog_char*)256, (const prog_char*)2},
|
||||
{" Rinse Cycle ", " Seconds ", " Seconds ", (const prog_char*)60, (const prog_char*)3},
|
||||
{"Pronase Cycle 2 ", " Minutes ", " Minutes ", (const prog_char*)256, (const prog_char*)4},
|
||||
{"Pronase Cycle 2 ", " Seconds ", " Seconds ", (const prog_char*)60, (const prog_char*)5},
|
||||
{" Rotation Speed ", " Percentage ", " Percent ", (const prog_char*)100, (const prog_char*)7},
|
||||
{"Rotation Ramping", " Percentage ", " Percent ", (const prog_char*)100, (const prog_char*)6},
|
||||
{" Pump Speed ", " Percentage ", " Percent ", (const prog_char*)100, (const prog_char*)8},
|
||||
{" Pump Ramp ", " Percentage ", " Percent ", (const prog_char*)100, (const prog_char*)9}
|
||||
};
|
||||
|
||||
const unsigned char NumSDConfig = 10; //Stores the maximum number of available configs
|
||||
|
||||
unsigned char EEPROMConfigSD[NumSDConfig] = { //User Modifiable Standard Dechorionation Config Array
|
||||
6, //Values correspond to each cycle above, in same array order
|
||||
30, //Default values here are for initial EEPROM Programming
|
||||
1,
|
||||
0,
|
||||
10,
|
||||
0,
|
||||
50,
|
||||
75,
|
||||
100,
|
||||
100
|
||||
};
|
||||
|
||||
// | Main Page Top | Main Page Bottom | Adjust Page Top | Max Value | EEPROM Address |
|
||||
PROGMEM const prog_char* TwoFourDechorionationConfig[][5] = {
|
||||
{"Pronase Cycle 1 ", " Minutes ", " Minutes ", (const prog_char*)256, (const prog_char*)10},
|
||||
{"Pronase Cycle 1 ", " Seconds ", " Seconds ", (const prog_char*)60, (const prog_char*)11},
|
||||
{" Rinse Cycle ", " Minutes ", " Minutes ", (const prog_char*)256, (const prog_char*)12},
|
||||
{" Rinse Cycle ", " Seconds ", " Seconds ", (const prog_char*)60, (const prog_char*)13},
|
||||
{"Pronase Cycle 2 ", " Minutes ", " Minutes ", (const prog_char*)256, (const prog_char*)14},
|
||||
{"Pronase Cycle 2 ", " Seconds ", " Seconds ", (const prog_char*)60, (const prog_char*)15},
|
||||
{" Rotation Speed ", " Percentage ", " Percent ", (const prog_char*)100, (const prog_char*)16},
|
||||
{"Rotation Ramping", " Percentage ", " Percent ", (const prog_char*)100, (const prog_char*)17},
|
||||
{" Pump Speed ", " Percentage ", " Percent ", (const prog_char*)100, (const prog_char*)18},
|
||||
{" Pump Ramp ", " Percentage ", " Percent ", (const prog_char*)100, (const prog_char*)19}
|
||||
};
|
||||
|
||||
const unsigned char NumTFConfig = 10; //Stores the maximum number of available configs
|
||||
|
||||
unsigned char EEPROMConfigTF[NumTFConfig] = { //User Modifiable 24 Hour Dechorionation Config Array
|
||||
3, //Values correspond to each cycle above, in same array order
|
||||
0, //Default values here are for initial EEPROM Programming
|
||||
1,
|
||||
0,
|
||||
10,
|
||||
0,
|
||||
85,
|
||||
85,
|
||||
85,
|
||||
85
|
||||
};
|
||||
|
||||
// | Main Page Top | Main Page Bottom | Adjust Page Top | Max Value | EEPROM Address |
|
||||
PROGMEM const prog_char* PronaseAndRinseConfig[][5] = {
|
||||
{"Pronase Cycle 1 ", " Minutes ", " Minutes ", (const prog_char*)256, (const prog_char*)10},
|
||||
{"Pronase Cycle 1 ", " Seconds ", " Seconds ", (const prog_char*)60, (const prog_char*)11},
|
||||
{" Rinse Cycle ", " Minutes ", " Minutes ", (const prog_char*)256, (const prog_char*)12},
|
||||
{" Rinse Cycle ", " Seconds ", " Seconds ", (const prog_char*)60, (const prog_char*)13},
|
||||
{"Pronase Cycle 2 ", " Minutes ", " Minutes ", (const prog_char*)256, (const prog_char*)14},
|
||||
{"Pronase Cycle 2 ", " Seconds ", " Seconds ", (const prog_char*)60, (const prog_char*)15},
|
||||
{" Rotation Speed ", " Percentage ", " Percent ", (const prog_char*)100, (const prog_char*)16},
|
||||
{"Rotation Ramping", " Percentage ", " Percent ", (const prog_char*)100, (const prog_char*)17},
|
||||
{" Pump Speed ", " Percentage ", " Percent ", (const prog_char*)100, (const prog_char*)18},
|
||||
{" Pump Ramp ", " Percentage ", " Percent ", (const prog_char*)100, (const prog_char*)19}
|
||||
};
|
||||
|
||||
const unsigned char NumPnRConfig = 10;
|
||||
|
||||
unsigned char EEPROMConfigPnR[NumPnRConfig] = { //User Modifiable Pronase and Rinse Config Array
|
||||
6, //Values correspond to each cycle above, in same array order
|
||||
30, //Default values here are for initial EEPROM Programming
|
||||
1,
|
||||
0,
|
||||
10,
|
||||
0,
|
||||
85,
|
||||
85,
|
||||
85,
|
||||
85
|
||||
};
|
||||
|
||||
// | Main Page Top | Main Page Bottom | Adjust Page Top | Max Value | EEPROM Address |
|
||||
PROGMEM const prog_char* RinseOnlyConfig[][5] = {
|
||||
{" Rinse Cycle ", " Minutes ", " Minutes ", (const prog_char*)256, (const prog_char*)30},
|
||||
{" Rinse Cycle ", " Seconds ", " Seconds ", (const prog_char*)60, (const prog_char*)31},
|
||||
{" Pump Speed ", " Percentage ", " Percent ", (const prog_char*)100, (const prog_char*)32},
|
||||
{" Pump Ramp ", " Percentage ", " Percent ", (const prog_char*)100, (const prog_char*)33}
|
||||
};
|
||||
|
||||
const unsigned char NumROConfig = 4;
|
||||
|
||||
unsigned char EEPROMConfigRO[NumROConfig] = { //User Modifiable Standard Dechorionation Config Array
|
||||
1, //Values correspond to each cycle above, in same array order
|
||||
0, //Default values here are for initial EEPROM Programming
|
||||
85,
|
||||
85
|
||||
};
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//Arduino Setup////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void setup(){
|
||||
MotorDriver.init(); //Initialize the VNH5019 Motor Driving Shield
|
||||
InitializePins(); //Initialize pins for switches, rotary encoder, and leds
|
||||
Serial.begin(115200); //Start communicating to PC at 115200 baud
|
||||
LcdSerial.begin(9600); //Start communicating with LCD dispaly at 9600 buad
|
||||
delay(TitleTimeout* 500); //Wait for Lcd to initialize
|
||||
FullLcdClear(); //Clear the LCD to remove artifacts
|
||||
FullLcdWrite((unsigned char*)" Tanguay Labs ", (unsigned char*)"Dechorionator #2"); //Show the device name
|
||||
Serial.println("Dechorionator Initialized"); //Debug on Serial
|
||||
delay(TitleTimeout* 1000); //Wait on name screen
|
||||
FullLcdClear(); //Clear the LCD
|
||||
//SaveToEEPROM(); //Used to write initial EEPROM configuration. It should no longer be needed.
|
||||
ReadFromEEPROM(); //Reads user configured settings from EEPROM into config arrays
|
||||
GetInitialEncoderData();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//Main Arduino Program Loop////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void loop(){
|
||||
switch(ArduinoProgram){
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
case ProgramSelection:
|
||||
if(DoneOnce != 1){ ShowProgramListIntro();} //Show an intro screen if the device has just turned on
|
||||
DisplayProgramList(); //Show the currently selected program title
|
||||
if(CheckProgramStart() | CheckConfigButton()){ //If the start button or configuration button are pressed, immediately switch to the new program
|
||||
SelectedConfig = PreviousConfig = 0; //Set config variables to 0 in preperation
|
||||
break; //Immediately break if a button has been pressed
|
||||
}
|
||||
SelectedProgram = ConstrainProgramList(SelectedProgram + ReturnEncoderDirection());//Determine if the encoder has moved, and change the program display if it has
|
||||
break;
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
case StandardDechorionation:
|
||||
EStop = 0;
|
||||
|
||||
//Pronase Cycle 1
|
||||
FullLcdWrite((unsigned char*)" Starting ",(unsigned char*)"Pronase Cycle 1 ");
|
||||
delay(LcdPageDelay*500);
|
||||
CycleSkip = 0;
|
||||
ClearAndRestartStopWatch();
|
||||
CycleSeconds = ((60*EEPROMConfigSD[0]) + EEPROMConfigSD[1]);
|
||||
while(MyStopWatch.elapsed() < CycleSeconds & !EStop & !CycleSkip){
|
||||
for(DriveLoop = RotationMinDriveSpeed ; DriveLoop < MaxDriveSpeed ; DriveLoop = DriveLoop + ((EEPROMConfigSD[7]*MaxRampValue)/100)){
|
||||
MotorDriver.setM1Speed((DriveLoop * EEPROMConfigSD[6])/100);
|
||||
LcdFullWriteString((unsigned char*)" Time Remaining ",(" " + String((CycleSeconds - MyStopWatch.elapsed()), DEC) + " "));
|
||||
if(digitalRead(StopSwitch) == LOW){
|
||||
SoftStopMotor(1);
|
||||
GoToProgramSelection();
|
||||
EStop = 1;
|
||||
break;
|
||||
}
|
||||
if(digitalRead(StartSwitch) == LOW){
|
||||
delay(DebounceTimeout);
|
||||
CycleSkip = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for( ; DriveLoop > RotationMinDriveSpeed ; DriveLoop = DriveLoop - ((EEPROMConfigSD[7]*MaxRampValue)/100)){
|
||||
MotorDriver.setM1Speed((DriveLoop * EEPROMConfigSD[6])/100);
|
||||
LcdFullWriteString((unsigned char*)" Time Remaining ",(" " + String((CycleSeconds - MyStopWatch.elapsed()), DEC) + " "));
|
||||
if(digitalRead(StopSwitch) == LOW){
|
||||
SoftStopMotor(1);
|
||||
GoToProgramSelection();
|
||||
EStop = 1;
|
||||
break;
|
||||
}
|
||||
if(digitalRead(StartSwitch) == LOW){
|
||||
delay(DebounceTimeout);
|
||||
CycleSkip = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
SoftStopMotor(1); //Stops Motor 1, rotation motor
|
||||
|
||||
//Rinse Cycle
|
||||
if(!EStop){
|
||||
FullLcdWrite((unsigned char*)" Starting ",(unsigned char*)" Rinse Cycle ");
|
||||
delay(LcdPageDelay*500);
|
||||
CycleSkip = 0;
|
||||
ClearAndRestartStopWatch();
|
||||
CycleSeconds = ((60*EEPROMConfigSD[2]) + EEPROMConfigSD[3]);
|
||||
|
||||
for(DriveLoop = PumpMinDriveSpeed ; DriveLoop < PumpMaxDriveSpeed ; DriveLoop = DriveLoop + (((EEPROMConfigSD[9]/4)*MaxPumpRampValue)/100)){
|
||||
MotorDriver.setM2Speed((EEPROMConfigSD[8]*DriveLoop)/100);
|
||||
delay(250);
|
||||
}
|
||||
MotorDriver.setM2Speed((EEPROMConfigSD[8]*PumpMaxDriveSpeed)/100);
|
||||
}
|
||||
while(MyStopWatch.elapsed() < CycleSeconds & !EStop & !CycleSkip){
|
||||
LcdFullWriteString((unsigned char*)" Time Remaining ",(" " + String((CycleSeconds - MyStopWatch.elapsed()), DEC) + " "));
|
||||
if(digitalRead(StopSwitch) == LOW){
|
||||
SoftStopMotor(1);
|
||||
GoToProgramSelection();
|
||||
EStop = 1;
|
||||
break;
|
||||
}
|
||||
if(digitalRead(StartSwitch) == LOW){
|
||||
delay(DebounceTimeout);
|
||||
CycleSkip = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
SoftStopMotor(2);
|
||||
|
||||
//Pronase Cycle 2
|
||||
if(!EStop){
|
||||
FullLcdWrite((unsigned char*)" Starting ",(unsigned char*)"Pronase Cycle 2 ");
|
||||
delay(LcdPageDelay*500);
|
||||
CycleSkip = 0;
|
||||
ClearAndRestartStopWatch();
|
||||
CycleSeconds = ((60*EEPROMConfigSD[4]) + EEPROMConfigSD[5]);
|
||||
}
|
||||
while(MyStopWatch.elapsed() < CycleSeconds & !EStop & !CycleSkip){
|
||||
for(DriveLoop = RotationMinDriveSpeed ; DriveLoop < MaxDriveSpeed ; DriveLoop = DriveLoop + ((EEPROMConfigSD[7]*MaxRampValue)/100)){
|
||||
MotorDriver.setM1Speed((DriveLoop * EEPROMConfigSD[6])/100);
|
||||
LcdFullWriteString((unsigned char*)" Time Remaining ",(" " + String((CycleSeconds - MyStopWatch.elapsed()), DEC) + " "));
|
||||
if(digitalRead(StopSwitch) == LOW){
|
||||
SoftStopMotor(1);
|
||||
GoToProgramSelection();
|
||||
EStop = 1;
|
||||
break;
|
||||
}
|
||||
if(digitalRead(StartSwitch) == LOW){
|
||||
delay(DebounceTimeout);
|
||||
CycleSkip = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for( ; DriveLoop > RotationMinDriveSpeed ; DriveLoop = DriveLoop - ((EEPROMConfigSD[7]*MaxRampValue)/100)){
|
||||
MotorDriver.setM1Speed((DriveLoop * EEPROMConfigSD[6])/100);
|
||||
LcdFullWriteString((unsigned char*)" Time Remaining ",(" " + String((CycleSeconds - MyStopWatch.elapsed()), DEC) + " "));
|
||||
if(digitalRead(StopSwitch) == LOW){
|
||||
SoftStopMotor(1);
|
||||
GoToProgramSelection();
|
||||
EStop = 1;
|
||||
break;
|
||||
}
|
||||
if(digitalRead(StartSwitch) == LOW){
|
||||
delay(DebounceTimeout);
|
||||
CycleSkip = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
SoftStopMotor(1); //Stops Motor 1, rotation motor
|
||||
|
||||
|
||||
EStop = 0;
|
||||
GoToProgramSelection();
|
||||
break;
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
case TwoFourDechorionation:
|
||||
|
||||
EStop = 0;
|
||||
|
||||
//Pronase Cycle 1
|
||||
FullLcdWrite((unsigned char*)" Starting ",(unsigned char*)"Pronase Cycle 1 ");
|
||||
delay(LcdPageDelay*500);
|
||||
CycleSkip = 0;
|
||||
ClearAndRestartStopWatch();
|
||||
CycleSeconds = ((60*EEPROMConfigTF[0]) + EEPROMConfigTF[1]);
|
||||
while(MyStopWatch.elapsed() < CycleSeconds & !EStop & !CycleSkip){
|
||||
for(DriveLoop = RotationMinDriveSpeed ; DriveLoop < MaxDriveSpeed ; DriveLoop = DriveLoop + ((EEPROMConfigTF[7]*MaxRampValue)/100)){
|
||||
MotorDriver.setM1Speed((DriveLoop * EEPROMConfigTF[6])/100);
|
||||
LcdFullWriteString((unsigned char*)" Time Remaining ",(" " + String((CycleSeconds - MyStopWatch.elapsed()), DEC) + " "));
|
||||
if(digitalRead(StopSwitch) == LOW){
|
||||
SoftStopMotor(1);
|
||||
GoToProgramSelection();
|
||||
EStop = 1;
|
||||
break;
|
||||
}
|
||||
if(digitalRead(StartSwitch) == LOW){
|
||||
delay(DebounceTimeout);
|
||||
CycleSkip = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for( ; DriveLoop > RotationMinDriveSpeed ; DriveLoop = DriveLoop - ((EEPROMConfigTF[7]*MaxRampValue)/100)){
|
||||
MotorDriver.setM1Speed((DriveLoop * EEPROMConfigTF[6])/100);
|
||||
LcdFullWriteString((unsigned char*)" Time Remaining ",(" " + String((CycleSeconds - MyStopWatch.elapsed()), DEC) + " "));
|
||||
if(digitalRead(StopSwitch) == LOW){
|
||||
SoftStopMotor(1);
|
||||
GoToProgramSelection();
|
||||
EStop = 1;
|
||||
break;
|
||||
}
|
||||
if(digitalRead(StartSwitch) == LOW){
|
||||
delay(DebounceTimeout);
|
||||
CycleSkip = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
SoftStopMotor(1); //Stops Motor 1, rotation motor
|
||||
|
||||
//Rinse Cycle
|
||||
if(!EStop){
|
||||
FullLcdWrite((unsigned char*)" Starting ",(unsigned char*)" Rinse Cycle ");
|
||||
delay(LcdPageDelay*500);
|
||||
CycleSkip = 0;
|
||||
ClearAndRestartStopWatch();
|
||||
CycleSeconds = ((60*EEPROMConfigTF[2]) + EEPROMConfigTF[3]);
|
||||
|
||||
for(DriveLoop = PumpMinDriveSpeed ; DriveLoop < PumpMaxDriveSpeed ; DriveLoop = DriveLoop + ((EEPROMConfigTF[9]*MaxPumpRampValue)/100)){
|
||||
MotorDriver.setM2Speed((EEPROMConfigTF[8]*DriveLoop)/100);
|
||||
}
|
||||
MotorDriver.setM2Speed((EEPROMConfigTF[8]*PumpMaxDriveSpeed)/100);
|
||||
}
|
||||
while(MyStopWatch.elapsed() < CycleSeconds & !EStop & !CycleSkip){
|
||||
LcdFullWriteString((unsigned char*)" Time Remaining ",(" " + String((CycleSeconds - MyStopWatch.elapsed()), DEC) + " "));
|
||||
if(digitalRead(StopSwitch) == LOW){
|
||||
SoftStopMotor(1);
|
||||
GoToProgramSelection();
|
||||
EStop = 1;
|
||||
break;
|
||||
}
|
||||
if(digitalRead(StartSwitch) == LOW){
|
||||
delay(DebounceTimeout);
|
||||
CycleSkip = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
SoftStopMotor(2);
|
||||
|
||||
//Pronase Cycle 2
|
||||
if(!EStop){
|
||||
FullLcdWrite((unsigned char*)" Starting ",(unsigned char*)"Pronase Cycle 2 ");
|
||||
delay(LcdPageDelay*500);
|
||||
CycleSkip = 0;
|
||||
ClearAndRestartStopWatch();
|
||||
CycleSeconds = ((60*EEPROMConfigTF[4]) + EEPROMConfigTF[5]);
|
||||
}
|
||||
while(MyStopWatch.elapsed() < CycleSeconds & !EStop & !CycleSkip){
|
||||
for(DriveLoop = RotationMinDriveSpeed ; DriveLoop < MaxDriveSpeed ; DriveLoop = DriveLoop + ((EEPROMConfigTF[7]*MaxRampValue)/100)){
|
||||
MotorDriver.setM1Speed((DriveLoop * EEPROMConfigTF[6])/100);
|
||||
LcdFullWriteString((unsigned char*)" Time Remaining ",(" " + String((CycleSeconds - MyStopWatch.elapsed()), DEC) + " "));
|
||||
if(digitalRead(StopSwitch) == LOW){
|
||||
SoftStopMotor(1);
|
||||
GoToProgramSelection();
|
||||
EStop = 1;
|
||||
break;
|
||||
}
|
||||
if(digitalRead(StartSwitch) == LOW){
|
||||
delay(DebounceTimeout);
|
||||
CycleSkip = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for( ; DriveLoop > RotationMinDriveSpeed ; DriveLoop = DriveLoop - ((EEPROMConfigTF[7]*MaxRampValue)/100)){
|
||||
MotorDriver.setM1Speed((DriveLoop * EEPROMConfigTF[6])/100);
|
||||
LcdFullWriteString((unsigned char*)" Time Remaining ",(" " + String((CycleSeconds - MyStopWatch.elapsed()), DEC) + " "));
|
||||
if(digitalRead(StopSwitch) == LOW){
|
||||
SoftStopMotor(1);
|
||||
GoToProgramSelection();
|
||||
EStop = 1;
|
||||
break;
|
||||
}
|
||||
if(digitalRead(StartSwitch) == LOW){
|
||||
delay(DebounceTimeout);
|
||||
CycleSkip = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
SoftStopMotor(1); //Stops Motor 1, rotation motor
|
||||
|
||||
|
||||
EStop = 0;
|
||||
GoToProgramSelection();
|
||||
break;
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
case PronaseAndRinse:
|
||||
EStop = 0;
|
||||
|
||||
//Pronase Cycle 1
|
||||
FullLcdWrite((unsigned char*)" Starting ",(unsigned char*)"Pronase Cycle 1 ");
|
||||
delay(LcdPageDelay*500);
|
||||
CycleSkip = 0;
|
||||
ClearAndRestartStopWatch();
|
||||
CycleSeconds = ((60*EEPROMConfigPnR[0]) + EEPROMConfigPnR[1]);
|
||||
while(MyStopWatch.elapsed() < CycleSeconds & !EStop & !CycleSkip){
|
||||
for(DriveLoop = RotationMinDriveSpeed ; DriveLoop < MaxDriveSpeed ; DriveLoop = DriveLoop + ((EEPROMConfigPnR[7]*MaxRampValue)/100)){
|
||||
MotorDriver.setM1Speed((DriveLoop * EEPROMConfigPnR[6])/100);
|
||||
LcdFullWriteString((unsigned char*)" Time Remaining ",(" " + String((CycleSeconds - MyStopWatch.elapsed()), DEC) + " "));
|
||||
if(digitalRead(StopSwitch) == LOW){
|
||||
SoftStopMotor(1);
|
||||
GoToProgramSelection();
|
||||
EStop = 1;
|
||||
break;
|
||||
}
|
||||
if(digitalRead(StartSwitch) == LOW){
|
||||
delay(DebounceTimeout);
|
||||
CycleSkip = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for( ; DriveLoop > RotationMinDriveSpeed ; DriveLoop = DriveLoop - ((EEPROMConfigPnR[7]*MaxRampValue)/100)){
|
||||
MotorDriver.setM1Speed((DriveLoop * EEPROMConfigPnR[6])/100);
|
||||
LcdFullWriteString((unsigned char*)" Time Remaining ",(" " + String((CycleSeconds - MyStopWatch.elapsed()), DEC) + " "));
|
||||
if(digitalRead(StopSwitch) == LOW){
|
||||
SoftStopMotor(1);
|
||||
GoToProgramSelection();
|
||||
EStop = 1;
|
||||
break;
|
||||
}
|
||||
if(digitalRead(StartSwitch) == LOW){
|
||||
delay(DebounceTimeout);
|
||||
CycleSkip = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
SoftStopMotor(1); //Stops Motor 1, rotation motor
|
||||
|
||||
//Rinse Cycle
|
||||
if(!EStop){
|
||||
FullLcdWrite((unsigned char*)" Starting ",(unsigned char*)" Rinse Cycle ");
|
||||
delay(LcdPageDelay*500);
|
||||
CycleSkip = 0;
|
||||
ClearAndRestartStopWatch();
|
||||
CycleSeconds = ((60*EEPROMConfigPnR[2]) + EEPROMConfigPnR[3]);
|
||||
|
||||
for(DriveLoop = PumpMinDriveSpeed ; DriveLoop < PumpMaxDriveSpeed ; DriveLoop = DriveLoop + ((EEPROMConfigPnR[9]*MaxPumpRampValue)/100)){
|
||||
MotorDriver.setM2Speed((EEPROMConfigPnR[8]*DriveLoop)/100);
|
||||
}
|
||||
MotorDriver.setM2Speed((EEPROMConfigPnR[8]*PumpMaxDriveSpeed)/100);
|
||||
}
|
||||
while(MyStopWatch.elapsed() < CycleSeconds & !EStop & !CycleSkip){
|
||||
LcdFullWriteString((unsigned char*)" Time Remaining ",(" " + String((CycleSeconds - MyStopWatch.elapsed()), DEC) + " "));
|
||||
if(digitalRead(StopSwitch) == LOW){
|
||||
SoftStopMotor(1);
|
||||
GoToProgramSelection();
|
||||
EStop = 1;
|
||||
break;
|
||||
}
|
||||
if(digitalRead(StartSwitch) == LOW){
|
||||
delay(DebounceTimeout);
|
||||
CycleSkip = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
SoftStopMotor(2);
|
||||
|
||||
//Pronase Cycle 2
|
||||
if(!EStop){
|
||||
FullLcdWrite((unsigned char*)" Starting ",(unsigned char*)"Pronase Cycle 2 ");
|
||||
delay(LcdPageDelay*500);
|
||||
CycleSkip = 0;
|
||||
ClearAndRestartStopWatch();
|
||||
CycleSeconds = ((60*EEPROMConfigPnR[4]) + EEPROMConfigPnR[5]);
|
||||
}
|
||||
while(MyStopWatch.elapsed() < CycleSeconds & !EStop & !CycleSkip){
|
||||
for(DriveLoop = RotationMinDriveSpeed ; DriveLoop < MaxDriveSpeed ; DriveLoop = DriveLoop + ((EEPROMConfigPnR[7]*MaxRampValue)/100)){
|
||||
MotorDriver.setM1Speed((DriveLoop * EEPROMConfigPnR[6])/100);
|
||||
LcdFullWriteString((unsigned char*)" Time Remaining ",(" " + String((CycleSeconds - MyStopWatch.elapsed()), DEC) + " "));
|
||||
if(digitalRead(StopSwitch) == LOW){
|
||||
SoftStopMotor(1);
|
||||
GoToProgramSelection();
|
||||
EStop = 1;
|
||||
break;
|
||||
}
|
||||
if(digitalRead(StartSwitch) == LOW){
|
||||
delay(DebounceTimeout);
|
||||
CycleSkip = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for( ; DriveLoop > RotationMinDriveSpeed ; DriveLoop = DriveLoop - ((EEPROMConfigPnR[7]*MaxRampValue)/100)){
|
||||
MotorDriver.setM1Speed((DriveLoop * EEPROMConfigPnR[6])/100);
|
||||
LcdFullWriteString((unsigned char*)" Time Remaining ",(" " + String((CycleSeconds - MyStopWatch.elapsed()), DEC) + " "));
|
||||
if(digitalRead(StopSwitch) == LOW){
|
||||
SoftStopMotor(1);
|
||||
GoToProgramSelection();
|
||||
EStop = 1;
|
||||
break;
|
||||
}
|
||||
if(digitalRead(StartSwitch) == LOW){
|
||||
delay(DebounceTimeout);
|
||||
CycleSkip = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
SoftStopMotor(1); //Stops Motor 1, rotation motor
|
||||
|
||||
|
||||
EStop = 0;
|
||||
GoToProgramSelection();
|
||||
break;
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
case RinseOnly:
|
||||
EStop = 0;
|
||||
|
||||
if(digitalRead(StopSwitch) == LOW){
|
||||
SoftStopMotor(1);
|
||||
GoToProgramSelection();
|
||||
EStop = 1;
|
||||
break;
|
||||
}
|
||||
FullLcdWrite((unsigned char*)" Starting ",(unsigned char*)" Rinse Cycle ");
|
||||
|
||||
if(!EStop){
|
||||
delay(LcdPageDelay*500);
|
||||
CycleSkip = 0;
|
||||
ClearAndRestartStopWatch();
|
||||
CycleSeconds = ((60*EEPROMConfigRO[0]) + EEPROMConfigRO[1]);
|
||||
|
||||
for(DriveLoop = PumpMinDriveSpeed ; DriveLoop < PumpMaxDriveSpeed ; DriveLoop = DriveLoop + ((EEPROMConfigRO[3]*MaxPumpRampValue)/100)){
|
||||
MotorDriver.setM2Speed((EEPROMConfigRO[2]*DriveLoop)/100);
|
||||
}
|
||||
MotorDriver.setM2Speed((EEPROMConfigRO[8]*PumpMaxDriveSpeed)/100);
|
||||
}
|
||||
while(MyStopWatch.elapsed() < CycleSeconds & !EStop & !CycleSkip){
|
||||
LcdFullWriteString((unsigned char*)" Time Remaining ",(" " + String((CycleSeconds - MyStopWatch.elapsed()), DEC) + " "));
|
||||
if(digitalRead(StopSwitch) == LOW){
|
||||
SoftStopMotor(1);
|
||||
GoToProgramSelection();
|
||||
EStop = 1;
|
||||
break;
|
||||
}
|
||||
if(digitalRead(StartSwitch) == LOW){
|
||||
delay(DebounceTimeout);
|
||||
CycleSkip = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
SoftStopMotor(2);
|
||||
|
||||
EStop = 0;
|
||||
GoToProgramSelection();
|
||||
break;
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
case SDConfig:
|
||||
ClearAndRestartStopWatch();;
|
||||
|
||||
while(MyStopWatch.elapsed() < (ConfigPageTimeout)){
|
||||
if(PreviousConfig != SelectedConfig ){
|
||||
ClearAndRestartStopWatch();
|
||||
|
||||
}
|
||||
|
||||
ShowSDConfigMainScreen();
|
||||
if(digitalRead(EncoderButton) == LOW){
|
||||
MyStopWatch.stop();
|
||||
delay(DebounceTimeout);
|
||||
PrevVal = NewVal = (int)EEPROMConfigSD[SelectedConfig];
|
||||
ConfigVal = " " + String(NewVal, DEC) + " ";
|
||||
ShowSDConfigIndividualConfigScreen();
|
||||
while(digitalRead(EncoderButton) == HIGH){
|
||||
NewVal = SDConfigIndividualConstrain(NewVal + ReturnEncoderDirection());
|
||||
if(NewVal != PrevVal){
|
||||
PrevVal = NewVal;
|
||||
ConfigVal = " " + String(NewVal, DEC) + " ";
|
||||
ShowSDConfigIndividualConfigScreen();
|
||||
}
|
||||
}
|
||||
EEPROMConfigSD[SelectedConfig] = NewVal;
|
||||
delay(DebounceTimeout);
|
||||
ClearAndRestartStopWatch();
|
||||
|
||||
}
|
||||
PreviousConfig = SelectedConfig;
|
||||
SelectedConfig = SDConfigMainConstrain(SelectedConfig += ReturnEncoderDirection());
|
||||
|
||||
if(digitalRead(StartSwitch) == LOW){
|
||||
GoToProgramSelection();
|
||||
SDConfigSaveToEEPROM();
|
||||
LcdWriteSavingScreen();
|
||||
break;
|
||||
}
|
||||
if(digitalRead(StopSwitch) == LOW){
|
||||
GoToProgramSelection();
|
||||
break;
|
||||
}
|
||||
}
|
||||
GoToProgramSelection();
|
||||
|
||||
break;
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
case TFConfig:
|
||||
ClearAndRestartStopWatch();
|
||||
|
||||
while(MyStopWatch.elapsed() < (ConfigPageTimeout)){
|
||||
if(PreviousConfig != SelectedConfig ){
|
||||
ClearAndRestartStopWatch();
|
||||
|
||||
}
|
||||
|
||||
ShowTFConfigMainScreen();
|
||||
if(digitalRead(EncoderButton) == LOW){
|
||||
MyStopWatch.stop();
|
||||
delay(DebounceTimeout);
|
||||
PrevVal = NewVal = (int)EEPROMConfigTF[SelectedConfig];
|
||||
ConfigVal = " " + String(NewVal, DEC) + " ";
|
||||
ShowTFConfigIndividualConfigScreen();
|
||||
while(digitalRead(EncoderButton) == HIGH){
|
||||
NewVal = TFConfigIndividualConstrain(NewVal + ReturnEncoderDirection());
|
||||
if(NewVal != PrevVal){
|
||||
PrevVal = NewVal;
|
||||
ConfigVal = " " + String(NewVal, DEC) + " ";
|
||||
ShowTFConfigIndividualConfigScreen();
|
||||
}
|
||||
}
|
||||
EEPROMConfigTF[SelectedConfig] = NewVal;
|
||||
delay(DebounceTimeout);
|
||||
ClearAndRestartStopWatch();
|
||||
|
||||
}
|
||||
PreviousConfig = SelectedConfig;
|
||||
SelectedConfig = TFConfigMainConstrain(SelectedConfig += ReturnEncoderDirection());
|
||||
|
||||
if(digitalRead(StartSwitch) == LOW){
|
||||
GoToProgramSelection();
|
||||
TFConfigSaveToEEPROM();
|
||||
LcdWriteSavingScreen();
|
||||
break;
|
||||
}
|
||||
if(digitalRead(StopSwitch) == LOW){
|
||||
GoToProgramSelection();
|
||||
break;
|
||||
}
|
||||
}
|
||||
GoToProgramSelection();
|
||||
|
||||
break;
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
case PnRConfig:
|
||||
ClearAndRestartStopWatch();
|
||||
|
||||
while(MyStopWatch.elapsed() < (ConfigPageTimeout)){
|
||||
if(PreviousConfig != SelectedConfig ){
|
||||
ClearAndRestartStopWatch();
|
||||
|
||||
}
|
||||
|
||||
ShowPnRConfigMainScreen();
|
||||
if(digitalRead(EncoderButton) == LOW){
|
||||
MyStopWatch.stop();
|
||||
delay(DebounceTimeout);
|
||||
PrevVal = NewVal = (int)EEPROMConfigPnR[SelectedConfig];
|
||||
ConfigVal = " " + String(NewVal, DEC) + " ";
|
||||
ShowPnRConfigIndividualConfigScreen();
|
||||
while(digitalRead(EncoderButton) == HIGH){
|
||||
NewVal = PnRConfigIndividualConstrain(NewVal + ReturnEncoderDirection());
|
||||
if(NewVal != PrevVal){
|
||||
PrevVal = NewVal;
|
||||
ConfigVal = " " + String(NewVal, DEC) + " ";
|
||||
ShowPnRConfigIndividualConfigScreen();
|
||||
}
|
||||
}
|
||||
EEPROMConfigPnR[SelectedConfig] = NewVal;
|
||||
delay(DebounceTimeout);
|
||||
ClearAndRestartStopWatch();
|
||||
|
||||
}
|
||||
PreviousConfig = SelectedConfig;
|
||||
SelectedConfig = PnRConfigMainConstrain(SelectedConfig += ReturnEncoderDirection());
|
||||
|
||||
if(digitalRead(StartSwitch) == LOW){
|
||||
GoToProgramSelection();
|
||||
PnRConfigSaveToEEPROM();
|
||||
LcdWriteSavingScreen();
|
||||
break;
|
||||
}
|
||||
if(digitalRead(StopSwitch) == LOW){
|
||||
GoToProgramSelection();
|
||||
break;
|
||||
}
|
||||
}
|
||||
GoToProgramSelection();
|
||||
|
||||
break;
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
case ROConfig:
|
||||
ClearAndRestartStopWatch();
|
||||
|
||||
while(MyStopWatch.elapsed() < (ConfigPageTimeout)){
|
||||
if(PreviousConfig != SelectedConfig ){
|
||||
ClearAndRestartStopWatch();
|
||||
|
||||
}
|
||||
|
||||
ShowROConfigMainScreen();
|
||||
if(digitalRead(EncoderButton) == LOW){
|
||||
MyStopWatch.stop();
|
||||
delay(DebounceTimeout);
|
||||
PrevVal = NewVal = (int)EEPROMConfigRO[SelectedConfig];
|
||||
ConfigVal = " " + String(NewVal, DEC) + " ";
|
||||
ShowROConfigIndividualConfigScreen();
|
||||
while(digitalRead(EncoderButton) == HIGH){
|
||||
NewVal = ROConfigIndividualConstrain(NewVal + ReturnEncoderDirection());
|
||||
if(NewVal != PrevVal){
|
||||
PrevVal = NewVal;
|
||||
ConfigVal = " " + String(NewVal, DEC) + " ";
|
||||
ShowROConfigIndividualConfigScreen();
|
||||
}
|
||||
}
|
||||
EEPROMConfigRO[SelectedConfig] = NewVal;
|
||||
delay(DebounceTimeout);
|
||||
ClearAndRestartStopWatch();
|
||||
|
||||
}
|
||||
PreviousConfig = SelectedConfig;
|
||||
SelectedConfig = ROConfigMainConstrain(SelectedConfig += ReturnEncoderDirection());
|
||||
|
||||
if(digitalRead(StartSwitch) == LOW){
|
||||
GoToProgramSelection();
|
||||
ROConfigSaveToEEPROM();
|
||||
LcdWriteSavingScreen();
|
||||
break;
|
||||
}
|
||||
if(digitalRead(StopSwitch) == LOW){
|
||||
GoToProgramSelection();
|
||||
break;
|
||||
}
|
||||
}
|
||||
GoToProgramSelection();
|
||||
break;
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
default:
|
||||
FullLcdWrite((unsigned char*)"Fatal Error ", (unsigned char*)"Contact Support ");
|
||||
while(1);
|
||||
break;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
void LcdMoveToTop(){
|
||||
LcdSerial.write(254); //Put LCD into move mode
|
||||
LcdSerial.write(128); //Move to the first character of the first row
|
||||
}
|
||||
|
||||
void LcdMoveToBottom(){
|
||||
LcdSerial.write(254); //Put LCD into move mode
|
||||
LcdSerial.write(192); //Move to the first character of the second row
|
||||
}
|
||||
|
||||
void FullLcdClear(){
|
||||
LcdSerial.write(254); //Send special command character
|
||||
LcdSerial.write(1); //Send Clear Screen Command
|
||||
}
|
||||
|
||||
void TopLcdClear(){
|
||||
LcdMoveToTop();
|
||||
LcdSerial.write(" "); //Write a blank 16 character string
|
||||
}
|
||||
|
||||
void BottomLcdClear(){
|
||||
LcdMoveToBottom();
|
||||
LcdSerial.write(" "); //Write a blank 16 character string
|
||||
}
|
||||
|
||||
void FullLcdWrite(unsigned char* TopLcd, unsigned char* BottomLcd){
|
||||
TopLcdWrite(TopLcd);
|
||||
BottomLcdWrite(BottomLcd);
|
||||
}
|
||||
|
||||
void TopLcdWrite(unsigned char *TopLcd){
|
||||
LcdMoveToTop();
|
||||
LcdSerial.write((const char*)TopLcd); //Write string
|
||||
|
||||
}
|
||||
|
||||
void BottomLcdWrite(unsigned char *BottomLcd){
|
||||
LcdMoveToBottom();
|
||||
LcdSerial.write((const char*)BottomLcd); //Write string
|
||||
}
|
||||
|
||||
void LcdFullWriteString(unsigned char* TopLcd, String BottomLcd){
|
||||
TopLcdWrite(TopLcd);
|
||||
LcdMoveToBottom();
|
||||
LcdSerial.print(BottomLcd);
|
||||
}
|
||||
|
||||
void LcdWriteSavingScreen(){
|
||||
FullLcdWrite((unsigned char*)" Settings Saved ",(unsigned char*)" Sucessfully ");
|
||||
delay(1500);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
void ReadFromEEPROM(){
|
||||
SDConfigLoadFromEEPROM();
|
||||
TFConfigLoadFromEEPROM();
|
||||
PnRConfigLoadFromEEPROM();
|
||||
ROConfigLoadFromEEPROM();
|
||||
}
|
||||
|
||||
void SaveToEEPROM(){
|
||||
SDConfigSaveToEEPROM();
|
||||
TFConfigSaveToEEPROM();
|
||||
PnRConfigSaveToEEPROM();
|
||||
ROConfigSaveToEEPROM();
|
||||
}
|
||||
|
||||
void DisplayProgramList(){
|
||||
FullLcdWrite((unsigned char*)pgm_read_word(&ProgramNames[SelectedProgram][0]), (unsigned char*)pgm_read_word(&ProgramNames[SelectedProgram][1]));
|
||||
}
|
||||
|
||||
void GetInitialEncoderData(){
|
||||
EncoderChannelALastValue = EncoderReferenceVariable = digitalRead(EncoderChannelA);
|
||||
}
|
||||
|
||||
signed char ReturnEncoderDirection(){
|
||||
EncoderReferenceVariable = digitalRead(EncoderChannelA);
|
||||
if((EncoderChannelALastValue == LOW) && (EncoderReferenceVariable == HIGH)){
|
||||
if(digitalRead(EncoderChannelB) == LOW){
|
||||
EncoderChannelALastValue = EncoderReferenceVariable;;
|
||||
return 1;
|
||||
}else{
|
||||
EncoderChannelALastValue = EncoderReferenceVariable;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
EncoderChannelALastValue = EncoderReferenceVariable;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ClearAndRestartStopWatch(){
|
||||
MyStopWatch.reset();
|
||||
MyStopWatch.start();
|
||||
}
|
||||
|
||||
void SoftStopMotor(unsigned char Motor){
|
||||
if(Motor == 1){
|
||||
for( ; DriveLoop != RotationMinDriveSpeed ; DriveLoop--){
|
||||
MotorDriver.setM1Speed(DriveLoop);
|
||||
}
|
||||
MotorDriver.setM1Speed(0);
|
||||
}
|
||||
else if(Motor == 2){
|
||||
for( ; DriveLoop != PumpMinDriveSpeed ; DriveLoop--){
|
||||
MotorDriver.setM2Speed(DriveLoop);
|
||||
}
|
||||
MotorDriver.setM2Speed(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
void ShowProgramListIntro(){
|
||||
FullLcdWrite((unsigned char*)"Select Program, ",(unsigned char*)"Press Start "); //Show the start screen
|
||||
delay(TitleTimeout* 1000); //Wait for three seconds
|
||||
FullLcdClear();
|
||||
DoneOnce = 1; //Set DoneOnce to 1 so we know it's been started for the first time
|
||||
EStop = 0;
|
||||
}
|
||||
|
||||
signed char ConstrainProgramList(signed char ProgramList){
|
||||
if(ProgramList == -1){
|
||||
return 3;
|
||||
}else if(ProgramList == 4){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char CheckConfigButton(){
|
||||
if(digitalRead(EncoderButton) == LOW){
|
||||
delay(DebounceTimeout);
|
||||
SelectedConfig = 0;
|
||||
ArduinoProgram = ArduinoPrograms((char)SelectedProgram + 4);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned char CheckProgramStart(){
|
||||
if(digitalRead(StartSwitch) == LOW){
|
||||
ArduinoProgram = (ArduinoPrograms)SelectedProgram; //Change arduino program selector to the new one
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GoToProgramSelection(){
|
||||
delay(DebounceTimeout);
|
||||
ArduinoProgram = ProgramSelection;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
void ShowPnRConfigMainScreen(){
|
||||
FullLcdWrite((unsigned char*)pgm_read_word(&PronaseAndRinseConfig[SelectedConfig][0]), (unsigned char*)pgm_read_word(&PronaseAndRinseConfig[SelectedConfig][1]));
|
||||
}
|
||||
|
||||
void ShowPnRConfigIndividualConfigScreen(){
|
||||
LcdFullWriteString((unsigned char*)pgm_read_word(&PronaseAndRinseConfig[SelectedConfig][2]), ConfigVal);
|
||||
}
|
||||
|
||||
int PnRConfigMainConstrain(signed int Constrain){
|
||||
int Constraint = NumPnRConfig - 1;
|
||||
if(Constrain > Constraint){
|
||||
Constrain = (NumPnRConfig - 1);
|
||||
}else if(Constrain < 0){
|
||||
Constrain = 0;
|
||||
}
|
||||
return Constrain;
|
||||
}
|
||||
|
||||
int PnRConfigIndividualConstrain(signed int Constrain){
|
||||
int Constraint = (int)pgm_read_word(&PronaseAndRinseConfig[SelectedConfig][3]);
|
||||
if(Constrain > Constraint){
|
||||
Constrain = (int)pgm_read_word(&PronaseAndRinseConfig[SelectedConfig][3]);
|
||||
}else if(Constrain < 0){
|
||||
Constrain = 0;
|
||||
}
|
||||
return Constrain;
|
||||
}
|
||||
|
||||
void PnRConfigLoadFromEEPROM(){
|
||||
for(int i = 0 ; i < NumPnRConfig ; i++){
|
||||
EEPROMConfigPnR[i] = EEPROM.read(pgm_read_word(&PronaseAndRinseConfig[i][4]));
|
||||
}
|
||||
}
|
||||
|
||||
void PnRConfigSaveToEEPROM(){
|
||||
for(int i = 0 ; i < NumPnRConfig ; i++){
|
||||
EEPROM.write(pgm_read_word(&PronaseAndRinseConfig[i][4]),EEPROMConfigPnR[i]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
void ShowROConfigMainScreen(){
|
||||
FullLcdWrite((unsigned char*)pgm_read_word(&RinseOnlyConfig[SelectedConfig][0]), (unsigned char*)pgm_read_word(&RinseOnlyConfig[SelectedConfig][1]));
|
||||
}
|
||||
|
||||
void ShowROConfigIndividualConfigScreen(){
|
||||
LcdFullWriteString((unsigned char*)pgm_read_word(&RinseOnlyConfig[SelectedConfig][2]), ConfigVal);
|
||||
}
|
||||
|
||||
int ROConfigMainConstrain(signed int Constrain){
|
||||
int Constraint = NumROConfig - 1;
|
||||
if(Constrain > Constraint){
|
||||
Constrain = (NumROConfig - 1);
|
||||
}else if(Constrain < 0){
|
||||
Constrain = 0;
|
||||
}
|
||||
return Constrain;
|
||||
}
|
||||
|
||||
int ROConfigIndividualConstrain(signed int Constrain){
|
||||
int Constraint = (int)pgm_read_word(&RinseOnlyConfig[SelectedConfig][3]);
|
||||
if(Constrain > Constraint){
|
||||
Constrain = (int)pgm_read_word(&RinseOnlyConfig[SelectedConfig][3]);
|
||||
}else if(Constrain < 0){
|
||||
Constrain = 0;
|
||||
}
|
||||
return Constrain;
|
||||
}
|
||||
|
||||
void ROConfigLoadFromEEPROM(){
|
||||
for(int i = 0 ; i < NumROConfig ; i++){
|
||||
EEPROMConfigRO[i] = EEPROM.read(pgm_read_word(&RinseOnlyConfig[i][4]));
|
||||
}
|
||||
}
|
||||
|
||||
void ROConfigSaveToEEPROM(){
|
||||
for(int i = 0 ; i < NumROConfig ; i++){
|
||||
EEPROM.write(pgm_read_word(&RinseOnlyConfig[i][4]),EEPROMConfigRO[i]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
void InitializePins(){
|
||||
pinMode(StartSwitch, INPUT); //Set Start Switch Pin to Input
|
||||
pinMode(StopSwitch, INPUT); //Set Stop Switch Pin to Input
|
||||
digitalWrite(StartSwitch, HIGH); //Set the internal pullup resistor for the switch
|
||||
digitalWrite(StopSwitch, HIGH); //Set the internal pullup resistor for the switch
|
||||
|
||||
pinMode(EncoderLed, OUTPUT); //Set LED Pin to Output
|
||||
pinMode(EncoderButton, INPUT); //Set Encoder Button Pin to Input
|
||||
pinMode(EncoderChannelA, INPUT); //Set Encoder Channel A Pin to Input
|
||||
pinMode(EncoderChannelB, INPUT); //Set Encoder Channel B Pin to Input
|
||||
digitalWrite(EncoderLed, HIGH);
|
||||
digitalWrite(EncoderButton, HIGH); //Set the internal pullup resistor for the switch
|
||||
digitalWrite(EncoderChannelA, HIGH); //Set the internal pullup resistor for the switch
|
||||
digitalWrite(EncoderChannelB, HIGH); //Set the internal pullup resistor for the switch
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//Program Functions////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//Config Functions/////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void ShowSDConfigMainScreen(){
|
||||
FullLcdWrite((unsigned char*)pgm_read_word(&StandardDechorionationConfig[SelectedConfig][0]), (unsigned char*)pgm_read_word(&StandardDechorionationConfig[SelectedConfig][1]));
|
||||
}
|
||||
|
||||
void ShowSDConfigIndividualConfigScreen(){
|
||||
LcdFullWriteString((unsigned char*)pgm_read_word(&StandardDechorionationConfig[SelectedConfig][2]), ConfigVal);
|
||||
}
|
||||
|
||||
int SDConfigMainConstrain(signed int Constrain){
|
||||
int Constraint = NumSDConfig - 1;
|
||||
if(Constrain > Constraint){
|
||||
Constrain = (NumSDConfig - 1);
|
||||
}else if(Constrain < 0){
|
||||
Constrain = 0;
|
||||
}
|
||||
return Constrain;
|
||||
}
|
||||
|
||||
int SDConfigIndividualConstrain(signed int Constrain){
|
||||
int Constraint = (int)pgm_read_word(&StandardDechorionationConfig[SelectedConfig][3]);
|
||||
if(Constrain > Constraint){
|
||||
Constrain = (int)pgm_read_word(&StandardDechorionationConfig[SelectedConfig][3]);
|
||||
}else if(Constrain < 0){
|
||||
Constrain = 0;
|
||||
}
|
||||
return Constrain;
|
||||
}
|
||||
|
||||
void SDConfigLoadFromEEPROM(){
|
||||
for(int i = 0 ; i < NumSDConfig ; i++){
|
||||
EEPROMConfigSD[i] = EEPROM.read(pgm_read_word(&StandardDechorionationConfig[i][4]));
|
||||
}
|
||||
}
|
||||
|
||||
void SDConfigSaveToEEPROM(){
|
||||
for(int i = 0 ; i < NumSDConfig ; i++){
|
||||
EEPROM.write(pgm_read_word(&StandardDechorionationConfig[i][4]),EEPROMConfigSD[i]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
void ShowTFConfigMainScreen(){
|
||||
FullLcdWrite((unsigned char*)pgm_read_word(&TwoFourDechorionationConfig[SelectedConfig][0]), (unsigned char*)pgm_read_word(&TwoFourDechorionationConfig[SelectedConfig][1]));
|
||||
}
|
||||
|
||||
void ShowTFConfigIndividualConfigScreen(){
|
||||
LcdFullWriteString((unsigned char*)pgm_read_word(&TwoFourDechorionationConfig[SelectedConfig][2]), ConfigVal);
|
||||
}
|
||||
|
||||
int TFConfigMainConstrain(signed int Constrain){
|
||||
int Constraint = NumTFConfig - 1;
|
||||
if(Constrain > Constraint){
|
||||
Constrain = (NumTFConfig - 1);
|
||||
}else if(Constrain < 0){
|
||||
Constrain = 0;
|
||||
}
|
||||
return Constrain;
|
||||
}
|
||||
|
||||
int TFConfigIndividualConstrain(signed int Constrain){
|
||||
int Constraint = (int)pgm_read_word(&TwoFourDechorionationConfig[SelectedConfig][3]);
|
||||
if(Constrain > Constraint){
|
||||
Constrain = (int)pgm_read_word(&TwoFourDechorionationConfig[SelectedConfig][3]);
|
||||
}else if(Constrain < 0){
|
||||
Constrain = 0;
|
||||
}
|
||||
return Constrain;
|
||||
}
|
||||
|
||||
void TFConfigLoadFromEEPROM(){
|
||||
for(int i = 0 ; i < NumTFConfig ; i++){
|
||||
EEPROMConfigTF[i] = EEPROM.read(pgm_read_word(&TwoFourDechorionationConfig[i][4]));
|
||||
}
|
||||
}
|
||||
|
||||
void TFConfigSaveToEEPROM(){
|
||||
for(int i = 0 ; i < NumTFConfig ; i++){
|
||||
EEPROM.write(pgm_read_word(&TwoFourDechorionationConfig[i][4]),EEPROMConfigTF[i]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,528 @@
|
||||
#LyX 2.0 created this file. For more info see http://www.lyx.org/
|
||||
\lyxformat 413
|
||||
\begin_document
|
||||
\begin_header
|
||||
\textclass article
|
||||
\use_default_options true
|
||||
\maintain_unincluded_children false
|
||||
\language english
|
||||
\language_package default
|
||||
\inputencoding auto
|
||||
\fontencoding global
|
||||
\font_roman default
|
||||
\font_sans default
|
||||
\font_typewriter default
|
||||
\font_default_family default
|
||||
\use_non_tex_fonts false
|
||||
\font_sc false
|
||||
\font_osf false
|
||||
\font_sf_scale 100
|
||||
\font_tt_scale 100
|
||||
|
||||
\graphics default
|
||||
\default_output_format default
|
||||
\output_sync 0
|
||||
\bibtex_command default
|
||||
\index_command default
|
||||
\paperfontsize default
|
||||
\spacing single
|
||||
\use_hyperref false
|
||||
\papersize default
|
||||
\use_geometry false
|
||||
\use_amsmath 1
|
||||
\use_esint 1
|
||||
\use_mhchem 1
|
||||
\use_mathdots 1
|
||||
\cite_engine basic
|
||||
\use_bibtopic false
|
||||
\use_indices false
|
||||
\paperorientation portrait
|
||||
\suppress_date true
|
||||
\use_refstyle 1
|
||||
\index Index
|
||||
\shortcut idx
|
||||
\color #008000
|
||||
\end_index
|
||||
\secnumdepth 3
|
||||
\tocdepth 3
|
||||
\paragraph_separation indent
|
||||
\paragraph_indentation default
|
||||
\quotes_language english
|
||||
\papercolumns 1
|
||||
\papersides 1
|
||||
\paperpagestyle default
|
||||
\tracking_changes false
|
||||
\output_changes false
|
||||
\html_math_output 0
|
||||
\html_css_as_file 0
|
||||
\html_be_strict false
|
||||
\end_header
|
||||
|
||||
\begin_body
|
||||
|
||||
\begin_layout Title
|
||||
|
||||
\series bold
|
||||
Dechorionation Table User Manual - Draft
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
\align center
|
||||
Sinhubber Aquatic Research Laboratory
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
\align center
|
||||
Oregon State University
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
\align center
|
||||
Corwin Perren
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
\begin_inset Newpage pagebreak
|
||||
\end_inset
|
||||
|
||||
|
||||
\end_layout
|
||||
|
||||
\begin_layout Part*
|
||||
Firmware Rev 1.0
|
||||
\end_layout
|
||||
|
||||
\begin_layout Section*
|
||||
Using the Dechorionator
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Turn on the Dechorionator using the power switch located on the rear of
|
||||
the unit.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Wait until the device has finished powering up and shows the program selection
|
||||
screen.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Rotate the selection knob until the desired program is shown.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Press the green start button to begin the program.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
To skip a particular cycle in a program, press the start button.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Press the stop button at any time to immediately end the currently running
|
||||
program and return to the selection screen.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Section*
|
||||
Changing Settings
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Rotate the selection knob until the program containing the settings you
|
||||
would like to modify is shown.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Press the knob to enter the settings editor for that program.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Rotate the selection knob until the setting you would like to change is
|
||||
shown.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Press the knob to enter the setting's edit screen.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Rotate the selection knob until the desired value is displayed.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Press the knob to save the new value and return to the settings selection
|
||||
screen.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Repeat for any other settings you would like to change for the selected
|
||||
program.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Saving Settings
|
||||
\end_layout
|
||||
|
||||
\begin_deeper
|
||||
\begin_layout Enumerate
|
||||
Save settings temporarily (Does not persist through reboots).
|
||||
\end_layout
|
||||
|
||||
\begin_deeper
|
||||
\begin_layout Enumerate
|
||||
Return to the settings selection screen.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Press the stop button or wait for a few seconds for it to timeout.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
You will be returned to the main program selection screen and any modified
|
||||
settings will be applied until a reboot.
|
||||
\end_layout
|
||||
|
||||
\end_deeper
|
||||
\begin_layout Enumerate
|
||||
Save settings permanently (Settings will persist through reboots).
|
||||
\end_layout
|
||||
|
||||
\begin_deeper
|
||||
\begin_layout Enumerate
|
||||
Return to the settings selection screen.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Press the start button.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
\begin_inset Quotes eld
|
||||
\end_inset
|
||||
|
||||
Settings Saved Sucessfully
|
||||
\begin_inset Quotes erd
|
||||
\end_inset
|
||||
|
||||
should display breifly before returning to the main program selection screen.
|
||||
\end_layout
|
||||
|
||||
\end_deeper
|
||||
\end_deeper
|
||||
\begin_layout Section*
|
||||
Program Cycle Information and Settings Defaults
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
|
||||
\shape italic
|
||||
Note that cycles are in order and motor settings apply to all cycles for
|
||||
a given program.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Subsubsection*
|
||||
Standard Dechorionation Cycles
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Pronase Cycle 1
|
||||
\end_layout
|
||||
|
||||
\begin_deeper
|
||||
\begin_layout Enumerate
|
||||
Pronase Cycle 1 - Minutes :
|
||||
\series bold
|
||||
6
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Pronase Cycle 1 - Seconds :
|
||||
\series bold
|
||||
30
|
||||
\end_layout
|
||||
|
||||
\end_deeper
|
||||
\begin_layout Enumerate
|
||||
Rinse Cycle
|
||||
\end_layout
|
||||
|
||||
\begin_deeper
|
||||
\begin_layout Enumerate
|
||||
Rinse Cycle - Minutes :
|
||||
\series bold
|
||||
1
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Rinse Cycle - Seconds :
|
||||
\series bold
|
||||
0
|
||||
\end_layout
|
||||
|
||||
\end_deeper
|
||||
\begin_layout Enumerate
|
||||
Pronase Cycle 2
|
||||
\end_layout
|
||||
|
||||
\begin_deeper
|
||||
\begin_layout Enumerate
|
||||
Pronase Cycle 2 - Minutes :
|
||||
\series bold
|
||||
10
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Pronase Cycle 2 - Seconds :
|
||||
\series bold
|
||||
0
|
||||
\end_layout
|
||||
|
||||
\end_deeper
|
||||
\begin_layout Enumerate
|
||||
Motor Settings
|
||||
\end_layout
|
||||
|
||||
\begin_deeper
|
||||
\begin_layout Enumerate
|
||||
Rotation Speed - Percentage :
|
||||
\series bold
|
||||
85
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Rotation Ramping Percentage :
|
||||
\series bold
|
||||
85
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Pump Speed :
|
||||
\series bold
|
||||
50
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Pump ramp :
|
||||
\series bold
|
||||
85
|
||||
\end_layout
|
||||
|
||||
\end_deeper
|
||||
\begin_layout Subsubsection*
|
||||
24 Hour Dechorionation Cycles
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Pronase Cycle 1
|
||||
\end_layout
|
||||
|
||||
\begin_deeper
|
||||
\begin_layout Enumerate
|
||||
Pronase Cycle 1 - Minutes :
|
||||
\series bold
|
||||
3
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Pronase Cycle 1 - Seconds :
|
||||
\series bold
|
||||
0
|
||||
\end_layout
|
||||
|
||||
\end_deeper
|
||||
\begin_layout Enumerate
|
||||
Rinse Cycle
|
||||
\end_layout
|
||||
|
||||
\begin_deeper
|
||||
\begin_layout Enumerate
|
||||
Rinse Cycle - Minutes :
|
||||
\series bold
|
||||
1
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Rinse Cycle - Seconds :
|
||||
\series bold
|
||||
0
|
||||
\end_layout
|
||||
|
||||
\end_deeper
|
||||
\begin_layout Enumerate
|
||||
Pronase Cycle 2
|
||||
\end_layout
|
||||
|
||||
\begin_deeper
|
||||
\begin_layout Enumerate
|
||||
Pronase Cycle 2 - Minutes :
|
||||
\series bold
|
||||
10
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Pronase Cycle 2 - Seconds :
|
||||
\series bold
|
||||
0
|
||||
\end_layout
|
||||
|
||||
\end_deeper
|
||||
\begin_layout Enumerate
|
||||
Motor Settings
|
||||
\end_layout
|
||||
|
||||
\begin_deeper
|
||||
\begin_layout Enumerate
|
||||
Rotation Speed - Percentage :
|
||||
\series bold
|
||||
85
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Rotation Ramping Percentage :
|
||||
\series bold
|
||||
85
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Pump Speed :
|
||||
\series bold
|
||||
50
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Pump ramp :
|
||||
\series bold
|
||||
85
|
||||
\end_layout
|
||||
|
||||
\end_deeper
|
||||
\begin_layout Subsubsection*
|
||||
6 Hour HPF Dechorionation Cycles
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Pronase Cycle 1
|
||||
\end_layout
|
||||
|
||||
\begin_deeper
|
||||
\begin_layout Enumerate
|
||||
Pronase Cycle 1 - Minutes :
|
||||
\series bold
|
||||
6
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Pronase Cycle 1 - Seconds :
|
||||
\series bold
|
||||
30
|
||||
\end_layout
|
||||
|
||||
\end_deeper
|
||||
\begin_layout Enumerate
|
||||
Rinse Cycle
|
||||
\end_layout
|
||||
|
||||
\begin_deeper
|
||||
\begin_layout Enumerate
|
||||
Rinse Cycle - Minutes :
|
||||
\series bold
|
||||
1
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Rinse Cycle - Seconds :
|
||||
\series bold
|
||||
0
|
||||
\end_layout
|
||||
|
||||
\end_deeper
|
||||
\begin_layout Enumerate
|
||||
Pronase Cycle 2
|
||||
\end_layout
|
||||
|
||||
\begin_deeper
|
||||
\begin_layout Enumerate
|
||||
Pronase Cycle 2 - Minutes :
|
||||
\series bold
|
||||
10
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Pronase Cycle 2 - Seconds :
|
||||
\series bold
|
||||
0
|
||||
\end_layout
|
||||
|
||||
\end_deeper
|
||||
\begin_layout Enumerate
|
||||
Motor Settings
|
||||
\end_layout
|
||||
|
||||
\begin_deeper
|
||||
\begin_layout Enumerate
|
||||
Rotation Speed - Percentage :
|
||||
\series bold
|
||||
85
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Rotation Ramping Percentage :
|
||||
\series bold
|
||||
85
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Pump Speed :
|
||||
\series bold
|
||||
50
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Pump ramp :
|
||||
\series bold
|
||||
85
|
||||
\end_layout
|
||||
|
||||
\end_deeper
|
||||
\begin_layout Subsubsection*
|
||||
Rinse Cycle
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Rinse Cycle
|
||||
\end_layout
|
||||
|
||||
\begin_deeper
|
||||
\begin_layout Enumerate
|
||||
Rinse Cycle - Minutes :
|
||||
\series bold
|
||||
1
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Rinse Cycle - Seconds :
|
||||
\series bold
|
||||
0
|
||||
\end_layout
|
||||
|
||||
\end_deeper
|
||||
\begin_layout Enumerate
|
||||
Motor Settings
|
||||
\end_layout
|
||||
|
||||
\begin_deeper
|
||||
\begin_layout Enumerate
|
||||
Pump Speed :
|
||||
\series bold
|
||||
50
|
||||
\end_layout
|
||||
|
||||
\begin_layout Enumerate
|
||||
Pump ramp :
|
||||
\series bold
|
||||
85
|
||||
\end_layout
|
||||
|
||||
\end_deeper
|
||||
\end_body
|
||||
\end_document
|
||||
@@ -0,0 +1,134 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//Includes, Defines, Instantiations, and Global Variables//////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//Includes
|
||||
#include "DualVNH5019MotorShield.h"
|
||||
#include <SoftwareSerial.h>
|
||||
#include <StopWatch.h>
|
||||
|
||||
//Pin Definitions (Arduino Suggested Method)
|
||||
const unsigned char LcdTX = 5; //Pin connected to LCD RX Line
|
||||
const unsigned char LedGreen = A2; //Pin connected to rotary encoder led
|
||||
const unsigned char LedRed = A3; //Pin connected to rotary encoder led
|
||||
|
||||
|
||||
const unsigned char StartSwitch = 11; //Pin connected to start switch
|
||||
const unsigned char StopSwitch = 13; //Pin connected to stop switch
|
||||
|
||||
const unsigned char EncoderChannelA = A4; //Pin connected to channel A of the rotary encoder
|
||||
const unsigned char EncoderChannelB = A5; //Pin connected to channel B of the rotary encoder
|
||||
|
||||
//Instantiations
|
||||
SoftwareSerial LcdSerial(3, LcdTX); //Software Serial Instantiation with Pin 3 as dummy for RX
|
||||
DualVNH5019MotorShield MotorDriver; //Motor Driver Library Instantiation
|
||||
StopWatch MyStopWatch(StopWatch::SECONDS); //StopWatch Instantiation for measuring time
|
||||
|
||||
enum ArduinoStates{ //Enumeration for defining the arduino program states
|
||||
WaitToStart,
|
||||
ChangeConfig,
|
||||
MainProg
|
||||
} ArduinoState = WaitToStart;
|
||||
|
||||
//Global Variables and Constants
|
||||
unsigned char DoneOnce = 0; //Variable to store whether something has happened or not.
|
||||
|
||||
const unsigned int LcdPageDelay = 2; //Seconds to wait before the lcd changes pages.
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//Arduino Setup////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void setup(){
|
||||
MotorDriver.init(); //Initialize the VNH5019 Motor Driving Shield
|
||||
InitializePins(); //Initialize pins for switches, rotary encoder, and leds
|
||||
|
||||
Serial.begin(115200); //Start communicating to PC at 115200 baud
|
||||
|
||||
LcdSerial.begin(9600); //Start communicating with LCD dispaly at 9600 buad
|
||||
FullLcdClear();
|
||||
FullLcdWrite("Tanguay Labs", "Dechlorinator"); //Show the device name
|
||||
Serial.print("Dechlorinator Initialized");
|
||||
delay(5000); //Wait on name screen for five seconds
|
||||
FullLcdClear(); //Clear the LCD
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//Main Arduino Program Loop////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void loop(){
|
||||
switch(ArduinoState){
|
||||
case WaitToStart:
|
||||
if(DoneOnce != 1){ //Check to see if the stopwatch needs to be started
|
||||
MyStopWatch.reset(); //Reset the stopwatch
|
||||
MyStopWatch.start(); //Start the stopwatch
|
||||
DoneOnce = 1; //Set DoneOnce to 1 so we know it's been started for the first time
|
||||
}
|
||||
|
||||
if(MyStopWatch.elapsed() < LcdPageDelay){ //Check if the time on the stopwatch is longer than our page delay
|
||||
FullLcdWrite(" Press Start To "," Begin "); //Show the start screen
|
||||
}else{ //If the time is over the page delay, switch to the config info screen
|
||||
FullLcdWrite(" Press Knob To ","Change Settings "); //Show the config info screen
|
||||
if(MyStopWatch.elapsed() > (2 * LcdPageDelay)){ //Check to see if the time is longer than two page delays
|
||||
MyStopWatch.reset(); //Reset the stopwatch to 0
|
||||
MyStopWatch.start(); //Start the stopwatch again
|
||||
}
|
||||
}
|
||||
|
||||
if(digitalRead(StartSwitch) == 0){ //Check to see if start button has been pressed
|
||||
ArduinoState = MainProg; //Switch to the main dechlorinator program
|
||||
}
|
||||
|
||||
if(digitalRead(StartSwitch) == 0){ //Check to see if start button has been pressed
|
||||
ArduinoState = MainProg; //Switch to the main dechlorinator program
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
/*
|
||||
lcdSerial.write(254);
|
||||
lcdSerial.write(128);
|
||||
lcdSerial.write("Press Start");
|
||||
lcdSerial.write(254);
|
||||
lcdSerial.write(192);
|
||||
lcdSerial.print("To Begin");
|
||||
if(digitalRead(11) == 0){
|
||||
for (int i = 0; i <= 400; i++)
|
||||
{
|
||||
md.setM1Speed(i);
|
||||
if (i%200 == 100)
|
||||
{
|
||||
Serial.print("M1 current: ");
|
||||
Serial.println(md.getM1CurrentMilliamps());
|
||||
lcdClear();
|
||||
lcdSerial.write(254);
|
||||
lcdSerial.write(128);
|
||||
lcdSerial.write("Motor 1 Current:");
|
||||
lcdSerial.write(254);
|
||||
lcdSerial.write(192);
|
||||
lcdSerial.print(md.getM1CurrentMilliamps());
|
||||
}
|
||||
delay(5);
|
||||
if(i == 400){
|
||||
while(1){
|
||||
Serial.print("M1 current: ");
|
||||
Serial.println(md.getM1CurrentMilliamps());
|
||||
lcdClear();
|
||||
lcdSerial.write(254);
|
||||
lcdSerial.write(128);
|
||||
lcdSerial.write("Motor 1 Current:");
|
||||
lcdSerial.write(254);
|
||||
lcdSerial.write(192);
|
||||
lcdSerial.print(md.getM1CurrentMilliamps());
|
||||
delay(100);
|
||||
if(digitalRead(3) == 0){
|
||||
i = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
void LcdMoveToTop(){
|
||||
LcdSerial.write(254); //Put LCD into move mode
|
||||
LcdSerial.write(128); //Move to the first character of the first row
|
||||
}
|
||||
|
||||
void LcdMoveToBottom(){
|
||||
LcdSerial.write(254); //Put LCD into move mode
|
||||
LcdSerial.write(192); //Move to the first character of the second row
|
||||
}
|
||||
|
||||
void FullLcdClear(){
|
||||
LcdSerial.write(254); //Send special command character
|
||||
LcdSerial.write(1); //Send Clear Screen Command
|
||||
}
|
||||
|
||||
void TopLcdClear(){
|
||||
LcdMoveToTop();
|
||||
LcdSerial.write(" "); //Write a blank 16 character string
|
||||
}
|
||||
|
||||
void BottomLcdClear(){
|
||||
LcdMoveToBottom();
|
||||
LcdSerial.write(" "); //Write a blank 16 character string
|
||||
}
|
||||
|
||||
void FullLcdWrite(const char* TopLcd, const char* BottomLcd){
|
||||
TopLcdWrite(TopLcd);
|
||||
BottomLcdWrite(BottomLcd);
|
||||
}
|
||||
|
||||
void TopLcdWrite(const char *TopLcd){
|
||||
/*
|
||||
unsigned char string[16];
|
||||
Serial.write("Size of string: ");
|
||||
Serial.write(sizeof(TopLcd));
|
||||
delay(5000);
|
||||
for(int i = 0 ; i < sizeof(TopLcd) ; i++){
|
||||
string[i] = TopLcd[i];
|
||||
}
|
||||
|
||||
if(sizeof(TopLcd) < 16){
|
||||
for(int i = sizeof(TopLcd) ; i < 16 ; i++){
|
||||
string[i] = 32;
|
||||
}
|
||||
}
|
||||
*/
|
||||
LcdMoveToTop();
|
||||
LcdSerial.write(TopLcd); //Write string
|
||||
|
||||
}
|
||||
|
||||
void BottomLcdWrite(const char *BottomLcd){
|
||||
LcdMoveToBottom();
|
||||
LcdSerial.write(BottomLcd); //Write string
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
I was very new to programming at the time. Also, I had no clue how to spell dechorionator. XD
|
||||
@@ -0,0 +1,12 @@
|
||||
void InitializePins(){
|
||||
pinMode(LedGreen, OUTPUT); //Set Green LED Pin to Output
|
||||
pinMode(LedRed, OUTPUT); //Set Red LED Pin to Output
|
||||
|
||||
pinMode(StartSwitch, INPUT); //Set Start Switch Pin to Input
|
||||
pinMode(StopSwitch, INPUT); //Set Stop Switch Pin to Input
|
||||
digitalWrite(StartSwitch, HIGH); //Set the internal pullup resistor for the switch
|
||||
digitalWrite(StopSwitch, HIGH); //Same for this one
|
||||
|
||||
pinMode(EncoderChannelA, INPUT); //Set Encoder Channel A Pin to Input
|
||||
pinMode(EncoderChannelB, INPUT); //Set Encoder Channel B Pin to Input
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Atmel Studio Solution File, Format Version 11.00
|
||||
Project("{E66E83B9-2572-4076-B26E-6BE79FF3018A}") = "DechorionatorV1.1", "DechorionatorV1.1.cppproj", "{C0A89A51-65B6-4173-AE27-4E91C9089ABF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|AVR = Debug|AVR
|
||||
Release|AVR = Release|AVR
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{C0A89A51-65B6-4173-AE27-4E91C9089ABF}.Debug|AVR.ActiveCfg = Debug|AVR
|
||||
{C0A89A51-65B6-4173-AE27-4E91C9089ABF}.Debug|AVR.Build.0 = Debug|AVR
|
||||
{C0A89A51-65B6-4173-AE27-4E91C9089ABF}.Release|AVR.ActiveCfg = Release|AVR
|
||||
{C0A89A51-65B6-4173-AE27-4E91C9089ABF}.Release|AVR.Build.0 = Release|AVR
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Binary file not shown.
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* DechorionatorV1.cpp
|
||||
*
|
||||
* Created: 7/30/2014 4:55:13 PM
|
||||
* Author: corwin
|
||||
*/
|
||||
#define F_CPU 16000000UL
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
#include "DefineMacrosAndPinDefs.h"
|
||||
#include "SoftLCD.h"
|
||||
#include "StepperClass.h"
|
||||
#include "PumpClass.h"
|
||||
#include "EncoderClass.h"
|
||||
#include "InterruptServiceRoutines.h"
|
||||
|
||||
SoftLCD LCD(&LCD_TX_PORT, &LCD_TX_DDR, P_LCD_TX, &LCD_PWR_PORT, &LCD_PWR_DDR, P_LCD_PWR);
|
||||
StepperClass Stepper(&STEPPER_EN_PORT, &STEPPER_EN_DDR, P_STEPPER_EN,
|
||||
&STEPPER_DIR_PORT, &STEPPER_DIR_DDR, P_STEPPER_DIR,
|
||||
&STEPPER_STEP_PORT, &STEPPER_STEP_DDR, P_STEPPER_STEP,
|
||||
&STEPPER_FAULT_PORT, &STEPPER_FAULT_DDR, P_STEPPER_FAULT,
|
||||
&STEPPER_M0_PORT, &STEPPER_M0_DDR, P_STEPPER_M0,
|
||||
&STEPPER_M1_PORT, &STEPPER_M1_DDR, P_STEPPER_M1,
|
||||
&STEPPER_M2_PORT, &STEPPER_M2_DDR, P_STEPPER_M2
|
||||
);
|
||||
|
||||
char TopTemp[17];
|
||||
char BottomTemp[17];
|
||||
|
||||
void TemporaryInit(){
|
||||
//////////Pump Initialization//////////
|
||||
PUMP_PWR_INIT();
|
||||
//////////End Pump Initialization//////////
|
||||
|
||||
//////////Rotary Encoder Initialization//////////
|
||||
ENCODER_A_INIT();
|
||||
|
||||
ENCODER_B_INIT();
|
||||
|
||||
ENCODER_BUTTON_INIT();
|
||||
//////////End Rotary Encoder Initialization//////////
|
||||
|
||||
|
||||
//////////Hardware Serial Initialization//////////
|
||||
UART_TX_INIT();
|
||||
UART_RX_INIT();
|
||||
//////////End Hardware Serial Initialization//////////
|
||||
|
||||
|
||||
//////////Control Switch Initialization//////////
|
||||
SWITCH_TOP_INIT();
|
||||
SWITCH_BOTTOM_INIT();
|
||||
//////////End Control Switch Initilization//////////
|
||||
|
||||
}
|
||||
|
||||
int TimeCount = 0;
|
||||
|
||||
int i = 0;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
TemporaryInit();
|
||||
TCCR2A = 0;
|
||||
TCCR2B = ((1 << CS22) | (1 << CS21) | (1 << CS20));
|
||||
TCNT2 = 0;
|
||||
TIMSK2 = (1 << TOIE0);
|
||||
|
||||
sei(); //Enable all system interrupts
|
||||
|
||||
//////////Startup Display and System Initialization//////////
|
||||
LCD.showNameScreen();
|
||||
|
||||
LCD.setTopText(" Time ");
|
||||
STEPPER_EN_SET();
|
||||
while(1)
|
||||
{
|
||||
for(int i = 2000 ; i > 1200 ; i--){
|
||||
LCD.show();
|
||||
snprintf(BottomTemp, 16, "%d", TimeCount);
|
||||
LCD.setBottomText(BottomTemp);
|
||||
OCR1A = i;
|
||||
_delay_us(2000);
|
||||
if(SWITCH_TOP_GET() || SWITCH_BOTTOM_GET()){
|
||||
STEPPER_EN_SET();
|
||||
}else{
|
||||
STEPPER_EN_CLR();
|
||||
}
|
||||
}
|
||||
for(int i = 1200 ; i < 2000 ; i++){
|
||||
LCD.show();
|
||||
snprintf(BottomTemp, 16, "%d", TimeCount);
|
||||
LCD.setBottomText(BottomTemp);
|
||||
OCR1A = i;
|
||||
_delay_us(2000);
|
||||
if(SWITCH_TOP_GET() || SWITCH_BOTTOM_GET()){
|
||||
STEPPER_EN_SET();
|
||||
}else{
|
||||
STEPPER_EN_CLR();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectVersion>6.2</ProjectVersion>
|
||||
<ToolchainName>com.Atmel.AVRGCC8.CPP</ToolchainName>
|
||||
<ProjectGuid>{c0a89a51-65b6-4173-ae27-4e91c9089abf}</ProjectGuid>
|
||||
<avrdevice>ATmega328</avrdevice>
|
||||
<avrdeviceseries>none</avrdeviceseries>
|
||||
<OutputType>Executable</OutputType>
|
||||
<Language>CPP</Language>
|
||||
<OutputFileName>$(MSBuildProjectName)</OutputFileName>
|
||||
<OutputFileExtension>.elf</OutputFileExtension>
|
||||
<OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>
|
||||
<AssemblyName>DechorionatorV1.1</AssemblyName>
|
||||
<Name>DechorionatorV1.1</Name>
|
||||
<RootNamespace>DechorionatorV1.1</RootNamespace>
|
||||
<ToolchainFlavour>Native</ToolchainFlavour>
|
||||
<KeepTimersRunning>true</KeepTimersRunning>
|
||||
<OverrideVtor>false</OverrideVtor>
|
||||
<CacheFlash>true</CacheFlash>
|
||||
<ProgFlashFromRam>true</ProgFlashFromRam>
|
||||
<RamSnippetAddress>0x20000000</RamSnippetAddress>
|
||||
<UncachedRange />
|
||||
<OverrideVtorValue>exception_table</OverrideVtorValue>
|
||||
<BootSegment>2</BootSegment>
|
||||
<eraseonlaunchrule>0</eraseonlaunchrule>
|
||||
<AsfFrameworkConfig>
|
||||
<framework-data xmlns="">
|
||||
<options />
|
||||
<configurations />
|
||||
<files />
|
||||
<documentation help="" />
|
||||
<offline-documentation help="" />
|
||||
<dependencies>
|
||||
<content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.18.1" />
|
||||
</dependencies>
|
||||
</framework-data>
|
||||
</AsfFrameworkConfig>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<ToolchainSettings>
|
||||
<AvrGccCpp>
|
||||
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
|
||||
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
|
||||
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
|
||||
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
|
||||
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
|
||||
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
|
||||
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
|
||||
<avrgcc.compiler.symbols.DefSymbols>
|
||||
<ListValues>
|
||||
<Value>NDEBUG</Value>
|
||||
</ListValues>
|
||||
</avrgcc.compiler.symbols.DefSymbols>
|
||||
<avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
|
||||
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
|
||||
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
|
||||
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
|
||||
<avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned>
|
||||
<avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned>
|
||||
<avrgcccpp.compiler.symbols.DefSymbols>
|
||||
<ListValues>
|
||||
<Value>NDEBUG</Value>
|
||||
</ListValues>
|
||||
</avrgcccpp.compiler.symbols.DefSymbols>
|
||||
<avrgcccpp.compiler.optimization.level>Optimize for size (-Os)</avrgcccpp.compiler.optimization.level>
|
||||
<avrgcccpp.compiler.optimization.PackStructureMembers>True</avrgcccpp.compiler.optimization.PackStructureMembers>
|
||||
<avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>
|
||||
<avrgcccpp.compiler.warnings.AllWarnings>True</avrgcccpp.compiler.warnings.AllWarnings>
|
||||
<avrgcccpp.linker.libraries.Libraries>
|
||||
<ListValues>
|
||||
<Value>libm</Value>
|
||||
</ListValues>
|
||||
</avrgcccpp.linker.libraries.Libraries>
|
||||
</AvrGccCpp>
|
||||
</ToolchainSettings>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<ToolchainSettings>
|
||||
<AvrGccCpp>
|
||||
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
|
||||
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
|
||||
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
|
||||
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
|
||||
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
|
||||
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
|
||||
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
|
||||
<avrgcc.compiler.symbols.DefSymbols>
|
||||
<ListValues>
|
||||
<Value>DEBUG</Value>
|
||||
</ListValues>
|
||||
</avrgcc.compiler.symbols.DefSymbols>
|
||||
<avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>
|
||||
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
|
||||
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
|
||||
<avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
|
||||
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
|
||||
<avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned>
|
||||
<avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned>
|
||||
<avrgcccpp.compiler.symbols.DefSymbols>
|
||||
<ListValues>
|
||||
<Value>DEBUG</Value>
|
||||
</ListValues>
|
||||
</avrgcccpp.compiler.symbols.DefSymbols>
|
||||
<avrgcccpp.compiler.optimization.level>Optimize (-O1)</avrgcccpp.compiler.optimization.level>
|
||||
<avrgcccpp.compiler.optimization.PackStructureMembers>True</avrgcccpp.compiler.optimization.PackStructureMembers>
|
||||
<avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>
|
||||
<avrgcccpp.compiler.optimization.DebugLevel>Default (-g2)</avrgcccpp.compiler.optimization.DebugLevel>
|
||||
<avrgcccpp.compiler.warnings.AllWarnings>True</avrgcccpp.compiler.warnings.AllWarnings>
|
||||
<avrgcccpp.linker.libraries.Libraries>
|
||||
<ListValues>
|
||||
<Value>libm</Value>
|
||||
</ListValues>
|
||||
</avrgcccpp.linker.libraries.Libraries>
|
||||
<avrgcccpp.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcccpp.assembler.debugging.DebugLevel>
|
||||
</AvrGccCpp>
|
||||
</ToolchainSettings>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DechorionatorV1.1.cpp">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DefineMacrosAndPinDefs.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="EncoderClass.cpp">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="EncoderClass.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="InterruptServiceRoutines.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MegaUART.cpp">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MegaUART.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="PumpClass.cpp">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="PumpClass.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SoftLCD.cpp">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SoftLCD.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="StepperClass.cpp">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="StepperClass.h">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* DefineMacrosAndPinDefs.h
|
||||
*
|
||||
* Created: 7/30/2014 4:56:56 PM
|
||||
* Author: corwin
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DEFINEMACROSANDPINDEFS_H_
|
||||
#define DEFINEMACROSANDPINDEFS_H_
|
||||
|
||||
//////////LCD Definitions//////////
|
||||
#define P_LCD_TX PORTB0 //Pin B0 runs tx pin for serial lcd
|
||||
#define LCD_TX_PORT PORTB //Port that the tx lcd pin is on
|
||||
#define LCD_TX_DDR DDRB //Direction port that the tx lcd pin is on
|
||||
#define LCD_TX_BM (1 << P_LCD_TX) //Bit mask for pin
|
||||
#define LCD_TX_INIT() DDRB |= LCD_TX_BM //Sets tx pin to output
|
||||
#define LCD_TX_SET() PORTB |= LCD_TX_BM //Macro for setting pin high
|
||||
#define LCD_TX_CLR() PORTB &= ~LCD_TX_BM //Macro for setting pin low
|
||||
|
||||
|
||||
#define P_LCD_PWR PORTC5 //Pin C5 controls the power to the lcd through a mosfet
|
||||
#define LCD_PWR_PORT PORTC //Port that the lcd power pin is on
|
||||
#define LCD_PWR_DDR DDRC //Direction port that the lcd power pin is on
|
||||
#define LCD_PWR_BM (1 << P_LCD_PWR) //Bit mask for pin
|
||||
#define LCD_PWR_INIT() DDRC |= LCD_PWR_BM //Sets lcd power control pin to an output
|
||||
#define LCD_PWR_SET() PORTC |= LCD_PWR_BM //Macro for setting pin high
|
||||
#define LCD_PWR_CLR() PORTC &= ~LCD_PWR_BM //Macro for setting pin low
|
||||
//////////End LCD Definitions
|
||||
|
||||
//////////Pump Definitions//////////
|
||||
#define P_PUMP_PWR PORTD5 //Pin D5 controls power to the water pump through a mosfet
|
||||
#define PUMP_PWR_BM (1 << P_PUMP_PWR) //Bit mask for pin
|
||||
#define PUMP_PWR_INIT() DDRD |= PUMP_PWR_BM //Sets pump power control pin to an output
|
||||
#define PUMP_PWR_SET() PORTD |= PUMP_PWR_BM //Macro for setting pin high
|
||||
#define PUMP_PWR_CLR() PORTD &= ~PUMP_PWR_BM //Macro for setting pin low
|
||||
//////////End Pump Definitions//////////
|
||||
|
||||
//////////DRV8825 Stepper Motor Driver Definitions//////////
|
||||
#define P_STEPPER_DIR PORTD6 //Pin D6 controls the direction of the stepper motor
|
||||
#define STEPPER_DIR_PORT PORTD
|
||||
#define STEPPER_DIR_DDR DDRD
|
||||
#define STEPPER_DIR_BM (1 << P_STEPPER_DIR) //Bit mask for pin
|
||||
#define STEPPER_DIR_INIT() DDRD |= STEPPER_DIR_BM //Sets stepper direction pin to an output
|
||||
#define STEPPER_DIR_SET() PORTD |= STEPPER_DIR_BM //Macro for setting pin high
|
||||
#define STEPPER_DIR_CLR() PORTD &= ~STEPPER_DIR_BM //Macro for setting pin low
|
||||
|
||||
|
||||
#define P_STEPPER_STEP PORTD7 //Pin D7 controls the step pin of the driver
|
||||
#define STEPPER_STEP_PORT PORTD
|
||||
#define STEPPER_STEP_DDR DDRD
|
||||
#define STEPPER_STEP_BM (1 << P_STEPPER_STEP) //Bit mask for pin
|
||||
#define STEPPER_STEP_INIT() DDRD |= STEPPER_STEP_BM //Sets the step pin to an output
|
||||
#define STEPPER_STEP_SET() PORTD |= STEPPER_STEP_BM //Macro for setting pin high
|
||||
#define STEPPER_STEP_CLR() PORTD &= ~STEPPER_STEP_BM //Macro for setting pin low
|
||||
|
||||
|
||||
#define P_STEPPER_EN PORTC1 //Pin C1 controls whether the stepper motor is enabled and running or not
|
||||
#define STEPPER_EN_PORT PORTC
|
||||
#define STEPPER_EN_DDR DDRC
|
||||
#define STEPPER_EN_BM (1 << P_STEPPER_EN) //Bit mask for pin
|
||||
#define STEPPER_EN_INIT() DDRC |= STEPPER_EN_BM //Sets stepper enable control pin to an output
|
||||
#define STEPPER_EN_SET() PORTC &= ~STEPPER_EN_BM //Macro for setting pin high (Note inverted logic!!!)
|
||||
#define STEPPER_EN_CLR() PORTC |= STEPPER_EN_BM //Macro for setting pin low (Note inverted logic!!!)
|
||||
|
||||
|
||||
#define P_STEPPER_FAULT PORTC0 //Pin C0 senses whether the stepper driver is in a fault state due to over current or over temp conditions
|
||||
#define STEPPER_FAULT_PORT PORTC
|
||||
#define STEPPER_FAULT_DDR DDRC
|
||||
#define STEPPER_FAULT_BM (1 << P_STEPPER_FAULT) //Bit mask for pin
|
||||
#define STEPPER_FAULT_INIT() DDRC &= ~STEPPER_FAULT_BM //Sets stepper fault check pin to an input (May need to enable internal pull up?)
|
||||
#define STEPPER_FAULT_GET() !(PINC & STEPPER_FAULT_BM) //Returns true if in fault state (0 is fault, 1 is non-fault)
|
||||
|
||||
|
||||
|
||||
#define P_STEPPER_M0 PORTC2 //Pin C2 sets the lowest bit of the driver micro-stepping
|
||||
#define STEPPER_M0_PORT PORTC
|
||||
#define STEPPER_M0_DDR DDRC
|
||||
#define STEPPER_M0_BM (1 << P_STEPPER_M0) //Bit mask for pin
|
||||
#define STEPPER_M0_INIT() DDRC |= STEPPER_M0_BM //Sets the micro-step pin to an output
|
||||
#define STEPPER_M0_SET() PORTC |= STEPPER_M0_BM //Macro for setting pin high
|
||||
#define STEPPER_M0_CLR() PORTC &= ~STEPPER_M0_BM //Macro for setting pin low
|
||||
|
||||
|
||||
#define P_STEPPER_M1 PORTC3 //Pin C3 sets the middle bit of the driver micro-stepping
|
||||
#define STEPPER_M1_PORT PORTC
|
||||
#define STEPPER_M1_DDR DDRC
|
||||
#define STEPPER_M1_BM (1 << P_STEPPER_M1) //Bit mask for pin
|
||||
#define STEPPER_M1_INIT() DDRC |= STEPPER_M1_BM //Sets the micro-step pin to an output
|
||||
#define STEPPER_M1_SET() PORTC |= STEPPER_M1_BM //Macro for setting pin high
|
||||
#define STEPPER_M1_CLR() PORTC &= ~STEPPER_M1_BM //Macro for setting pin low
|
||||
|
||||
|
||||
#define P_STEPPER_M2 PORTC4 //Pin C4 sets the upper bit of the driver micro-stepping
|
||||
#define STEPPER_M2_PORT PORTC
|
||||
#define STEPPER_M2_DDR DDRC
|
||||
#define STEPPER_M2_BM (1 << P_STEPPER_M2) //Bit mask for pin
|
||||
#define STEPPER_M2_INIT() DDRC |= STEPPER_M2_BM //Sets the micro-step pin to an output
|
||||
#define STEPPER_M2_SET() PORTC |= STEPPER_M2_BM //Macro for setting pin high
|
||||
#define STEPPER_M2_CLR() PORTC &= ~STEPPER_M2_BM //Macro for setting pin low
|
||||
//////////End DRV8825 Stepper Motor Driver Definitions//////////
|
||||
|
||||
//////////Rotary Encoder Definitions//////////
|
||||
#define P_ENCODER_A PORTD2 //Pin D2 senses the state for channel A on the rotary encoder
|
||||
#define ENCODER_A_BM (1 << P_ENCODER_A) //Bit mask for pin
|
||||
#define ENCODER_A_INIT() {DDRD &= ~ENCODER_A_BM; PORTD |= ENCODER_A_BM;} //Sets channel A pin to an input and enables the internal pull up resistor
|
||||
#define ENCODER_A_GET() !(PIND & ENCODER_A_BM) //Returns state of the pin (Note inverted logic!!! Makes gray code logic less confusing...)
|
||||
|
||||
|
||||
#define P_ENCODER_B PORTD3 //Pin D3 sense the state for channel B on the rotary encoder
|
||||
#define ENCODER_B_BM (1 << P_ENCODER_B) //Bit mask for pin
|
||||
#define ENCODER_B_INIT() {DDRD &= ~ENCODER_B_BM; PORTD |= ENCODER_B_BM;} //Sets channel B pin to an input and enables the internal pull up resistor
|
||||
#define ENCODER_B_GET() !(PIND & ENCODER_B_BM) //Returns state of the pin (Note inverted logic!!! Makes gray code logic less confusing...)
|
||||
|
||||
|
||||
#define P_ENCODER_BUTTON PORTD4 //Pin D4 senses whether the tactile button on the rotary encoder has been pushed
|
||||
#define ENCODER_BUTTON_BM (1 << P_ENCODER_BUTTON) //Bit mask for pin
|
||||
#define ENCODER_BUTTON_INIT() {DDRD &= ~ENCODER_BUTTON_BM; PORTD |= ENCODER_BUTTON_BM;} //Sets encoder button pin to an input and enables the internal pull up resistor
|
||||
#define ENCODER_BUTTON_GET() !(PIND & ENCODER_BUTTON_BM) //Returns whether the button has been pushed (Note inverted logic!!!)
|
||||
//////////End Rotary Encoder Definitions//////////
|
||||
|
||||
//////////Hardware Serial Definitions//////////
|
||||
#define P_UART_TX PORTD1 //Pin D1 is the transmit line for the hardware uart
|
||||
#define UART_TX_BM (1 << P_UART_TX) //Bit mask for pin
|
||||
#define UART_TX_INIT() DDRD |= UART_TX_BM //Sets the transmit line to an output
|
||||
|
||||
|
||||
#define P_UART_RX PORTD0 //Pin D0 is the receive line for the hardware uart
|
||||
#define UART_RX_BM (1 << P_UART_RX) //Bit mask for pin
|
||||
#define UART_RX_INIT() DDRD &= ~UART_RX_BM //Sets the receive line to an input
|
||||
//////////End Hardware Serial Definitions//////////
|
||||
|
||||
//////////Control Switch Definitions//////////
|
||||
#define P_SWITCH_TOP PORTB2 //Pin B1 senses whether the top button on the control switch has been pushed (RINSE)
|
||||
#define SWITCH_TOP_BM (1 << P_SWITCH_TOP) //Bit mask for pin
|
||||
#define SWITCH_TOP_INIT() {DDRB |= SWITCH_TOP_BM; PORTB |= SWITCH_TOP_BM;} //Sets the button to an input and enables the internal pull up resistor
|
||||
#define SWITCH_TOP_GET() !(PINB & SWITCH_TOP_BM) //Returns whether the button has been pushed (Note inverted logic!!!)
|
||||
|
||||
|
||||
#define P_SWITCH_BOTTOM PORTB1 //Pin B2 senses whether the bottom button on the control switch has been pushed (ESTOP)
|
||||
#define SWITCH_BOTTOM_BM (1 << P_SWITCH_BOTTOM) //Bit mask for pin
|
||||
#define SWITCH_BOTTOM_INIT() {DDRB |= SWITCH_BOTTOM_BM; PORTB |= SWITCH_BOTTOM_BM;} //Sets the button to an input and enables the internal pull up resistor
|
||||
#define SWITCH_BOTTOM_GET() !(PINB & SWITCH_BOTTOM_BM) //Returns whether the button has been pushed (Note inverted logic!!!)
|
||||
//////////Control Switch Definitions//////////
|
||||
|
||||
|
||||
#endif /* DEFINEMACROSANDPINDEFS_H_ */
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* EncoderClass.cpp
|
||||
*
|
||||
* Created: 8/6/2014 9:20:23 AM
|
||||
* Author: corwin
|
||||
*/
|
||||
|
||||
|
||||
#include "EncoderClass.h"
|
||||
|
||||
// default constructor
|
||||
EncoderClass::EncoderClass()
|
||||
{
|
||||
} //EncoderClass
|
||||
|
||||
// default destructor
|
||||
EncoderClass::~EncoderClass()
|
||||
{
|
||||
} //~EncoderClass
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* EncoderClass.h
|
||||
*
|
||||
* Created: 8/6/2014 9:20:23 AM
|
||||
* Author: corwin
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __ENCODERCLASS_H__
|
||||
#define __ENCODERCLASS_H__
|
||||
|
||||
|
||||
class EncoderClass
|
||||
{
|
||||
//variables
|
||||
public:
|
||||
protected:
|
||||
private:
|
||||
|
||||
//functions
|
||||
public:
|
||||
EncoderClass();
|
||||
~EncoderClass();
|
||||
protected:
|
||||
private:
|
||||
EncoderClass( const EncoderClass &c );
|
||||
EncoderClass& operator=( const EncoderClass &c );
|
||||
|
||||
}; //EncoderClass
|
||||
|
||||
#endif //__ENCODERCLASS_H__
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* InterruptServiceRoutines.h
|
||||
*
|
||||
* Created: 8/4/2014 4:55:26 PM
|
||||
* Author: corwin
|
||||
*/
|
||||
|
||||
|
||||
#ifndef INTERRUPTSERVICEROUTINES_H_
|
||||
#define INTERRUPTSERVICEROUTINES_H_
|
||||
|
||||
extern SoftLCD LCD;
|
||||
extern StepperClass Stepper;
|
||||
extern int i;
|
||||
extern int TimeCount;
|
||||
|
||||
ISR(TIMER2_OVF_vect){
|
||||
static int CountDelay = 0;
|
||||
CountDelay++;
|
||||
if(CountDelay >= 61){
|
||||
TimeCount++;
|
||||
CountDelay = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ISR(TIMER1_COMPA_vect){
|
||||
Stepper.OneStep();
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
////////Pin change interrupt 2 is for pins pcint 23 to 16
|
||||
////////
|
||||
//Pin change interrupt 18 is on pin PORTD2
|
||||
//ISR(){
|
||||
|
||||
//}
|
||||
|
||||
//Pin change interrupt 19 is on pin PORTD3
|
||||
//ISR(){
|
||||
|
||||
//}
|
||||
|
||||
|
||||
|
||||
#endif /* INTERRUPTSERVICEROUTINES_H_ */
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* MegaUART.cpp
|
||||
*
|
||||
* Created: 7/31/2014 12:00:58 PM
|
||||
* Author: corwin
|
||||
*/
|
||||
|
||||
|
||||
#include "MegaUART.h"
|
||||
|
||||
// default constructor
|
||||
MegaUART::MegaUART()
|
||||
{
|
||||
} //MegaUART
|
||||
|
||||
// default destructor
|
||||
MegaUART::~MegaUART()
|
||||
{
|
||||
} //~MegaUART
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* MegaUART.h
|
||||
*
|
||||
* Created: 7/31/2014 12:00:58 PM
|
||||
* Author: corwin
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __MEGAUART_H__
|
||||
#define __MEGAUART_H__
|
||||
|
||||
|
||||
class MegaUART
|
||||
{
|
||||
//variables
|
||||
public:
|
||||
protected:
|
||||
private:
|
||||
|
||||
//functions
|
||||
public:
|
||||
MegaUART();
|
||||
~MegaUART();
|
||||
protected:
|
||||
private:
|
||||
MegaUART( const MegaUART &c );
|
||||
MegaUART& operator=( const MegaUART &c );
|
||||
|
||||
}; //MegaUART
|
||||
|
||||
#endif //__MEGAUART_H__
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* PumpClass.cpp
|
||||
*
|
||||
* Created: 8/6/2014 9:16:05 AM
|
||||
* Author: corwin
|
||||
*/
|
||||
|
||||
|
||||
#include "PumpClass.h"
|
||||
|
||||
// default constructor
|
||||
PumpClass::PumpClass()
|
||||
{
|
||||
} //PumpClass
|
||||
|
||||
// default destructor
|
||||
PumpClass::~PumpClass()
|
||||
{
|
||||
} //~PumpClass
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* PumpClass.h
|
||||
*
|
||||
* Created: 8/6/2014 9:16:05 AM
|
||||
* Author: corwin
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __PUMPCLASS_H__
|
||||
#define __PUMPCLASS_H__
|
||||
|
||||
|
||||
class PumpClass
|
||||
{
|
||||
//variables
|
||||
public:
|
||||
protected:
|
||||
private:
|
||||
|
||||
//functions
|
||||
public:
|
||||
PumpClass();
|
||||
~PumpClass();
|
||||
protected:
|
||||
private:
|
||||
PumpClass( const PumpClass &c );
|
||||
PumpClass& operator=( const PumpClass &c );
|
||||
|
||||
}; //PumpClass
|
||||
|
||||
#endif //__PUMPCLASS_H__
|
||||
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* SoftLCD.cpp
|
||||
*
|
||||
* Created: 7/31/2014 11:20:02 AM
|
||||
* Author: corwin
|
||||
*/
|
||||
|
||||
|
||||
#include "SoftLCD.h"
|
||||
|
||||
// default constructor
|
||||
SoftLCD::SoftLCD(volatile uint8_t *txport, volatile uint8_t *txddr, int txpin, volatile uint8_t *pwrport, volatile uint8_t *pwrddr, int pwrpin)
|
||||
{
|
||||
//Set up public variables
|
||||
//strncpy(TopLine, "Test", 16);
|
||||
snprintf(TopLine, 16, " ");
|
||||
snprintf(BottomLine, 16, " ");
|
||||
|
||||
strcpy(TopLinePrev, TopLine);
|
||||
strcpy(BottomLinePrev, BottomLine);
|
||||
|
||||
//Set up private variables
|
||||
serPort = txport;
|
||||
serDDR = txddr;
|
||||
serPin = txpin;
|
||||
|
||||
pwrPort = pwrport;
|
||||
pwrDDR = pwrddr;
|
||||
pwrPin = pwrpin;
|
||||
|
||||
//Set up tx pin for transmission
|
||||
*serDDR |= (1 << serPin);
|
||||
*serPort |= (1 << serPin);
|
||||
|
||||
//Set up power control pin for output
|
||||
*pwrDDR |= (1 << pwrPin);
|
||||
setLCDOn(true); //On by default
|
||||
putChar(124);
|
||||
putChar(157);
|
||||
|
||||
setRefreshRate(5); //Keep at 10fps or lower to keep screen looking nice. 5 fps seems like a good middle ground
|
||||
|
||||
|
||||
} //SoftLCD
|
||||
|
||||
// default destructor
|
||||
SoftLCD::~SoftLCD()
|
||||
{
|
||||
} //~SoftLCD
|
||||
|
||||
void SoftLCD::putChar(char c) {
|
||||
//TCCR1B &= ~((1 << CS10) | (1 << CS11) | (1 << CS12));
|
||||
//Start bit
|
||||
*serPort &= ~(1 << serPin); //Write a zero for the start bit
|
||||
_delay_us(MICROSECONDS_PER_BIT); //Wait one bit period
|
||||
|
||||
//Begin data bits
|
||||
for (uint8_t bit_mask = 0x01; bit_mask ; bit_mask <<= 1) { //Move through each bit in the char starting with the least significant bit
|
||||
if (c & bit_mask) { //If that position contains a 1
|
||||
*serPort |= (1 << serPin); //Write a 1 to the tx pin
|
||||
}else { //Otherwise...
|
||||
*serPort &= ~(1 << serPin); //Write a 0 to the tx pin
|
||||
}
|
||||
_delay_us(MICROSECONDS_PER_BIT); //Delay for the correct period of time for one bit
|
||||
}
|
||||
|
||||
//Stop bit(s)
|
||||
*serPort |= (1<<serPin); //Write a one for the stop bit
|
||||
_delay_us(MICROSECONDS_PER_BIT * STOP_BITS); //Wait the period of time required for the number of stop bits desired
|
||||
//TCCR1B |= ((1 << CS10) | (1 << CS11));
|
||||
}
|
||||
|
||||
|
||||
void SoftLCD::setLCDOn(bool on)
|
||||
{
|
||||
if(on == true){
|
||||
*pwrPort |= (1 << pwrPin);
|
||||
}else if(on == false){
|
||||
*pwrPort &= ~(1 << pwrPin);
|
||||
}
|
||||
}
|
||||
|
||||
void SoftLCD::setRefreshRate(int rate)
|
||||
{/*
|
||||
TCCR0A = 0;
|
||||
TCCR0B = ((1 << CS10) | (1 << CS12));
|
||||
TCNT0 = 0;
|
||||
TIMSK0 = (1 << TOIE0);
|
||||
*/
|
||||
}
|
||||
|
||||
void SoftLCD::show()
|
||||
{
|
||||
if(strcmp(TopLine, TopLinePrev) != 0){
|
||||
_moveToTop();
|
||||
_printLine((char *)" ");
|
||||
_moveToTop();
|
||||
_printLine(TopLine);
|
||||
strcpy(TopLinePrev, TopLine);
|
||||
}
|
||||
|
||||
if(strcmp(BottomLine, BottomLinePrev) != 0){
|
||||
_moveToBottom();
|
||||
_printLine((char *)" ");
|
||||
_moveToBottom();
|
||||
_printLine(BottomLine);
|
||||
strcpy(BottomLinePrev, BottomLine);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SoftLCD::_moveToTop()
|
||||
{
|
||||
putChar(254); //Puts lcd into command mode
|
||||
putChar(128); //Moves to first character on top
|
||||
}
|
||||
|
||||
void SoftLCD::_moveToBottom()
|
||||
{
|
||||
putChar(254); //Puts lcd into command mode
|
||||
putChar(192); //Moves to first character on bottom
|
||||
}
|
||||
|
||||
void SoftLCD::_printLine(char *text)
|
||||
{
|
||||
for(int i = 0 ; ((i < 16) && (text[i] != '\0')) ; i++){
|
||||
putChar(text[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void SoftLCD::setTopText(char *top)
|
||||
{
|
||||
snprintf(TopLine, 16, top);
|
||||
}
|
||||
|
||||
void SoftLCD::setTopText(const char *top)
|
||||
{
|
||||
snprintf(TopLine, 16, top);
|
||||
}
|
||||
|
||||
void SoftLCD::setBottomText(char *bottom)
|
||||
{
|
||||
snprintf(BottomLine, 16, bottom);
|
||||
}
|
||||
|
||||
void SoftLCD::setBottomText(const char *bottom)
|
||||
{
|
||||
snprintf(BottomLine, 16, bottom);
|
||||
}
|
||||
|
||||
void SoftLCD::showNameScreen()
|
||||
{
|
||||
_delay_ms(2000); //Delay for LCD
|
||||
setTopText(" Dechorionator"); //Startup Text Top
|
||||
setBottomText(" Revision 2.0"); //Startup Text Bottom
|
||||
show();
|
||||
_delay_ms(2750); //Pause for effect
|
||||
}
|
||||
|
||||
void SoftLCD::disableSparkfunLogo()
|
||||
{
|
||||
putChar(124);
|
||||
putChar(9);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* SoftLCD.h
|
||||
*
|
||||
* Created: 7/31/2014 11:20:02 AM
|
||||
* Author: corwin
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __SOFTLCD_H__
|
||||
#define __SOFTLCD_H__
|
||||
#define F_CPU 16000000UL
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <inttypes.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <util/delay.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "DefineMacrosAndPinDefs.h"
|
||||
|
||||
#define REFRESH_RATE_CONSTANT (16000000ul/1024)
|
||||
|
||||
#define BAUD 9600
|
||||
#define STOP_BITS 1
|
||||
|
||||
#define MICROSECONDS_OVERHEAD_ADJUST 0
|
||||
#define MICROSECONDS_PER_BIT ((1000000ul / BAUD) - MICROSECONDS_OVERHEAD_ADJUST)
|
||||
|
||||
class SoftLCD
|
||||
{
|
||||
//variables
|
||||
public:
|
||||
protected:
|
||||
private:
|
||||
FILE static usartout;
|
||||
|
||||
volatile uint8_t *serPort;
|
||||
volatile uint8_t *serDDR;
|
||||
int serPin;
|
||||
|
||||
volatile uint8_t *pwrPort;
|
||||
volatile uint8_t *pwrDDR;
|
||||
int pwrPin;
|
||||
|
||||
char TopLine[17];
|
||||
char BottomLine[17];
|
||||
|
||||
char TopLinePrev[17];
|
||||
char BottomLinePrev[17];
|
||||
//functions
|
||||
public:
|
||||
SoftLCD(volatile uint8_t *txport, volatile uint8_t *txddr, int txpin, volatile uint8_t *pwrport, volatile uint8_t *pwrddr, int pwrpin);
|
||||
|
||||
void disableSparkfunLogo();
|
||||
void showNameScreen();
|
||||
|
||||
void putChar(char c);
|
||||
void setLCDOn(bool on);
|
||||
void setRefreshRate(int rate);
|
||||
void show();
|
||||
|
||||
void setTopText(char *top);
|
||||
void setBottomText(char *bottom);
|
||||
void setTopText(const char *top);
|
||||
void setBottomText(const char *bottom);
|
||||
|
||||
~SoftLCD();
|
||||
protected:
|
||||
private:
|
||||
SoftLCD(const SoftLCD & c);
|
||||
SoftLCD& operator=( const SoftLCD &c );
|
||||
void _printLine(char *text);
|
||||
void _moveToTop();
|
||||
void _moveToBottom();
|
||||
|
||||
}; //SoftLCD
|
||||
|
||||
#endif //__SOFTLCD_H__
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* StepperClass.cpp
|
||||
*
|
||||
* Created: 8/1/2014 5:13:57 PM
|
||||
* Author: corwin
|
||||
*/
|
||||
|
||||
|
||||
#include "StepperClass.h"
|
||||
|
||||
// default constructor
|
||||
StepperClass::StepperClass(volatile uint8_t *enport, volatile uint8_t *enddr, int enpin,
|
||||
volatile uint8_t *dirport, volatile uint8_t *dirddr, int dirpin,
|
||||
volatile uint8_t *stepport, volatile uint8_t *stepddr, int steppin,
|
||||
volatile uint8_t *faultport, volatile uint8_t *faultddr, int faultpin,
|
||||
volatile uint8_t *m0port, volatile uint8_t *m0ddr, int m0pin,
|
||||
volatile uint8_t *m1port, volatile uint8_t *m1ddr, int m1pin,
|
||||
volatile uint8_t *m2port, volatile uint8_t *m2ddr, int m2pin
|
||||
)
|
||||
{
|
||||
enPort = enport;
|
||||
enDDR = enddr;
|
||||
enPin = enpin;
|
||||
_setupPinAsOutput(enDDR, enPin);
|
||||
_disableStepper();
|
||||
|
||||
dirPort = dirport;
|
||||
dirDDR = dirddr;
|
||||
dirPin = dirpin;
|
||||
_setupPinAsOutput(enDDR, enPin);
|
||||
_setPinLow(dirPort, dirPin);
|
||||
|
||||
stepPort = stepport;
|
||||
stepDDR = stepddr;
|
||||
stepPin = steppin;
|
||||
_setupPinAsOutput(enDDR, enPin);
|
||||
_setPinLow(stepPort, stepPin);
|
||||
|
||||
faultPort = faultport;
|
||||
faultDDR = faultddr;
|
||||
faultPin = faultpin;
|
||||
_setupPinAsInput(faultPort, faultDDR, faultPin, false);
|
||||
|
||||
m0Port = m0port;
|
||||
m0DDR = m0ddr;
|
||||
m0Pin = m0pin;
|
||||
_setupPinAsOutput(enDDR, enPin);
|
||||
_setPinHigh(m0Port, m0Pin);
|
||||
|
||||
m1Port = m1port;
|
||||
m1DDR = m1ddr;
|
||||
m1Pin = m1pin;
|
||||
_setupPinAsOutput(enDDR, enPin);
|
||||
_setPinLow(m1Port, m1Pin);
|
||||
|
||||
m2Port = m2port;
|
||||
m2DDR = m2ddr;
|
||||
m2Pin = m2pin;
|
||||
_setupPinAsOutput(enDDR, enPin);
|
||||
_setPinLow(m2Port, m2Pin);
|
||||
|
||||
|
||||
TCCR1A = 0; //Set output compare mode for channel A and B to normal operation and waveform generation to normal
|
||||
TCCR1B = ((1 << WGM12) | (1 << CS10) | (1 << CS11)); //Set clk prescalar for timer to clk/1024 and enable clear on timer compare match
|
||||
TCNT1 = 0; //Zero the count register
|
||||
TIMSK1 = (1 << OCIE1A); //Set interrupt flag to trigger on counter 1 overflow
|
||||
OCR1A = 2000; //Set the count value based on what's needed to update at a specific number of fps
|
||||
|
||||
} //StepperClass
|
||||
|
||||
// default destructor
|
||||
StepperClass::~StepperClass()
|
||||
{
|
||||
} //~StepperClass
|
||||
|
||||
void StepperClass::_setupPinAsOutput(volatile uint8_t *ddr, int pin)
|
||||
{
|
||||
*ddr |= (1 << pin);
|
||||
}
|
||||
|
||||
void StepperClass::_setupPinAsInput(volatile uint8_t *port, volatile uint8_t *ddr, int pin, bool enablePullup = false)
|
||||
{
|
||||
*ddr &= ~(1 << pin);
|
||||
if(enablePullup){
|
||||
*port |= (1 << pin);
|
||||
}
|
||||
}
|
||||
|
||||
void StepperClass::_enableStepper()
|
||||
{
|
||||
*enPort &= ~(1 << enPin);
|
||||
}
|
||||
|
||||
void StepperClass::_disableStepper()
|
||||
{
|
||||
*enPort |= (1 << enPin);
|
||||
}
|
||||
|
||||
void StepperClass::_setPinLow(volatile uint8_t *port, int pin)
|
||||
{
|
||||
*port &= ~(1 << pin);
|
||||
}
|
||||
|
||||
void StepperClass::_setPinHigh(volatile uint8_t *port, int pin)
|
||||
{
|
||||
*port |= (1 << pin);
|
||||
}
|
||||
|
||||
void StepperClass::OneStep()
|
||||
{
|
||||
_setPinHigh(stepPort, stepPin);
|
||||
_delay_us(2);
|
||||
_setPinLow(stepPort, stepPin);
|
||||
}
|
||||
|
||||
void StepperClass::SetRPM(int rpm)
|
||||
{
|
||||
OCR1B = 35000;//(long(STEPPER_RPM_CONSTANT)/rpm); //Set the count value based on what's needed to update at a specific number of fps
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* StepperClass.h
|
||||
*
|
||||
* Created: 8/1/2014 5:13:57 PM
|
||||
* Author: corwin
|
||||
*
|
||||
* MSTEP M2 M1 M0 DEC
|
||||
* 1 0 0 0 0
|
||||
* 2 0 0 1 1
|
||||
* 4 0 1 0 2
|
||||
* 8 0 1 1 3
|
||||
* 16 1 0 0 4
|
||||
* 32 1 0 1 5
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __STEPPERCLASS_H__
|
||||
#define __STEPPERCLASS_H__
|
||||
#define F_CPU 16000000UL
|
||||
|
||||
#include <util/delay.h>
|
||||
#include <avr/io.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#define STEPPER_RPM_CONSTANT (16000000ul/1024)*60)
|
||||
|
||||
class StepperClass
|
||||
{
|
||||
//variables
|
||||
public:
|
||||
protected:
|
||||
private:
|
||||
volatile uint8_t *enPort;
|
||||
volatile uint8_t *enDDR;
|
||||
int enPin;
|
||||
|
||||
volatile uint8_t *dirPort;
|
||||
volatile uint8_t *dirDDR;
|
||||
int dirPin;
|
||||
|
||||
volatile uint8_t *stepPort;
|
||||
volatile uint8_t *stepDDR;
|
||||
int stepPin;
|
||||
|
||||
volatile uint8_t *faultPort;
|
||||
volatile uint8_t *faultDDR;
|
||||
int faultPin;
|
||||
|
||||
volatile uint8_t *m0Port;
|
||||
volatile uint8_t *m0DDR;
|
||||
int m0Pin;
|
||||
|
||||
volatile uint8_t *m1Port;
|
||||
volatile uint8_t *m1DDR;
|
||||
int m1Pin;
|
||||
|
||||
volatile uint8_t *m2Port;
|
||||
volatile uint8_t *m2DDR;
|
||||
int m2Pin;
|
||||
|
||||
//functions
|
||||
public:
|
||||
StepperClass(volatile uint8_t *enport, volatile uint8_t *enddr, int enpin,
|
||||
volatile uint8_t *dirport, volatile uint8_t *dirddr, int dirpin,
|
||||
volatile uint8_t *stepport, volatile uint8_t *stepddr, int steppin,
|
||||
volatile uint8_t *faultport, volatile uint8_t *faultddr, int faultpin,
|
||||
volatile uint8_t *m0port, volatile uint8_t *m0ddr, int m0pin,
|
||||
volatile uint8_t *m1port, volatile uint8_t *m1ddr, int m1pin,
|
||||
volatile uint8_t *m2port, volatile uint8_t *m2ddr, int m2pin
|
||||
);
|
||||
void SetRPM(int rpm);
|
||||
void OneStep();
|
||||
|
||||
~StepperClass();
|
||||
protected:
|
||||
private:
|
||||
StepperClass( const StepperClass &c );
|
||||
StepperClass& operator=( const StepperClass &c );
|
||||
void _setupPinAsOutput(volatile uint8_t *ddr, int pin);
|
||||
void _setupPinAsInput(volatile uint8_t *port, volatile uint8_t *ddr, int pin, bool enablePullup);
|
||||
|
||||
void _enableStepper();
|
||||
void _disableStepper();
|
||||
|
||||
void _setPinLow(volatile uint8_t *port, int pin);
|
||||
void _setPinHigh(volatile uint8_t *port, int pin);
|
||||
|
||||
}; //StepperClass
|
||||
|
||||
#endif //__STEPPERCLASS_H__
|
||||
Reference in New Issue
Block a user