Giter Site home page Giter Site logo

6-axis-usbcnc-grbl's People

Contributors

robomechs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

6-axis-usbcnc-grbl's Issues

two GRBL welcome message when power is applied

I have implemented NC hard limits (connected to ground).
I put a RC filter to avoid false trigering.
I have configure GRBL for hard limit ($21=1) and invert mask ($5=1)

When I power up the stm32, I get twice the welcome message (Grbl 1.1f ['$' for help]) folowed by an ALARM:1.
I am forced to do a soft reset to go on.

This does not occurs if I do hard reset using the reset button on the blue pill (I get only one welcome message and I do not have to do a softreset.

I check the code and it seems that at power on, I get a false trigering of interrupt on limit pin.

I fixed the issue adding delay of 100msec (perhaps a lower value will be ok) in the init function of the limit (in limit.c).
Here my code.
if (bit_istrue(settings.flags, BITFLAG_HARD_LIMIT_ENABLE)) { delay_ms(100); // added by MS for debug GPIO_EXTILineConfig(GPIO_LIMIT_PORT, X_LIMIT_BIT); GPIO_EXTILineConfig(GPIO_LIMIT_PORT, Y_LIMIT_BIT); GPIO_EXTILineConfig(GPIO_LIMIT_PORT, Z_LIMIT_BIT);

Question: maximum clock?

This is more a question than an issue, but I could not find the related information: the STM32F103C8 can run with up to 72 MHz clock. Is this supported by this firmware too? If yes: where/how can I configure it?

Uart1 cant connect hc05 bluetooth

Hello, I delete #useusb in Attolic studio and compiled. Flashing and connect hc05 bluetooth module with baudrate 1155200 with grbl controller but not working. Try to connect usb to serial but no signal. Any help plz

No #undef USEUSB in grbl.h

Just #undef USEUSB in grbl.h after #ifdef STM32F103C8 or delete "USEUSB" in project properties -> C/C++ General -> Path and Symbols -> Symbols.

there isnt a line in the grbl.h file that i can uncomment to use uart.

CNCjs Issue due to bug in mode state reporting

CNCjs is not able to parse modal state reports by 6-AXIS-USBCNC-GRBL due to a small glitch in report.c. Cause is an additional report_util_gcode_modes_M(); in Line 318 of report.c here which is not in the original grbl v1.1f

  report_util_gcode_modes_M();   <<< Offending statement, will inject a singular ' M' into the report that cannot be parsed
  #ifdef ENABLE_M7
    if (gc_state.modal.coolant) { // Note: Multiple coolant states may be active at the same time.
      if (gc_state.modal.coolant & PL_COND_FLAG_COOLANT_MIST) { report_util_gcode_modes_M(); serial_write('7'); }
      if (gc_state.modal.coolant & PL_COND_FLAG_COOLANT_FLOOD) { report_util_gcode_modes_M(); serial_write('8'); }
    } else { report_util_gcode_modes_M(); serial_write('9'); }
  #else
    report_util_gcode_modes_M();
    if (gc_state.modal.coolant) { serial_write('8'); }
    else { serial_write('9'); }
  #endif

It creates this (wrong syntax)
[GC:G0 G54 G17 G21 G90 G94 M0 M M9 T0 S0 F0]

instead of this (correct syntax)
[GC:G0 G54 G17 G21 G90 G94 M0 M9 T0 S0 F0]

This Bug will cause GrblLineParserResultParserState.js to ditch all modal reports and not update its grbl info panels accordingly:

class GrblLineParserResultParserState {
    // * Grbl v0.9
    //   [G38.2 G54 G17 G21 G91 G94 M0 M5 M9 T0 F20. S0.]
    // * Grbl v1.1
    //   [GC:G0 G54 G17 G21 G90 G94 M0 M5 M9 T0 S0.0 F500.0]
    static parse(line) {
        const r = line.match(/^\[(?:GC:)?((?:[a-zA-Z][0-9]+(?:\.[0-9]*)?\s*)+)\]$/);
        if (!r) {
            return null;
        }
...

Makefile?

Would it be hard to add a makefile / platformio configuration / whatever else doesn't require a giant IDE (which is also proprietary as far as I can tell)? that's pretty overkill for someone who just wants to compile the firmware once.

The original compiles just fine with the makefile, why drop it?

Issue with USB

When I configure GRBL with USEUSB (so using USB and not UART1), it seems that USB connection locks if I send a Soft Reset or if I push on the Reset button on the blue pill.

I faced this issue following e.g. this process:

  • I connect blue pill to pc via USB
  • I open a serial terminal session (e.g. using arduino Terminal).
  • I can sent commands to GRBL (e.g. "?" to know the status and position)
  • If GRBL reach a hard limit (those are activated in my configuration), GRBL sent ALARM:1
  • To unlock GRBL you normally have to send a Soft Reset (CTRL+X or 0X18). If I try this, GRBL does not react.
  • even a hard reset pressing the reset button on the blue pill does not unlock GRBL communication.
  • To continue, it seems that I have to close my terminal session (even close the program) and reopen it.

When I work with a UART connection between PC and blue pill, GRBL reacts (as expected) after a soft reset.

Do you experience the same issue?

Using UART instead of USB- unneeded code.

When GRBL has to send messages to the GRBL controller, it uses this code
`
void serial_write(uint8_t data) {
// Calculate next head
uint8_t next_head = serial_tx_buffer_head + 1;
#ifdef STM32F103C8
#ifndef USEUSB
USART_SendData(USART1, data);
while (!(USART1->SR & USART_FLAG_TXE));
return;
#endif
#endif
if (next_head == TX_RING_BUFFER) { next_head = 0; }

// Wait until there is space in the buffer
while (next_head == serial_tx_buffer_tail) {
// TODO: Restructure st_prep_buffer() calls to be executed here during a long print.
if (sys_rt_exec_state & EXEC_RESET) { return; } // Only check for abort to avoid an endless loop.
#ifdef WIN32
Sleep(1);
#endif
}
(code continue in order to fill the ring buffer)
`
This code fills a ring buffer that is read only by a USB callback (EP1_IN_Callback)
So, when we deactivate the USEUSB, there is no need to spent time to fill the ring buffer.

I would also expect that the USB callback would be called only when USB is activated but it does not seems so. Otherwise this code would stay in a blocking loop : while ( next_head == serial_tx_buffer_tail) when USEUSB is commented.
So, it means that USB code is not deactivated when USEUSB is commented.

It would be much more efficient to completely deactivate USB code when USEUSB is commented and to avoid filling this buffer.

As said in another issue, it would be good to implement a ring buffer for bytes being sent via UART and to read it by interrupts (in order to avoid current blocking code).

Dual Y axis

I don't know how to contact with you, so I m asking here: how to define dual y axis? I modified homing order, but i can not find how to link two axis. Anyway it is a great project.

Planner buffer question

Hello, I'm fairly new in GRBL world. I've made a 3 Axis machine for myself with this build.
I've implement a streaming GCode routine in order to fill both RX buffer and Planner buffer efficiently and make it run smooth, it works great most of the cases.
I look how many bytes are available in RX buffer than I look Planner buffer how many moves I can send then I both substract line bytes and 1 movement from planner buffer as well. But I run into some faulty movements especially after an arc or a curved carve moves. I realized while linear Gcode lines are consuming 1 planner buffer spot, Arc movements or circle lines consumes more than one spot when I stream.
Is it random how much spot a line can consume in planner buffer or is there a consistent number here?
Any clarificatioun would be great
Best regards
Zeki

Using USART instead of USB (#undef USEUSB)

Во первых, хочу поблагодарить за проделанный труд, очень кстати , но возникла проблема с включение UART. добавление #undef USEUSB в main.c отключает юсб но не включает uart. Можете проверить?

Using Serial1 and USB at the same time?

Today I was wondering what would it take to enable both USB and Serial1 at the same time. Enabling Serial1 just for sending a duplicate of the report would be trivial (just uncomment #ifndef USEUSB in line 177 of serial.c and uncomment #ifndef USEUSB in line 104 of main.c, which calls USART1_Configuration(115200);). This would be useful for providing data for something like a DRO or sending it via bluetooth to an android/tablet, but what if I wanted to use both at the same time? Would I need to keep separate buffers for USB rx data and for Usart1 so text coming from both don't get mixed up? With this it would be possible to use a cellphone for control without having the machine plugged to a computer, or even make it wifi-ready using ESP3D, while at the same time being able to control from a PC.

Perhaps a bug

in util/stm32f10x_it.c, there is currently this code

#ifdef USEUSB
/* Includes ------------------------------------------------------------------*/
#include "stm32f10x_it.h"
#include "usb_lib.h"
#include "usb_istr.h"
#include "hw_config.h"

There is no #Endif just after (only at the end).
So this file is not processed if USEUSB is not defined

big issue in communication with GRBL at least with UART

I have a GRBL controller running on a ESP32. It sent commands to GRBL (e.g. based on a SD file, waiting OK between each command) and it send also "?" every 300 msec (to get the current status).

If I let it communicate with the original AVR 328P GRBL version1.1, it works perfectly.
When I try to let it communicate with STM32 using UART, it does not work.
GRBL gives errors saying that there are syntax errors. So, it seems GRBL is loosing some characrers being sent.
I put a digital scope to analyse the exchanged data and timing.
It confirms that my micro is sending the right data but GRBL replies on regular basis with an error 8:
While the original AVR GRBL is always giving a fast answer to a "?" , the STM32 takes from time to time much more time to reply.
I also noticed that when I sent a command, GRBL takes more and more time to give the OK.
Sometime I get the "O" (from OK) and I get the "K" abour 100msec later.
So it seems something is "freezing" GRBL and it loose some char being sent in the UART.

I do not know if someone uses UART and already noticed such an issue.
This is blocking my project currently.

I can reproduce this issue when I send a file like this (whis is the same as the command generated by my micro controller when I use a joystick to move the motors):
`
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y0.01 F2000
$j=G91 G21 Y0.01 F2000
$j=G91 G21 Y0.01 F2000
$j=G91 G21 Y0.01 F2000
$j=G91 G21 Y0.01 F2000
$j=G91 G21 Y0.01 F2000
$j=G91 G21 Y0.01 F2000
$j=G91 G21 Y0.01 F2000
$j=G91 G21 Y0.01 F2000
$j=G91 G21 Y0.01 F2000
$j=G91 G21 Y0.01 F2000
$j=G91 G21 Y0.10 F2000
$j=G91 G21 Y0.10 F2000
$j=G91 G21 Y0.10 F2000
$j=G91 G21 Y0.10 F2000
$j=G91 G21 Y0.10 F2000
$j=G91 G21 Y0.10 F2000
$j=G91 G21 Y1.00 F2000
$j=G91 G21 Y1.00 F2000
$j=G91 G21 Y1.00 F2000
$j=G91 G21 Y1.00 F2000
$j=G91 G21 Y1.00 F2000
$j=G91 G21 Y1.00 F2000
$j=G91 G21 Y1.00 F2000
$j=G91 G21 Y1.00 F2000
$j=G91 G21 Y1.00 F2000
$j=G91 G21 Y1.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000
$j=G91 G21 Y3.00 F2000

`

invert feed-hold

hi togheter.
i have tried so far without any success to invert the signal in the file cpu_map.h

Line 123

  #define CONTROL_MASK      ((1<<CONTROL_RESET_BIT)|(1<<CONTROL_FEED_HOLD_BIT)|(1<<CONTROL_CYCLE_START_BIT)|(1<<CONTROL_SAFETY_DOOR_BIT))
  #define CONTROL_INVERT_MASK   CONTROL_MASK // May be re-defined to only invert certain control pins.

without any success...

how do i do that exactly?

Using UART3 same times with UART1 please

I have successfully changed the B C limit pins on RX3 and TX3. I set same configuration & IRQ for USART3. But not working. I know this not easy process. What can i do, please help me.

new 2.txt

 USART3_Configuration(u32 BaudRate) {

    GPIO_InitTypeDef GPIO_InitStructure;
    USART_InitTypeDef USART_InitStructure;
    NVIC_InitTypeDef NVIC_InitStructure;
    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
    NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);
    RCC_APB2PeriphClockCmd(
		    RCC_APB1Periph_USART3 | RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO,
		    ENABLE);

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOB, &GPIO_InitStructure);
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
    GPIO_Init(GPIOB, &GPIO_InitStructure);

    USART_InitStructure.USART_BaudRate = BaudRate;
    USART_InitStructure.USART_WordLength = USART_WordLength_8b;
    USART_InitStructure.USART_StopBits = USART_StopBits_1;
    USART_InitStructure.USART_Parity = USART_Parity_No;
    USART_InitStructure.USART_HardwareFlowControl =
		    USART_HardwareFlowControl_None;
    USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
    USART3->CR1 |= (USART_CR1_RE | USART_CR1_TE);
    USART_Init(USART3, &USART_InitStructure);
    //	USART_ITConfig(USART3, USART_IT_TXE, ENABLE);
    USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
    USART_Cmd(USART3, ENABLE);
}


void USART3_IRQHandler (void) 
{
    volatile unsigned int IIR;
    uint8_t data;
    uint8_t next_head;

    IIR = USART3->SR;
    if (IIR & USART_FLAG_RXNE) 
    {                  // read interrupt
        data = USART3->DR & 0x1FF;

  // Pick off realtime command characters directly from the serial stream. These characters are
  // not passed into the main buffer, but these set system state flag bits for realtime execution.
  switch (data) {
    case CMD_RESET:         mc_reset(); break; // Call motion control reset routine.
    case CMD_STATUS_REPORT: system_set_exec_state_flag(EXEC_STATUS_REPORT); break; // Set as true
    case CMD_CYCLE_START:   system_set_exec_state_flag(EXEC_CYCLE_START); break; // Set as true
    case CMD_FEED_HOLD:     system_set_exec_state_flag(EXEC_FEED_HOLD); break; // Set as true
    default :
      if (data > 0x7F) { // Real-time control characters are extended ACSII only.
        switch(data) {
          case CMD_SAFETY_DOOR:   system_set_exec_state_flag(EXEC_SAFETY_DOOR); break; // Set as true
          case CMD_JOG_CANCEL:
            if (sys.state & STATE_JOG) { // Block all other states from invoking motion cancel.
              system_set_exec_state_flag(EXEC_MOTION_CANCEL);
            }
            break;

          case CMD_FEED_OVR_RESET: system_set_exec_motion_override_flag(EXEC_FEED_OVR_RESET); break;
          case CMD_FEED_OVR_COARSE_PLUS: system_set_exec_motion_override_flag(EXEC_FEED_OVR_COARSE_PLUS); break;
          case CMD_FEED_OVR_COARSE_MINUS: system_set_exec_motion_override_flag(EXEC_FEED_OVR_COARSE_MINUS); break;
          case CMD_FEED_OVR_FINE_PLUS: system_set_exec_motion_override_flag(EXEC_FEED_OVR_FINE_PLUS); break;
          case CMD_FEED_OVR_FINE_MINUS: system_set_exec_motion_override_flag(EXEC_FEED_OVR_FINE_MINUS); break;
          case CMD_RAPID_OVR_RESET: system_set_exec_motion_override_flag(EXEC_RAPID_OVR_RESET); break;
          case CMD_RAPID_OVR_MEDIUM: system_set_exec_motion_override_flag(EXEC_RAPID_OVR_MEDIUM); break;
          case CMD_RAPID_OVR_LOW: system_set_exec_motion_override_flag(EXEC_RAPID_OVR_LOW); break;
          case CMD_SPINDLE_OVR_RESET: system_set_exec_accessory_override_flag(EXEC_SPINDLE_OVR_RESET); break;
          case CMD_SPINDLE_OVR_COARSE_PLUS: system_set_exec_accessory_override_flag(EXEC_SPINDLE_OVR_COARSE_PLUS); break;
          case CMD_SPINDLE_OVR_COARSE_MINUS: system_set_exec_accessory_override_flag(EXEC_SPINDLE_OVR_COARSE_MINUS); break;
          case CMD_SPINDLE_OVR_FINE_PLUS: system_set_exec_accessory_override_flag(EXEC_SPINDLE_OVR_FINE_PLUS); break;
          case CMD_SPINDLE_OVR_FINE_MINUS: system_set_exec_accessory_override_flag(EXEC_SPINDLE_OVR_FINE_MINUS); break;
          case CMD_SPINDLE_OVR_STOP: system_set_exec_accessory_override_flag(EXEC_SPINDLE_OVR_STOP); break;
          case CMD_COOLANT_FLOOD_OVR_TOGGLE: system_set_exec_accessory_override_flag(EXEC_COOLANT_FLOOD_OVR_TOGGLE); break;
     
            case CMD_COOLANT_MIST_OVR_TOGGLE: system_set_exec_accessory_override_flag(EXEC_COOLANT_MIST_OVR_TOGGLE); break;
        
        }
        // Throw away any unfound extended-ASCII character by not passing it to the serial buffer.
      } else { // Write character to buffer
        next_head = serial_rx_buffer_head + 1;
        if (next_head == RX_RING_BUFFER) { next_head = 0; }

        // Write data to buffer unless it is full.
        if (next_head != serial_rx_buffer_tail) {
          serial_rx_buffer[serial_rx_buffer_head] = data;
          serial_rx_buffer_head = next_head;
        }
      }
  }

        USART3->SR &= ~USART_FLAG_RXNE;	          // clear interrupt

   }

}

$h then system happens to restart

Sometimes i use command $h to return origin ,then system do not response my command and later will restart.
I can not figure out this issue , any clue? Thanks so much for your guys offer such a great project!

Feed Overrides doesn't work properly

Hello,
Feed Overrides doesn't work properly. Plus, minus 10 percent work well change to 20 percent
freeze STM32 GRBL.
Version "stm32grbl11_11122018" work well, later versions doesn't work.
Greetings Stefan

only x axis can reach 230khz, y and z axis have problem

Hi,
i have checked with oscilloscope, only x axis can reach 230khz frequency.
Y axis reach 230khz in one direction, in opposite direction frequency is reduced to 136khz,
Z axis can reach only 136 khz in both directions.

Also, $0=6 works with x axis in both direction, for y axis it only works in one direction, for z axis it work only for lower frequencies.
Please fix it.

Thanks

Rotary Encoder Jogging

Hi Yaroslav,

first of all thanks for the work you put into this, it's great to have an STM32 version of grbl that actually receives support!

Something that I've always wanted for my machine was a proper jog wheel. I've bought the hardware (one of these MPG wheels) to tinker around. I tried connecting the wheel to a separate Arduino Uno and sending the position via serial, feeding that into a modified version of OpenCNCPilot and using jog commands to execute that on the machine. This always resulted in very jerky motion, sometimes the machine jumped back and forth etc.

I think a better way to implement a hand wheel would be to connect the MPG to grbl directly.
Here's what I have in mind:

  • the MPG wheel is connected to two pins on the STM32 (it's a regular quadrature encoder). A hardware timer is used to decode the signal (see the last piece of code here)
  • a new state "HAND_JOG" is added to grbl, which is enabled/disabled with a realtime command or some M-code by the GUI. The MPG is only active in this mode to prevent the user from interfering with normal machine operation. The GUI also chooses the axis, step size and maximum speed (maybe introduce a new G-Code like "G99 X1 F1000", which chooses the X axis with 1mm steps etc.)
  • Behavior:
    • turning the wheel by one increment moves the machine by one step (user selected distance, not machine steps)
    • turning the wheel more than one increment moves the machine by x number of steps, with a feed rate which is selectable. If the distance specified by the jog wheel is some distance Y away from the current machine position, stop accepting new pulses from the wheel so the machine always comes to a stop Y mm after the user stopped turning the wheel. (aka if the user turns the wheel very quickly, have it behave like a constant speed jog instead of a fixed distance jog)
    • when the user turns the wheel in the opposite direction than the machine is currently moving, cancel the jog motion and wait for a few milliseconds before accepting new input

I've already tried my hands at implementing this myself, but I don't have the knowledge of grbl's core to pull it off. Should this actually become a thing, you can bet that OpenCNCPilot will be among the first GUIs to support it :)

Cheers!
Martin

Support for the Black Pill STM32F411CEU6

Hi there

how hard is it to port GRBL to the new and fast Black Pill?

im looking for high step rates 500 kHz and stand alone features such as display and sd card support...

cheers

about coolant!

If there is no heat sensor, what is a coolant for, for why, and how is it used?

Spindle enable Bit

Hello
I am sending M3 , M5 commands but i can not see PB1 bit (spindle enable bit) to toggle.

Avoid blocking main loop while sending data via UART

I had at look at the way data are sent via UART.
I found this code
#ifndef USEUSB
USART_SendData(USART1, data);
while (!(USART1->SR & USART_FLAG_TXE));
return;
#endif
It means that the CPU waits in the "while" loop when a byte is written in UART if the UART is still sending a previous byte.
So if several bytes have to be sent (e.g in case of error, alarm or on reply on "?") the CPU will be blocked (waiting) several times for about max 100 micro sec per char).
During this time, the cpu can not plan new motions.
I presume it should be better to write the data to be sent in a buffer and to use an interrupt to send the buffer without blocking the main loop.

Another way to upload

Just some info that you can add to the wiki.

With Atollic you can ask it to output a .bin or .hex.
Once you have one of these files you can upload them with this program : "https://www.st.com/content/st_com/en/products/development-tools/software-development-tools/stm32-software-development-tools/stm32-programmers/flasher-stm32.html?"
You just have to set the boot pins first.

On another note in Atollic you can set the flash to 128KB which seems to be the right flash size for my bluepill.

support for tmc2130

Hi , I am looking at using tmc2130 drivers with a 3 axis engraver . Would it conflict with any hardware if I add a hardware spi port on the bluepill ? The hardware pins does not conflict with any pins I need : /**SPI1 GPIO Configuration
PB3 ------> SPI1_SCK
PB4 ------> SPI1_MISO
PB5 ------> SPI1_MOSI
*/
pc13 , pc14 , pc15 would be chip select for x , y , z .

UART TX overlapping

Dear all,

I'm actually migrating the code to a STM32G070 microcontroller, (64MHz), and I'm having issues with TX overlapping the RX message.

I'm sending some comands like $ with no problems:

29/07/2022 14:28:42.91 [TX] - $

29/07/2022 14:28:42.92 [RX] - [HLP:$$ $# $G $I $N $x=val $Nx=line $J=line $SLP $C $X $H ~ ! ? ctrl-x]
ok

But, if using "?", the overlapping causes this:

29/07/2022 14:28:40.01 [TX] - ?
29/07/2022 14:28:40.02 [RX] - ÿŅɵñ5A½Íé0.000,0.000,0.000,0.000,0.000|Bf:35,254|F:0>

It works if I comment "protocol_execute_realtime" in the end of the " for (;;)" in protocol.c, but I think its not fair, this will cause another problems.

As I can see, the flag "EXEC_STATUS_REPORT" is set on storeHandleDataIn() in USART IRQHandler when I'm receiving the "?" character and it's processed SO fast as the RX frame isn't arrived completely.

Any idea of why this doesn't happen in the STM32F103 microcontroller, or how can I solve this?

Thank you a lot!

It is not possible to deactivate the internal pull ups for limits

The official version of GRBL has an option that allows to deactivate the internal pull up for limits.
It is a parameter in config.h.

This option has not been migrate in the STM32 version.
The correction is easy (one #ifdef and 1 line of code:

Here the new code
`#ifdef STM32F103C8
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_LIMIT_PORT | RCC_APB2Periph_AFIO, ENABLE);
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
#ifdef DISABLE_LIMIT_PIN_PULL_UP
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
#else
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
#endif
GPIO_InitStructure.GPIO_Pin = LIMIT_MASK;
GPIO_Init(LIMIT_PORT, &GPIO_InitStructure);

if (bit_istrue(settings.flags, BITFLAG_HARD_LIMIT_ENABLE))

`

Can I use CNCjs?

Can I use CNCjs to send gcode to the 6-AXIS-USBCNC-GRBL controlled XYZA-4 axis?

cncjs

It should be useful allowing to invert PWM signal

I am using a board that has an ULN2803 between the STM32 output pins and the externals components (like Spindle, Laser,...).
This is useful because it is cheap but still increase the security and allows to drive external components using more than 3.3V or needing more power.
Still the ULN2803 is an array of open collector transistor and so, it inverts the signal.
GRBL allows to invert most signals (in the config.h file or in the setup of the parameters)
Still it is not possible to invert the variable PWM signal (only the PWM enable).
For STM32 adding a parameter in the config to INVERT_PWM is quite easy.
I did it in my fork at this link
https://github.com/mstrens/grbl_6axis_on_stm32
The change concerns only the file spindle_conctrol.c (and a new parameter in config.h).
The principle consist to change one bit in the init
#ifdef INVERT_SPINDLE_PWM outputChannelInit.TIM_OCPolarity = TIM_OCPolarity_Low; #else outputChannelInit.TIM_OCPolarity = TIM_OCPolarity_High; #endif It is also necessary to let PWM always run (so avoiding TIM_CtrlPWMOutputs(TIM1, DISABLE)) and just setting the PWM value to 0 when the code has to stop the PWM. Otherwise, the signal can't be inverted when PWM is stopped.

Hope, this can help other users.

4-6 axis feed rate

It is necessary to check the consistency of the feed rate on the 3,4,5,6 axis.
It is necessary to understand how the speed should be calculated on more than 3 axes. And check how it is calculated on 3 axes.

Bug with PWM when frequency is reduced

For STM32, the timer used by PWM is a 16 bit.
In file spindle_control.c a new type (SPINDLE_PWM_TYPE) has been define to take care of this.

Still in file stepper.c, there are 2 fields that are used to store rpm values (converted in PWM timer values). Those 2 fields should be defined as SPINDLE_PWM_TYPE too.
Otherwise, when frequency is reduced to e.g. 2000Hz, the max value for the timer is 500 and exceed a uint8_t and stepper.c generates wrong PWM.

The 2 fields to redefine are :
Here my changes:

#ifdef VARIABLE_SPINDLE
//uint8_t spindle_pwm; replaced by mstrens for STM32 by next line
SPINDLE_PWM_TYPE spindle_pwm; // SPINDLE_PWM_TYPE is Uint16_t for STM32 and uint8_t for AVR
#endif

and the second:

#ifdef VARIABLE_SPINDLE
float inv_rate; // Used by PWM laser mode to speed up segment calculations.
//uint8_t current_spindle_pwm; // replaced by mstrens by next line for STM32
SPINDLE_PWM_TYPE current_spindle_pwm; // for STM32 SPINDLE_PWM_TYPE must be uint16_t
#endif

Reset not working on Blue Pill and Black Pill with limit alarm is set

Hi, I opened a new issue as this is not USB related. I cannot clear an alarm after hitting a limit switch and after the limit alarm gets set. I cannot get Ctrl+X to work on blue pill or back pill (STM32f103C8). Reset button does not work either. $X works for some alarms, but not a limit alarm (with $22=1).

Shutting down the software host and unplugging the USB does work, but it seems like it should respond to soft reset ($X, Ctrl+X) or a hard reset (button). It should not require a complete reboot.

Thank you for all your hard work!

Set machine positions for homed limit switches

Hi,
When I'm homed max direction, then position is negative. i see

set_axis_position = lroundf((settings.max_travel[idx]+settings.homing_pulloff)*settings.steps_per_mm[idx]);
and change it to:
if ( !bit_istrue(settings.homing_dir_mask,bit(idx)) ) {
set_axis_position = lroundf(-(settings.max_travel[idx]+settings.homing_pulloff)settings.steps_per_mm[idx]);
} else {
set_axis_position = lroundf(settings.homing_pulloff
settings.steps_per_mm[idx]);
}
and solved that problem. I don't know if it makes perfect sense?

Modify Virtual_Com_Port_ConfigDescriptor to allow for more power?

Spindle enable bit and dir bit works ok, I tested them with a brushless spindle motor driver, now there's something that is bugging me. I'm powering a small relay board with 5V coming from the USB Port itself, when either relay is turned on I get a significant voltage drop on the 5V line. Like, with no relay on I get 4.8v, each relay drops the voltage by about 0.2v. Reading into the code, I found this part.

The STM32 identifies itself as a Virtual Com Port, so there's a Configuration Descriptor for it. The byte that specifies how much power the circuit can draw is set at 0x32, or 50 in decimal. This is in usb_desc.c , line 67

According to this page:
https://www.beyondlogic.org/usbnutshell/usb5.shtml#ConfigurationDescriptors

The amount of current the circuit is allowed to draw is that number times 2 mA, 50 times 2 is just 100 mA.

Now, could this be the reason why just a few puny relays are causing that voltage drop? I'll change that value to 7D in order to pull up to 250mA and see what happens

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.