Controlling GPIO pins



  • When I turn on my machine, the GPIO pins default to around 1.9 volts. M42 P100 S0 will change it to 0 volts. I have three questions:

    1. Why is the voltage 1.9V at the beginning? Shouldn't it be 3.3V?

    2. When I do M42 P100 S1, the voltage is 2.33V. Shouldn't it go to 3.3V?

    3. How do I ensure that the GPIO goes to 0V as soon as the machine is turned on? I tried putting M42 P100 S0 at the beginning of the config.g file, but this command does not get executed for one or two seconds. I have a feeling I should use this command somewhere, but I am not sure where to put it, or what value to put for freq:

    IoPort::WriteAnalog(pin, val, freq);


  • administrators

    You haven't said which GPIO pins you are using, but as mention P100 I guess it's the GPIO pins on a DueX2 or DueX5. Those pins are connected to +5V via 100K resistors, see https://github.com/T3P3/Duet/blob/master/Duet_Expansion/Duex5v0.8/Duex5v0.8_Schematic.pdf for the schematic. My guess is that you are putting a load on those pins somewhat below 100K.



  • Using GPIO1 on the Duex5. I can't figure out how to make the pin go low as soon as the printer turns on.



  • Thanks for the schematic, very useful. I see the GPIOs are pulled up to 5V. As described earlier, when I use them without connected to anything, they go from 0 to 5V using M42. But when connected to my load, it goes from 0 to 2.3V instead of the desired 5V.

    If I remove the pull-up resistors, will this fix the problem (so it will go up to 5V)? Alternatively I can replace them with larger resistors, but thats harder.



  • Depending on how it works, maybe reducing the pull-up resistance values would work better. What do you recommend I try?


  • administrators

    Reducing the values of the pullup resistors - or adding your own additional pullup resistors external to the board - will increase the output voltage to nearer 5V with your load connected. But the output will still be high when the Duet boot up, before you send the first M42 command. This is unavoidable when using pins that can be configured as as either inputs or open-drain outputs.

    One solution would be to use an external gate, mosfet or BJT to invert the output from the pin.



  • Thanks for the suggestions, I will try them later.

    Are there other pins that I could use that are not able to be configured as either inputs or open-drain outputs?



  • Easy enough to add my own external pullups to reduce the effective pullup resistance, thanks, I'll do that!


  • administrators

    @jml:

    Thanks for the suggestions, I will try them later.

    Are there other pins that I could use that are not able to be configured as either inputs or open-drain outputs?

    If you are not using all the heater outputs on the DueX5, you could use the associated servo outputs.



  • @dc42 The servo outputs and the fan pwm pins all seem to become active twice for a very split second during bootup. I can see that this happens because the heater LEDs on the DUEX light up for a split second, and my RGB LEDs on the fan light up for a very short period of time. Can I change this behavior in the firmware?



  • @jml How high are the servo pins bouncing to voltage-wise? That sounds more like the e0/e1 diodes draining from initial capacitance when power is connected... any chance you could check the servo pins on start with a meter or scope and report the results?



  • I will take a look with a scope when I can. By eye, the first blip makes the LEDs go on very briefly and dim. The second blip is brighter.


Locked
 

Looks like your connection to Duet3D was lost, please wait while we try to reconnect.