BIGTREETECH-S42B-V1.0 icon indicating copy to clipboard operation
BIGTREETECH-S42B-V1.0 copied to clipboard

Added sensorless homing functionality to S42B

Open Quas7 opened this issue 5 years ago • 3 comments

Use SWDO pin (silkscreen on PCB) of S42B communication pin header as active low signal to trigger endstop based on angular deviation.

Mind that connecting SWDIO to an endstop pin on the mainboard is a non-buffered direct connection to the STM32 controller on the S42B Adjust the sensitivty for sensorless homing with #define sensorless_sensitivty. And generally do not home too fast during testing.

Also note that the repurposing of the SWDIO Pin (PA13) as sensorless homing endstop output might break the on-the-fly SWD programming. Pressing RES(ET) on the S42B once and retry programming normally works fine. The triggering of the sensorless homing sensitivty threshold kills the on-the-fly SWD interface!). If it does not, you will have to hold the RES(ET) button manually until "hla_swd" is shown during openOCD programming. Releasing RES directly at this point will start the normal programming. Holding RES too long will result in a timeout.

Quas7 avatar Oct 25 '20 22:10 Quas7

I had to add a LL_GPIO_Init call into the TIM6_IRQHandler(void) interrupt function to keep SWD programming fully functional. It would be more appropriate to set only a varialbe as a flag and do the GPIO handling in the main loop afterwards, if the timing penalty is too high in this handler.

Quas7 avatar Oct 25 '20 22:10 Quas7

After testing a bit, the sensitivity needs to be rather high (~1.8deg) to not falsely trigger on starting of rotation.

Quas7 avatar Oct 26 '20 14:10 Quas7

Offloaded the pin handling from the interrupt routine to main. Decreased sensitivity to prevent triggering during regular movement. Added noise filter functionality on top: deviation treshold has to be hit multiple times in a row.

Quas7 avatar Oct 26 '20 21:10 Quas7