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

Please, help check and suggest modifications CNC3040 map file. #40

Open
RepRapThailand opened this issue Aug 30, 2023 · 16 comments
Open

Comments

@RepRapThailand
Copy link

RepRapThailand commented Aug 30, 2023

Hello,

I use Blue Pill but try to re-map pins difference from CNC3040 and need UART1. This is a map file that I try to modifications and What other files do I need to edit?

1693461534130

#if N_ABC_MOTORS > 2 || N_GANGED
#error Axis configuration is not supported!
#endif

#if EEPROM_ENABLE
#error EEPROM plugin not supported!
#endif

#if N_AXIS == 5
#define BOARD_NAME "CNC 3040 5-axis"
#elif N_AXIS == 4
#define BOARD_NAME "CNC 3040 4-axis"
#else
#define BOARD_NAME "CNC 3040"
#endif

// Define step pulse output pins.
#define X_STEP_PORT GPIOA
#define X_STEP_PIN 5
#define Y_STEP_PIN 7
#define Z_STEP_PORT GPIOB
#define Z_STEP_PIN 1
#define STEP_OUTMODE GPIO_BITBAND

// Define step direction output pins.
#define X_DIRECTION_PORT GPIOA
#define X_DIRECTION_PIN 6
#define Z_DIRECTION_PORT GPIOB
#define Y_DIRECTION_PIN 0
#define Z_DIRECTION_PIN 10
#define DIRECTION_OUTMODE GPIO_BITBAND

// Define stepper driver enable/disable output pin.
#define STEPPERS_ENABLE_PORT GPIOB
#define STEPPERS_ENABLE_PIN 13

// Define homing/hard limit switch input pins.
#define LIMIT_PORT GPIOA
#define X_LIMIT_PIN 0
#define Y_LIMIT_PIN 1
#define Z_LIMIT_PIN 2
#define LIMIT_INMODE GPIO_SHIFT10

// Define ganged axis or A axis step pulse and step direction output pins.
#if N_ABC_MOTORS > 0
#define M3_AVAILABLE
#define M3_STEP_PORT GPIOB
#define M3_STEP_PIN 11
#define M3_DIRECTION_PORT GPIOB
#define M3_DIRECTION_PIN 12
#define M3_LIMIT_PORT GPIOA
#define M3_LIMIT_PIN 3
#endif

// Define ganged axis or B axis step pulse and step direction output pins.
#if N_ABC_MOTORS == 2
#define M4_AVAILABLE
#define M4_STEP_PORT GPIOB
#define M4_STEP_PIN 14
#define M4_DIRECTION_PORT GPIOB
#define M4_DIRECTION_PIN 15
#define M4_LIMIT_PORT GPIOA
#define M4_LIMIT_PIN 4
#endif

// Define spindle enable and spindle direction output pins.
#define SPINDLE_ENABLE_PORT GPIOA
#define SPINDLE_ENABLE_PIN 8
#define SPINDLE_DIRECTION_PORT GPIOA
#define SPINDLE_DIRECTION_PIN 9

// Define spindle PWM output pin.
#define SPINDLE_PWM_PORT_BASE GPIOA_BASE
#define SPINDLE_PWM_PIN 10

// Define flood and mist coolant enable output pins.
#define COOLANT_FLOOD_PORT GPIOB
#define COOLANT_FLOOD_PIN 3
#define COOLANT_MIST_PORT GPIOA
#define COOLANT_MIST_PIN 15

// Define user-control controls (cycle start, reset, feed hold) input pins.
#define CONTROL_PORT GPIOB
#define RESET_PIN 9
#define CYCLE_START_PIN 5
#define CONTROL_PORT GPIOC
#define FEED_HOLD_PIN 14
#if SAFETY_DOOR_ENABLE
#define SAFETY_DOOR_PIN 15
#endif
#define CONTROL_INMODE GPIO_BITBAND

// Define probe switch input pin.
#define PROBE_PORT GPIOB
#define PROBE_PIN 8

#if KEYPAD_ENABLE == 1
#error I2C keypad mode is not supported!
#endif

@terjeio
Copy link
Contributor

terjeio commented Aug 30, 2023

If you rename the file to my_machine_map.h then no other files than my_machine.h needs to be changed. Enable the map file here.
If you plan to submit a PR my_machine.h and driver.h has to be changed and the map file given a new name.

The FEED_HOLD_PIN and M4_LIMIT_PIN (incorrectly defined as M3_LIMIT_PIN above) cannot have the same pin number since the STM32 architecture only allows one interrupt per pin number regardless of the port. M3_LIMIT_PORT has also a duplicate definition.

FYI the C8 (128K flash version, in reality a CB device) is nearly at its limits for both flash and RAM and updates will soon no longer be possible, consider switching to a medium density (RC or better) variant or F303/F411 Blackpills.

@RepRapThailand
Copy link
Author

Hi, Terjeio

Thanks a lot for your suggest. I don't know how to code but look at other map files and try to fix them. I edited it as you suggested.
Is this correct?

  1. FEED_HOLD_PIN >> PC14
  2. M4_LIMIT_PIN >> PA4

@terjeio
Copy link
Contributor

terjeio commented Aug 31, 2023

Is this correct?

I believe so, compile and flash - then test.

@terjeio
Copy link
Contributor

terjeio commented Sep 5, 2023

Your grbl folder is nearly empty, it should contain all the core files.

@RepRapThailand
Copy link
Author

RepRapThailand commented Sep 6, 2023

Fixed

Capture4

@terjeio
Copy link
Contributor

terjeio commented Sep 6, 2023

Oops, I forgot to check for allowed PWM pins. Replace these lines with the code below to add PA10 PWM output:

#if SPINDLE_PWM_PORT_BASE == GPIOA_BASE
  #if SPINDLE_PWM_PIN == 1 // PA1 - TIM5_CH2
    #define SPINDLE_PWM_TIMER_N     5
    #define SPINDLE_PWM_TIMER_CH    2
    #define SPINDLE_PWM_TIMER_INV   0
    #define SPINDLE_PWM_AF_REMAP    0
  #elif SPINDLE_PWM_PIN == 8 // PA8 - TIM1_CH1
    #define SPINDLE_PWM_TIMER_N     1
    #define SPINDLE_PWM_TIMER_CH    1
    #define SPINDLE_PWM_TIMER_INV   0
    #define SPINDLE_PWM_AF_REMAP    0
  #elif SPINDLE_PWM_PIN == 10 // PA10 - TIM1_CH3
    #define SPINDLE_PWM_TIMER_N     1
    #define SPINDLE_PWM_TIMER_CH    3
    #define SPINDLE_PWM_TIMER_INV   0
    #define SPINDLE_PWM_AF_REMAP    0
  #elif SPINDLE_PWM_PIN == 1 // PA1 - TIM2_CH2
    #define SPINDLE_PWM_TIMER_N 2
    #define SPINDLE_PWM_TIMER_CH 2
    #define SPINDLE_PWM_TIMER_INV 0
    #define SPINDLE_PWM_AF_REMAP 0
  #endif
#elif SPINDLE_PWM_PORT_BASE == GPIOB_BASE
  #if SPINDLE_PWM_PIN == 0 // PB0 - TIM1_CH2N
    #define SPINDLE_PWM_TIMER_N     1
    #define SPINDLE_PWM_TIMER_CH    2
    #define SPINDLE_PWM_TIMER_INV   1
    #define SPINDLE_PWM_AF_REMAP    0b01
  #endif
#endif

@RepRapThailand
Copy link
Author

RepRapThailand commented Sep 7, 2023

Some error

Capture5

@terjeio
Copy link
Contributor

terjeio commented Sep 7, 2023

Y_STEP_PORT and Y_DIRECTION_PORT are missing in the map file.

Is the board map above the version you are compiling with? I cannot see issues with the IRQ enabled pins in that.

@RepRapThailand
Copy link
Author

Y_STEP_PORT and Y_DIRECTION_PORT are missing in the map file.

Is the board map above the version you are compiling with? I cannot see issues with the IRQ enabled pins in that.

https://github.com/grblHAL/STM32F1xx/archive/refs/heads/master.zip
https://github.com/grblHAL/core/archive/refs/tags/20230714.zip

@terjeio
Copy link
Contributor

terjeio commented Sep 7, 2023

Add your latest copy of the modified map file to a comment.

@terjeio
Copy link
Contributor

terjeio commented Sep 7, 2023

There is a duplicate #define CONTROL_PORT with conflicting definition.
Z_LIMIT_PIN and RESET_PIN cannot have the same pin number.
M4_LIMIT_PIN and FEED_HOLD_PIN cannot have the same pin number, but it does not matter if motor 4 is not enabled.
Ref. the <interrupt enabled pins> cannot have the same pin number since the STM32 architecture only allows one interrupt per pin number regardless of the port comment above. Control and limit pins are interrupt enabled.

@RepRapThailand
Copy link
Author

There is a duplicate #define CONTROL_PORT with conflicting definition. Z_LIMIT_PIN and RESET_PIN cannot have the same pin number. M4_LIMIT_PIN and FEED_HOLD_PIN cannot have the same pin number, but it does not matter if motor 4 is not enabled. Ref. the cannot have the same pin number since the STM32 architecture only allows one interrupt per pin number regardless of the port comment above. Control and limit pins are interrupt enabled.

#if N_ABC_MOTORS > 2 || N_GANGED
#error Axis configuration is not supported!
#endif

#if EEPROM_ENABLE
#error EEPROM plugin not supported!
#endif

#if N_AXIS == 5
#define BOARD_NAME "My Machine 5-axis"
#elif N_AXIS == 4
#define BOARD_NAME "My Machine 4-axis"
#else
#define BOARD_NAME "My Machine"
#endif

// Define step pulse output pins.
#define X_STEP_PORT GPIOA
#define X_STEP_PIN 5
#define Y_STEP_PORT GPIOA
#define Y_STEP_PIN 7
#define Z_STEP_PORT GPIOB
#define Z_STEP_PIN 1
#define STEP_OUTMODE GPIO_BITBAND

// Define step direction output pins.
#define X_DIRECTION_PORT GPIOA
#define X_DIRECTION_PIN 6
#define Y_DIRECTION_PORT GPIOB
#define Y_DIRECTION_PIN 0
#define Z_DIRECTION_PORT GPIOB
#define Z_DIRECTION_PIN 10
#define DIRECTION_OUTMODE GPIO_BITBAND

// Define stepper driver enable/disable output pin.
#define STEPPERS_ENABLE_PORT GPIOB
#define STEPPERS_ENABLE_PIN 13

// Define homing/hard limit switch input pins.
#define LIMIT_PORT GPIOA
#define X_LIMIT_PIN 0
#define Y_LIMIT_PIN 1
#define Z_LIMIT_PIN 2
#define LIMIT_INMODE GPIO_SHIFT10

// Define ganged axis or A axis step pulse and step direction output pins.
#if N_ABC_MOTORS > 0
#define M3_AVAILABLE
#define M3_STEP_PORT GPIOB
#define M3_STEP_PIN 11
#define M3_DIRECTION_PORT GPIOB
#define M3_DIRECTION_PIN 12
#define M3_LIMIT_PORT GPIOA
#define M3_LIMIT_PIN 3
#endif

// Define ganged axis or B axis step pulse and step direction output pins.
#if N_ABC_MOTORS == 2
#define M4_AVAILABLE
#define M4_STEP_PORT GPIOB
#define M4_STEP_PIN 14
#define M4_DIRECTION_PORT GPIOB
#define M4_DIRECTION_PIN 15
#define M4_LIMIT_PORT GPIOA
#define M4_LIMIT_PIN 4
#endif

// Define spindle enable and spindle direction output pins.
#define SPINDLE_ENABLE_PORT GPIOA
#define SPINDLE_ENABLE_PIN 8
#define SPINDLE_DIRECTION_PORT GPIOA
#define SPINDLE_DIRECTION_PIN 9
// Define spindle PWM output pin.
#define SPINDLE_PWM_PORT_BASE GPIOA_BASE
#define SPINDLE_PWM_PIN 10

// Define flood and mist coolant enable output pins.
#define COOLANT_FLOOD_PORT GPIOB
#define COOLANT_FLOOD_PIN 3
#define COOLANT_MIST_PORT GPIOA
#define COOLANT_MIST_PIN 15

// Define user-control controls (cycle start, reset, feed hold) input pins.
#define CONTROL_PORT GPIOB
#define CYCLE_START_PIN 5
#define CONTROL_PORT GPIOC
#define RESET_PIN 13
#define FEED_HOLD_PIN 14
#if SAFETY_DOOR_ENABLE
#define SAFETY_DOOR_PIN 15
#endif
#define CONTROL_INMODE GPIO_BITBAND

// Define probe switch input pin.
#define PROBE_PORT GPIOB
#define PROBE_PIN 8

#if KEYPAD_ENABLE == 1
#error I2C keypad mode is not supported!
#endif

@RepRapThailand
Copy link
Author

Capture7

Capture8

@terjeio
Copy link
Contributor

terjeio commented Sep 7, 2023

Seems like you are building a debug version, this will not or barely fit flash depending on the options enabled in my_machine.h.
The release version is smaller and will allow you to enable more options. Select the Release build type from the tool icon (hammer).
Here is how it looks when I built with no options enabled other than your board map:

image

PS: I removed the duplicate #define CONTROL_PORT definition before compiling.

Tip: to reclaim flash disable USB and use an external USB <> UART breakout board for talking to the controller.

@RepRapThailand
Copy link
Author

I still trying...

@terjeio
Copy link
Contributor

terjeio commented Sep 11, 2023

I still trying...

Here is a release binary that I built with your map file:

GRBL Driver STM32F103C8.zip

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