grblHAL / iMXRT1062

grblHAL driver for NXP iMXRT1062 (Teensy 4.x)
Other
51 stars 39 forks source link

Can I add the 7th and 8th axis support.? #43

Closed pzh11001 closed 2 years ago

pzh11001 commented 2 years ago

I checked part of the source code and found that there are definitions of U-axis and V-axis in many places. I try to imitate the programming, add the U-axis and v-axis code where there is ABC axis code, simply and completely imitate the macro definition and variable declaration of ABC axis. Unfortunately, although I have checked it many times to make sure that the U-axis and V-axis codes have been added to all places with ABC axis codes. The compilation can pass smoothly without any errors, and it can also be downloaded to teensy4.1 normally. But when I try to control with the serial assistant, the MCU microcomputer didn't respond at all, and the USB serial port of the computer was constantly lost and reconnected. This shows that the MCU is constantly restarting. There must be something wrong. I think grblHAL should definitely support 8 or 9 axes running at the same time. What should I do?

pzh11001 commented 2 years ago

i use ArduinoIDE1.8.19。 Just in config.h set N_AXIS . If axis is larger than 6, MCU will crash. As long as 6 axes or less are set. Everything is back to normal. Why doesn't the code I added work。I need to use 7 independent axes instead of ganged axes 《motor_pins.h》

ifdef C_AXIS

ifndef M5_AVAILABLE

error "C_AXIS pins are not available"

endif

define C_STEP_PORT M5_STEP_PORT

define C_STEP_PIN M5_STEP_PIN

define C_STEP_BIT (1<<M5_STEP_PIN)

define C_DIRECTION_PORT M5_DIRECTION_PORT

define C_DIRECTION_PIN M5_DIRECTION_PIN

define C_DIRECTION_BIT (1<<M5_DIRECTION_PIN)

ifdef M5_LIMIT_PIN

define C_LIMIT_PORT M5_LIMIT_PORT

define C_LIMIT_PIN M5_LIMIT_PIN

define C_LIMIT_BIT (1<<M5_LIMIT_PIN)

endif

ifdef M5_LIMIT_PIN_MAX

define C_LIMIT_PORT_MAX M5_LIMIT_PORT_MAX

define C_LIMIT_PIN_MAX M5_LIMIT_PIN_MAX

define C_LIMIT_BIT_MAX (1<<M5_LIMIT_PIN_MAX)

endif

ifdef M5_ENABLE_PIN

define C_ENABLE_PORT M5_ENABLE_PORT

define C_ENABLE_PIN M5_ENABLE_PIN

define C_ENABLE_BIT (1<<M5_ENABLE_PIN)

endif

endif

ifdef U_AXIS

ifndef M6_AVAILABLE

error "U_AXIS pins are not available"

endif

define U_STEP_PORT M6_STEP_PORT

define U_STEP_PIN M6_STEP_PIN

define U_STEP_BIT (1<<M6_STEP_PIN)

define U_DIRECTION_PORT M6_DIRECTION_PORT

define U_DIRECTION_PIN M6_DIRECTION_PIN

define U_DIRECTION_BIT (1<<M6_DIRECTION_PIN)

ifdef M6_LIMIT_PIN

define U_LIMIT_PORT M6_LIMIT_PORT

define U_LIMIT_PIN M6_LIMIT_PIN

define U_LIMIT_BIT (1<<M6_LIMIT_PIN)

endif

ifdef M6_LIMIT_PIN_MAX

define U_LIMIT_PORT_MAX M6_LIMIT_PORT_MAX

define U_LIMIT_PIN_MAX M6_LIMIT_PIN_MAX

define U_LIMIT_BIT_MAX (1<<M6_LIMIT_PIN_MAX)

endif

ifdef M6_ENABLE_PIN

define U_ENABLE_PORT M6_ENABLE_PORT

define U_ENABLE_PIN M6_ENABLE_PIN

define U_ENABLE_BIT (1<<M6_ENABLE_PIN)

endif

endif

ifdef V_AXIS

ifndef M7_AVAILABLE

error "V_AXIS pins are not available"

endif

define V_STEP_PORT M7_STEP_PORT

define V_STEP_PIN M7_STEP_PIN

define V_STEP_BIT (1<<M7_STEP_PIN)

define V_DIRECTION_PORT M7_DIRECTION_PORT

define V_DIRECTION_PIN M7_DIRECTION_PIN

define V_DIRECTION_BIT (1<<M7_DIRECTION_PIN)

ifdef M7_LIMIT_PIN

define V_LIMIT_PORT M7_LIMIT_PORT

define V_LIMIT_PIN M7_LIMIT_PIN

define V_LIMIT_BIT (1<<M7_LIMIT_PIN)

endif

ifdef M7_LIMIT_PIN_MAX

define V_LIMIT_PORT_MAX M7_LIMIT_PORT_MAX

define V_LIMIT_PIN_MAX M7_LIMIT_PIN_MAX

define V_LIMIT_BIT_MAX (1<<M7_LIMIT_PIN_MAX)

endif

ifdef M7_ENABLE_PIN

define V_ENABLE_PORT M7_ENABLE_PORT

define V_ENABLE_PIN M7_ENABLE_PIN

define V_ENABLE_BIT (1<<M7_ENABLE_PIN)

endif

endif

《my_machine_map.h》 :

define BOARD_NAME "myboard"

define HAS_IOPORTS

define X_STEP_PIN (0u)

define X_DIRECTION_PIN (1u)

define X_ENABLE_PIN (24u)

define X_LIMIT_PIN (23u)

define Y_STEP_PIN (2u)

define Y_DIRECTION_PIN (3u)

define Y_ENABLE_PIN (25u)

define Y_LIMIT_PIN (22u)

define Z_STEP_PIN (4u)

define Z_DIRECTION_PIN (5u)

define Z_ENABLE_PIN (26u)

define Z_LIMIT_PIN (21u)

define M3_AVAILABLE

define M3_STEP_PIN (6u)

define M3_DIRECTION_PIN (7u)

define M3_ENABLE_PIN (27u)

define M3_LIMIT_PIN (20u)

define M4_AVAILABLE

define M4_STEP_PIN (8u)

define M4_DIRECTION_PIN (9u)

define M4_ENABLE_PIN (28u)

define M4_LIMIT_PIN (19u)

define M5_AVAILABLE

define M5_STEP_PIN (10u)

define M5_DIRECTION_PIN (11u)

define M5_ENABLE_PIN (29u)

define M5_LIMIT_PIN (18u)

define M6_AVAILABLE

define M6_STEP_PIN (41u)

define M6_DIRECTION_PIN (40u)

define M6_ENABLE_PIN (39u)

define M6_LIMIT_PIN (38u)

define M7_AVAILABLE

define M7_STEP_PIN (37u)

define M7_DIRECTION_PIN (36u)

define M7_ENABLE_PIN (35u)

define M7_LIMIT_PIN (34u)

terjeio commented 2 years ago

I think grblHAL should definitely support 8 or 9 axes running at the same time.

8 axes should be relatively easy to add since a byte is used to hold information such as step and direction output. 9 (or more) requires two bytes and will trigger more significant changes?

What should I do?

Debug? Support for U and V is work (in slow) progress for me and there may be issues such as settings/parameter storage allocation that has to be resolved. It is a pity that the Teensy is not easily debuggable, myself I would use a Nucleo STM32F756 board to debug as it has plenty of pins.

For the iMXRT1062: if you have a UART <> USB breakout board you may either add debug output to a UART channel or switch the primary output stream to that. Debug output can be enabled in grbl/config.h (DEBUGOUT) and writing is via debug_write().

pzh11001 commented 2 years ago

I think grblHAL should definitely support 8 or 9 axes running at the same time.

8 axes should be relatively easy to add since a byte is used to hold information such as step and direction output. 9 (or more) requires two bytes and will trigger more significant changes?

What should I do?

Debug? Support for U and V is work (in slow) progress for me and there may be issues such as settings/parameter storage allocation that has to be resolved. It is a pity that the Teensy is not easily debuggable, myself I would use a Nucleo STM32F756 board to debug as it has plenty of pins.

For the iMXRT1062: if you have a UART <> USB breakout board you may either add debug output to a UART channel or switch the primary output stream to that. Debug output can be enabled in grbl/config.h (DEBUGOUT) and writing is via debug_write().

I see. Thank you very much. I think I need to prepare a UART to USB device. Connect to uart1 of teensy4.1.

pzh11001 commented 2 years ago

Finally found the problem, The starting macro definition in 《nvc.h》 file is too small. After the expansion, grbHALl will not crash and can operate normally. Next, the 7-axis and 8-axis motors still don't rotate, but the command "?" of grblhal has been able to correctly show the coordinates, and I already know where to find the problem. It should be solved soon!

Thank you again for your help!

terjeio commented 2 years ago

The starting macro definition in 《nvc.h》 file is too small

I've fixed this, and related stuff, in the latest commit.