Hi @wconturo
it may be possible, but it will be tricky to do.
First of all because it's a non standard axis, so I don't have any idea how to access it.
The machine defintion is integrated in a machine simulation file, or is independant?
Bluntly, is it a .mch file, or a f3d file?
If you can share it directly or via DM, I can take a look.
As a general information, in the machine defintion file the information will be stored in a object. (I just dont know which one, as it's non standard)
As an example the legacy rotary axes are defined that way.
"controller" : {
"synced_configuration" : {
"max_block_processing_speed" : 0,
"max_normal_speed" : 0,
"parts" : {
"U" : {
"coordinate" : 0,
"max_normal_speed" : 21600,
"max_rapid_speed" : 0,
"preference" : "no preference",
"reset" : "never",
"reversed" : false,
"tcp" : true,
"zero_position_offset" : 0
},
"V" : {
"coordinate" : 2,
"max_normal_speed" : 21600,
"max_rapid_speed" : 0,
"preference" : "no preference",
"reset" : "never",
"reversed" : false,
"tcp" : true,
"zero_position_offset" : 0
},
The max_normal_spee seems to contains the desired information. But it will probably not be stored in the U or V object.
Interrogating a machine defintion associated in the setup can be done on the post side.
Here is a sample to display the C axis speed, the function need to be added somewhere in the post, inside the onOpen or somewhere else.
Here is the code to read the obkect and find the C axis.
The rotary axes are always stored as U and V, instead of using A, B or C.
Depending on the value in coordinate 0 is for A, 1 = B, 2= C
(pallet is ????)
function interrogateMachine() {
var maxRotationSpeedCaxis;
var machineData = hasGlobalParameter("machine-v2") ? JSON.parse(getGlobalParameter("machine-v2")) : null;
if (machineData && typeof machineData == "object") {
// data in the machine definition is always stored as degree celsius and millimeters
// Let suppose we want to access the C axis value
if (machineData.controller.synced_configuration.parts.U.coordinate == 2) { // 0 would be A, 1 B, 2 C
maxRotationSpeedCaxis = parseFloat(machineData.controller.synced_configuration.parts.U.max_normal_speed);
} else {
maxRotationSpeedCaxis = parseFloat(machineData.controller.synced_configuration.parts.V.max_normal_speed);
}
writeln("Debug Max axis speed is : " + xyzFormat.format(maxRotationSpeedCaxis));
} else {
warning("Failed to read machine data, default values will be used instead.");
}
}
So, that code need to be altered for the correct object reading.
We are using a similar workflow in the additive fff posts, to read some parameters from the machine defintion that are not mapped to post variables, or not read by a specific function.
Use that kind of "workaround" with caution.
I will point several flaws in that implementation, and i will try to improve it tomorrow.
But we are not checking if the object controller, synced_configuration, part, the U and V part object, and then the max_normal_spped variable exists.
So, the code may crash posting if there is no U and V axis defined...
If the selected machine is a turning machine, some object will not exist and so on.
______________________________________________________________
If my post answers your question, please click the "Accept Solution" button. This helps everyone find answers more quickly!
.mch file, but there is a F3d file for the model in simulation. I'm still not totally clear how to have a 100% locally stored machine definition including the model...
The .mch file is in a local folder, linked... F3d file is in my part library. It would be nice if these two things could stick together somehow. Any insight on that would be helpful as well. I'd like to be able to put them on a USB drive and hand it over to the programmer and just have it all ready to go.
Ok, so I guess a follow-up question is, why is the option there in the machine definition?
My specific project is a 5 axis with turning, matsuura CUBLEX, probably most similar to the Brother M300/M500 (already in the fusion library) in terms of layout and capabilities. Seems like the ideal use case for this kind of machine definition. So yes, will be using this data for turning operations, instead of the post property. It's only a nice integration feature, just curious really.
Hi @wconturo ,
I'm still not totally clear how to have a 100% locally stored machine definition including the model
=> When creating a machine simulation, using Machine Builder, you have to select the machine definition file (.mch), and it's then integrated inside the f3.d.
So, if you lose the .mch file, the machine can still be added to a machine library folder, by importing a definition, and selecting the f3d.
The .mch component will be read from the internal copy inside the f3d.
Ok, so I guess a follow-up question is, why is the option there in the machine definition?
=> It's not clear to me which option you are talking about here.
If you look at the Brother M140 machine definition, the post associated is supporting turning operation, and the machine definition is simpler that your
Why adding a second axis rotating around Z? What is the intent? Having the rotational speed expressed in a different unit? (rpm vs degree per minute)
The Brother definition
"controller" : {
"default" : {
"head_info_part_id" : "head",
"max_block_processing_speed" : 0,
"max_normal_speed" : 30000,
"non_tcp_rapid_interpolation_mode" : "Synchronized",
"parts" : {
"X" : {
"coordinate" : 0,
"max_normal_speed" : 30000,
"max_rapid_speed" : 0,
"preference" : "negative",
"reset" : "never",
"reversed" : false,
"tcp" : false,
"zero_position_offset" : 0
},
"Y" : {
"coordinate" : 1,
"max_normal_speed" : 30000,
"max_rapid_speed" : 0,
"preference" : "negative",
"reset" : "never",
"reversed" : false,
"tcp" : false,
"zero_position_offset" : 0
},
"Z" : {
"coordinate" : 2,
"max_normal_speed" : 30000,
"max_rapid_speed" : 0,
"preference" : "negative",
"reset" : "never",
"reversed" : false,
"tcp" : false,
"zero_position_offset" : 0
},
"rotary_0" : {
"coordinate" : 0,
"max_normal_speed" : 21600,
"max_rapid_speed" : 0,
"preference" : "no preference",
"reset" : "never",
"reversed" : false,
"tcp" : false,
"zero_position_offset" : 0
},
"rotary_1" : {
"coordinate" : 2,
"max_normal_speed" : 72000,
"max_rapid_speed" : 0,
"preference" : "no preference",
"reset" : "never",
"reversed" : false,
"tcp" : false,
"wrap_around_at_max" : 360,
"wrap_around_at_min" : 0,
"zero_position_offset" : 0
}
},
"table_part_id" : "table",
"tcp_rapid_interpolation_mode" : "ToolTip"
}
},
Regarding the safer code
Here is some samples:
A brute force approach for a safer code, but not giving much information in case of error can be as below
function interrogateMachine() {
var maxRotationSpeedCaxis;
var machineData = hasGlobalParameter("machine-v2") ? JSON.parse(getGlobalParameter("machine-v2")) : null;
if (machineData && typeof machineData == "object") {
// data in the machine definition is always stored as degree celsius and millimeters
// Let suppose we want to access the C axis value
try {
if (machineData.controller.synced_configuration.parts.U.coordinate == 2) { // 0 would be A, 1 B, 2 C
maxRotationSpeedCaxis = parseFloat(machineData.controller.synced_configuration.parts.U.max_normal_speed);
} else {
maxRotationSpeedCaxis = parseFloat(machineData.controller.synced_configuration.parts.V.max_normal_speed);
}
} catch (e) {
error(localize("Something went wrong."));
}
writeln("Debug Max axis speed is : " + xyzFormat.format(maxRotationSpeedCaxis));
} else {
warning("Failed to read machine data, default values will be used instead.");
}
}
A finer granularity in the error analysis, it can be done that way
function getController(machineObject) {
if (typeof machineObject == "object") { // normally already verified
if (typeof machineObject.controller == "undefined") {
warning("The controller data is not defined in that machine");
}
return machineObject.controller;
} else {
return undefined;
}
}
function getSyncedConfig(controllerObject) {
if (typeof controllerObject == "object") { // previous function called (getController) may have returned an undefined object
if (typeof controllerObject.synced_configuration == "undefined") {
warning("The synced_configuration data is not defined in that machine");
}
return controllerObject.synced_configuration;
} else {
return undefined;
}
}
function getPart(syncedConfigObject) { // previous function called (getSyncedConfig) may have returned an undefined object
if (typeof syncedConfigObject == "object") {
if (typeof syncedConfigObject.parts == "undefined") {
warning("The parts data is not defined in that machine");
}
return syncedConfigObject.parts;
} else {
return undefined;
}
}
function interrogateMachine() {
var maxRotationSpeedCaxis = 121212;
var machineData = hasGlobalParameter("machine-v2") ? JSON.parse(getGlobalParameter("machine-v2")) : null;
if (machineData && typeof machineData == "object") {
// data in the machine definition is always stored as degree celsius and millimeters
// Let suppose we want to access the C axis value
var controllerData = getController(machineData);
var synched = getSyncedConfig(controllerData);
var parts = getPart(synched);
for (item in parts) {
if (typeof typeof parts[item].coordinate != "undefined") {
if (parts[item].coordinate == 2) {
if (item != "Z") {
if (typeof typeof parts[item].max_normal_speed != "undefined") {
maxRotationSpeedCaxis = parts[item].max_normal_speed;
}
}
}
}
}
writeln("Debug Max axis speed is : " + xyzFormat.format(maxRotationSpeedCaxis));
} else {
warning("Failed to read machine data, default values will be used instead.");
}
}
It's not the only solution, others will prefer to use assert, or create several object classes....
They would prefer try catch instead of checking object type.
Regards