Code for Endstop Pinout?
-
I am trying to modify RRF 2.05.1 in Eclipse. I am using a Duet2 Ethernet board. I want to utilize endstop E1 and E0, but cannot find the code to do so. Is there a way to use a digital read function to see if the endstop is triggered or not? Is there an example somewhere in the firmware already?
I already tried accessing the 9 endstop pins defined in END_STOP_PINS in Pins_Duet.h with digitalread, after declaring the pins as INPUT (using pinMode()). I also tried declaring the Pins in Gcodes.h, since I was trying to create a custom MCode that would tell me when E1 and E0 were triggered.
Any tips?
-
Does it have to be 2.05? This sounds like something that could be easily done with conditional gcode and the object model available in RRF3. But I don't know exactly what you're trying to do.
-
@rl_at_berk what you want to do is already possible in RRF3.
-
@rl_at_berk You can read the state of each endstop that your printer supports by using the
IoPort::ReadPin(endStopPins[axisOrExtruder])
function. -
-
@hareshPrajapati I am looking into your solution. I am trying to write a custom MCode to verify that this is going to work. From my initial test with this, I am getting an error saying "endStopPins" is not declared in this scope, after writing that line directly in my Mcode function in GCodes2.cpp. I found a workaround where I can create the function somewhere else (currently writing it in Platform.cpp), and simply have the Mcode call that function, but is there an easier way to do this? I am still working through errors with this method as well, I will update you after I try some debugging.
-
@hareshPrajapati So I tried using this and am getting some weird results. From my above comment, my Mcode command (in Gcodes2.cpp) cannot use endStopPins, as it is not in scope. Instead, my Mcode calls a function in Platform.cpp, which simply returns a pin from endStopPins. my Mcode then uses IoPort::ReadPin(Call that function in Platform.cpp). The result of this I do not understand:
No matter what the endstop pins current state, the first call of this will return false for every pin (I ended up testing all 9 pins in endStopPins individually). Then, if the state of ANY pin changes, the function call causes a crash (crash of software and WebController, resets everything). Note I am testing every pin at once here. In addition, the first time I call this, every endStopPin always returns false regardless of the actual state of the machine, for all axes including X, Y, and Z. This leads me to believe that endStopPins is not actually the correct Pins? I am using the Duet2 Ethernet Board with the Wifi Breakout Board.
I tried looking into Pin definitions and I cannot find anything in the reprapfirmware code that has pin definitions that match the actual hardware. I also tried to trace the X and Y endstop code, but it is not readable (at least for me, who does not have that advanced of an understanding of this code). I also found that IoPort::ReadPin uses digitalRead(pin), and this is the same behavior if I just use that (as expected).
Thoughts? Is there something I can look at for the X and Y endstops, so that I can test to see how to read the endstop pins? Because those work for other code, just not mine. Is there another way I can implement reading the endstops? Thanks for your help
EDIT: Another thing I have been looking at is the actual pinout from the Duet board. I found a map of some pins in CoreNG/variants/duet/varient.cpp which gives some pinouts. The issue is I cannot find a physical schematic which matches these pinouts. I am using the Duet2 Ethernet Board version 1.05. I can only find schematics for 1.04, did the pinouts change from 1.04 to 1.05?
-
@rl_at_berk ISSUE SOLVED: Turns out the pin definitions that are in the code do not match the actual endstop pins on the 1.05. I ended up looping through EVERY pin on the board, and found that E1 and E0 on the board are pins 42 and 74. Then, digital(read) and IoPort::ReadPin() both work fine.
-
@rl_at_berk good to know
BTW, END_STOP_PINS are define in Duet_Pins.h line 67 ( for 9 axis )