How to read state of servo/output/input pins
-
You can use the Object Model Browser to determine how to access just about any thing in code.
Check in the DWC under Settings/Plugins/INTEGRATED PLUGINS to see if it is started:
Here is an example using the browser to view sensors:
Then you can select the value of interest:
Then you can use a neat feature to copy the needed code fragment which you can then paste into your actual code:
You see that little icon to the right of the grayed out box? You click that and the code fragment will appear and be copied ready for pasting.
At this point all you need to do is determine where in the Object Model the values you want are located.
If you post the code that configures one of your servos I can show you where in the Object Model the values are.
Frederick
-
@fcwilt
Hi Frederick,Many thank you for your clear and easy to follow instructions, I appreciate a lot :)!
Now I was able to start using Object Model Browser and look it through. Also, I think I found the places where the endstops, temperature sensors and heaters are specified. However, I did not find especially the outputs and inputs, which I have configured with the sys/confiq. file. Also the servo was missing.
- Here is part of my confiq file, consisting the servo that I would like to see:
; Extruder head and cutter servo
M302 P1 S120 R110; Allow cold extrusion from 120 and rectraction from 110
M950 S1 C"!out2" ; Create cutter servo pin number 1- And here are another examples of configured outputs (Sending tigger) and inputs (Check external trigger), which states I would like to see also:
; Send trigger
M950 P4 C"io5.out" ; create output 4 in pin io5.out; Check external trigger
M950 J1 C"io4.in" ; create input 1 to pin io4.in
M581 T2 P1 S1 R0 ; invoke trigger 2 when an inactive-to-active edge is detected on input 1 anytime -
-
@HeidiH the state of the GpIn pins created by M950 J commands can be read from sensors.gpIn. The state of GpOut and servo pins can be read from state.gpOut.
-
Many thanks for both of you, based on these I was able to find those pins and get to read the values for example with echo command on the Console. Also, I created a macro for manual datalogging of these values and used in it M929 to initiate data logging on SD card as csv file and specified the measured channels using M118.
This on-demand recording was useful, but I would also like to monitor these same values online on the web interface.
How could I add these values to be shown continuously on the screen, for example in Status bar, like Machine position/Extruder drives/Speeds/Sensors? This would help me to monitor finding out problems with trigger signals, which are only short-term and not occurring long-term.
With best wishes, Heidi
-
@HeidiH you could use the plugin BtnCmd https://plugins.duet3d.com/plugins/BtnCmd.html
-
I can highly recommended the BtnCmd plugin that jay_s_uk referenced.
I use it on all of my printers.
If you are using RRF firmware 3.4.x the version of BtnCmd is a bit out of date and no longer maintained as the author (a fine person and a blessing to all mankind) is focusing on RRF firmware 3.5.x which necessitated changes to BtnCmd.
Despite the quirks in the BtnCmd 0.10.15 it is a wonderfully useful tool and I would not want to be without.
Frederick
-
@fcwilt @jay_s_uk Many thank you, and my apologies for the delayed response on this topic.
Yes, I agree that this BtnCmd plugin is great, really like it! Thanks both for you for letting me know about this. I have it now working and it helps a lot. I updated my duet firmware to the newest version and chose appropriate newest BtnCmd version for that.
I would have another question, a bit related to this inputs and output for Duet 3 (RRF firmware 3.4.6). I would like to double check if I can use input pin and output pin of same io header to have input from an external device and to send output for this device. I have electrically isolated the Duet board and the external device with semi conductor relays. However, I use the same ground for both input and output.
-
-
@HeidiH See https://docs.duet3d.com/Duet3D_hardware/Duet_3_family/Duet_3_Mainboard_6HC_Hardware_Overview#inputoutput
Except as noted in the table below, an IO_x_IN pin can always be used to provide a digital input (e.g. for endstop inputs or filament monitors), and an IO_x_OUT pin can always be used to provide a digital output.
IO output pins can be used as inputs, but are only 3.3V tolerant. IO input pins can be used as outputs, but have 10K protection resistors in series with them, so you would need to bypass these to use them as outputs.
Ian
-
@droftarts @dc42 Thank you for your responses. I was again possible to continue with these. Now we are aiming to use Duet 6HC board to switch on and off our device requiring 24Vdc. Does the board have this property?
-
@HeidiH It really depends on how much current your 'device' draws. The heater outputs are wired (and fused) for 24V (or rather VIN, ie whatever voltage PSU you are using). The bed heater output has it's own supply input, and the screw terminal and fuse are rated at 15A. The three heater outputs OUT1, OUT2 and OUT3 are rated at 6A. The fan outputs can also be run on 24V, but the connectors mean that they are limited to 2A total. There are also other IO pins that switch to ground that can be used, if you supply your 'device' with 24V directly, but these are also generally limited to 2A because of the connector, and would not have the benefit of a fuse.
If it is a particularly high current device, you can also control an external Solid State Relay from the OUT or IO pins; see https://docs.duet3d.com/en/User_manual/Connecting_hardware/Heaters_bed#bed-heater-driven-using-a-solid-state-relay
Ian
-
@HeidiH the OUT ports are open-drain mosfets. If you are looking to interface to a PLC then they are like NPN outputs. The IO_OUT ports are 3.3V only.
The 6XD board has additional features designed to make interfacing to 24V PLCs easier.
-
@dc42 @droftarts Thank you again very much! Our device had a current draw of 100 mA only, and based on your advices we were now able to start using OUT 4-6 for our 24V devices. What a great feeling, thank you for excellent support!
-
@dc42 @droftarts I would still again have another question related to IO headers (1-8).
We have at the moment 3.3V output in our input pin, but we have not aimed to this.
We have supplied 5V input voltage for this input, so does this have made our input pin to act like as an output continuously?
Is it possible to return the stage of the input pin back as input?
-
@HeidiH said in How to read state of servo/output/input pins:
We have at the moment 3.3V output in our input pin, but we have not aimed to this.
All io_in pins have a pullup resistor to +3.3V. Is this what you are measuring?
-
@dc42 Yes, great. it is that. We solved the issue by using a semiconductor relay allowing to provide external trigger for our Duet 3 board input, in which we chose the active-to-inactive stage change. Thanks again!