Skip to content

Commit

Permalink
Merge pull request #62 from c3charvat/Experimental
Browse files Browse the repository at this point in the history
Slim_UI
  • Loading branch information
c3charvat authored Feb 16, 2022
2 parents 6c7c6d4 + 6c6bdd5 commit d650716
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 126 deletions.
6 changes: 3 additions & 3 deletions Firmware_V11/src/Error.ino
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ void Somthing_Error(void) {
MAIN_MENU();
}
if ( Error_selection ==3){
// Hard Restart
//softwareReset::standard();
// software resert -> from mbed os
NVIC_SystemReset();
}
}
void Parsing_Error(void){
Expand All @@ -53,7 +53,7 @@ void Parsing_Error(void){
// Return back to main menu

if ( Error_selection == 1) {
// Go back nothing happed return to where ever the system
// Go back nothing happed return to where ever the system was
return;
}
}
169 changes: 70 additions & 99 deletions Firmware_V11/src/Move_Functions.ino
Original file line number Diff line number Diff line change
Expand Up @@ -15,105 +15,76 @@
// const int Motor7LimitSw =PG15;

void MOVE_FUNCTION(void)
{ // Selection =0
movevar[0] = 0; // clear out any previous data that may or maynot have been canceled
{ // Selection =0
movevar[0] = 0; // clear out any previous data that may or maynot have been canceled
movevar[1] = 0;
movevar[2] = 0;
movevar[3] = 0;
Serial.println("I got to \"MOVE_FUNCTION()\".");
// Parse Out The Data into the correct move variable
movevar[0] = ABS_POS(Xpos, 0); // X Move
movevar[1] = ABS_POS(Ypos, 1); // Y and Z Move // Pull Data From LCD MENU VARIBLES
movevar[2] = ABS_POS(AoA[0], 2); // E0 Move AoA Top
movevar[3] = ABS_POS(AoA[1], 3); // E1 Move AoA Bottom
gui_output_function(); // return the stuff to the python the gui

if (Com_selection != 2)
{ // If we arent in LCD Mode This avoids onyl 1 stepper moving
Serial.println("Motion_selection != 2");
// Parse Out The Data into the correct move variable
movevar[0] = ABS_POS(Xpos, 0); // X Move
movevar[1] = ABS_POS(Ypos, 1); // Y and Z Move // Pull Data From LCD MENU VARIBLES
movevar[2] = ABS_POS(AoA[0], 2); // E0 Move AoA Top
movevar[3] = ABS_POS(AoA[1], 3); // E1 Move AoA Bottom
gui_output_function();
}

if (Motion_selection == 2 && Com_selection == 2)
{ // If in Normal LCD Mode with motion in non trigger mode and
Serial.println("Motion_selection == 2 Com select == 2");
// Normal Mode LCD
Serial.println("Steps to move");
Serial.println(movevar[0] * 6400);
X_stepper.setupRelativeMoveInSteps(movevar[0] * 6400); // Future: Make these iun terms of MM
Y0_stepper.setupRelativeMoveInSteps(movevar[1] * 6400);
Y12_stepper.setupRelativeMoveInSteps(movevar[1] * 6400);
Y3_stepper.setupRelativeMoveInSteps(movevar[1] * 6400);
AOAT_stepper.setupRelativeMoveInSteps(movevar[2] / (Degree_per_step[2] / Micro_stepping[2]));
AOAB_stepper.setupRelativeMoveInSteps(movevar[3] / (Degree_per_step[3] / Micro_stepping[3]));
// Call A Blocking Function that Stops the Machine from doing anything else while the stepper is moving This is desired since we aren not updating mid move.
Serial.println("Entering while loop");
while ((!X_stepper.motionComplete()) || (!Y0_stepper.motionComplete()) || (!Y12_stepper.motionComplete()) || (!Y3_stepper.motionComplete()) || (!AOAT_stepper.motionComplete()) || (!AOAB_stepper.motionComplete()))
{
X_stepper.processMovement();
Y0_stepper.processMovement();
Y12_stepper.processMovement(); // moving the Steppers here was a simple soltuion to having to do system interups and blah blah.
Y3_stepper.processMovement();
AOAT_stepper.processMovement();
AOAB_stepper.processMovement();
}
Serial.println("Exited While Loop");

if (Motion_selection == 1) // Think this is old error stuff leaving this in for now
{
Abs_pos_error = false;
MAIN_MENU();
}
else
{
Abs_pos_error = false;
return;
}
// return;
}

// if (Motion_selection == 2) // old lcd trigger mode
// // LCD Trigger mode
// // Let the UI command issue move commands and just keep issuing this string untill the desired settings are made
// // We need to make sure that this doesnt log multiple moves

// Go_Pressed = 1; // There is new data to move to this disables the Trigger button to prevent multiple moves uless the entire sequence has been completeted
// return;
// }

if (Motion_selection == 1 && Com_selection == 2)
Serial.println("Motion_selection == 2 Com select == 2");
// Normal Mode LCD
Serial.println("Steps to move");
Serial.println(movevar[0] * 6400);
X_stepper.setupRelativeMoveInSteps(movevar[0] * 6400); // Future: Make these iun terms of MM
Y0_stepper.setupRelativeMoveInSteps(movevar[1] * 6400);
Y12_stepper.setupRelativeMoveInSteps(movevar[1] * 6400);
Y3_stepper.setupRelativeMoveInSteps(movevar[1] * 6400);
AOAT_stepper.setupRelativeMoveInSteps(movevar[2] / (Degree_per_step[2] / Micro_stepping[2]));
AOAB_stepper.setupRelativeMoveInSteps(movevar[3] / (Degree_per_step[3] / Micro_stepping[3]));
// Call A Blocking Function that Stops the Machine from doing anything else while the stepper is moving This is desired since we aren not updating mid move.
Serial.println("Entering while loop");
while ((!X_stepper.motionComplete()) || (!Y0_stepper.motionComplete()) || (!Y12_stepper.motionComplete()) || (!Y3_stepper.motionComplete()) || (!AOAT_stepper.motionComplete()) || (!AOAB_stepper.motionComplete()))
{
// LCD External Trigger mode and Serial External Trigger
Serial.println("Steps to move");
Serial.println(movevar[0] * X_mm_to_micro);
X_stepper.setupRelativeMoveInSteps(movevar[0] * 6400); // Future: Make these iun terms of MM
Y0_stepper.setupRelativeMoveInSteps(movevar[1] * 6400);
Y12_stepper.setupRelativeMoveInSteps(movevar[1] * 6400);
Y3_stepper.setupRelativeMoveInSteps(movevar[1] * 6400);
AOAT_stepper.setupRelativeMoveInSteps(movevar[2] / (Degree_per_step[2] / Micro_stepping[2]));
AOAB_stepper.setupRelativeMoveInSteps(movevar[3] / (Degree_per_step[3] / Micro_stepping[3]));
// E2stepper.setupRelativeMoveInSteps((movevar[*axis*] / Degree_per_step[4]) * Micro_stepping[4]);
// Serial.print("Waiting in Motion MODE 3: LCD Continous with Trigger"); // Debug Stuff
// Serial.print("Ready For Trigger");
// digitalWrite(27, HIGH); // Sound Buzzer That The Control Borad is waiting on user
// delay(10);
// digitalWrite(27, LOW); // Turn the buzzor onff
while(Go_Pressed =! true){
// do nothing here and wait for the interrupt
delayMicroseconds(1);
}
Go_Pressed = false;
while ((!X_stepper.motionComplete()) || (!Y0_stepper.motionComplete()) || (!Y12_stepper.motionComplete()) || (!Y3_stepper.motionComplete()) || (!AOAT_stepper.motionComplete()) || (!AOAB_stepper.motionComplete()))
{
X_stepper.processMovement();
Y0_stepper.processMovement();
Y12_stepper.processMovement(); // moving the Steppers here was a simple soltuion to having to do system interups and blah blah.
Y3_stepper.processMovement();
AOAT_stepper.processMovement();
AOAB_stepper.processMovement();
}
Abs_pos_error = false;
// return;
X_stepper.processMovement();
Y0_stepper.processMovement();
Y12_stepper.processMovement(); // moving the Steppers here was a simple soltuion to having to do system interups and blah blah.
Y3_stepper.processMovement();
AOAT_stepper.processMovement();
AOAB_stepper.processMovement();
}
Serial.println("Exited While Loop");

// if (Trigger_selection == 1) // old external trigger code
// {
// // LCD External Trigger mode and Serial External Trigger
// Serial.println("Steps to move");
// Serial.println(movevar[0] * X_mm_to_micro);
// X_stepper.setupRelativeMoveInSteps(movevar[0] * 6400); // Future: Make these iun terms of MM
// Y0_stepper.setupRelativeMoveInSteps(movevar[1] * 6400);
// Y12_stepper.setupRelativeMoveInSteps(movevar[1] * 6400);
// Y3_stepper.setupRelativeMoveInSteps(movevar[1] * 6400);
// AOAT_stepper.setupRelativeMoveInSteps(movevar[2] / (Degree_per_step[2] / Micro_stepping[2]));
// AOAB_stepper.setupRelativeMoveInSteps(movevar[3] / (Degree_per_step[3] / Micro_stepping[3]));
// // E2stepper.setupRelativeMoveInSteps((movevar[*axis*] / Degree_per_step[4]) * Micro_stepping[4]);
// // Serial.print("Waiting in Motion MODE 3: LCD Continous with Trigger"); // Debug Stuff
// // Serial.print("Ready For Trigger");
// // digitalWrite(27, HIGH); // Sound Buzzer That The Control Borad is waiting on user
// // delay(10);
// // digitalWrite(27, LOW); // Turn the buzzor onff
// while(Go_Pressed =! true){
// // do nothing here and wait for the interrupt
// delayMicroseconds(1);
// }
// Go_Pressed = false;
// while ((!X_stepper.motionComplete()) || (!Y0_stepper.motionComplete()) || (!Y12_stepper.motionComplete()) || (!Y3_stepper.motionComplete()) || (!AOAT_stepper.motionComplete()) || (!AOAB_stepper.motionComplete()))
// {
// X_stepper.processMovement();
// Y0_stepper.processMovement();
// Y12_stepper.processMovement(); // moving the Steppers here was a simple soltuion to having to do system interups and blah blah.
// Y3_stepper.processMovement();
// AOAT_stepper.processMovement();
// AOAB_stepper.processMovement();
// }
// Abs_pos_error = false;
// // return;
// }
} // End Function

// home function
Expand All @@ -126,7 +97,7 @@ void HomeAll(void)
Y12_stepper.setupRelativeMoveInSteps(10 * 6400);
Y3_stepper.setupRelativeMoveInSteps(10 * 6400);
AOAT_stepper.setupRelativeMoveInSteps(10 / (Degree_per_step[2] / Micro_stepping[2]));
AOAB_stepper.setupRelativeMoveInSteps(10/ (Degree_per_step[3] / Micro_stepping[3]));
AOAB_stepper.setupRelativeMoveInSteps(10 / (Degree_per_step[3] / Micro_stepping[3]));
while ((!X_stepper.motionComplete()) || (!Y0_stepper.motionComplete()) || (!Y12_stepper.motionComplete()) || (!Y3_stepper.motionComplete()) || (!AOAT_stepper.motionComplete()) || (!AOAB_stepper.motionComplete()))
{
X_stepper.processMovement();
Expand Down Expand Up @@ -192,8 +163,8 @@ void HomeAll(void)
LL_GPIO_ResetOutputPin(GPIOF, LL_GPIO_PIN_11);
LL_GPIO_ResetOutputPin(GPIOG, LL_GPIO_PIN_4);
LL_GPIO_ResetOutputPin(GPIOF, LL_GPIO_PIN_9);
delayMicroseconds(70); // delay between high states, how long between step signals
//Serial.print("Hl");// debug to make sure it got here // kept short to minimize time
delayMicroseconds(70); // delay between high states, how long between step signals
// Serial.print("Hl");// debug to make sure it got here // kept short to minimize time
}
//
Xpos = 0;
Expand All @@ -204,8 +175,8 @@ void HomeAll(void)
CurrentPositions[1] = 0;
CurrentPositions[2] = 0;
CurrentPositions[3] = 0;
volatile bool xhome=false;
volatile bool yhome=false;
volatile bool aoathome=false; // second it leaves this function we assume its not home
volatile bool aoabhome=false;
volatile bool xhome = false;
volatile bool yhome = false;
volatile bool aoathome = false; // second it leaves this function we assume its not home
volatile bool aoabhome = false;
}
16 changes: 15 additions & 1 deletion Firmware_V11/src/Pin_Setup.ino
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,21 @@ pinMode(Motor6LimitSw, INPUT);
pinMode(BEEPER, OUTPUT); // Beeper on LCD
pinMode(BUTTON, INPUT); // Encoder button
pinMode(ENCODER_RT, INPUT); // Encoder Move Direction
pinMode(ENCODER_LT, INPUT); // Encoder Move Direction
pinMode(ENCODER_LT, INPUT); // Encoder Move Direction
// Fan setup
const int Fan0 = PA8;
const int Fan1 = PE5;
const int Fan2 = PD12;
pinMode(Fan0, OUTPUT);
pinMode(Fan1,OUTPUT);
pinMode(Fan2,OUTPUT);
digitalWrite(Fan0,LOW);
digitalWrite(Fan1,LOW);
digitalWrite(Fan2,LOW);
/*
Fan 6 and 7 are on by default.
The remaining fan pins can be reused the top pin is hot as defined by the jumpers see pin diagram.
*/
// Stepper Enables
digitalWrite(MOTOR0_ENABLE , LOW); // Set the Enable Pin to Low to Enable the Driver
digitalWrite(MOTOR1_ENABLE , LOW);
Expand Down
1 change: 1 addition & 0 deletions Firmware_V11/src/UI_Functions.ino
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ void SERIAL_UI(void)
delay(400);
u8g2.sendBuffer();
Com_selection = 2;
Sub_selection = 1; // default sub_selction back to 1 so you dont end up in the serial menu every time you click settings.
//return 1;
MAIN_MENU();
}
Expand Down
52 changes: 29 additions & 23 deletions Firmware_V11/src/UI_Version_11.ino
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ float Y_mm_to_micro = (1 / Y_Lead_p) * (360 / Degree_per_step[1]) * (Micro_stepp
U8G2_ST7920_128X64_F_SW_SPI u8g2(U8G2_R0, /* clock=*/PE13, /* data=*/PE15, /* CS=*/PE14, /* reset=*/PE10); //
// Define the LCD Type and Pins Reset is currently pin 29 which us unused or unconnected on the board.
// ~~~~~~~~~~~~~~~~~~~~~~~~~ Trigger Pin Define ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int TRIGGER_PIN = 24; // Temp0 pin on Melzi board
bool Go_Pressed = false; // Default state of the trigger ISR variable
const int TRIGGER_PIN = 24; // Temp0 pin on Melzi board
volatile bool Go_Pressed = false; // Default state of the trigger ISR variable
// ~~~~~~~~~~~~~~~~~~~~~~~~~~ Estop Pin define ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const int Estop_pin = 24;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MOTION CONTROL ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Initalize Stepper Class
/*
Expand Down Expand Up @@ -131,27 +133,26 @@ const char *Main_menu = // Define the Main Menu options
const char *Setting_list = // Define the Settings Sub menu options
"Acceleration\n"
"Speed\n"
"Serial Com."
"Trigger Mode\n"
"Serial Com.\n" // "Trigger Mode\n"
"Home All Axis\n"
"BACK";

const char *Com_select = // Communcations method select menu
"SERIAL\n"
"LCD";
const char *Motion_select = // motion select menu
"Trigger ON\n"
"Trigger OFF\n";
// const char *Motion_select = // motion select menu
// "Trigger ON\n"
// "Trigger OFF";

const char *Error_String = // Error strings
"Acknowledge\n"
"Main Menu\n"
"Hard Restart\n";
"Software Restart";

uint8_t current_selection = 0; // Keep track of current selection in menu
uint8_t Sub_selection = 0;
uint8_t Com_selection = 2; // communications selection tracker by default use the LCD
uint8_t Motion_selection = 2; // Default to OFF
//uint8_t Motion_selection = 2; // Default to OFF



Expand Down Expand Up @@ -201,7 +202,8 @@ void setup(void)
attachInterrupt(digitalPinToInterrupt(Motor2LimitSw), yHomeIsr, CHANGE);
attachInterrupt(digitalPinToInterrupt(Motor4LimitSw), aoatHomeIsr, CHANGE);
attachInterrupt(digitalPinToInterrupt(Motor6LimitSw), aoabHomeIsr, CHANGE);
attachInterrupt(digitalPinToInterrupt(TRIGGER_PIN), motionTriggerIsr, FALLING); //External Trigger
//attachInterrupt(digitalPinToInterrupt(TRIGGER_PIN), motionTriggerIsr, FALLING); //External Trigger
//attachInterrupt(digitalPinToInterrupt(Estop_pin), estopIsr, FALLING); //External Trigger

// delay(5000); // dely five seconds so the monitor can connect first --> VsCode monitor only
DRIVER_SETUP();
Expand All @@ -218,6 +220,7 @@ void setup(void)
// Define the System Font see https://github.com/olikraus/u8g2/wiki/u8g2reference for more information about the commands
u8g2.setFont(u8g2_font_6x12_tr);
Draw_bitmap(); // DRAW THE BOOT SCREEN
HomeAll();
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ VOID LOOP ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -257,7 +260,7 @@ void loop(void)
}
if (current_selection == 3)
{
u8g2.userInterfaceInputValue("AOA Top:", "", &AoA_t_value[0], 0, 5, 1, " 0-3 Hundreds Degrees");
//u8g2.userInterfaceInputValue("AOA Top:", "", &AoA_t_value[0], 0, 5, 1, " 0-3 Hundreds Degrees");
u8g2.userInterfaceInputValue("AOA Top:", "", &AoA_t_value[1], 0, 99, 2, " 0-99 Tens/Ones Degree"); // Error Message needs to be made if the input is made over the max AoA
u8g2.userInterfaceInputValue("AOA Top:", "", &AoA_t_value[2], 0, 9, 1, " 0-9 Decimal Degree");
// headder,re string, pointer to unsigned char, min value, max vlaue, # of digits , post char
Expand All @@ -272,7 +275,7 @@ void loop(void)
}
if (current_selection == 4)
{
u8g2.userInterfaceInputValue("AOA Bottom:", "", &AoA_b_value[0], 0, 3, 1, " 0-3 Hundreds Degrees");
//u8g2.userInterfaceInputValue("AOA Bottom:", "", &AoA_b_value[0], 0, 3, 1, " 0-3 Hundreds Degrees");
u8g2.userInterfaceInputValue("AOA Bottom:", "", &AoA_b_value[1], 0, 99, 2, " 0-99 Tens/Ones Degree"); // Error Message needs to be made if the input is made over the max AoA
u8g2.userInterfaceInputValue("AOA Bottom:", "", &AoA_b_value[2], 0, 9, 1, " 0-9 Decimal Degree");
// headder,re string, pointer to unsigned char, min value, max vlaue, # of digits , post char
Expand All @@ -298,13 +301,13 @@ void loop(void)
if (Sub_selection == 1)
{
// Acceleration Settings Code
u8g2.userInterfaceInputValue("Acceleration:", "", Acceleration, 0, 20, 2, "*25 Steps/s^2");
u8g2.userInterfaceInputValue("Acceleration:", "", Acceleration, 0, 20, 2, "*25 Rev/s^2");
SET_ACELL(*Acceleration * 25, *Acceleration * 25, *Acceleration * 25, *Acceleration * 25);
}
if (Sub_selection == 2)
{
// Speed Settings
u8g2.userInterfaceInputValue("Speed:", "", Speed, 0, 20, 2, "*25 Steps/s");
u8g2.userInterfaceInputValue("Speed:", "", Speed, 0, 20, 2, "*25 Rev/s");
SET_SPEED(*Speed * 25, *Speed * 25, *Speed * 25, *Speed * 25);
}
if (Sub_selection == 3)
Expand All @@ -313,20 +316,20 @@ void loop(void)
Com_selection = 1; // switch to serial Comunications
SERIAL_UI(); // call the serial UI
}
// if (Sub_selection == 4)
// {
// // Trigger mode
// Motion_selection = u8g2.userInterfaceSelectionList( // Bings up the trigger Menu
// "Trigger Select",
// Motion_selection,
// Motion_select);
// }
if (Sub_selection == 4)
{
// Trigger mode
Motion_selection = u8g2.userInterfaceSelectionList( // Bings up the trigger Menu
"Trigger Select",
Motion_selection,
Motion_select);
}
if (Sub_selection == 5)
{
// Home All Axis
HomeAll();
}
if (Sub_selection == 6)
if (Sub_selection == 5)
{
// Head back to Main meanu
MAIN_MENU();
Expand Down Expand Up @@ -366,6 +369,9 @@ void aoabHomeIsr()
void motionTriggerIsr(){
Go_Pressed = true;
}
void estopIsr(){
NVIC_SystemReset(); // use a software reset to kill the board
}

/* For As long As the Octopus Board is used under no circustances should this ever be modified !!!*/
/*
Expand Down

0 comments on commit d650716

Please sign in to comment.