Commit 61bc7546 authored by Chetan Sharma's avatar Chetan Sharma
Browse files

Saving progress

parent add66329
This source diff could not be displayed because it is too large. You can view the blob instead.
(PLATE_3_16)
(T3 D=4.762 CR=0 - ZMIN=-6.35 - flat end mill)
G90 G94
G17
G21
G28 G91 Z0
G90
(2D Contour1)
T3 M6
S5000 M3
G54
M8
G0 X32.124 Y80.01
Z25
Z5
G1 Z-0.524 F250
G19 G2 Y79.534 Z-1 J-0.476 K0 F586
G1 Y79.058
G17 G3 X32.6 Y78.581 I0.476 J0
G2 X37.981 Y73.2 I0 J-5.381
G1 Y55.239
G2 X34.244 Y50.115 I-5.381 J0
G3 X41.956 Y26.085 I3.856 J-12.015
X41.956 Y50.115 I-3.856 J12.015
G2 X38.219 Y55.239 I1.644 J5.124
G1 Y73.2
G2 X43.6 Y78.581 I5.381 J0
G3 X44.076 Y79.058 I0 J0.476
G1 Y79.534
G19 G3 Y80.01 Z-0.524 J0 K0.476
G1 X32.124
Z-1.524 F250
G2 Y79.534 Z-2 J-0.476 K0 F586
G1 Y79.058
G17 G3 X32.6 Y78.581 I0.476 J0
G2 X37.981 Y73.2 I0 J-5.381
G1 Y55.239
G2 X34.244 Y50.115 I-5.381 J0
G3 X41.956 Y26.085 I3.856 J-12.015
X41.956 Y50.115 I-3.856 J12.015
G2 X38.219 Y55.239 I1.644 J5.124
G1 Y73.2
G2 X43.6 Y78.581 I5.381 J0
G3 X44.076 Y79.058 I0 J0.476
G1 Y79.534
G19 G3 Y80.01 Z-1.524 J0 K0.476
G1 X32.124
Z-2.524 F250
G2 Y79.534 Z-3 J-0.476 K0 F586
G1 Y79.058
G17 G3 X32.6 Y78.581 I0.476 J0
G2 X37.981 Y73.2 I0 J-5.381
G1 Y55.239
G2 X34.244 Y50.115 I-5.381 J0
G3 X41.956 Y26.085 I3.856 J-12.015
X41.956 Y50.115 I-3.856 J12.015
G2 X38.219 Y55.239 I1.644 J5.124
G1 Y73.2
G2 X43.6 Y78.581 I5.381 J0
G3 X44.076 Y79.058 I0 J0.476
G1 Y79.534
G19 G3 Y80.01 Z-2.524 J0 K0.476
G1 X32.124
Z-3.524 F250
G2 Y79.534 Z-4 J-0.476 K0 F586
G1 Y79.058
G17 G3 X32.6 Y78.581 I0.476 J0
G2 X37.981 Y73.2 I0 J-5.381
G1 Y55.239
G2 X34.244 Y50.115 I-5.381 J0
G3 X41.956 Y26.085 I3.856 J-12.015
X41.956 Y50.115 I-3.856 J12.015
G2 X38.219 Y55.239 I1.644 J5.124
G1 Y73.2
G2 X43.6 Y78.581 I5.381 J0
G3 X44.076 Y79.058 I0 J0.476
G1 Y79.534
G19 G3 Y80.01 Z-3.524 J0 K0.476
G1 X32.124
Z-4.524 F250
G2 Y79.534 Z-5 J-0.476 K0 F586
G1 Y79.058
G17 G3 X32.6 Y78.581 I0.476 J0
G2 X37.981 Y73.2 I0 J-5.381
G1 Y55.239
G2 X34.244 Y50.115 I-5.381 J0
G3 X41.956 Y26.085 I3.856 J-12.015
X41.956 Y50.115 I-3.856 J12.015
G2 X38.219 Y55.239 I1.644 J5.124
G1 Y73.2
G2 X43.6 Y78.581 I5.381 J0
G3 X44.076 Y79.058 I0 J0.476
G1 Y79.534
G19 G3 Y80.01 Z-4.524 J0 K0.476
G1 X32.124
Z-5.524 F250
G2 Y79.534 Z-6 J-0.476 K0 F586
G1 Y79.058
G17 G3 X32.6 Y78.581 I0.476 J0
G2 X37.981 Y73.2 I0 J-5.381
G1 Y55.239
G2 X34.244 Y50.115 I-5.381 J0
G3 X41.956 Y26.085 I3.856 J-12.015
X41.956 Y50.115 I-3.856 J12.015
G2 X38.219 Y55.239 I1.644 J5.124
G1 Y73.2
G2 X43.6 Y78.581 I5.381 J0
G3 X44.076 Y79.058 I0 J0.476
G1 Y79.534
G19 G3 Y80.01 Z-5.524 J0 K0.476
G1 X32.124
Z-5.874 F250
G2 Y79.534 Z-6.35 J-0.476 K0 F586
G1 Y79.058
G17 G3 X32.6 Y78.581 I0.476 J0
G2 X37.981 Y73.2 I0 J-5.381
G1 Y55.239
G2 X34.244 Y50.115 I-5.381 J0
G3 X41.956 Y26.085 I3.856 J-12.015
X41.956 Y50.115 I-3.856 J12.015
G2 X38.219 Y55.239 I1.644 J5.124
G1 Y73.2
G2 X43.6 Y78.581 I5.381 J0
G3 X44.076 Y79.058 I0 J0.476
G1 Y79.534
G19 G3 Y80.01 Z-5.874 J0 K0.476
G0 Z25
G17
(Slot1)
G0 X92.749 Y22.265
Z25
Z5
G1 Z0.5 F586
G3 X83.535 Y13.051 Z0.075 I8.051 J-17.265
G2 X92.749 Y22.265 Z-0.35 I17.265 J-8.051
G3 X83.535 Y13.051 I8.051 J-17.265
G2 X92.749 Y22.265 Z-0.683 I17.265 J-8.051
G3 X83.535 Y13.051 Z-1.017 I8.051 J-17.265
G2 X92.749 Y22.265 Z-1.35 I17.265 J-8.051
G3 X83.535 Y13.051 I8.051 J-17.265
G2 X92.749 Y22.265 Z-1.683 I17.265 J-8.051
G3 X83.535 Y13.051 Z-2.017 I8.051 J-17.265
G2 X92.749 Y22.265 Z-2.35 I17.265 J-8.051
G3 X83.535 Y13.051 I8.051 J-17.265
G2 X92.749 Y22.265 Z-2.683 I17.265 J-8.051
G3 X83.535 Y13.051 Z-3.017 I8.051 J-17.265
G2 X92.749 Y22.265 Z-3.35 I17.265 J-8.051
G3 X83.535 Y13.051 I8.051 J-17.265
G2 X92.749 Y22.265 Z-3.683 I17.265 J-8.051
G3 X83.535 Y13.051 Z-4.017 I8.051 J-17.265
G2 X92.749 Y22.265 Z-4.35 I17.265 J-8.051
G3 X83.535 Y13.051 I8.051 J-17.265
G2 X92.749 Y22.265 Z-4.683 I17.265 J-8.051
G3 X83.535 Y13.051 Z-5.017 I8.051 J-17.265
G2 X92.749 Y22.265 Z-5.35 I17.265 J-8.051
G3 X83.535 Y13.051 I8.051 J-17.265
G2 X92.749 Y22.265 Z-5.683 I17.265 J-8.051
G3 X83.535 Y13.051 Z-6.017 I8.051 J-17.265
G2 X92.749 Y22.265 Z-6.35 I17.265 J-8.051
G3 X83.535 Y13.051 I8.051 J-17.265
G0 Z25
(2D Pocket1)
X100.919 Y5
Z25
Z5
G1 Z-1 F250
G3 X100.681 Y5 I-0.119 J0 F586
X100.919 Y5 I0.119 J0
G1 Z-2 F250
G3 X100.681 Y5 I-0.119 J0 F586
X100.919 Y5 I0.119 J0
G1 Z-3 F250
G3 X100.681 Y5 I-0.119 J0 F586
X100.919 Y5 I0.119 J0
G1 Z-4 F250
G3 X100.681 Y5 I-0.119 J0 F586
X100.919 Y5 I0.119 J0
G1 Z-5 F250
G3 X100.681 Y5 I-0.119 J0 F586
X100.919 Y5 I0.119 J0
G1 Z-6 F250
G3 X100.681 Y5 I-0.119 J0 F586
X100.919 Y5 I0.119 J0
G1 Z-6.35 F250
G3 X100.681 Y5 I-0.119 J0 F586
X100.919 Y5 I0.119 J0
G1 X100.913 Y5.035 Z-6.343
X100.898 Y5.067 Z-6.336
X100.874 Y5.093 Z-6.329
X100.843 Y5.111 Z-6.322
X100.804 Y5.119 Z-6.295
X100.764 Y5.113 Z-6.268
X100.729 Y5.095 Z-6.242
X100.701 Y5.065 Z-6.181
X100.685 Y5.028 Z-6.12
X100.681 Y5 Z-5.977
G0 Z25
M9
G28 G91 Z0
G90
G28 G91 X0 Y0
G90
M5
M30
(PLATE_DRILL_1_8)
(T2 D=3.175 CR=0 TAPER=118deg - ZMIN=-5.85 - drill)
G90 G94
G17
G21
G28 G91 Z0
G90
(Drill2)
T2 M6
S9170 M3
G54
M8
G0 X24.63 Y51.57
Z25
Z15
Z5
Z2
G1 Z-0.794 F229.3
G0 Z-0.694
G1 Z-1.587 F229.3
G0 Z-1.487
G1 Z-2.381 F229.3
G0 Z-2.281
G1 Z-3.175 F229.3
G0 Z-3.075
G1 Z-3.969 F229.3
G0 Z-3.869
G1 Z-4.762 F229.3
G0 Z-4.662
G1 Z-5.556 F229.3
G0 Z-5.456
G1 Z-5.85 F229.3
G0 Z15
X4 Y49.1
Z5
Z2
G1 Z-0.794 F229.3
G0 Z-0.694
G1 Z-1.587 F229.3
G0 Z-1.487
G1 Z-2.381 F229.3
G0 Z-2.281
G1 Z-3.175 F229.3
G0 Z-3.075
G1 Z-3.969 F229.3
G0 Z-3.869
G1 Z-4.762 F229.3
G0 Z-4.662
G1 Z-5.556 F229.3
G0 Z-5.456
G1 Z-5.85 F229.3
G0 Z15
Y27.1
Z5
Z2
G1 Z-0.794 F229.3
G0 Z-0.694
G1 Z-1.587 F229.3
G0 Z-1.487
G1 Z-2.381 F229.3
G0 Z-2.281
G1 Z-3.175 F229.3
G0 Z-3.075
G1 Z-3.969 F229.3
G0 Z-3.869
G1 Z-4.762 F229.3
G0 Z-4.662
G1 Z-5.556 F229.3
G0 Z-5.456
G1 Z-5.85 F229.3
G0 Z15
X24.63 Y24.63
Z5
Z2
G1 Z-0.794 F229.3
G0 Z-0.694
G1 Z-1.587 F229.3
G0 Z-1.487
G1 Z-2.381 F229.3
G0 Z-2.281
G1 Z-3.175 F229.3
G0 Z-3.075
G1 Z-3.969 F229.3
G0 Z-3.869
G1 Z-4.762 F229.3
G0 Z-4.662
G1 Z-5.556 F229.3
G0 Z-5.456
G1 Z-5.85 F229.3
G0 Z15
X51.57
Z5
Z2
G1 Z-0.794 F229.3
G0 Z-0.694
G1 Z-1.587 F229.3
G0 Z-1.487
G1 Z-2.381 F229.3
G0 Z-2.281
G1 Z-3.175 F229.3
G0 Z-3.075
G1 Z-3.969 F229.3
G0 Z-3.869
G1 Z-4.762 F229.3
G0 Z-4.662
G1 Z-5.556 F229.3
G0 Z-5.456
G1 Z-5.85 F229.3
G0 Z15
X72.2 Y27.1
Z5
Z2
G1 Z-0.794 F229.3
G0 Z-0.694
G1 Z-1.587 F229.3
G0 Z-1.487
G1 Z-2.381 F229.3
G0 Z-2.281
G1 Z-3.175 F229.3
G0 Z-3.075
G1 Z-3.969 F229.3
G0 Z-3.869
G1 Z-4.762 F229.3
G0 Z-4.662
G1 Z-5.556 F229.3
G0 Z-5.456
G1 Z-5.85 F229.3
G0 Z15
Y49.1
Z5
Z2
G1 Z-0.794 F229.3
G0 Z-0.694
G1 Z-1.587 F229.3
G0 Z-1.487
G1 Z-2.381 F229.3
G0 Z-2.281
G1 Z-3.175 F229.3
G0 Z-3.075
G1 Z-3.969 F229.3
G0 Z-3.869
G1 Z-4.762 F229.3
G0 Z-4.662
G1 Z-5.556 F229.3
G0 Z-5.456
G1 Z-5.85 F229.3
G0 Z15
X51.57 Y51.57
Z5
Z2
G1 Z-0.794 F229.3
G0 Z-0.694
G1 Z-1.587 F229.3
G0 Z-1.487
G1 Z-2.381 F229.3
G0 Z-2.281
G1 Z-3.175 F229.3
G0 Z-3.075
G1 Z-3.969 F229.3
G0 Z-3.869
G1 Z-4.762 F229.3
G0 Z-4.662
G1 Z-5.556 F229.3
G0 Z-5.456
G1 Z-5.85 F229.3
G0 Z15
X100.8 Y5
Z5
Z2
G1 Z-0.794 F229.3
G0 Z-0.694
G1 Z-1.587 F229.3
G0 Z-1.487
G1 Z-2.381 F229.3
G0 Z-2.281
G1 Z-3.175 F229.3
G0 Z-3.075
G1 Z-3.969 F229.3
G0 Z-3.869
G1 Z-4.762 F229.3
G0 Z-4.662
G1 Z-5.556 F229.3
G0 Z-5.456
G1 Z-5.85 F229.3
G0 Z15
Z25
M9
G28 G91 Z0
G90
G28 G91 X0 Y0
G90
M5
M30
(PLATE_SPOT)
(T1 D=6.35 CR=0 TAPER=90deg - ZMIN=-1 - spot drill)
G90 G94
G17
G21
G28 G91 Z0
G90
(Drill1)
T1 M6
S10000 M3
G54
M8
G0 X24.63 Y51.57
Z25
Z15
Z5
G1 Z-1 F762
G0 Z15
X4 Y49.1
Z5
G1 Z-1 F762
G0 Z15
Y27.1
Z5
G1 Z-1 F762
G0 Z15
X24.63 Y24.63
Z5
G1 Z-1 F762
G0 Z15
X51.57
Z5
G1 Z-1 F762
G0 Z15
X72.2 Y27.1
Z5
G1 Z-1 F762
G0 Z15
Y49.1
Z5
G1 Z-1 F762
G0 Z15
X51.57 Y51.57
Z5
G1 Z-1 F762
G0 Z15
X100.8 Y5
Z5
G1 Z-1 F762
G0 Z15
Z25
M9
G28 G91 Z0
G90
G28 G91 X0 Y0
G90
M5
M30
#include <due_can.h>
#define CAN_COMM_MB_IDX 0
#define CAN_TRANSFER_ID 0x07
#define CAN_TX_PRIO 0
CAN_FRAME pack_frame(float p, float v, float t) {
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Can0.begin(CAN_BPS_1000K);
Can0.watchFor();
}
void loop() {
// put your main code here, to run repeatedly:
}
This source diff could not be displayed because it is too large. You can view the blob instead.
from sensors import Machine, Spindle, TFD
import numpy as np
import time
import shelve
import logging
from queue import PriorityQueue
from tqdm import tqdm
class RawDataPacket():
def __init__(self, D, W, R, N, f_r, w, measurements):
self.D = D
self.W = W
self.R = R
self.N = N
self.f_r = f_r
self.w = w
self.measurements = measurements
def decompose_packet_sorta(self):
tTs, tFys = list(), list()
Ts, Fys = list(), list()
for measurement in self.measurements:
t, reading = measurement
reading_type, = reading.keys()
reading_data, = reading.values()
if reading_type == 'spindle':
tTs.append(t)
Ts.append(reading_data['torque'])
elif reading_type == 'tfd':
tFys.append(t)
Fys.append(reading_data)
return (tTs, tFys, Ts, Fys)
def decompose_packet(self):
Ts, Fys = list(), list()
for measurement in self.measurements:
_, reading = measurement
reading_type, = reading.keys()
reading_data, = reading.values()
if reading_type == 'spindle':
Ts.append(reading_data['torque'])
elif reading_type == 'tfd':
Fys.append(reading_data)
T = np.median(Ts)
Fy = np.median(Fys)
return DataPoint(self.D, self.W, self.R, self.N, self.f_r, self.w, T, Fy)
class MillingTest():
def __init__(self, machine_port, spindle_port, tfd_port):
self._logger = logging.Logger("Milling Test")
self._logger.setLevel(logging.INFO)
self.machine = Machine(machine_port)
self.spindle = Spindle(spindle_port)
self.tfd = TFD(tfd_port)
print("Initialized all serial objects")
# initialize machine
self.machine.unlock()
self.machine.zero()
print("Machine unlocked and zeroed.")
# create test dbs
self.db = shelve.open('results')
def run_test(self, x, y, D, W, R, fmin, fmax, w, N, test_name, offset_depth = 0):
# save params
# calculate constants
CLEARANCE = R
Y_START = -CLEARANCE * 1.5
Y_END = CLEARANCE * 1.5 + y
SWEEPS = int((x - R * 2) / W)
Y_DATA_START = CLEARANCE
Y_DATA_END = y - CLEARANCE
# calculate arrays and whatnot
feeds = np.linspace(fmin, fmax, SWEEPS)
xpos = np.linspace(CLEARANCE + W, CLEARANCE + W * SWEEPS, SWEEPS)
# start spindle
self.spindle.set_w(w)
print("Spindle started")
# initial clearing cycle
self.machine.rapid({'x': CLEARANCE, 'y': Y_START, 'z': 1})
self.machine.rapid({'z': -(D + offset_depth)})
self.machine.cut({'y': Y_END}, (fmin + fmax)/2)
print("Clearing cycle sent")
self.machine.hold_until_still()
print("Starting actual cuts. " + str(SWEEPS) + " cuts in queue.")
# begin collecting data and cutting
results = []
for f_r, x in tqdm(zip(feeds, xpos)):
# position
self.machine.rapid({'z': 1})
self.machine.rapid({'x': x, 'y': Y_START})
self.machine.rapid({'z': -(D + offset_depth)})
self.machine.hold_until_still()
print("Positioned for cut at x = " + str(x) + " with feed " + str(f_r))
# measure spindle
self.spindle.find_avg_current()
# tare
self.tfd.tare()
print("Current calibrated, tfd re-tared")
# send cut command
self.machine.cut({'y': Y_END}, f_r)
# delay until we get to a significant place
print("Waiting until fully in cut")
self.machine.hold_until_condition(lambda state : state['wpos']['y'] > Y_DATA_START)
# start counting time
outQueue = PriorityQueue()
start = time.perf_counter()
self.machine.start_measurement(outQueue, start)
self.spindle.start_measurement(outQueue, start)
self.tfd.start_measurement(outQueue, start)
# fetch all data until finished
print("Measurement started, waiting until cut is left")
self.machine.hold_until_condition(lambda state : state['wpos']['y'] > Y_DATA_END)
print("Cut finished")
# stop measurements