Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mks_robin_nano_v3.0 board map wrong AUXINPUT0_PORT selected #213

Open
calabr opened this issue Jan 23, 2025 · 11 comments
Open

mks_robin_nano_v3.0 board map wrong AUXINPUT0_PORT selected #213

calabr opened this issue Jan 23, 2025 · 11 comments

Comments

@calabr
Copy link

calabr commented Jan 23, 2025

Hi Terge,
Started to play with MKS robin nano v3.1 board found AUXINPUT0_PORT are configured to use GPIOG, which are not exists on this CPU.
As result, created by WebBuilder firmware mapping Safety door and Motor fault inputs to nowhere.
Most probable it's some copy-past error from different board map

mks_robin_nano_v3.0_map.h

[OPT:VNMSL,100,1024,5,0]
[AXS:5:XYZAB]
[NEWOPT:ENUMS,RT+,ES,MPG,SED,ODO,SD,YM]
[FIRMWARE:grblHAL]
[SIGNALS:HSEFP]
[NVS STORAGE:*EEPROM 4K]
[FREE MEMORY:81K]
[DRIVER:STM32F407]
[DRIVER VERSION:250118]
[BOARD:MKS ROBIN-NANO 3.0]
[AUX IO:0,1,0,0]
[PLUGIN:Bootloader Entry v0.02]
[PLUGIN:Trinamic v0.24]
[PLUGIN:KEYPAD v1.38]
[PLUGIN:Macro plugin v0.10]
[PLUGIN:Homing pulloff v0.01]
[PLUGIN:ODOMETERS v0.06]
[PLUGIN:SDCARD v1.19]
[PLUGIN:FS macro plugin v0.15]
ok
GrblHAL 1.1f ['$' or '$HELP' for help]
[PIN:PC1,Feed hold]
[PIN:PD9,Cycle start]
[PIN:PC0,Emergency stop]
[PIN:PG6,Motor fault]
[PIN:PC4,Probe]

It's also mapping the same pin for AUXOUTPUT1 and AUXOUTPUT4 and some other overlapping definitions

#define AUXOUTPUT1_PIN          1

#define AUXOUTPUT4_PORT         GPIOB // Coolant mist, HEAT1
#define AUXOUTPUT4_PIN          1

MOOR_UARTZ and MOTOR_UART3 are mapped to the same pin, MOTOR_UART5 are configured but board only supports 5 drivers in total
mks_robin_nano_v3.0_map

@calabr
Copy link
Author

calabr commented Jan 23, 2025

I'm trying to summarize board alignment from MKS documents and board mapping.
Problematic or not even mapping are highlighted yellow in this table
MKS Robin nano V3.1 port map

@terjeio
Copy link
Contributor

terjeio commented Jan 23, 2025

This is better? I do not have a board to verify with.

mks_robin_nano_v3.0_map.zip

@calabr
Copy link
Author

calabr commented Jan 24, 2025

This is better? I do not have a board to verify with.

mks_robin_nano_v3.0_map.zip

Thank you! it's looks much better.
MOT3 and MOT4 UART are crossed - should be:

#ifdef M3_AVAILABLE
#define MOTOR_UARTM3_PORT GPIOD
#define MOTOR_UARTM3_PIN 9
#endif

#ifdef M4_AVAILABLE
#define MOTOR_UARTM4_PORT GPIOD
#define MOTOR_UARTM4_PIN 8
#endif

#ifdef M3_AVAILABLE
#define MOTOR_CSM3_PORT GPIOD
#define MOTOR_CSM3_PIN 9
#endif

#ifdef M4_AVAILABLE
#define MOTOR_CSM4_PORT GPIOD
#define MOTOR_CSM4_PIN 8
#endif

I'll also propose different port and button allocation It will use more protected inputs for buttons, allow more free inputs :

PA13	SAFETY_DOOR			PW_DET
PA4	FEED_HOLD			MT_DET1
PE6	CYCLE_START			MT_DET2
PB2	RESET				PW_OFF
PA8	AUXOUTPUT1 (SPINDLE_DIRECTION)	BLTOUCH	
PC0	PROBE				TB 
PA2	AUXINPUT0 (motor_fault)		TH2	
PC1 	AUXINPUT1 - FREE		TH1	

power outputs: - move spindle PWM to most powerful output to allow connecting DC motors directly and logical output for the same port, direct connection of coolant DC motor or relay, reserve fan port for fan/vacuum etc. control

(PC14)	AUXOUTPUT5 - FREE reserved power out	FAN1 
(PB1)	AUXOUTPUT4 (COOLANT_MIST)		FAN2 
  High power outputs
PB0	AUXOUTPUT3 (COOLANT_FLOOD)		HE2/HE2-	
PE5	AUXOUTPUT2 (SPINDLE_ENABLE)		HE1/HE1-	
PA0	AUXOUTPUT0 (SPINDLE_PWM)		HB/HB-

It's also lots of ports still free on the board, but I'm only few days playing with board and cannot explore it yet.

@terjeio
Copy link
Contributor

terjeio commented Jan 24, 2025

I'll commit the version I now have with the CS/UART pins fixed.

Note that limit inputs for M3 and M4 motors has to be interrupt capable, this puts a restraint on how you assign other pins that requires interrupt capability, this is due to how STM32 interrupts are "wired". There are only 16 GPIO IRQs and a given pin number can only be assigned to one IRQ regardless of which port it belongs to. So e.g. the M3_LIMIT_PIN (PC4) and MT_DET1 (PA4) cannot both be assigned to an interrupt.
TH1 and TH2 has to be tested, not sure these inputs can be used to detect digital signals reliably due to the voltage divider at the inputs.

When you are happy with a board map please create a PR with your changes.

@calabr
Copy link
Author

calabr commented Jan 27, 2025

There are only 16 GPIO IRQs and a given pin number can only be assigned to one IRQ regardless of which port it belongs to. So e.g. the M3_LIMIT_PIN (PC4) and MT_DET1 (PA4) cannot both be assigned to an interrupt.

If I'm understand correctly, we can freely assign interrupt to to any port, but pins with the same ID on different ports should be served by the same IRQ - Like PA0 and PB0 will trigger IRQ PinChange0.
What is requirements of grblHAL for IRQ? every limit on unique IRQ? what is IRQ requirements for probe and buttons ?
I'm also interested to play with encoder in future.

@terjeio
Copy link
Contributor

terjeio commented Jan 27, 2025

pins with the same ID on different ports should be served by the same IRQ - Like PA0 and PB0 will trigger IRQ PinChange0.

Not so, only one of them can be "wired" to the IRQ line. See Figure 31 in the PRM.

What is requirements of grblHAL for IRQ?

Limit and control inputs (reset, feed hold, cycle start etc). Probe is optional since it is polled, but best to have on an IRQ line since that triggers a SR latch.

Some plugins requires interrupt capable auxiliary inputs as well.
There is support in some drivers for polling the Z limit input (for badly engineered 3D printer boards). I am no fan of polling inputs constantly, if you need to use polling it can be implemented in a board specific plugin.

Encoder signals can be fed to a encoder peripheral if available (STM32 timers can also be used) - this way it is possible to avoid "using" up" the available GPIO IRQ lines.

@calabr
Copy link
Author

calabr commented Jan 28, 2025

Unfortunately trying to build firmware with WebBuilder causing error

Src/driver.c:83:2: error: #error Interrupt enabled input pins must have unique pin numbers!
#error Interrupt enabled input pins must have unique pin numbers!
^~~~~
*** [.pio/build/test/src/driver.o] Error 1

Cannot decide what exactly overrides - minimal setup for 3 axis, no probe etc. giving the same results
Not sure if WebBuilder excluding all declarations related to unused inputs.
at-least I see

#define CYCLE_START_PORT        GPIOE
#define CYCLE_START_PIN         6                           // MT_DET2
#define AUXINPUT0_PORT          GPIOA                       // EXP1 PA6
#define AUXINPUT0_PIN           6
...
#define RESET_PORT              GPIOE
#define RESET_PIN               12                          // EXP2 PE12

#define SD_DETECT_PORT          GPIOD
#define SD_DETECT_PIN           12

It's will be helpful if WebBuilder allows to download generated config files no matter successful build or not

@terjeio
Copy link
Contributor

terjeio commented Jan 28, 2025

I'll remove support for SD detect - it is not that important and is causing the compilation failure.

It's will be helpful if WebBuilder allows to download generated config files no matter successful build or not

Sure, I'll try to add it.

@calabr
Copy link
Author

calabr commented Jan 29, 2025

But what about AUXINPUT0 ? it's mapped to SAFETY_DOOR and MOTOR_FAULT
Proposing the next mapping with regard of PIN interrupt restriction

Con 	| port name 	| PortID|IRQ 	| Column 1
----------------------------------------------------------
J54.3 	| PW_DET 	| PA13 	| 13 	| SAFETY_DOOR
J53.3 	| MT_DET2 	| PE6 	| 6 	| PROBE
EXP1.5 	| LCD_D4 	| PE14 	| 14 	| CYCLE_START
EXP1.7 	| LCD_D6 	| PD11 	| 11 	| FEED_HOLD
EXP1.8 	| LCD_D7 	| PD10 	| 10 	| Reset
EXP2.1 	| SPI1_MISO	| PA6 	|	| ENCODER A reserved
EXP2.2 	| SPI1_SCK 	| PA5 	| 5 	| INDEX reserved
EXP2.6 	| SPI1_MOSI 	| PA7 	|   	| ENCODER B reserved
SD5 	| SD_DET 	| PD12 	| 12 	| SD_DETECT

The idea is to move Door and Probe inputs to PW_DET and MT_DET2 because this connectors are 3-pin and contains +5V power, copacitor - better much for external connectors.
move buttons to EXP1 connector - it's open pins from controller, better much buttons and future control panel connection
PA6,PA7 are inputs of encoder capable counter, so good candidates for encoder connection without PIN interrupts.

Regarding analog inputs TB, TH1, TH2 - it's isn't divider - it's filtered - 10u capacitor in parallel, 4k pool-up to 3v3, protective diodes from GND and 3v3, 100 Ohm resistor toward controller PIN. So it's not the keys for digital inputs/outputs until capacitors are removed.

@calabr
Copy link
Author

calabr commented Jan 30, 2025

I'm just realized, analog inputs TB, TH1,TH2 on this boards should fit button connection - 10u capacitor not best, but not the problem for mechanical buttons.
Proposing better inputs allocation with some room for encoder and AUX inputs

Con Board port name Port ID PIN IRQ grblHAL input
J54.3 PW_DET PA13 13 SAFETY_DOOR
J53.3 MT_DET2 PE6 6 PROBE
TB.2 TB PC0 0 CYCLE_START
TH1.2 TH1 PC1 1 RESET
EXP1.5 LCD_D4 PE14 14 AUX_in reserved (reserved)
EXP2.1 SPI1_MISO PA6 TIM3 ENCODER A (timer) (reserved)
EXP2.2 SPI1_SCK PA5 5 INDEX (reserved)
EXP2.4 SPI1_CS PE10 10 ENCODER2 A (reserved)
EXP2.5 BTN_EN2 PE11 11 ENCODER2 B (reserved)
EXP2.6 SPI1_MOSI PA7 TIM3 ENCODER B (timer) (reserved)
SD5 SD_DET PD12 12 SD_DETECT

I'm didn't setup my build environment yet, so it's not tested.

Going to prepare map.h @terjeio is it Ok for WebBuilder to allocate PROBE_PIN and SAFETY_DOOR_PIN directly without reference to AUXINPUT0_PIN AUXINPUT1_PIN ? I'm want to free AUX for different tasks from plugins.
Or probable add additional AUXINPUT declaration

@terjeio
Copy link
Contributor

terjeio commented Jan 31, 2025

I'm just realized, analog inputs TB, TH1,TH2 on this boards should fit button connection

You have to verify that these inputs can actually be used first. There are no values for the resistors in my schematic so impossible to calculate if the input low voltage is below the min. required.

Ok for WebBuilder to allocate PROBE_PIN and SAFETY_DOOR_PIN directly without reference to AUXINPUT0_PIN AUXINPUT1_PIN ?

No, add additional aux inputs instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants