• Tags
  • Documentation
  • Order
  • Register
  • Login
Duet3D Logo Duet3D
  • Tags
  • Documentation
  • Order
  • Register
  • Login

Code for Endstop Pinout?

Scheduled Pinned Locked Moved
Firmware installation
4
9
351
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • undefined
    rl_at_berk
    last edited by 7 Jun 2023, 00:51

    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?

    undefined undefined 2 Replies Last reply 7 Jun 2023, 06:20 Reply Quote 0
    • undefined
      Phaedrux Moderator
      last edited by 7 Jun 2023, 05:50

      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.

      Z-Bot CoreXY Build | Thingiverse Profile

      1 Reply Last reply Reply Quote 0
      • undefined
        dc42 administrators @rl_at_berk
        last edited by 7 Jun 2023, 06:20

        @rl_at_berk what you want to do is already possible in RRF3.

        Duet WiFi hardware designer and firmware engineer
        Please do not ask me for Duet support via PM or email, use the forum
        http://www.escher3d.com, https://miscsolutions.wordpress.com

        undefined 1 Reply Last reply 7 Jun 2023, 17:08 Reply Quote 0
        • undefined
          hareshPrajapati @rl_at_berk
          last edited by hareshPrajapati 6 Jul 2023, 11:39 7 Jun 2023, 11:39

          @rl_at_berk You can read the state of each endstop that your printer supports by using the IoPort::ReadPin(endStopPins[axisOrExtruder]) function.

          undefined 2 Replies Last reply 7 Jun 2023, 18:38 Reply Quote 0
          • undefined
            rl_at_berk @dc42
            last edited by 7 Jun 2023, 17:08

            @dc42 @Phaedrux The project I am working on is using existing 2.05.1 code, and I want to merge my stuff with that. So unfortunately RRF3 is not an option.

            1 Reply Last reply Reply Quote 0
            • undefined
              rl_at_berk @hareshPrajapati
              last edited by 7 Jun 2023, 18:38

              @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.

              1 Reply Last reply Reply Quote 0
              • undefined
                rl_at_berk @hareshPrajapati
                last edited by rl_at_berk 6 Jul 2023, 21:43 7 Jun 2023, 20:31

                @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?

                undefined 1 Reply Last reply 8 Jun 2023, 01:35 Reply Quote 0
                • undefined
                  rl_at_berk @rl_at_berk
                  last edited by 8 Jun 2023, 01:35

                  @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.

                  undefined 1 Reply Last reply 8 Jun 2023, 04:02 Reply Quote 0
                  • undefined
                    hareshPrajapati @rl_at_berk
                    last edited by hareshPrajapati 6 Aug 2023, 04:10 8 Jun 2023, 04:02

                    @rl_at_berk good to know👍
                    BTW, END_STOP_PINS are define in Duet_Pins.h line 67 ( for 9 axis )

                    1 Reply Last reply Reply Quote 0
                    8 out of 9
                    • First post
                      8/9
                      Last post
                    Unless otherwise noted, all forum content is licensed under CC-BY-SA