Skip to content

Commit

Permalink
Numerous fixes - all listed on forum post
Browse files Browse the repository at this point in the history
  • Loading branch information
coelacant2 committed Jan 20, 2016
1 parent e2be506 commit 8e4cbc1
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 60 deletions.
1 change: 1 addition & 0 deletions OpenDACT/Class Files/Calibration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ static class Calibration
{
public static bool calibrateInProgress = false;
public static bool calibrationState = false;
public static bool calibrationComplete = false;
public static int calibrationSelection = 0;
public static int iterationNum = 0;
private static float tempAccuracy;
Expand Down
97 changes: 49 additions & 48 deletions OpenDACT/Class Files/DecisionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static void handleInput(string message, bool canMove)
{
//rm
}
else if (GCode.checkHeights == true && EEPROMFunctions.tempEEPROMSet == true && Calibration.calibrateInProgress == false && EEPROMFunctions.EEPROMReadOnly == false && canMove == true)
else if (GCode.checkHeights == true && EEPROMFunctions.tempEEPROMSet == true && Calibration.calibrateInProgress == false && EEPROMFunctions.EEPROMReadOnly == false)
{
if (UserVariables.probeChoice == "Z-Probe" && GCode.wasZProbeHeightSet == false && GCode.wasSet == true)
{
Expand All @@ -37,73 +37,74 @@ public static void handleInput(string message, bool canMove)
EEPROMFunctions.sendEEPROM();
}
}
else
else if (canMove == true)
{
//UserInterface.logConsole("position flow");
GCode.positionFlow();
}
}
else if (Calibration.calibrationState == true && Calibration.calibrateInProgress == false && GCode.checkHeights == false && EEPROMFunctions.tempEEPROMSet == true && EEPROMFunctions.EEPROMReadOnly == false)
{
if (HeightFunctions.parseZProbe(message) != 1000 && HeightFunctions.heightsSet == false)
else if (HeightFunctions.parseZProbe(message) != 1000 && HeightFunctions.heightsSet == false)
{
HeightFunctions.setHeights(HeightFunctions.parseZProbe(message));
}
else if (HeightFunctions.heightsSet == true)
}
else if (Calibration.calibrationState == true && Calibration.calibrateInProgress == false && GCode.checkHeights == false && EEPROMFunctions.tempEEPROMSet == true && EEPROMFunctions.EEPROMReadOnly == false && HeightFunctions.heightsSet == true)
{
Program.mainFormTest.setHeightsInvoke();

if (Calibration.calibrationState == true && HeightFunctions.checkHeightsOnly == false)
{
Program.mainFormTest.setHeightsInvoke();
Calibration.calibrateInProgress = true;

if (Calibration.calibrationState == true && HeightFunctions.checkHeightsOnly == false)
/*
if (EEPROMFunctions.EEPROMRequestSent == false)
{
Calibration.calibrateInProgress = true;
EEPROMFunctions.readEEPROM();
EEPROMFunctions.EEPROMRequestSent = true;
}
*/

/*
if (EEPROMFunctions.EEPROMRequestSent == false)
{
EEPROMFunctions.readEEPROM();
EEPROMFunctions.EEPROMRequestSent = true;
}
*/
if (UserVariables.advancedCalibration == false || GCode.isHeuristicComplete == true)
{
UserInterface.logConsole("Calibration Iteration Number: " + Calibration.iterationNum);
Calibration.calibrate();

if (UserVariables.advancedCalibration == false || GCode.isHeuristicComplete == true)
{
UserInterface.logConsole("Calibration Iteration Number: " + Calibration.iterationNum);
Calibration.calibrate();

Program.mainFormTest.setEEPROMGUIList();
EEPROMFunctions.sendEEPROM();

if (Calibration.calibrationState == false)
{
GCode.homeAxes();
UserInterface.logConsole("Calibration Complete");
//end calibration
}
}
else
{
UserInterface.logConsole("Heuristic Step: " + UserVariables.advancedCalCount);
GCode.heuristicLearning();
Program.mainFormTest.setEEPROMGUIList();
EEPROMFunctions.sendEEPROM();

Program.mainFormTest.setEEPROMGUIList();
EEPROMFunctions.sendEEPROM();
if (Calibration.calibrationState == false)
{
GCode.homeAxes();
Calibration.calibrationComplete = true;
UserInterface.logConsole("Calibration Complete");
//end calibration
}


Calibration.calibrateInProgress = false;
}
else
{
if (UserVariables.probeChoice == "FSR")
{
EEPROM.zMaxLength -= UserVariables.FSROffset;
UserInterface.logConsole("Setting Z Max Length with adjustment for FSR\nHeights checked");
}
UserInterface.logConsole("Heuristic Step: " + UserVariables.advancedCalCount);
GCode.heuristicLearning();

GCode.homeAxes();
Program.mainFormTest.setEEPROMGUIList();
EEPROMFunctions.sendEEPROM();
}

HeightFunctions.heightsSet = false;

Calibration.calibrateInProgress = false;
}
else
{
if (UserVariables.probeChoice == "FSR")
{
EEPROM.zMaxLength -= UserVariables.FSROffset;
UserInterface.logConsole("Setting Z Max Length with adjustment for FSR");
}

GCode.homeAxes();

UserInterface.logConsole("Heights checked");
}

HeightFunctions.heightsSet = false;
}
/*
else
Expand Down
7 changes: 6 additions & 1 deletion OpenDACT/Class Files/GCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace OpenDACT.Class_Files
static class GCode
{
public static int currentPosition = 0;
public static int iteration = 0;
public static bool checkHeights = false;
public static bool wasSet = false;
public static bool wasZProbeHeightSet = false;
Expand Down Expand Up @@ -115,6 +116,7 @@ public static void pauseTimeZMaxThird()
Thread.Sleep(Convert.ToInt32(((EEPROM.zMaxLength / 3) / UserVariables.xySpeed) * 1000));
}


public static void positionFlow()
{
float probingHeight = UserVariables.probingHeight;
Expand All @@ -123,7 +125,6 @@ public static void positionFlow()
float valueZ = 0.482F * plateDiameter;
float valueXYLarge = 0.417F * plateDiameter;
float valueXYSmall = 0.241F * plateDiameter;
int iteration = 0;

if (UserVariables.probeChoice == "Z-Probe" && wasSet == false)
{
Expand Down Expand Up @@ -342,9 +343,13 @@ public static void positionFlow()
case 2:
Connection._serialPort.WriteLine("G1 Z" + probingHeight.ToString() + " X0 Y0");
iteration++;
if (Calibration.calibrateInProgress == false){ iteration++; }
break;
case 3:
Connection._serialPort.WriteLine("G1 Z" + Convert.ToInt32(EEPROM.zMaxLength / 3) + " X0 Y0");
iteration++;
break;
case 4:
currentPosition = 0;
checkHeights = false;
iteration = 0;
Expand Down
20 changes: 13 additions & 7 deletions OpenDACT/Class Files/Threading.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,21 @@ public static void HandleRead()

while (_continue)
{
while (isCalibrating && !readLineData.Any())
try
{
try
bool hasData;
lock (readLineData)
{
hasData = readLineData.Any();
}

while (isCalibrating && hasData)
{
//wait for ok to perform calculation?
UserVariables.isInitiated = true;
bool canMove;

if (readLineData.First().Contains("ok"))
if (readLineData.First().Contains("wait"))
{
canMove = true;
}
Expand All @@ -58,10 +64,10 @@ public static void HandleRead()
}

DecisionHandler.handleInput(readLineData.First(), canMove);
readLineData.Remove(readLineData.First());
}
catch (Exception) { }
}//end while
readLineData.RemoveAt(0);
}//end while
}
catch (Exception) { }
}//end while continue
}

Expand Down
1 change: 0 additions & 1 deletion OpenDACT/Class Files/Validation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class Validation
{
public static float checkZero(float value)
{

if (value > 0 && value < 0.001F)
{
return 0;
Expand Down
4 changes: 2 additions & 2 deletions OpenDACT/OpenDACT.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>C:\Users\Rollie\Desktop\opendact\</PublishUrl>
<PublishUrl>C:\Users\Steven\Desktop\OpenDACT310A\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
Expand All @@ -23,7 +23,7 @@
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>3</ApplicationRevision>
<ApplicationRevision>4</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
Expand Down
4 changes: 3 additions & 1 deletion OpenDACT/mainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ private void calibrateButton_Click(object sender, EventArgs e)
GCode.checkHeights = true;
EEPROMFunctions.readEEPROM();
EEPROMFunctions.EEPROMReadOnly = false;
Calibration.calibrationComplete = false;
Calibration.calibrationState = true;
Calibration.calibrationSelection = 0;
HeightFunctions.checkHeightsOnly = false;
Expand Down Expand Up @@ -383,6 +384,7 @@ private void checkHeights_Click(object sender, EventArgs e)
Calibration.calibrationSelection = 0;
HeightFunctions.checkHeightsOnly = true;
HeightFunctions.heightsSet = false;
Calibration.calibrationComplete = false;
}

private void stopBut_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -433,7 +435,7 @@ private void manualCalibrateBut_Click(object sender, EventArgs e)
EEPROM.DA = Convert.ToSingle(delRadAMan.Text);
EEPROM.DB = Convert.ToSingle(delRadBMan.Text);
EEPROM.DC = Convert.ToSingle(delRadCMan.Text);

Calibration.basicCalibration();

//set eeprom vals in manual calibration
Expand Down

0 comments on commit 8e4cbc1

Please sign in to comment.