Notifications
Clear all

Access MINI GPIO via G-code  

  RSS
eekwils
(@eekwils)
New Member
Access MINI GPIO via G-code

Hi everyone,

I was wondering if there is any information out there regarding the use of the set GPIO pin command (M42) on the Prusa MINI.

I have been using it to great success on the Mk3 to remote trigger cameras for timelapse photography and would really like to get the same system working on the MINI.

Taking a look at the layout of the Buddy control board I can see that there are some pins in the white expansion header (J23) are pinned out to PortE-0 and PortB-5 on the STM32 microcontroller. (and there is also the PortE-6 pin that's in the ESP header). I was wondering if you can access any of these pins via the GPIO commands in the G-Code processor (Marlin, I'm assuming).

I've had a quick search through the buddy firmware repo and I found the gpio.h header which seems to give logical numbers to each of physical port/pin combos. So I was thinking that these numbers might be the ones I can use as the pin number in the M42 command, something like:

M42 P64 S1 (Set pin 64 (mapped to PE0 in gpio.h) to high)

However when I run a command like this the printer crashes, and displays a error screen (picture attached)

Has anyone had any success with something like this? Am I going about it in the right way or am I missing something fundamental about the MINI's firmware?

Thanks in advance!

This topic was modified 4 years ago by eekwils
Posted : 31/03/2021 3:32 am
Turro75
(@turro75)
Estimable Member
RE: Access MINI GPIO via G-code

The source code You referred is old, the whole gpio have been rewritten so currently there is any association among pin and number.

You could try a previous firmware such as 4.2 which still has the previous code

Posted : 31/03/2021 4:34 pm
Meerman
(@meerman)
Active Member
RE: Access MINI GPIO via G-code

@eekwils: Did you get anywhere with this approach?

I too want a way to signal an external device that it's time to take a photo. (I've tried OctoPrint, but personally prefer the Prusa MINI's native display which shows a nice progress bar and ETA).

Is it possible from gcode to print something over the serial port?

Posted : 10/07/2021 10:33 pm
Meerman
(@meerman)
Active Member
Serial port workaround

FWIW, I resorted to using a Raspberry Pi to read the serial port directly (not using OctoPrint) and noticed that the MINI+ emits a single line of text at the end of every layer, e.g.:

X:62.70 Y:88.98 Z:5.00 E:0.00 Count X:6410 Y:9835 Z:1734

So that can serve as a trigger.

I initially had trouble whenever I tried to read the serial port - errors about "Unknown command" every time the MINI printed something. I  think the text was being written back to the printer as a command input? Anyways, I solved it by using socat like so:

socat STDIO /dev/ttyACM0,echo=0

If anyone else is old like me and wonders "Where is the serial port on the MINI?"... it's the micro-USB socket next to the power switch, which enumerates as a USB Serial Device. Not pins on the buddy board, or a DB9/DB25 connector. 😓

Posted : 30/08/2021 8:35 pm
Share: