Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 25:7b3826dddcba
- Parent:
- 24:92f612ca218b
- Child:
- 26:f891ff6beb33
--- a/main.cpp Tue May 15 18:38:50 2018 +0000
+++ b/main.cpp Wed May 16 12:19:49 2018 +0000
@@ -299,6 +299,7 @@
}
void zeroX(int pps){
+ printf("Zero X\n\r");
float time = 1.0/pps/2.0;
if(dirX != x_minus){
@@ -317,6 +318,7 @@
totalX = 0;
}
void zeroY(int pps){
+ printf("Zero Y\n\r");
float time = 1.0/pps/2.0;
if(dirY != y_minus){
@@ -335,6 +337,26 @@
totalY = 0;
}
+void zeroZ(int pps){
+ printf("Zero Z\n\r");
+ float time = 1.0/pps/2.0;
+
+ if(dirZ != z_minus){
+ dirZ = z_minus;
+ }
+
+ while(!z_block_min){
+ stepZ = 1;
+ wait(time);
+ stepZ = 0;
+ wait(time);
+ }
+
+ printf("Z zero\n\r");
+
+ totalZ = 0;
+}
+
float steps_to_distance(int steps, float pitch){
float delta_S = (((float)steps)/steps_by_rotation)*pitch;
return delta_S;
@@ -549,13 +571,18 @@
}
void killJog(void){
- saved = 0;
kill_jog = 1;
printf("Jog killed\n\r");
}
+void cancelProgram(void){
+ saved = 0;
+ killJog();
+}
+
void readSerial(void){
char recv;
+ char last_recv;
//save
int save = 0;
@@ -571,6 +598,16 @@
int jog_mode = 0;
int kill_jog_mode = 0;
+ //reset
+ int reset = 0;
+
+ //cancel
+ int cancel = 0;
+
+ //zero
+ int zero = 0;
+ int machine_zero = 0;
+
printf("\n\nReceiving...\n\r");
t.reset();
@@ -596,7 +633,24 @@
} else {
jog();
}
- }
+ } else if(reset){
+ NVIC_SystemReset();
+ } else if(cancel){
+ cancel = 1;
+ cancelProgram();
+ } else if(zero){
+ if(machine_zero){
+ zeroX(ppsMax);
+ zeroY(ppsMax);
+ zeroZ(ppsMax);
+ } else if(last_recv == 'X'){
+ totalX = 0;
+ } else if(last_recv == 'Y'){
+ totalY = 0;
+ } else if(last_recv == 'Z'){
+ totalZ = 0;
+ }
+ }
break;
}
@@ -612,6 +666,18 @@
jog_mode = 1;
}
+ if(recv == 'r'){
+ reset = 1;
+ }
+
+ if(recv == 'c'){
+ cancel = 1;
+ }
+
+ if(recv == 'z'){
+ zero = 1;
+ }
+
if(save){
if(recv == 'M'){
mode = 1;
@@ -635,6 +701,12 @@
if(jog_mode && recv == 'k'){
kill_jog_mode = 1;
}
+
+ if(zero && recv == 'm'){
+ machine_zero = 1;
+ } else if(zero && recv != 'm'){
+ last_recv = recv;
+ }
}
t.reset();
}
\ No newline at end of file