Welcome! Log In Create A New Profile

Advanced

Need help with pins for i/o - how I can set them?

Posted by yello3d 
Need help with pins for i/o - how I can set them?
January 03, 2023 11:54PM
I am working on this issue already for some weeks, and so far no luck.

I am using Fysetc Spider v2.3 (they don't react to support questions) and I need some pins for switching externals (that is 3 pumps). I.e. for switches I I set in *_adv.h >

#define CUSTOM_USER_BUTTONS 
#if ENABLED(CUSTOM_USER_BUTTONS)
 #define BUTTON1_PIN PC9 // is pin 66
  #if PIN_EXISTS(BUTTON1)
    #define BUTTON1_HIT_STATE     HIGH      // tried LOW too
    #define BUTTON1_WHEN_PRINTING false     // Button allowed to trigger during printing?
    #define BUTTON1_GCODE         "G0 X5"
    #define BUTTON1_DESC          "Move X 5"  // Optional string to set the LCD status
  #endif

For the pumps etc. I set in *.adv.h

#define DIRECT_PIN_CONTROL
#define CUSTOM_1 PA8  // 67

And then try to set state with `M42 P66 S255` (Tried all the numbers incl. S0m S1, T0, T1 in all combinations.)

Pumps are connected to 5V and 24V via a mosfet breakout module.

On the web I found no instruction, so I hope to get some hints here.

BTW, I am using Marlin 2.1.x

Edited 2 time(s). Last edit at 01/03/2023 11:56PM by yello3d.
Re: Need help with pins for i/o - how I can set them?
January 04, 2023 03:25AM
I'm a bit confused. Sounds like you want to do the following:
  • Connect buttons/switches to your motherboard.
  • Have the motherboard set/clear an I/O pin that is connected to an external MOSFET board that runs a pump.
  • Use M42 xxxx xxxx xxxx command as the BUTTON1_GCODE to turn on/off the I/O pin

Why not just connect the button to the external MOSFET board? I see no value add in using the motherboard.

PC9 and PA8 are on the EXP1 LCD connector. I expect you'll want to use that connector for your LCD.

How did you determine that PC9 is pin 66 when using the M42 command? The only way I know to determine this for an STM32 based board is to enable PINS_DEBUGGING in configuration_adv.h and then issue the command M43. That'll list the known pins, what they're used for and the M42 name to use for it. If multiple functions are assigned to a pin then all are listed. If another function is already assigned to that pin then the other function may override your M42 command.

For M42 I suggest using the I option. That way it'll always attempt to write to the pin no matter what.

I don't think adding the line #define CUSTOM_1 PA8 // 67 will do anything. What do you want it to do?
Re: Need help with pins for i/o - how I can set them?
January 04, 2023 03:42AM
FYI

PA8, //D8

You might have better luck with M42 P8 S255

M42 P66 S255 makes no sense
ignoring the wrong port, you are trying to set the pin you have defined as a inpout for your switch as an output via gcode???


how have you wired the switch?
normally the switch would connect the io pin to gnd with a pull up resistor to vcc
So open it reads high and closed it read low



Port identification
Its a merry chase, but follow this.

Start in Marlin/src/pins/pins.h

#elif MB(FYSETC_SPIDER_V2_2)
  #include "stm32f4/pins_FYSETC_SPIDER_V2_2.h"  // STM32F4                                env:FYSETC_S6 env:FYSETC_S6_8000

It shows the motherboard uses build environment env:FYSETC_S6

If you look at that env

#
# FYSETC S6 (STM32F446RET6 ARM Cortex-M4)
#
[env:FYSETC_S6]
extends                     = stm32_variant
board                       = marlin_fysetc_s6

the controller board is marlin_fysetc_s6

So you look in

buildroot/share/PlatformIO/boards/marlin_fysetc_s6.json

and you see "variant": "MARLIN_FYSETC_S6"

This leads you to your final destination

buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/


In variant.h is the translation from stm32 pin names to raw port number

eg

#define PA6   6  //D6
#define PA7   7  //D7
#define PA8   8  //D8
#define PA9   9  //D9
#define PA10  10 //D10
...
#define PC7   39 //D39
#define PC8   40 //D40
#define PC9   41 //D41
#define PC10  42 //D42
#define PC11  43 //D43

Edited 9 time(s). Last edit at 01/04/2023 04:29AM by Dust.
Re: Need help with pins for i/o - how I can set them?
January 04, 2023 04:29AM
Quote
[email protected]
What do you want it to do?

I have a number of tact-switches I like to connect, like HOME, STEP (there are 7, I don't need all though)

Then i have a few external devices I like to switch on/off. That is:
2 vac pumps
1 air pump
2 LED lights
2 actuators

Application is a Pick & Place machine. I don't plan to use any LCD.

One update, it looks like to pin assignment from the manufacturers wiki is different from a M43 printout. When I use the pin # from the M43 seems I can do something. I will continue tomorrow. To the makes no sense from the makers page I see that PA8 is #67 in their wiki, but P8 when I do a M43. It's confusing. But I think I can get a step closer now.

Thank you guys!



@Dust
You kinda sneaked in while I typed. I will work on it tomorrow with what I learned today.

Edited 1 time(s). Last edit at 01/04/2023 04:34AM by yello3d.
Re: Need help with pins for i/o - how I can set them?
January 05, 2023 05:44AM
I am getting sort of slowly into that. One error, the vac-motors are 12V, not 5V

I tried some extruder outputs today, that generate 24V.

I declared E1 in the firmware with `#define CUSTOM_4 PC8`

Then tested with:
M42 P40 S200 (24V with multimeter)
M42 P40 S62 (12V with multimeter)

When I tried the motor the output got stuck at 24V, even with M42 P40 S0. Now it's always 24V. Did I blew the E1 channel? Rest of the controller seem to work.

The motor has ~380mA at 12V, So at 24V mA will be obviously more, is that PWM OUT even suitable for DC motors?.
Re: Need help with pins for i/o - how I can set them?
January 05, 2023 06:07AM
yes you probably killed it

Motors have back emf, you have to protect the mosfet from the motor by putting a diode over the motor pins

eg



Edited 1 time(s). Last edit at 01/05/2023 06:08AM by Dust.
Re: Need help with pins for i/o - how I can set them?
January 05, 2023 08:05AM
Quote
Dust
yes you probably killed it

Seems it's a WSD3050, anyway, I have a few more channels I can blow ;-)

But will not try that out. No more directly connected motors for me, will get some logic level mosfets.
Sorry, only registered users may post in this forum.

Click here to login