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

    Additional outputs using a SX1509B Expander

    Scheduled Pinned Locked Moved
    Accessories and Add-ons
    4
    20
    1.2k
    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.
    • t0biasundefined
      t0bias
      last edited by

      Hi everyone,

      I have wired up a Sparkfun SX1509 (BOB-13601) to my Duet 2 WiFi.
      The SX1509 is set to use the 0x71 I²C address (I double-checked it is indeed using 0x71 using a Arduino).
      In my config.g I assign Ports to the Output pins like so:

      
      ; GPIO Ports									; Create GPIO Ports on SX1509B expander pins
      M950 P5 C"sx1509b.0"			; Assign P5 to pin 1
      M950 P6 C"sx1509b.1"			; Assign P6 to pin 2
      M950 P7 C"sx1509b.2"			; Assign P7 to pin 3
      M950 P8 C"sx1509b.3"			; Assign P8 to pin 4
      M950 P9 C"sx1509b.4"			; Assign P9 to pin 5
      M950 P10 C"sx1509b.5"			; Assign P10 to pin 6
      M950 P11 C"sx1509b.6"			; Assign P11 to pin 7
      M950 P12 C"sx1509b.7"			; Assign P12 to pin 8
      M950 P13 C"sx1509b.8"			; Assign P13 to pin 9
      M950 P14 C"sx1509b.9"			; Assign P14 to pin 10
      M950 P15 C"sx1509b.10"			; Assign P15 to pin 11
      M950 P16 C"sx1509b.11"			; Assign P16 to pin 12
      M950 P17 C"sx1509b.12"			; Assign P17 to pin 13
      M950 P18 C"sx1509b.13"			; Assign P18 to pin 14
      M950 P19 C"sx1509b.14"			; Assign P19 to pin 15
      M950 P20 C"sx1509b.15"			; Assign P20 to pin 16
      

      Now the first issue is the number of pins, according to the Gcode dictionary (link) the Duet only supports up to 10 pins.
      Is there another way, I could use those pins?

      Secondly, by using

      M42 P5 S1
      

      or

      M42 P5 S0
      

      I would expect the first pin on the SX1509B Port Expander to toggle the state of said pin, however nothing happens.
      Any ideas?
      Thanks!

      dc42undefined 1 Reply Last reply Reply Quote 0
      • alankilianundefined
        alankilian
        last edited by alankilian

        @t0bias THIS page says use pin numbers 120-135

        1 Reply Last reply Reply Quote 0
        • t0biasundefined
          t0bias
          last edited by

          @alankilian true, but as far as I understand (see this note on the very same page this no longer works for RepRap Firmware 3.x

          alankilianundefined 1 Reply Last reply Reply Quote 0
          • alankilianundefined
            alankilian
            last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • alankilianundefined
              alankilian @t0bias
              last edited by

              @t0bias Yeah, I have no specific knowledge on this. Just trying to help.

              Let us know when you figure it out.

              1 Reply Last reply Reply Quote 0
              • alankilianundefined
                alankilian
                last edited by

                Maybe use M122 and look for the I2C debugging information to see if your I2C is running properly?

                I2C nak errors 0, send timeouts 0, receive timeouts 0, finishTimeouts 0, resets 0
                
                1 Reply Last reply Reply Quote 0
                • t0biasundefined
                  t0bias
                  last edited by

                  Good point!
                  Unfortunately no luck here either..

                  I2C nak errors 0, send timeouts 0, receive timeouts 0, finishTimeouts 0, resets 0
                  
                  1 Reply Last reply Reply Quote 0
                  • alankilianundefined
                    alankilian
                    last edited by

                    @t0bias Are the outputs set to open-drain by default or something?

                    (I'll go take a peek at the firmware to see how they are initialized next.)

                    1 Reply Last reply Reply Quote 0
                    • t0biasundefined
                      t0bias
                      last edited by

                      Not that I was aware of..
                      However, I just checked the datasheet and according to it, all pins are configured as inputs upon power-on, so I think I would need to configure them as outputs. I don't really know what the duet firmware is doing internally here.. 😕

                      1 Reply Last reply Reply Quote 0
                      • alankilianundefined
                        alankilian
                        last edited by alankilian

                        @t0bias said in Additional outputs using a SX1509B Expander:

                        I think I would need to configure them as outputs

                        When you say P5 instead of J5 it is configured as an output (I think).

                        Maybe add the "^" character to the M950 would do it?

                        C"name" Pin name(s) and optional inversion status, see Pin Names. Pin name "nil" frees up the pin. A leading '!' character inverts the input or output. A leading '^' character enables the pullup resistor. The '^' and '!' characters may be placed in either order.
                        
                        1 Reply Last reply Reply Quote 0
                        • t0biasundefined
                          t0bias
                          last edited by

                          I may be wrong, but I think pull-up resistors can only be enabled on ports of the Duet board itself.
                          There are source-files specifically for this expansion chip (here), however I have no idea what the "DuetNG" denomination is about to be honest. Also, this branch seems to be of the 2.x firmware only?

                          1 Reply Last reply Reply Quote 0
                          • dc42undefined
                            dc42 administrators @t0bias
                            last edited by dc42

                            @t0bias, which firmware version are you using? In particular, part of that code was rewritten between versions 3.2.2 and 3.3beta1, so what works in one might not work in the other.

                            I can increase the number of available GpOut ports in the next 3.3beta. Would 20 be sufficient?

                            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

                            1 Reply Last reply Reply Quote 0
                            • t0biasundefined
                              t0bias
                              last edited by

                              @dc42 thanks for your reply. I am using version 3.1.1, would a upgrade fix the issue?
                              yes, 20 would be sufficient, maybe a bit more would be even better still? 😉

                              dc42undefined 1 Reply Last reply Reply Quote 0
                              • dc42undefined
                                dc42 administrators @t0bias
                                last edited by dc42

                                @t0bias said in Additional outputs using a SX1509B Expander:

                                @dc42 thanks for your reply. I am using version 3.1.1, would a upgrade fix the issue?

                                An upgrade to 3.3beta1 might possibly fix it, if it doesn't then let me know and I'll implement a fix in 3.3beta2.

                                yes, 20 would be sufficient, maybe a bit more would be even better still? 😉

                                Memory is rather tight on the Duet 2, so I'll set it to 20 in 3.3beta2. It's already 32 on Duet 3 and 3 Mini.

                                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

                                1 Reply Last reply Reply Quote 0
                                • t0biasundefined
                                  t0bias
                                  last edited by

                                  I upgraded to 3.3beta1 today, but it still doesn't work unfortunately

                                  1 Reply Last reply Reply Quote 0
                                  • dc42undefined
                                    dc42 administrators
                                    last edited by

                                    Thanks, this is on my list to test/investigate.

                                    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

                                    1 Reply Last reply Reply Quote 0
                                    • dc42undefined
                                      dc42 administrators
                                      last edited by dc42

                                      I have just tested this, and ports sx1509b.0, .1 and .2 all work for me using RRF 3.2.2 and also using RRF 3.3beta1. I didn't test the other ports.

                                      Points to note:

                                      1. M115 will report the SX1509B if it is detected:
                                      04/03/2021, 11:17:06 	m115
                                      FIRMWARE_NAME: RepRapFirmware for Duet 2 WiFi/Ethernet FIRMWARE_VERSION: 3.3beta1 ELECTRONICS: Duet WiFi 1.02 or later + DueX5 + SX1509B expander FIRMWARE_DATE: 2021-02-14 16:00:49
                                      
                                      1. My test system includes a very old DueX5. On these old boards, the TWC and TWD pins are labelled the wrong way round on the 10-pin expansion header. They are also labelled incorrectly on the wiring diagrams at https://duet3d.dozuki.com/Wiki/Duex_wiring_diagrams for the 0.6 and 0.7 boards. On all DueX revisions, TWC (aka SCL) is next to the ground pin at the end of the header.

                                      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

                                      1 Reply Last reply Reply Quote 0
                                      • t0biasundefined
                                        t0bias
                                        last edited by

                                        Strange, the SX1509B is in fact detected:

                                        FIRMWARE_NAME: RepRapFirmware for Duet 2 WiFi/Ethernet FIRMWARE_VERSION: 3.3beta1 ELECTRONICS: Duet WiFi 1.02 or later + SX1509B expander FIRMWARE_DATE: 2021-02-14 16:00:49
                                        

                                        however the pins don't get driven high (or low) using the M42 commands.
                                        I am confident the I²C-Wiring is correct, since I tried using a MCP23017 based relay board that responds to I²C-Commands just fine.

                                        Any suggestions or ideas are highly appreciated!

                                        DIY-O-Sphereundefined dc42undefined 2 Replies Last reply Reply Quote 0
                                        • DIY-O-Sphereundefined
                                          DIY-O-Sphere @t0bias
                                          last edited by DIY-O-Sphere

                                          @t0bias
                                          Have you checked the I2C address?
                                          It has to be set to 0x71

                                          Here some code to test it directly with M260
                                          https://forum.duet3d.com/topic/13911/sx1509-on-maestro-does-it-work/3

                                          (UTC+1)

                                          1 Reply Last reply Reply Quote 0
                                          • dc42undefined
                                            dc42 administrators @t0bias
                                            last edited by dc42

                                            @t0bias, if the board is detected then the I2C pins are connected correctly and the slave address is set correctly.

                                            How are you testing the outputs of the SX1509B? I have connected each output through a 100 ohm resistor to one of the cathodes of a 2-digit common anode 7-segment display, with the anodes connected to +3.3V.

                                            2021-03-09 21.15.43.jpg

                                            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

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