Making it work for Ardunio based ATMega328p
Hi! I followed along your blog and built my embroidery machine based on an Arduino Uno with a CNC shield. The machine works now but I had to make some changes to the code.
- The Timer0 is not started for uCs excluding ATMega32/16. Additionally the line 73
PD6_DDR = 0xFF
sets all pins of port D to outputs which also includes the encoder and needle inputs. I thought it might also be good to change that also for the ATMega32 (line 41) but I cannot test with such a uC so I left it as is. See first commit. - I observed unconsistent movement of the x axis when using the jog buttons of the control app. I could narrow it down to the variable
startpoint_steps
in motor.c. It seems that a different process/variable is colliding in memory with it leading to unconsistent steps taken. I found that removingstartpoint_steps
from the BSS section works out fine altough this is not the most elegant solution. I configured it such that for ATMega328/328P/168 the variable is not put into BSS. For all other uCs it is still in BSS. If you are interested in fixing it "the right way" I will be happy to help. See commit 2.