GPIO Project Question - Filter control
 
Notifications
Clear all

GPIO Project Question - Filter control  

  RSS
tmorgenthaler
(@tmorgenthaler)
Member
GPIO Project Question - Filter control

I just upgraded my MK4 to the MK4S, and I ordered the GPIO board along with it.

One thing I would like to do is control a VOXEL Bento Box 2 that I use in my Ikea Lack enclosure, to control the PTEG fumes.  Right now, I have to use a wall outlet, and plug it in when I want to use the filter.  Ideally, I'd like to wire it to the printer power supply, but use GCODE to turn it on.  Has anybody done anything similar?

I saw there was a thread about controlling the Prusa Enclosure Fan and LEDs, but that links to another controller board.

Thanks.

Posted : 25/09/2024 3:20 pm
Brian liked
bkerler
(@bkerler)
Trusted Member
RE: GPIO Project Question - Filter control

It is pretty easy actually.

If you for example have the led and fan extension board connected:

Fan

"M262 P0 B0" < switch pin 0 (fan) to output

"M264 P0 B0" < turn pin 0 to low (fan off)

"M264 P0 B1" < set pin 0 to high (fan on)

you can replace P0 with P1 for Pin 1 (led). If you haven't got any extension board, just solder a input pin to the pin 0 .. 7 header.

Posted : 27/09/2024 1:47 pm
bkerler
(@bkerler)
Trusted Member
RE: GPIO Project Question - Filter control

Example start gcode:

M262 P0 B0 ; Fan to output
M264 P0 B1 ; Fan on
M262 P1 B0 ; LED to output
M264 P1 B1 ; LED on

Example end gcode:

M264 P1 B0 ; LED off
M264 P0 B0 ; Fan off

Remember that on the  extension board, the settings can be overridden manually so make sure to turn them off beforehands (leds on board should be off), otherwise it won't work.

Posted : 27/09/2024 2:05 pm
Sembazuru
(@sembazuru)
Prominent Member
RE:

Remember, use the IO board to control a relay (electromechanical or solid-state) that controls your VOXEL Bento Box. You probably don't want to run the fan power (definitely don't want to run the wall power) through the IO board.

See my (limited) designs on:
Printables - https://www.printables.com/@Sembazuru
Thingiverse - https://www.thingiverse.com/Sembazuru/designs

Posted : 08/10/2024 5:03 pm
ssmith liked
Vir
 Vir
(@vir)
Active Member
RE: GPIO Project Question - Filter control

I can't make it to work. Soldered own Jack-Molex cable, all connections have continuity, GPIO board is plugged in to Buddy and Basic and still no bueno.

Any one has any ideas how to troubleshoot this?

Posted : 21/10/2024 8:25 pm
PreZ
 PreZ
(@prez)
Eminent Member
RE: GPIO Project Question - Filter control

1) I would say don't rely on the outputs to provide voltage to the fan.  ie. don't wire the fan directly to the GPIO board.

2) Most fans require a minimum of 5V, often 12V or 24V.  The GPIO board doesn't supply enough.

3) The output pins (0-3) only provide a floating voltage (something between 0 and 3.3v) or 0 volts (grounded).  You COULD wire something to pins 4-7 as output, which supposedly supports up to 24V, but there is no way to specify output voltage, and if you solder the jumper for it, it will emit either 3.3v or 0v.

 

I actually use relays.  You can buy cheap relays on amazon.  Wire the power directly to the fan via. the relay (be sure to convert the 24V to the appropriate voltage of the fan), then wire the relay signal pin to the GPIO, so if the signal is high it will close the relay and activate the fan.

If you buy a 5V relay, and the fan is also 5V, you could add a buck converter ( https://www.amazon.com/gp/product/B07HRGV7XD) to power both the fan and relay, and power it directly from the Prusa power supply, which supplies 24V - and still use the GPIO output as the input signal for the relay to switch the relay on and off.

 

My setup is a little more complex.  I actually have a quad relay, since I have 3 buttons I wired into my lack enclosure, each of those buttons can also light up.  And I have a 24V LED strip along the top of the enclosure as well as a 24V fan.  So I have pins 5-7 sensing the buttons at the front of my enclosure being pressed.  Outputs 0-2 going to data pins on the relay to light up said buttons.  Output 4 goes to the 4th relay data pin to control the LED strip.  Output 3 goes to a fan controller that when active actually outputs a PWM signal so I can control the speed of the fan.  The LED strip and fan, since both are 24V, hook directly to the Prusa input power (the fan is on/off based on a relay, and the fan is controlled by the fan controller's PWM signal).  The relay and button lights all run at 5V so I convert the prusa power to 5V to power the relay itself and the buttons (which are powered via. the relay).

This lets me have a setup where I have a STOP button (emits a M112), a light control button, and a fan on/off button, with variable speed controlled separately.  It also uses up all 8 ports on my hackerboard (3 inputs, 5 outputs).

I wanted to change the world, but God wouldn't give me the source code.

Posted : 28/12/2024 4:24 pm
Vir
 Vir
(@vir)
Active Member
RE: GPIO Project Question - Filter control

Well the issue was with the firmware. After updating it to newest version it just started to work.

Nonetheless I was thinking about using relays and stuff because I don’t like how turning fan on from GPIO disables the front buttons. But since Core One has been announced this whole GPIO/enclosure/whatever is obsolete now, since most likely it will not be reused for that upgrade. Money and time wasted, starts to become a theme with Prusa recently. 

Posted : 28/12/2024 8:04 pm
VJ
 VJ
(@vj)
Active Member
RE:
Posted by: @prez

I actually use relays.  You can buy cheap relays on amazon.  Wire the power directly to the fan via. the relay (be sure to convert the 24V to the appropriate voltage of the fan), then wire the relay signal pin to the GPIO, so if the signal is high it will close the relay and activate the fan.

What kind of relay do you use? What specs should I be looking for? I have 2 24v fans (for enclosure) that are currently powered by the PSU and activated via a switch. I'd like to use the GPIO to turn the fans on when a print starts and stop when it ends.

This post was modified 2 weeks ago 2 times by VJ
Posted : 06/01/2025 11:12 pm
_KaszpiR_
(@_kaszpir_)
Prominent Member
RE: GPIO Project Question - Filter control

Use MOSFET with octocouplers such as HW-532, or electromagnetic relay switches which can be controlled via octocouplers via 5v  https://www.explainthatstuff.com/howrelayswork.html

See my GitHub and printables.com for some 3d stuff that you may like.

Posted : 07/01/2025 8:11 am
VJ liked
VJ
 VJ
(@vj)
Active Member
RE: GPIO Project Question - Filter control

If the GPIO output is 3.3V, wouldn't it make sense to use a 3.3V Octocoupler? Like this one?

Posted by: @_kaszpir_

Use MOSFET with octocouplers such as HW-532, or electromagnetic relay switches which can be controlled via octocouplers via 5v  https://www.explainthatstuff.com/howrelayswork.html

 

Posted : 07/01/2025 4:58 pm
PreZ
 PreZ
(@prez)
Eminent Member
RE: GPIO Project Question - Filter control

No, the sensors are for any voltage.

 

I used https://www.amazon.com/gp/product/B00KTEN3TM - a 4x relay (5V).  The power for the relay board itself is 5V, which is convenient for me since I also power a few 5V devices too (so I can split the 5V to the relay board AND to the devices via. the relay itself).

The power you are switching (ie. the fans, lights, whatever) doesn't generally matter except that they are within the capacity of the relay itself (which in this case is DC up to 30V or AC up to 250V at 10 amps).

The sensor wires just detect if there are 0V or some volts.  It doesn't matter if it detects 3.3, 1.2, 5, etc.  It's either grounded (0V) or not.  If not grounded, then the relay closes, if grounded the relay opens.

 

That said, if you want to use a 3.3V relay, that's fine - or a 24V relay.  Any of them will do, as long as the power you supply to the relay itself is at the 5V, 3.3V, 24V or whatever the relay board itself needs.

I wanted to change the world, but God wouldn't give me the source code.

Posted : 07/01/2025 5:07 pm
VJ
 VJ
(@vj)
Active Member
RE: GPIO Project Question - Filter control

OK so a 12V, 24v relay will be able to work even with a 3.3v input to close the relay?

Posted by: @prez

No, the sensors are for any voltage.

 

I used https://www.amazon.com/gp/product/B00KTEN3TM - a 4x relay (5V).  The power for the relay board itself is 5V, which is convenient for me since I also power a few 5V devices too (so I can split the 5V to the relay board AND to the devices via. the relay itself).

The power you are switching (ie. the fans, lights, whatever) doesn't generally matter except that they are within the capacity of the relay itself (which in this case is DC up to 30V or AC up to 250V at 10 amps).

The sensor wires just detect if there are 0V or some volts.  It doesn't matter if it detects 3.3, 1.2, 5, etc.  It's either grounded (0V) or not.  If not grounded, then the relay closes, if grounded the relay opens.

 

That said, if you want to use a 3.3V relay, that's fine - or a 24V relay.  Any of them will do, as long as the power you supply to the relay itself is at the 5V, 3.3V, 24V or whatever the relay board itself needs.

 

Posted : 07/01/2025 5:12 pm
PreZ
 PreZ
(@prez)
Eminent Member
RE:

It should, yes.  Assuming the relay is separately powered from input voltage.

There ARE relays out there that power themselves from the same line they are powering - those will generally only have 4 wires (input, output, ground, sense).  They will, when they sense voltage, close the input to the output so that the switched device gets the same input power.  For these, the input voltage needs to match the voltage of the device you're switching, and the relay needs to match that voltage.

However, a properly isolated relay has 5 wires (power, ground, sense, input, output) - or more correctly, 2 wires (board power/ground) + 3 wires per relay (sense, input, output).  The board power is the 5V, 3.3V, 12V, 24V, etc.  That's not a range usually, it's very specific.  The input is often more a max capacity (like the AC 250V or DC 30V at 10 Amps I mentioned before).  This is the kind of relay you usually want.

Either way the sense wire can usually have any voltage on it DC (I am sure you could overload it with a massive voltage, but that's beyond this scope), so the floating voltage output from the GPIO (which can be anything from 0V to 3.3V, depending on line noise) is sufficient to be sensed by the relay.

This post was modified 2 weeks ago by PreZ

I wanted to change the world, but God wouldn't give me the source code.

Posted : 07/01/2025 5:20 pm
VJ liked
VJ
 VJ
(@vj)
Active Member
RE:

What I have a hard time understanding is the board power. How would I give power to the relay module if I'm using the GPIO? My understanding is the the GPIO outputs 3.3v, so if I understand correctly, I use one of the GPIO outputs to activate the Relay module input. but where/what do I connect the GND and VCC on the module to? (I understand the other side of the module, Fans connected to NO and COM connected to ground)

Some of the tutorials I've seen talk about an Arduino 5V pin, but from what i can see on the Prusa GPIO page, there's no similar power pin, correct?

Posted by: @prez

It should, yes.  Assuming the relay is separately powered from input voltage.

There ARE relays out there that power themselves from the same line they are powering - those will generally only have 4 wires (input, output, ground, sense).  They will, when they sense voltage, close the input to the output so that the switched device gets the same input power.  For these, the input voltage needs to match the voltage of the device you're switching, and the relay needs to match that voltage.

However, a properly isolated relay has 5 wires (power, ground, sense, input, output) - or more correctly, 2 wires (board power/ground) + 3 wires per relay (sense, input, output).  The board power is the 5V, 3.3V, 12V, 24V, etc.  That's not a range usually, it's very specific.  The input is often more a max capacity (like the AC 250V or DC 30V at 10 Amps I mentioned before).  This is the kind of relay you usually want.

Either way the sense wire can usually have any voltage on it DC (I am sure you could overload it with a massive voltage, but that's beyond this scope), so the floating voltage output from the GPIO (which can be anything from 0V to 3.3V, depending on line noise) is sufficient to be sensed by the relay.

 

This post was modified 2 weeks ago 2 times by VJ
Posted : 07/01/2025 5:50 pm
PreZ
 PreZ
(@prez)
Eminent Member
RE: GPIO Project Question - Filter control

If you were going to power the relay from the GPIO, then the ground for the relay would go to one of the GPIO ground pins.

However, I would recommend instead buying a 24V -> 5V buck converter (eg. https://www.amazon.com/gp/product/B07HRGV7XD) - then connect the input of the buck converter to the VCC (+) 24V (red cable) input to the Prusa.  I would recommend the one for the electronics, not the heat bed.  The ground (both for the buck converter AND the relay board) can go to the ground (black cable) for the Prusa too.  That way the relay works regardless of the state of any GPIO pins, etc.

This would then mean that 1) you would not be using up a GPIO pin to just power a relay, 2) you would not need to make sure that GPIO pin is enabled for the relay to work, etc.

 

Preston

I wanted to change the world, but God wouldn't give me the source code.

Posted : 08/01/2025 2:19 am
VJ
 VJ
(@vj)
Active Member
RE: GPIO Project Question - Filter control

Yeah that makes sense, then just use one of the GPIO pins as relay input to activate it. Now I just gotta figure out the G-Code instructions, heh.

Posted by: @prez

If you were going to power the relay from the GPIO, then the ground for the relay would go to one of the GPIO ground pins.

However, I would recommend instead buying a 24V -> 5V buck converter (eg. https://www.amazon.com/gp/product/B07HRGV7XD) - then connect the input of the buck converter to the VCC (+) 24V (red cable) input to the Prusa.  I would recommend the one for the electronics, not the heat bed.  The ground (both for the buck converter AND the relay board) can go to the ground (black cable) for the Prusa too.  That way the relay works regardless of the state of any GPIO pins, etc.

This would then mean that 1) you would not be using up a GPIO pin to just power a relay, 2) you would not need to make sure that GPIO pin is enabled for the relay to work, etc.

 

Preston

 

Posted : 08/01/2025 2:09 pm
Share: