add microsteps
parent
08259b0ab1
commit
beee68850a
|
@ -374,6 +374,9 @@ export function fakeFirmwareConfig(): TaggedFirmwareConfig {
|
|||
movement_step_per_mm_x: 5,
|
||||
movement_step_per_mm_y: 5,
|
||||
movement_step_per_mm_z: 25,
|
||||
movement_microsteps_x: 1,
|
||||
movement_microsteps_y: 1,
|
||||
movement_microsteps_z: 1,
|
||||
movement_steps_acc_dec_x: 300,
|
||||
movement_steps_acc_dec_y: 300,
|
||||
movement_steps_acc_dec_z: 300,
|
||||
|
|
|
@ -113,6 +113,10 @@ export namespace ToolTips {
|
|||
trim(`The number of motor steps required to move the axis one millimeter.
|
||||
(default: x: 5, y: 5, z: 25)`);
|
||||
|
||||
export const MICROSTEPS_PER_STEP =
|
||||
trim(`The number of microsteps required to move the motor one step.
|
||||
(default: x: 1, y: 1, z: 1)`);
|
||||
|
||||
export const ALWAYS_POWER_MOTORS =
|
||||
trim(`Keep power applied to motors. Prevents slipping from gravity in
|
||||
certain situations. (default: enabled)`);
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
import {
|
||||
calcMicrostepsPerMm, calculateAxialLengths
|
||||
} from "../direction_axes_props";
|
||||
import { fakeFirmwareConfig } from "../../../__test_support__/fake_state/resources";
|
||||
|
||||
describe("calcMicrostepsPerMm()", () => {
|
||||
it("uses fallback values", () => {
|
||||
expect(calcMicrostepsPerMm(undefined, undefined)).toEqual(1);
|
||||
});
|
||||
|
||||
it("calculates value with no microstepping", () => {
|
||||
expect(calcMicrostepsPerMm(5, 1)).toEqual(5);
|
||||
});
|
||||
|
||||
it("calculates value with microstepping", () => {
|
||||
expect(calcMicrostepsPerMm(5, 4)).toEqual(20);
|
||||
});
|
||||
});
|
||||
|
||||
describe("calculateAxialLengths()", () => {
|
||||
it("calculates lengths", () => {
|
||||
const firmwareSettings = fakeFirmwareConfig().body;
|
||||
firmwareSettings.movement_axis_nr_steps_x = 0;
|
||||
firmwareSettings.movement_step_per_mm_x = 0;
|
||||
firmwareSettings.movement_microsteps_x = 0;
|
||||
firmwareSettings.movement_axis_nr_steps_y = 100;
|
||||
firmwareSettings.movement_step_per_mm_y = 5;
|
||||
firmwareSettings.movement_microsteps_y = 1;
|
||||
firmwareSettings.movement_axis_nr_steps_z = 100;
|
||||
firmwareSettings.movement_step_per_mm_z = 25;
|
||||
firmwareSettings.movement_microsteps_z = 4;
|
||||
expect(calculateAxialLengths({ firmwareSettings })).toEqual({
|
||||
x: 0, y: 20, z: 1
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,17 +1,34 @@
|
|||
import { DirectionAxesProps } from "./interfaces";
|
||||
import { McuParams } from "farmbot";
|
||||
|
||||
const _ = (nr_steps: number | undefined, steps_mm: number | undefined) => {
|
||||
return (nr_steps || 0) / (steps_mm || 1);
|
||||
export const calcMicrostepsPerMm = (
|
||||
steps_per_mm: number | undefined,
|
||||
microsteps_per_step: number | undefined) =>
|
||||
(steps_per_mm || 1) * (microsteps_per_step || 1);
|
||||
|
||||
const calcAxisLength = (
|
||||
nr_steps: number | undefined,
|
||||
steps_per_mm: number | undefined,
|
||||
microsteps_per_step: number | undefined) => {
|
||||
return (nr_steps || 0)
|
||||
/ calcMicrostepsPerMm(steps_per_mm, microsteps_per_step);
|
||||
};
|
||||
|
||||
function calculateAxialLengths(props: { firmwareSettings: McuParams }) {
|
||||
export function calculateAxialLengths(props: { firmwareSettings: McuParams }) {
|
||||
const fwParams = props.firmwareSettings;
|
||||
|
||||
return {
|
||||
x: _(fwParams.movement_axis_nr_steps_x, fwParams.movement_step_per_mm_x),
|
||||
y: _(fwParams.movement_axis_nr_steps_y, fwParams.movement_step_per_mm_y),
|
||||
z: _(fwParams.movement_axis_nr_steps_z, fwParams.movement_step_per_mm_z),
|
||||
x: calcAxisLength(
|
||||
fwParams.movement_axis_nr_steps_x,
|
||||
fwParams.movement_step_per_mm_x,
|
||||
fwParams.movement_microsteps_x),
|
||||
y: calcAxisLength(
|
||||
fwParams.movement_axis_nr_steps_y,
|
||||
fwParams.movement_step_per_mm_y,
|
||||
fwParams.movement_microsteps_y),
|
||||
z: calcAxisLength(
|
||||
fwParams.movement_axis_nr_steps_z,
|
||||
fwParams.movement_step_per_mm_z,
|
||||
fwParams.movement_microsteps_z),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import { Header } from "./header";
|
|||
import { Collapse } from "@blueprintjs/core";
|
||||
import { minFwVersionCheck } from "../../../util";
|
||||
import { t } from "../../../i18next_wrapper";
|
||||
import { calculateScale } from "./motors";
|
||||
|
||||
export function HomingAndCalibration(props: HomingAndCalibrationProps) {
|
||||
|
||||
|
@ -31,6 +32,8 @@ export function HomingAndCalibration(props: HomingAndCalibrationProps) {
|
|||
*/
|
||||
const disabled = disabledAxisMap(hardware);
|
||||
|
||||
const scale = calculateScale(sourceFwConfig);
|
||||
|
||||
return <section>
|
||||
<Header
|
||||
title={t("Homing and Calibration")}
|
||||
|
@ -79,11 +82,11 @@ export function HomingAndCalibration(props: HomingAndCalibrationProps) {
|
|||
name={t("Axis Length (mm)")}
|
||||
tooltip={ToolTips.LENGTH}
|
||||
x={"movement_axis_nr_steps_x"}
|
||||
xScale={sourceFwConfig("movement_step_per_mm_x").value}
|
||||
y={"movement_axis_nr_steps_y"}
|
||||
yScale={sourceFwConfig("movement_step_per_mm_y").value}
|
||||
z={"movement_axis_nr_steps_z"}
|
||||
zScale={sourceFwConfig("movement_step_per_mm_z").value}
|
||||
xScale={scale.x}
|
||||
yScale={scale.y}
|
||||
zScale={scale.z}
|
||||
gray={{
|
||||
x: !sourceFwConfig("movement_stop_at_max_x").value,
|
||||
y: !sourceFwConfig("movement_stop_at_max_y").value,
|
||||
|
|
|
@ -12,6 +12,9 @@ import { Collapse } from "@blueprintjs/core";
|
|||
import { McuInputBox } from "../mcu_input_box";
|
||||
import { minFwVersionCheck } from "../../../util";
|
||||
import { t } from "../../../i18next_wrapper";
|
||||
import { Xyz, McuParamName } from "farmbot";
|
||||
import { SourceFwConfig } from "../../interfaces";
|
||||
import { calcMicrostepsPerMm } from "../../../controls/move/direction_axes_props";
|
||||
|
||||
const SingleSettingRow =
|
||||
({ label, tooltip, settingType, children }: {
|
||||
|
@ -30,6 +33,19 @@ const SingleSettingRow =
|
|||
: <Col xs={6}>{children}</Col>}
|
||||
</Row>;
|
||||
|
||||
export const calculateScale =
|
||||
(sourceFwConfig: SourceFwConfig): Record<Xyz, number | undefined> => {
|
||||
const getV = (name: McuParamName) => sourceFwConfig(name).value;
|
||||
return {
|
||||
x: calcMicrostepsPerMm(getV("movement_step_per_mm_x"),
|
||||
getV("movement_microsteps_x")),
|
||||
y: calcMicrostepsPerMm(getV("movement_step_per_mm_y"),
|
||||
getV("movement_microsteps_y")),
|
||||
z: calcMicrostepsPerMm(getV("movement_step_per_mm_z"),
|
||||
getV("movement_microsteps_z")),
|
||||
};
|
||||
};
|
||||
|
||||
export function Motors(props: MotorsProps) {
|
||||
const {
|
||||
dispatch, firmwareVersion, controlPanelState,
|
||||
|
@ -38,6 +54,7 @@ export function Motors(props: MotorsProps) {
|
|||
const enable2ndXMotor = sourceFwConfig("movement_secondary_motor_x");
|
||||
const invert2ndXMotor = sourceFwConfig("movement_secondary_motor_invert_x");
|
||||
const eStopOnMoveError = sourceFwConfig("param_e_stop_on_mov_err");
|
||||
const scale = calculateScale(sourceFwConfig);
|
||||
|
||||
return <section>
|
||||
<Header
|
||||
|
@ -69,9 +86,9 @@ export function Motors(props: MotorsProps) {
|
|||
x={"movement_max_spd_x"}
|
||||
y={"movement_max_spd_y"}
|
||||
z={"movement_max_spd_z"}
|
||||
xScale={sourceFwConfig("movement_step_per_mm_x").value}
|
||||
yScale={sourceFwConfig("movement_step_per_mm_y").value}
|
||||
zScale={sourceFwConfig("movement_step_per_mm_z").value}
|
||||
xScale={scale.x}
|
||||
yScale={scale.y}
|
||||
zScale={scale.z}
|
||||
sourceFwConfig={sourceFwConfig}
|
||||
dispatch={dispatch} />
|
||||
{(minFwVersionCheck(firmwareVersion, "5.0.5") || isValidFwConfig) &&
|
||||
|
@ -81,9 +98,9 @@ export function Motors(props: MotorsProps) {
|
|||
x={"movement_home_spd_x"}
|
||||
y={"movement_home_spd_y"}
|
||||
z={"movement_home_spd_z"}
|
||||
xScale={sourceFwConfig("movement_step_per_mm_x").value}
|
||||
yScale={sourceFwConfig("movement_step_per_mm_y").value}
|
||||
zScale={sourceFwConfig("movement_step_per_mm_z").value}
|
||||
xScale={scale.x}
|
||||
yScale={scale.y}
|
||||
zScale={scale.z}
|
||||
sourceFwConfig={sourceFwConfig}
|
||||
dispatch={dispatch} />}
|
||||
<NumericMCUInputGroup
|
||||
|
@ -92,9 +109,9 @@ export function Motors(props: MotorsProps) {
|
|||
x={"movement_min_spd_x"}
|
||||
y={"movement_min_spd_y"}
|
||||
z={"movement_min_spd_z"}
|
||||
xScale={sourceFwConfig("movement_step_per_mm_x").value}
|
||||
yScale={sourceFwConfig("movement_step_per_mm_y").value}
|
||||
zScale={sourceFwConfig("movement_step_per_mm_z").value}
|
||||
xScale={scale.x}
|
||||
yScale={scale.y}
|
||||
zScale={scale.z}
|
||||
sourceFwConfig={sourceFwConfig}
|
||||
dispatch={dispatch} />
|
||||
<NumericMCUInputGroup
|
||||
|
@ -103,9 +120,9 @@ export function Motors(props: MotorsProps) {
|
|||
x={"movement_steps_acc_dec_x"}
|
||||
y={"movement_steps_acc_dec_y"}
|
||||
z={"movement_steps_acc_dec_z"}
|
||||
xScale={sourceFwConfig("movement_step_per_mm_x").value}
|
||||
yScale={sourceFwConfig("movement_step_per_mm_y").value}
|
||||
zScale={sourceFwConfig("movement_step_per_mm_z").value}
|
||||
xScale={scale.x}
|
||||
yScale={scale.y}
|
||||
zScale={scale.z}
|
||||
sourceFwConfig={sourceFwConfig}
|
||||
dispatch={dispatch} />
|
||||
<NumericMCUInputGroup
|
||||
|
@ -114,9 +131,20 @@ export function Motors(props: MotorsProps) {
|
|||
x={"movement_step_per_mm_x"}
|
||||
y={"movement_step_per_mm_y"}
|
||||
z={"movement_step_per_mm_z"}
|
||||
xScale={sourceFwConfig("movement_microsteps_x").value}
|
||||
yScale={sourceFwConfig("movement_microsteps_y").value}
|
||||
zScale={sourceFwConfig("movement_microsteps_z").value}
|
||||
float={false}
|
||||
sourceFwConfig={props.sourceFwConfig}
|
||||
dispatch={props.dispatch} />
|
||||
<NumericMCUInputGroup
|
||||
name={t("Microsteps per step")}
|
||||
tooltip={ToolTips.MICROSTEPS_PER_STEP}
|
||||
x={"movement_microsteps_x"}
|
||||
y={"movement_microsteps_y"}
|
||||
z={"movement_microsteps_z"}
|
||||
sourceFwConfig={props.sourceFwConfig}
|
||||
dispatch={props.dispatch} />
|
||||
<BooleanMCUInputGroup
|
||||
name={t("Always Power Motors")}
|
||||
tooltip={ToolTips.ALWAYS_POWER_MOTORS}
|
||||
|
|
|
@ -27,6 +27,7 @@ import { Feature } from "../devices/interfaces";
|
|||
import { reduceFarmwareEnv } from "../farmware/state_to_props";
|
||||
import { getFirmwareConfig } from "../resources/getters";
|
||||
import { DevSettings } from "../account/dev/dev_support";
|
||||
import { calcMicrostepsPerMm } from "../controls/move/direction_axes_props";
|
||||
|
||||
const plantFinder = (plants: TaggedPlant[]) =>
|
||||
(uuid: string | undefined): TaggedPlant =>
|
||||
|
@ -64,7 +65,11 @@ export function mapStateToProps(props: Everything): Props {
|
|||
const { mcu_params } = props.bot.hardware;
|
||||
const firmwareSettings = fwConfig || mcu_params;
|
||||
|
||||
const { movement_step_per_mm_x, movement_step_per_mm_y } = firmwareSettings;
|
||||
const fw = firmwareSettings;
|
||||
const stepsPerMmXY = {
|
||||
x: calcMicrostepsPerMm(fw.movement_step_per_mm_x, fw.movement_microsteps_x),
|
||||
y: calcMicrostepsPerMm(fw.movement_step_per_mm_y, fw.movement_microsteps_y),
|
||||
};
|
||||
|
||||
const peripherals = uniq(selectAllPeripherals(props.resources.index))
|
||||
.map(x => {
|
||||
|
@ -119,7 +124,7 @@ export function mapStateToProps(props: Everything): Props {
|
|||
plants,
|
||||
botLocationData: validBotLocationData(props.bot.hardware.location_data),
|
||||
botMcuParams: firmwareSettings,
|
||||
stepsPerMmXY: { x: movement_step_per_mm_x, y: movement_step_per_mm_y },
|
||||
stepsPerMmXY,
|
||||
peripherals,
|
||||
eStopStatus: props.bot.hardware.informational_settings.locked,
|
||||
latestImages,
|
||||
|
|
|
@ -15,6 +15,7 @@ import { getFirmwareConfig } from "../resources/getters";
|
|||
import { Farmwares } from "../farmware/interfaces";
|
||||
import { manifestInfo } from "../farmware/generate_manifest_info";
|
||||
import { DevSettings } from "../account/dev/dev_support";
|
||||
import { calculateAxialLengths } from "../controls/move/direction_axes_props";
|
||||
|
||||
export function mapStateToProps(props: Everything): Props {
|
||||
const uuid = props.resources.consumers.sequences.current;
|
||||
|
@ -42,14 +43,7 @@ export function mapStateToProps(props: Everything): Props {
|
|||
y: !!firmwareSettings.movement_home_up_y,
|
||||
z: !!firmwareSettings.movement_home_up_z
|
||||
},
|
||||
axisLength: {
|
||||
x: (firmwareSettings.movement_axis_nr_steps_x || 0)
|
||||
/ (firmwareSettings.movement_step_per_mm_x || 1),
|
||||
y: (firmwareSettings.movement_axis_nr_steps_y || 0)
|
||||
/ (firmwareSettings.movement_step_per_mm_y || 1),
|
||||
z: (firmwareSettings.movement_axis_nr_steps_z || 0)
|
||||
/ (firmwareSettings.movement_step_per_mm_z || 1)
|
||||
},
|
||||
axisLength: calculateAxialLengths({ firmwareSettings }),
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
"coveralls": "3.0.3",
|
||||
"enzyme": "3.9.0",
|
||||
"enzyme-adapter-react-16": "1.12.1",
|
||||
"farmbot": "7.0.4-rc1",
|
||||
"farmbot": "7.0.4-rc3",
|
||||
"farmbot-toastr": "1.0.3",
|
||||
"i18next": "15.0.9",
|
||||
"jest": "24.7.1",
|
||||
|
|
Loading…
Reference in New Issue