Closed JoachimF closed 1 year ago
The spindle pulse input has to be routed as clock input to a timer here. If a pin other than D2 is to be used for that it has to be changed accordingly and the timer has to be changed as well. See table 9, Alternate function mapping in the STM32F411 datasheet for possible alternatives.
Unfortunately, on the F401CC, port D is not available and the TIM3_ETR has no alternate pin. Should it be possible to swap RPM_TIMER and RPM_COUNTER to get the pulse on TIM2_ETR on PA0 or PA5 or PA15 ?
driver.h
driver.c GPIO_Init.Mode = GPIO_MODE_AF_PP; GPIO_Init.Pin = SPINDLE_PULSE_BIT; GPIO_Init.Pull = GPIO_NOPULL; GPIO_Init.Speed = GPIO_SPEED_FREQ_LOW; GPIO_Init.Alternate = GPIO_AF1_TIM2; HAL_GPIO_Init(SPINDLE_PULSE_PORT, &GPIO_Init);
Is it correct ?
Dear Terjeio,
I know why the stm crash on start up, I enable the VFD plugin and the Spindle_sync, but when VFD is enable, the hal.spindle.set_state is not set ! The pointer is set after the call of grbl.on_spindle_select that is called after the spindle sync init.
....
hal.spindle.set_state = spindleSetState;
Best Regards,
Joachim
Should it be possible to swap RPM_TIMER and RPM_COUNTER to get the pulse on TIM2_ETR on PA0 or PA5 or PA15 ?
It should be - you can try?
The pointer is set after the call of grbl.on_spindle_select that is called after the spindle sync init.
It looks like your driver code is outdated - spindle handling was changed recently so perhaps ok if you update?
Should it be possible to swap RPM_TIMER and RPM_COUNTER to get the pulse on TIM2_ETR on PA0 or PA5 or PA15 ?
It should be - you can try?
I'll try it and I'll make you a feedback, it would be a nice option to have for the low pins MCUs
The pointer is set after the call of grbl.on_spindle_select that is called after the spindle sync init.
It looks like your driver code is outdated - spindle handling was changed recently so perhaps ok if you update?
Shame on me, I debug code that you have already done... The lack of time is faulty ☺
Where can I send you a tip to thanks your amazing work?
good day terjeio, friend I have an emco compact 5 CNC lathe and a stm32f411 with grblHAL but I do not know how to configure the encoder I can not find where it is configured and the input pins as I do I remain attentive thanks
@Juank23 See the st_morpho_map.h file, search for the SPINDLE_SYNC_ENABLE symbol. You will have to add those definitions to the map file you are using. Note that currenly only D2 is supported as input for the spindle encoder pulse input. Info in this comment above.
Good morning thanks for your prompt response, friend I added those lines to the code but there is a problem, you have to make any other modification to the code ?? in iosender when it is in lathe mode gives a problem when trying to make the threads I remain attentive thank you very much.
... but there is a problem ...
And the problem is...?
First you have to ensure that the spindle encoder input is handled correctly. When enabled the RPM display in ioSender goes "live" and displays the real RPM as read from the encoder. Does it? and does the "live" value match reality?
For spindle synced motion the index pulse is needed, you can use the $SD
command to check. This outputs a list of comma separated values: current index pulse count, pulse count, error count and angular position. Error count is a count of misread pulses for each revolution (> 0 if pulses per revolution does not match the PPR setting - $38). The $SR
command resets the counters and angular position.
When the encoder pulses are read correctly then tuning of the PID loop has to be done with settings $80 - $82. To aid that it is best to enable PID logging. This is a compile time option found in config.h. When enabled a new tab is presented in ioSender where the data from the log is presented graphically. To tune issue a G33 command and fetch the data afterwards. Then adjust the PID parameters and repeat until you get a good response. Here is one how-to description of PID tuning, many more can be found by searching for pid tuning.
buen dia terjeio, amigo descargue grblhall pero no encuentro la menara de conifurar, modifique las lineas de codigo que me digiste pero no funciona no aparece ninguna pestaña de pidtuning en iosender como hago para configurarlo estoy compilando en stm32cubeIDE a continuacion te envio unas capturas espero me puedas ayudar muchas gracias
good day terjeio, friend download grblhall but I can not find the menara of conifurar, modify the lines of code that you told me but it does not work does not appear any tab of pidtuning in iosender as I do to configure it I am compiling in stm32cubeIDE then I send you some captures I hope you can help me thank you very much
If I read this translation correctly you did not manage to compile with PID logging. This is a compile time option found in config.h - uncomment the PID_LOG definition, recompile and reflash and the PID tab should show up.
From the images above it also looks like you have not added/uncommented this line in your map file?
Thanks for your prompt reply, I am using the blackpill_map.h map, I added the lines you told me before but I notice there are errors here I send you a copy of the map that I am using thanks
The 411 Blackpill does not have the PD2 pin brought out so more code changes are needed to use one of the alternatives. PA15 is currently not in use so that seems to be the best candidate.
good day terjeio, I tell you that already appears the pid tuning tab, I have changed the turret motor and I have adapted a stepper motor so that the tool change is automatic, there are 6 tools in the turret, I also added some limit switches, but I do not know how to create the macro to make the tool change from the gcode, I have done some tests with some small macros and I have added them to the gcode to see how it works and it works fine but it should be automatic, from the gcode I see a t1, t2, iosender pauses to make the tool change, but as I have not made the appropriate macro does not work then a video to see the project thanks for your help greetings https://www.youtube.com/watch?v=5Jw0SQXnH1w
I have just uploaded code changes for swapping the timers, and thus using some port A pins, for spindle pulse input. Only tested with a simulator and there is a smallish risk for the interrupt driven extension of the RPM timer to 32 bits to produce invalid values. Testing in a real machine is required to validate this change. The blackpill map has been updated to use this option.
@Juank23 There is not much I can do to help without detailed information of how the turret is controlled. And please open another issue as it is not related to this.
good morning terjeio, I did some small tests and with a bad connection I burned the card, I was sad but I have already ordered 2 more cards, I am waiting for them to arrive to continue with the project, thank you very much for your help, best regards
Hello Terjeio,
I continue my work to create a mainboard from blackpill and I test all fonctions available on this target. When I enable spindle_sync, all is OK, but when I set PPR to 600, because my encoder is 600PPR, the blackpill doesn't boot. No serial port available in the Windows device manager, I have to reflash the stm to make it works again.
I set index and pulse to pins B3 and B4 to have 2 differents timers, have I made something wrong ?