Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* Added comments to ToolModel to clarify use

* Added info/comments to MachineModel to clarify use
* Updated Replicator.xml to clarify and update tools RPM and names
* Changed source of RPM speed in ExtruderPanel to avoid bad-data bug
* Documented more of MightyBoard.java
* Changed some initialization of MightyBoard to create first-connection smoothness
* Added new setMotorRPM to MightyBoard to avoid sending cmd to bot for MightyBoard
* Converted Sanguino3GDriver's 'getVersionInternal' to a proper sync and init function to fix inheritance problems with initialization of MightyBoard
* Added Documentation to Makerbot4GAlternateDriver
  • Loading branch information...
commit 01999b7ad36eddbd153871d3e0958cb02414e57f 1 parent cd44db8
@FarMcKon FarMcKon authored
View
97 machines/replicator.xml
@@ -1,105 +1,18 @@
<?xml version="1.1" encoding="utf-8"?>
<machines>
- <machine experimental="1">
- <name>The Replicator Dual Rev-A</name>
- <geometry type="cartesian">
- <!-- different pulleys on X and Y axii -->
- <axis id="x" length="80" maxfeedrate="10000" homingfeedrate="500" stepspermm="47.069852" endstops="min"/> <!-- Pulley dia: 10.82mm / 1/8 step = 1/(10.82 * pi / 1600) -->
- <axis id="y" length="80" maxfeedrate="10000" homingfeedrate="500" stepspermm="47.069852" endstops="min"/> <!-- Pulley dia: 10.82mm / 1/8 step = 1/(10.82 * pi / 1600) -->
- <axis id="z" length="106" maxfeedrate="1000" homingfeedrate="500" stepspermm="400" endstops="min"/> <!-- TR-8x8 Z axis = 1/(8/1600) -->
- <axis id="a" length="100000" maxfeedrate="1600" stepspermm="50.235478806907409" endstops="none"/> <!-- stepspermm is incoming filament length, 127 is ca. 4 RPM, 1600 ca. 50 RPM -->
- <axis id="b" length="100000" maxfeedrate="1600" stepspermm="50.235478806907409" endstops="none"/> <!-- stepspermm is incoming filament length, 127 is ca. 4 RPM, 1600 ca. 50 RPM -->
- </geometry>
- <tools>
- <tool name="Left" index="0" type="extruder" motor="true" fan="false" heatedplatform="true" motor_steps="1600" default_rpm="3" heater="true" stepper_axis="a"/>
- </tools>
- <wipes>
- <wipe index="0" X1="44.0" Y1="55.0" Z1="9" X2="44.0" Y2="55.0" Z2="9" wait="1000.0" purge_duration="1000" reverse_duration="15" purge_rpm="5.0" reverse_rpm="25.0"/>
- <wipe index="1" X1="-36.0" Y1="55.0" Z1="9" X2="-45.0" Y2="55.0" Z2="9" wait="1000.0" purge_duration="1000" reverse_duration="15" purge_rpm="5.0" reverse_rpm="25.0"/>
- </wipes>
- <clamps></clamps>
- <driver name="makerbot4ga">
- <!-- optional: <portname>COM1</portname> -->
- <rate>115200</rate>
- </driver>
- <warmup>
- </warmup>
- <cooldown>
-(Turn off steppers after a build.)
-M18
- </cooldown>
- </machine>
- <machine experimental="1">
- <name>The Replicator Dual Rev-D</name>
- <geometry type="cartesian">
- <!-- different pulleys on X and Y axii -->
- <axis id="x" length="211" maxfeedrate="10000" homingfeedrate="2500" stepspermm="94.139704" endstops="max"/> <!-- Pulley dia: 10.82mm / 1/8 step = 1/(10.82 * pi / 1600) -->
- <axis id="y" length="148" maxfeedrate="10000" homingfeedrate="2500" stepspermm="94.139704" endstops="max"/> <!-- Pulley dia: 10.82mm / 1/8 step = 1/(10.82 * pi / 1600) -->
- <axis id="z" length="158" maxfeedrate="1000" homingfeedrate="1000" stepspermm="400" endstops="min"/> <!-- TR-8x8 Z axis = 1/(8/1600) -->
- <axis id="a" length="100000" maxfeedrate="1600" stepspermm="50.235478806907409" endstops="none"/> <!-- stepspermm is incoming filament length, 127 is ca. 4 RPM, 1600 ca. 50 RPM -->
- <axis id="b" length="100000" maxfeedrate="1600" stepspermm="50.235478806907409" endstops="none"/> <!-- stepspermm is incoming filament length, 127 is ca. 4 RPM, 1600 ca. 50 RPM -->
- </geometry>
- <tools>
- <tool name="Right (B)" index="1" type="extruder" motor="true" fan="true" heatedplatform="true" motor_steps="3200" default_rpm="3" heater="true" stepper_axis="b"/>
- <tool name="Left (A)" index="0" type="extruder" motor="true" fan="true" heatedplatform="true" motor_steps="3200" default_rpm="3" heater="true" stepper_axis="a"/>
- </tools>
- <wipes>
- <wipe index="0" X1="44.0" Y1="55.0" Z1="9" X2="44.0" Y2="55.0" Z2="9" wait="1000.0" purge_duration="1000" reverse_duration="15" purge_rpm="5.0" reverse_rpm="25.0"/>
- <wipe index="1" X1="-36.0" Y1="55.0" Z1="9" X2="-45.0" Y2="55.0" Z2="9" wait="1000.0" purge_duration="1000" reverse_duration="15" purge_rpm="5.0" reverse_rpm="25.0"/>
- </wipes>
- <clamps></clamps>
- <driver name="makerbot4ga">
- <!-- optional: <portname>COM1</portname> -->
- <rate>115200</rate>
- </driver>
- <warmup>
- </warmup>
- <cooldown>
-M18 (Turn off steppers after a build.)
- </cooldown>
- </machine>
- <machine experimental="1">
- <name>The Replicator Dual Rev-F</name>
- <geometry type="cartesian">
- <!-- different pulleys on X and Y axii -->
- <axis id="x" length="211" maxfeedrate="5000" homingfeedrate="2500" stepspermm="94.139704" endstops="max"/> <!-- Pulley dia: 10.82mm / 1/8 step = 1/(10.82 * pi / 1600) -->
- <axis id="y" length="148" maxfeedrate="5000" homingfeedrate="2500" stepspermm="94.139704" endstops="max"/> <!-- Pulley dia: 10.82mm / 1/8 step = 1/(10.82 * pi / 1600) -->
- <axis id="z" length="158" maxfeedrate="1400" homingfeedrate="1100" stepspermm="200" endstops="min"/> <!-- TR-8x8 Z axis = 1/(8/1600) -->
- <axis id="a" length="100000" maxfeedrate="1600" stepspermm="50.235478806907409" endstops="none"/> <!-- stepspermm is incoming filament length, 127 is ca. 4 RPM, 1600 ca. 50 RPM -->
- <axis id="b" length="100000" maxfeedrate="1600" stepspermm="50.235478806907409" endstops="none"/> <!-- stepspermm is incoming filament length, 127 is ca. 4 RPM, 1600 ca. 50 RPM -->
- </geometry>
- <tools>
- <tool name="Right (B/1)" index="1" type="extruder" motor="true" fan="false" heatedplatform="false" motor_steps="3200" default_rpm="3" heater="true" stepper_axis="b"/>
- <tool name="Left (A/0)" index="0" type="extruder" motor="true" fan="false" heatedplatform="false" motor_steps="3200" default_rpm="3" heater="true" stepper_axis="a"/>
- </tools>
- <wipes>
- <wipe index="0" X1="44.0" Y1="55.0" Z1="9" X2="44.0" Y2="55.0" Z2="9" wait="1000.0" purge_duration="1000" reverse_duration="15" purge_rpm="5.0" reverse_rpm="25.0"/>
- <wipe index="1" X1="-36.0" Y1="55.0" Z1="9" X2="-45.0" Y2="55.0" Z2="9" wait="1000.0" purge_duration="1000" reverse_duration="15" purge_rpm="5.0" reverse_rpm="25.0"/>
- </wipes>
- <clamps></clamps>
- <driver name="makerbot4ga">
- <!-- optional: <portname>COM1</portname> -->
- <rate>115200</rate>
- </driver>
- <warmup>
- </warmup>
- <cooldown>
-M18 (Turn off steppers after a build.)
- </cooldown>
- </machine>
<machine experimental="0">
<name>The Replicator Dual (Shipping Config) </name>
<geometry type="cartesian">
<!-- different pulleys on X and Y axii -->
<axis id="x" length="227" maxfeedrate="5000" homingfeedrate="2500" stepspermm="94.139704" endstops="max"/> <!-- Pulley dia: 10.82mm / 1/8 step = 1/(10.82 * pi / 1600) -->
<axis id="y" length="148" maxfeedrate="5000" homingfeedrate="2500" stepspermm="94.139704" endstops="max"/> <!-- Pulley dia: 10.82mm / 1/8 step = 1/(10.82 * pi / 1600) -->
- <axis id="z" length="150" maxfeedrate="1400" homingfeedrate="1100" stepspermm="200" endstops="min"/> <!-- TR-8x8 Z axis = 1/(8/1600) -->
+ <axis id="z" length="150" maxfeedrate="1400" homingfeedrate="1100" stepspermm="400" endstops="min"/> <!-- TR-8x8 Z axis = 1/(8/1600) -->
<axis id="a" length="100000" maxfeedrate="1600" stepspermm="50.235478806907409" endstops="none"/> <!-- stepspermm is incoming filament length, 127 is ca. 4 RPM, 1600 ca. 50 RPM -->
<axis id="b" length="100000" maxfeedrate="1600" stepspermm="50.235478806907409" endstops="none"/> <!-- stepspermm is incoming filament length, 127 is ca. 4 RPM, 1600 ca. 50 RPM -->
</geometry>
<tools>
- <tool name="A/Left (T1)" index="1" type="extruder" motor="true" fan="true" automatedplatform="true" heatedplatform="true" motor_steps="3200" default_rpm="3" heater="true" stepper_axis="b"/>
- <tool name="B/Right (T0)" index="0" type="extruder" motor="true" fan="true" automatedplatform="true" heatedplatform="true" motor_steps="3200" default_rpm="3" heater="true" stepper_axis="a"/>
+ <tool name="Mk7 Left" stepper_axis="b" index="1" type="extruder" motor="true" fan="true" automatedplatform="true" heatedplatform="true" motor_steps="3200" default_rpm="3" heater="true"/>
+ <tool name="Mk7 Right" stepper_axis="a" index="0" type="extruder" motor="true" fan="true" automatedplatform="true" heatedplatform="true" motor_steps="3200" default_rpm="3" heater="true"/>
</tools>
<wipes>
<wipe index="0" X1="-135.0" Y1="55.0" Z1="0" X2="-135.0" Y2="45.0" Z2="0" wait="1000.0" purge_duration="1000" reverse_duration="15" purge_rpm="5.0" reverse_rpm="35.0"/>
@@ -122,11 +35,11 @@ M18 (Turn off steppers after a build.)
<!-- different pulleys on X and Y axii -->
<axis id="x" length="227" maxfeedrate="5000" homingfeedrate="2500" stepspermm="94.139704" endstops="max"/> <!-- Pulley dia: 10.82mm / 1/8 step = 1/(10.82 * pi / 1600) -->
<axis id="y" length="148" maxfeedrate="5000" homingfeedrate="2500" stepspermm="94.139704" endstops="max"/> <!-- Pulley dia: 10.82mm / 1/8 step = 1/(10.82 * pi / 1600) -->
- <axis id="z" length="150" maxfeedrate="1400" homingfeedrate="1100" stepspermm="200" endstops="min"/> <!-- TR-8x8 Z axis = 1/(8/1600) -->
+ <axis id="z" length="150" maxfeedrate="1400" homingfeedrate="1100" stepspermm="400" endstops="min"/> <!-- TR-8x8 Z axis = 1/(8/1600) -->
<axis id="a" length="100000" maxfeedrate="1600" stepspermm="50.235478806907409" endstops="none"/> <!-- stepspermm is incoming filament length, 127 is ca. 4 RPM, 1600 ca. 50 RPM -->
</geometry>
<tools>
- <tool name="Mk7" index="0" type="extruder" motor="true" fan="true" automatedplatform="true" heatedplatform="true" motor_steps="3200" default_rpm="3" heater="true" stepper_axis="a"/>
+ <tool name="Mk7" stepper_axis="a" index="0" type="extruder" motor="true" fan="true" automatedplatform="true" heatedplatform="true" motor_steps="3200" default_rpm="3" heater="true"/>
</tools>
<wipes>
<wipe index="0" X1="-135.0" Y1="55.0" Z1="0" X2="-135.0" Y2="45.0" Z2="0" wait="1000.0" purge_duration="1000" reverse_duration="15" purge_rpm="5.0" reverse_rpm="35.0"/>
View
13 src/replicatorg/app/ui/controlpanel/ExtruderPanel.java
@@ -188,16 +188,21 @@ public ExtruderPanel(MachineInterface machine, ToolModel tool) {
// create our initial panel
setLayout(new MigLayout());
+
// create our motor options
if (tool.hasMotor()) {
+
// Due to current implementation issues, we need to send the PWM
// before the RPM for a stepper motor. Thus we display both controls in these
// cases. This shouldn't be necessary for a Gen4 stepper extruder. (it's not!)
- if ((tool.getMotorStepperAxis() == null) && !(tool.motorHasEncoder() || tool.motorIsStepper())) {
+ if ((tool.getMotorStepperAxis() == null) &&
+ !(tool.motorHasEncoder() || tool.motorIsStepper())) {
// our motor speed vars
JLabel label = makeLabel("Motor Speed (PWM)");
+
JFormattedTextField field = new CallbackTextField(this, "handleTextField", "motor-speed-pwm", 9, Base.getLocalFormat());
- field.setValue(Integer.toString(machine.getDriverQueryInterface().getMotorSpeedPWM()));
+ field.setValue(Integer.toString(tool.getMotorSpeedReadingPWM()) );// <-- should be
+ //field.setValue(Integer.toString(machine.getDriver().getMotorSpeedPWM()));
add(label);
add(field,"wrap");
}
@@ -206,7 +211,8 @@ public ExtruderPanel(MachineInterface machine, ToolModel tool) {
// our motor speed vars
JLabel label = makeLabel("Motor Speed (RPM)");
JFormattedTextField field = new CallbackTextField(this, "handleTextField", "motor-speed", 9, Base.getLocalFormat());
- field.setValue(machine.getDriverQueryInterface().getMotorRPM());
+ field.setValue(tool.getMotorSpeedReadingRPM() );// <-- should be
+ //field.setValue(machine.getDriver().getMotorRPM());
add(label);
add(field,"wrap");
@@ -222,6 +228,7 @@ public ExtruderPanel(MachineInterface machine, ToolModel tool) {
add(timeList,"wrap");
}
}
+
// create our motor options
JLabel motorEnabledLabel = makeLabel("Motor Control");
View
3  src/replicatorg/drivers/gen3/Makerbot4GAlternateDriver.java
@@ -377,7 +377,8 @@ public void setMachine(MachineModel m) {
@Override
/**
- * Overridden to not ask the board for the RPM as it would report the RPM from the extruder controller, which doesn't know about it in this case.
+ * Overridden to not ask the board for the RPM as it would report the RPM from the extruder
+ * controller, which doesn't know about it in this case.
*/
public double getMotorRPM() {
double rpm = machine.currentTool().getMotorSpeedRPM();
View
71 src/replicatorg/drivers/gen3/MightyBoard.java
@@ -76,7 +76,6 @@
//
//
// public final int offset;
-// public final int byteSz;
// public final String info;
//
// /// standard constructor.
@@ -233,16 +232,40 @@ public MightyBoard() {
stepperValues= new Hashtable();
}
+
+ /**
+ * Initalize the extruder or sub-controllers.
+ * For mightyboard, this involves setting some tool values,
+ * and checking some eeprom values
+ * @param toolIndex
+ * @return
+ */
+ public boolean initSlave(int toolIndex)
+ {
+ // since our motor speed is controlled by host software,
+ // initalize 'running' motor speed to be the same as the
+ // default motor speed
+ ToolModel curTool = machine.getTool(toolIndex);
+ curTool.setMotorSpeedReadingRPM( curTool.getMotorSpeedRPM() );
+ return true;
+ }
/**
* This function is called just after a connection is made, to do initial
* sycn of any values stored in software that are not available by
* s3g command. For example, stepper vRef
- * @see replicatorg.drivers.gen3.Sanguino3GDriver#initialSync()
+ * @see replicatorg.drivers.gen3.Sanguino3GDriver#pullInitialValuesFromBot()
*/
@Override
- public void initialSync()
+ public boolean initializeBot()
{
+ // Scan for each slave
+ for (ToolModel t : getMachine().getTools()) {
+ if (t != null) {
+ initSlave(t.getIndex());
+ }
+ }
+
int stepperCountMightyBoard = 5;
Base.logger.severe("MightBoard initial Sync");
for(int i = 0; i < stepperCountMightyBoard; i++)
@@ -252,6 +275,13 @@ public void initialSync()
Base.logger.info("i = " + i + " vRef =" + vRef);
stepperValues.put(new Integer(i), new Integer(vRef) );
}
+
+ //load our motor RPM from firmware if we can.
+ getMotorRPM();
+
+ //
+ getSpindleSpeedPWM();
+ return true;
}
@@ -709,7 +739,7 @@ protected void writeToToolEEPROM(int offset, byte[] data) {
@Override
-protected void writeToToolEEPROM(int offset, byte[] data, int toolIndex) {
+ protected void writeToToolEEPROM(int offset, byte[] data, int toolIndex) {
final int MAX_PAYLOAD = 11;
while (data.length > MAX_PAYLOAD) {
byte[] head = new byte[MAX_PAYLOAD];
@@ -1018,11 +1048,44 @@ public double getTemperatureSetting() {
}
return super.getTemperatureSetting();
}
+
+
public Version getToolVersion() {
return toolVersion;
}
+ @Override
+ public void setMotorRPM(double rpm) throws RetryException {
+
+ ///TRICKY: fot The Replicator,the firmware no longer handles this command
+ // it's all done on host side via 5D command translation
+
+ // convert RPM into microseconds and then send.
+// long microseconds = rpm == 0 ? 0 : Math.round(60.0 * 1000000.0 / rpm); // no
+// // unsigned
+// // ints?!?
+// // microseconds = Math.min(microseconds, 2^32-1); // limit to uint32.
+//
+// Base.logger.fine("Setting motor 1 speed to " + rpm + " RPM ("
+// + microseconds + " microseconds)");
+//
+// // send it!
+// PacketBuilder pb = new PacketBuilder(
+// MotherboardCommandCode.TOOL_COMMAND.getCode());
+// pb.add8((byte) machine.currentTool().getIndex());
+// pb.add8(ToolCommandCode.SET_MOTOR_1_RPM.getCode());
+// pb.add8((byte) 4); // length of payload.
+// pb.add32(microseconds);
+// runCommand(pb.getPacket());
+//
+
+ machine.currentTool().setMotorSpeedRPM(rpm);
+// super.setMotorRPM(rpm); TODO: this should be setMotorRPM running?
+// check read value vs running/tested value
+ }
+
+
}
View
113 src/replicatorg/drivers/gen3/Sanguino3GDriver.java
@@ -167,14 +167,35 @@ public void initialize() {
dispose();
}
}
+
+ public boolean initializeBot()
+ {
+ // Scan for each slave
+ for (ToolModel t : getMachine().getTools()) {
+ if (t != null) {
+ initSlave(t.getIndex());
+ }
+ }
+ return true;
+ }
+
private boolean attemptConnection() {
// Eat anything in the serial buffer
serial.clear();
version = getVersionInternal();
- if (getVersion() != null)
+ if (version != null){
+ initializeBot();
+ final String MB_NAME = "RepRap Motherboard v1.X";
+ FirmwareUploader.checkLatestVersion(MB_NAME, version);
+
+ // If we're dealing with older firmware, set timeout to infinity
+ if (version.getMajor() < 2) {
+ serial.setTimeout(Integer.MAX_VALUE);
+ }
setInitialized(true);
+ }
return isInitialized();
}
@@ -344,10 +365,17 @@ protected PacketResponse runCommand(byte[] packet, int retries)
}
pp = new PacketProcessor();
+
+ if(packet == null) {
+ Base.logger.severe("null packet in runCommand");
+ return PacketResponse.timeoutResponse();
+ }
- // Do not allow a stop or reset command to interrupt mid-packet!
- serial.write(packet);
-
+ synchronized (serial) {
+ // Do not allow a stop or reset command to interrupt mid-packet!
+ serial.write(packet);
+ }
+
printDebugData("OUT", packet);
// Read entire response packet
@@ -458,8 +486,8 @@ public void dispose() {
* @return
*/
public Version getVersionInternal() {
- PacketBuilder pb = new PacketBuilder(
- MotherboardCommandCode.VERSION.getCode());
+
+ PacketBuilder pb = new PacketBuilder(MotherboardCommandCode.VERSION.getCode());
pb.add16(Base.VERSION);
PacketResponse pr = runQuery(pb.getPacket(), 1);
@@ -487,34 +515,10 @@ public Version getVersionInternal() {
Version v = new Version(versionNum / 100, versionNum % 100);
Base.logger.warning("Motherboard firmware v" + v + buildname);
-
- final String MB_NAME = "RepRap Motherboard v1.X";
- FirmwareUploader.checkLatestVersion(MB_NAME, v);
-
- // Do inital sync of MotherBoard values to local valuse
- this.initialSync();
-
- // Scan for each slave
- for (ToolModel t : getMachine().getTools()) {
- if (t != null) {
- initSlave(t.getIndex());
- }
- }
-
- // If we're dealing with older firmware, set timeout to infinity
- if (v.getMajor() < 2) {
- serial.setTimeout(Integer.MAX_VALUE);
- }
return v;
}
- /// Once connected, do the initial sync of the MotherBoard state
- // to the remote machine state
- public void initialSync()
- {
- // do nothing
- }
-
+
public CommunicationStatistics getCommunicationStatistics() {
CommunicationStatistics stats = new CommunicationStatistics();
@@ -534,6 +538,7 @@ public CommunicationStatistics getCommunicationStatistics() {
}
private void initSlave(int toolIndex) {
+
PacketBuilder slavepb = new PacketBuilder(
MotherboardCommandCode.TOOL_QUERY.getCode());
slavepb.add8((byte) toolIndex);
@@ -579,6 +584,23 @@ private void initSlave(int toolIndex) {
final String EC_NAME = "Extruder Controller v2.2";
FirmwareUploader.checkLatestVersion(EC_NAME, sv);
}
+
+ ToolModel curToolMod = getMachine().getTool(toolIndex);
+ if (curToolMod != null) {
+ double targetRPM = curToolMod.getMotorSpeedRPM();
+ ///set 'running RPM' to be the same as the default RPM
+ try {
+ this.setMotorRPM( targetRPM, toolIndex );
+ }
+ catch (replicatorg.drivers.RetryException e)
+ {
+ Base.logger.severe("could not init motor RPM, got exception" + e );
+ }
+ }
+// //TRICKY: this is just called to get the value cached into the ToolModel
+// double ignore = getMotorRPM(toolIndex);
+
+
}
public void sendInit() {
@@ -691,9 +713,9 @@ public void setCurrentPosition(Point5d p) throws RetryException {
super.setCurrentPosition(p);
}
- // TODO: this says it homes the first three axes, but it actually homes
- // whatever's passed
- // Homes the three first axes
+ /// TODO: this says it homes the first three axes, but it actually homes
+ /// whatever's passed
+ /// Homes the three first axes
public void homeAxes(EnumSet<AxisId> axes, boolean positive, double feedrate)
throws RetryException {
Base.logger.fine("Homing axes " + axes.toString());
@@ -871,10 +893,14 @@ public void selectTool(int toolIndex) throws RetryException {
super.selectTool(toolIndex);
}
+ public void setMotorRPM(double rpm) throws RetryException {
+ setMotorRPM( rpm, machine.currentTool().getIndex() );
+ }
+
/***************************************************************************
* Motor interface functions
**************************************************************************/
- public void setMotorRPM(double rpm) throws RetryException {
+ public void setMotorRPM(double rpm, int toolIndex) throws RetryException {
// convert RPM into microseconds and then send.
long microseconds = rpm == 0 ? 0 : Math.round(60.0 * 1000000.0 / rpm); // no
// unsigned
@@ -887,15 +913,19 @@ public void setMotorRPM(double rpm) throws RetryException {
// send it!
PacketBuilder pb = new PacketBuilder(
MotherboardCommandCode.TOOL_COMMAND.getCode());
- pb.add8((byte) machine.currentTool().getIndex());
+ pb.add8((byte) toolIndex );
pb.add8(ToolCommandCode.SET_MOTOR_1_RPM.getCode());
pb.add8((byte) 4); // length of payload.
pb.add32(microseconds);
runCommand(pb.getPacket());
- super.setMotorRPM(rpm);
+ //TRICKY: WAS vvvv , but this seems not to work right. Seems to set default motor value(motorSppedRPM , not 'running' motor value. Caused gui to show bad values
+ //super.setMotorRPM(rpm);
+ machine.currentTool().setMotorSpeedReadingRPM(rpm);
+
}
+
public void setMotorSpeedPWM(int pwm) throws RetryException {
// If we are using a relay, make sure that we don't enable the PWM
if (machine.currentTool().getMotorUsesRelay() && pwm > 0) {
@@ -978,10 +1008,15 @@ public int getMotorSpeedPWM() {
return pwm;
}
- public double getMotorRPM() {
+ public double getMotorRPM()
+ {
+ return getMotorRPM(machine.currentTool().getIndex());
+ }
+
+ public double getMotorRPM(int toolIndex) {
PacketBuilder pb = new PacketBuilder(
MotherboardCommandCode.TOOL_QUERY.getCode());
- pb.add8((byte) machine.currentTool().getIndex());
+ pb.add8((byte)toolIndex);
pb.add8(ToolCommandCode.GET_MOTOR_1_RPM.getCode());
PacketResponse pr = runQuery(pb.getPacket());
View
14 src/replicatorg/machine/model/MachineModel.java
@@ -38,6 +38,13 @@
import replicatorg.app.tools.XML;
import replicatorg.util.Point5d;
+/**
+ * Loads a machine model from XML, and contains data related to that XML setup for the
+ * machine model, and a lot (but not all) of machine state values
+ *
+ * @author unknows
+ *
+ */
public class MachineModel
{
//our xml config info
@@ -97,6 +104,7 @@ public MachineModel()
currentTool.set(nullTool);
}
+
//load data from xml config
public void loadXML(Node node)
{
@@ -109,6 +117,8 @@ public void loadXML(Node node)
parseWipes();
parseExclusion();
}
+
+
private void parseExclusion()
{
if(XML.hasChildNode(xml, "exclusion"))
@@ -127,6 +137,8 @@ private void parseExclusion()
}
}
}
+
+
private void parseWipes()
{
if(XML.hasChildNode(xml, "wipes"))
@@ -147,6 +159,8 @@ private void parseWipes()
}
}
}
+
+
//load axes configuration
private void parseAxes()
{
View
36 src/replicatorg/machine/model/ToolModel.java
@@ -52,14 +52,16 @@
protected int motorDirection;
protected double motorSpeedRPM;
protected int motorSpeedPWM;
+
protected double motorSpeedReadingRPM;
protected int motorSpeedReadingPWM;
+
protected boolean motorUsesRelay = false;
protected boolean motorHasEncoder;
protected int motorEncoderPPR;
protected boolean motorIsStepper;
- protected double motorSteps; // motor steps per full rotation
- protected String motorStepperAxis; // Stepper axis this motor is connected to
+ protected double motorSteps; // motor steps per full rotation
+ protected String motorStepperAxis; // Stepper axis this motor is connected to
//spindle stuff
protected boolean spindleEnabled;
@@ -368,11 +370,19 @@ public int getMotorDirection()
return motorDirection;
}
+ /**
+ * Motor speed *read from the XML*
+ * @return
+ */
public void setMotorSpeedRPM(double rpm)
{
motorSpeedRPM = rpm;
}
+ /**
+ * Motor speed *read from the XML*
+ * @return
+ */
public void setMotorSpeedPWM(int pwm)
{
motorSpeedPWM = pwm;
@@ -391,31 +401,52 @@ public double getMotorSteps()
return motorSteps;
}
+ /**
+ * Motor speed *read from the XML*
+ * @return
+ */
public int getMotorSpeedPWM()
{
return motorSpeedPWM;
}
+
public boolean getMotorUsesRelay()
{
return motorUsesRelay;
}
+ /**
+ * Motor speed *read from the device*
+ * @param rpm
+ */
public void setMotorSpeedReadingRPM(double rpm)
{
motorSpeedReadingRPM = rpm;
}
+ /**
+ * Motor speed *read from the device*
+ * @param rpm
+ */
public void setMotorSpeedReadingPWM(int pwm)
{
motorSpeedReadingPWM = pwm;
}
+ /**
+ * Motor speed *read from the device*
+ * @param rpm
+ */
public double getMotorSpeedReadingRPM()
{
return motorSpeedReadingRPM;
}
+ /**
+ * Motor speed *read from the device*
+ * @param rpm
+ */
public int getMotorSpeedReadingPWM()
{
return motorSpeedReadingPWM;
@@ -690,4 +721,5 @@ public boolean isAutomatedBuildPlatformEnabled(boolean state) {
* Retrieve XML node. A temporary hack until new tool models.
*/
public Node getXml() { return xml; }
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.