How can I create a toggle macro?
-
@owend said in How can I create a toggle macro?:
if fans[10].actualValue = 1
Thank You for your reply.
I did not know there was a Meta Commands section in the forum.I have learnt and understand a little more now, thank you.
Regards,
Paul.
-
@dc42 is something like this (led toggle on/off with if-else macro) also possible for OUT1 on duet3 board ?
I can't seem to get it to work...
Thanks. -
@yao
Yes it is.
Please post what you have so far.
Both config.g and macro so we know how you're configuring the pin and how you're controlling it. -
@owend Hi, thanks for your response,
in the config:
; white led chamber light ALL
M950 P25 C"out1" ;use main out1 for full Chamber light
M42 P25 S0.5 ;on 50%this can be adjusted with:
; chamber lights hi
M42 P25 S1
; chamber lights low
M42 P25 S0.02I was trying:
if out1[25].actualValue >= 0.8
M42 P25 S0.02
else
M42 P25 S1whatever I try i get unknow value 'out1'
-
@yao
What board are you using?
On my Duet 2 running RRF3.4 , the output port limit seems to be 20.
Do you really need it to be 25?
Try using a lower numberAnd your code should look like
if state.gpOut[nn].pwm >= 0.8
-
@owend !!! that works!
I am running a duet3. my lights start at P20.
originally from the 3HC (hence the P20 range) but I ran out of connections so moved back to the main. for clarity for myself I kept the lights within the P20 range.using the following now:
if state.gpOut[25].pwm >= 0.8
M42 P25 S0.02
else
M42 P25 S{state.gpOut[25].pwm + 0.2}I now have 5 steps to full brightness and then it toggles to almost off.
Thanks for this. I have to investigate more into correct names and designations for usage of pins. I am not C minded, more of a mechanical guy. It amazes me every time how garbled the expression stackups need to be..
what does the 'pwm' mean? and why does it need to be there?
-
@yao
Is not really that complicated
It's a hierarchical structure no different to your street address. Country/state/city/street/number/unit
These are not official designations but...
State - refers to functions on the board you might normally monitor
GPout[] - refers to the GP output pins as a whole (analogous with your street). It's an array, so you need a port number to identify an individual pin (house number)
pwm - refers to the PWM (pulse width modulation) value of that pin. You need that because the pin may have many different properties that are applied. e.g (name, inversion etc). Just as a street number may have one or 100 dwellings. If you don't address the right one, your letter may not get there.If you use the object model browser it becomes easy and you can copy the correct syntax with the button provided.
-
@owend @owend Never had such a clear explanation is this!
But, is there a clear 'roadmap' where i can find all these specific DUET adresses, numbers, extensions and designations?
Where can I find the 'object model browser' :
this ?: https://github.com/Duet3D/RepRapFirmware/wiki/Object-Model-Documentation#overview
I can't find the specific addresses you mention in that list.
M409 gives me an empty list of strings... -
@yao
This post shows you how to look at the object model browser
https://forum.duet3d.com/post/277538 -
some where I found this some time ago
Macro "leds on/off"
if state.gpOut[1].pwm == 1 M42 P1 S0 else M42 P1 S1
in config files
; LEDS M950 P1 C"e1heat" Q500 ;use heater 1 outupt for LED M42 P1 S1 ; turn off LEDS