AXIS_SET(homed, bool)
-AXIS_GET(velocity_max, float, 0)
-AXIS_GET(accel_max, float, 0)
AXIS_GET(homed, bool, false)
AXIS_GET(homing_mode, homing_mode_t, HOMING_MANUAL)
AXIS_GET(radius, float, 0)
AXIS_GET(zero_backoff, float, 0)
AXIS_GET(latch_backoff, float, 0)
-/* Note on jerk functions
- *
- * Jerk values can be rather large. Jerk values are stored in the system in
- * truncated format; values are divided by 1,000,000 then multiplied before use.
- *
- * The axis_jerk() functions expect the jerk in divided by 1,000,000 form.
- */
+
+/// Velocity is scaled by 1,000.
+float axis_get_velocity_max(int axis) {
+ int motor = axis_get_motor(axis);
+ return motor == -1 ? 0 : axes[motor].velocity_max * VELOCITY_MULTIPLIER;
+}
+AXIS_VAR_GET(velocity_max, float)
+
+
+/// Acceleration is scaled by 1,000.
+float axis_get_accel_max(int axis) {
+ int motor = axis_get_motor(axis);
+ return motor == -1 ? 0 : axes[motor].accel_max * ACCEL_MULTIPLIER;
+}
+AXIS_VAR_GET(accel_max, float)
+
+
+/// Jerk is scaled by 1,000,000.
float axis_get_jerk_max(int axis) {
int motor = axis_get_motor(axis);
return motor == -1 ? 0 : axes[motor].jerk_max * JERK_MULTIPLIER;
AXIS_VAR_SET(velocity_max, float)
AXIS_VAR_SET(accel_max, float)
+AXIS_VAR_SET(jerk_max, float)
AXIS_VAR_SET(radius, float)
AXIS_VAR_SET(travel_min, float)
AXIS_VAR_SET(travel_max, float)
AXIS_VAR_SET(latch_velocity, float)
AXIS_VAR_SET(zero_backoff, float)
AXIS_VAR_SET(latch_backoff, float)
-AXIS_VAR_SET(jerk_max, float)
float get_homing_dir(int axis) {
#define CURRENT_SENSE_RESISTOR 0.05 // ohms
#define CURRENT_SENSE_REF 2.75 // volts
#define MAX_CURRENT 10 // amps
+#define VELOCITY_MULTIPLIER 1000.0
+#define ACCEL_MULTIPLIER 1000.0
#define JERK_MULTIPLIER 1000000.0
#define SYNC_QUEUE_SIZE 4096
#define EXEC_FILL_TARGET 8
// Variable callbacks
int32_t get_line() {return ex.line;}
uint8_t get_tool() {return ex.tool;}
-float get_velocity() {return ex.velocity;}
-float get_acceleration() {return ex.accel;}
-float get_jerk() {return ex.jerk;}
+float get_velocity() {return ex.velocity / VELOCITY_MULTIPLIER;}
+float get_acceleration() {return ex.accel / ACCEL_MULTIPLIER;}
+float get_jerk() {return ex.jerk / JERK_MULTIPLIER;}
float get_feed_override() {return ex.feed_override;}
float get_speed_override() {return ex.spindle_override;}
float get_axis_position(int axis) {return ex.position[axis];}
#include "switch.h"
#include "estop.h"
#include "util.h"
+#include "state.h"
#include <stdint.h>
unsigned command_seek_size() {return sizeof(seek_t);}
-
-
void command_seek_exec(void *data) {seek = *(seek_t *)data;}
bool switch_is_active(int index) {
+ // NOTE, switch inputs are active lo
switch (switches[index].type) {
case SW_DISABLED: break; // A disabled switch cannot be active
case SW_NORMALLY_OPEN: return !switches[index].state;
table.info
tr
th Velocity
- td {{state.v || 0 | fixed 0}}
- td mm/min
+ td {{state.v || 0 | fixed 2}}
+ td m/min
tr
th Line
td {{0 <= state.ln ? state.ln : '-'}}
import json
import time
import logging
+import traceback
from collections import deque
import bbctrl
if self.ctrl.ioloop.READ & events: self.serial_read()
if self.ctrl.ioloop.WRITE & events: self.serial_write()
except Exception as e:
- log.error('Serial handler error: %s', e)
+ log.error('Serial handler error: %s', traceback.format_exc())
def serial_write(self):
STEP = 'S'
RESUME = 'c'
-SEEK_OPEN = 1 << 0
-SEEK_ERROR = 1 << 1
+SEEK_ACTIVE = 1 << 0
+SEEK_ERROR = 1 << 1
def encode_float(x):
def dwell(seconds): return 'd' + encode_float(seconds)
def pause(optional = False): 'P' + ('1' if optional else '0')
def jog(axes): return 'j' + encode_axes(axes)
+
+
+def seek(switch, active, error):
+ cmd = SEEK
+
+ if switch == 'probe': cmd += '1'
+ elif switch == 'x-min': cmd += '2'
+ elif switch == 'x-max': cmd += '3'
+ elif switch == 'y-min': cmd += '4'
+ elif switch == 'y-max': cmd += '5'
+ elif switch == 'z-min': cmd += '6'
+ elif switch == 'z-max': cmd += '7'
+ elif switch == 'a-min': cmd += '8'
+ elif switch == 'a-max': cmd += '9'
+ else: raise Exception('Unsupported switch "%s"' % switch)
+
+ flags = 0
+ if active: flags |= SEEK_ACTIVE
+ if error: flags |= SEEK_ERROR
+ cmd += chr(flags + ord('0'))
+
+ return cmd
# Planner config
self.config = {
- "start": start,
- "max-vel": get_vector('vm'),
- "max-accel": get_vector('am'),
- "max-jerk": get_vector('jm', 1000000),
+ "start": start,
+ "max-vel": get_vector('vm', 1000),
+ "max-accel": get_vector('am', 1000),
+ "max-jerk": get_vector('jm', 1000000),
# TODO junction deviation & accel
}
log.info('Planner config: ' + json.dumps(self.config))
if type == 'speed': return Cmd.speed(block['speed'])
if type == 'dwell': return Cmd.dwell(block['seconds'])
if type == 'pause': return Cmd.pause(block['optional'])
+ if type == 'seek':
+ return Cmd.seek(block['switch'], block['active'], block['error'])
raise Exception('Unknown planner type "%s"' % type)
"max-velocity": {
"type": "float",
"min": 0,
- "unit": "mm/min",
- "default": 6000,
+ "unit": "m/min",
+ "default": 5,
"code": "vm"
},
+ "max-accel": {
+ "type": "float",
+ "min": 0,
+ "unit": "m/min²",
+ "default": 100,
+ "code": "am"
+ },
"max-jerk": {
"type": "float",
"min": 0,
- "unit": "mm/min³",
+ "unit": "km/min³",
"default": 50,
"code": "jm"
},