Variable Expression given on conditions of limit switchs
-
Firstly I would like to say Hi! I'm Connor, Mechanical Engineer from South, UK
I fairly new at using Duet variable, but have used Fanuc Variable
I hope you are able to help with the below questions:
I am doing a project for my degree on my printer, which I won't disclose for the time being
Firstly I wondered if you have a definitive list of variables for the Duet 2 or 3? I have looked through the Wiki and cannot see it (but this may just be me being silly :P)
I am trying to achieve something around these lines (written how I interpret it):
IF = LIMITSWITCH1=1 (ON) GOTO M98 'P000' (presumably within a macro call? M98 P***)
IF = LIMITSWITCH2=1 (ON) GOTO M98 'P001' presumably within a macro call? M98 P***)
I guess the limit switch would be a Pin ID and either 0 or 1 (off on)?
Code within the Macro program would be laid out as below or seperated if more appropriate:
N555
Function.... G0 X1 Y1 Z1.
END OF PROGRAM
N556
Function.... G0 X2 Y2 Z2.
END OF PROGRAMI cannot find an MCode for end of program?
I am also interested to know whether the Duet has the ability to call coordinate or offset information from a config file, to which it can call specific flags when given specific values, ie, pick and place based on what is in a machine. IE Tool Lengths:
N444 Z56.22
N445 Z65.00
N446 Z32.00Does the Duet have the ability to output a signal from single pins (presumably from the GPIO pins?), that I could potentially program an arduino with CNC sheild to pick up and act in variation (if it is not capable of the above questions)
My last question, having read some of your other posts, I am scared to ask. But. Within a variable arrangement such as
N550 IF=LIMITSWITCH1=1
Am I able to use GOTO and THEN functions to continue to the next flag ie.
N550 IF=LIMITSWITCH=1 GOTO N551
N550 IF=LIMITSWITCH=0 THEN M98"P001"I know above is not used but similarly used in Fanuc for jumping around programs. LIMITSWITCH is representative of what I was asking above..
I understand there will be people shaking there heads at me, but please be kind..
I hope you are able to help? Examples would be absolutely amazing if possible?
Thankyou
Connor
-
@connorm2009 said in Variable Expression given on conditions of limit switchs:
Firstly I would like to say Hi! I'm Connor, Mechanical Engineer from South, UK
Welcome!
Firstly I wondered if you have a definitive list of variables for the Duet 2 or 3? I have looked through the Wiki and cannot see it (but this may just be me being silly :P)
We introduce new fields in the object model at every release, so such a list would quickly get out of date. However, you can explore all the variables in Duet Web Control. Go to Settings->General->Integrated Plugins and start Object Model Browser (you only need to do this once). Then the Object Model tab will appear.
I am trying to achieve something around these lines (written how I interpret it):
IF = LIMITSWITCH1=1 (ON) GOTO M98 'P000' (presumably within a macro call? M98 P***)
IF = LIMITSWITCH2=1 (ON) GOTO M98 'P001' presumably within a macro call? M98 P***)
See https://duet3d.dozuki.com/Wiki/GCode_Meta_Commands for how to do conditional execution and loops.
I guess the limit switch would be a Pin ID and either 0 or 1 (off on)?
If the limit switch is an also used for homing, you can read its state in sensors.endstops in the object model. If it is an extra switch, then use M950 with a J parameter to create a GpIn pin, and its state will appear in sensors.gpIn.
Code within the Macro program would be laid out as below or seperated if more appropriate:
N555
Function.... G0 X1 Y1 Z1.
END OF PROGRAM
N556
Function.... G0 X2 Y2 Z2.
END OF PROGRAMI cannot find an MCode for end of program?
In RRF you need to put each function in a separate macro file. You can use M99 to return from a macro, however that's rarely used, because it will return when it reaches the end of the file.
I am also interested to know whether the Duet has the ability to call coordinate or offset information from a config file, to which it can call specific flags when given specific values, ie, pick and place based on what is in a machine. IE Tool Lengths:
If they are tool Z offsets already configured in the config.g file then you can pick them up from the object model. If you want to configure things not in the object model, you can create global variables to do that.
Does the Duet have the ability to output a signal from single pins (presumably from the GPIO pins?), that I could potentially program an arduino with CNC sheild to pick up and act in variation (if it is not capable of the above questions)
Yes, use M950 with P parameter to create them, and M42 to set the pin state.
My last question, having read some of your other posts, I am scared to ask. But. Within a variable arrangement such as
N550 IF=LIMITSWITCH1=1
Am I able to use GOTO and THEN functions to continue to the next flag ie.
N550 IF=LIMITSWITCH=1 GOTO N551
N550 IF=LIMITSWITCH=0 THEN M98"P001"I know above is not used but similarly used in Fanuc for jumping around programs. LIMITSWITCH is representative of what I was asking above..
You can't jump around programs in RRF (GOTO fell out of favour more than 50 years ago), but you can use conditions and loops as described at https://duet3d.dozuki.com/Wiki/GCode_Meta_Commands.
-
Hi
Thankyou so much, that is so much help!!!
I want to achieve a tool selection by the limit switch has been selected, whilst allowing the Duet to know what is in the seat of the carriage. The limit switch m state being its function.
Is the Duet able to write variable offset values (using Set?) Within another configuration file
So for example:
#1 = 2.45 "config2.g"
Can it pull this information from the config file in the same manner?
-
@dc42 just to further clarify,if I had tool 1 in the carriage seat if I then selected tool 4 stored in a different coordinate location I would like the duet board to know to put tool 1 back before collecting tool. How would you lay this kind of work flow out in the programme ? Thanks,connor
-
Thanks for the clarification of what you are trying to achieve. You do not need to write custom macros and pass custom variables around to do what you want to do. See the tool documentation here:
https://duet3d.dozuki.com/Wiki/Gcode#Section_T_Select_Toolyou will see it refers to the tool change macro files:
https://duet3d.dozuki.com/Wiki/Multiple_tools_and_Tool_change_macros
https://duet3d.dozuki.com/Wiki/Macros#Section_Tool_changeI wrote this below before you sent the clarifying post - i will leave it here for general information but there is a built in way to do what you want
you can use variables previously set using the following format:set xoffset = 10.5 G10 X{var.xoffset}
its also possible to pass parameters to a macro:
https://duet3d.dozuki.com/Wiki/GCode_Meta_Commands#Section_Macro_parametersor use global variables if thats more appropriate.
Commands to not all need to be in config.g - so you can change the offset at any point by sending the appropriate command.
using the object model browser as David describes is the easiest way as it will show you what the values are on your board.
It is also posisble to use the autogenerated object model documentation for the latest stable version (3.3) here:
https://github.com/Duet3D/RepRapFirmware/wiki/Object-Model-Documentation
and here for the latest beta version (3.4b6) which has a fiew more fields:
https://github.com/Duet3D/RepRapFirmware/wiki/Object-Model-Documentation-Beta-&-RC -