Need help with spindle sync and pid tune
So i am in uncharted waters here.
I am trying to setup my mill spindle with spindle sync and pid tune feedback.
The catch that makes this hard and existing examples not so helpful as i only have a basic understanding of the HAL files and i am attempting to use github.com/scottalford75/Remora.
So this uses a a skr1.4 board via SPI to a RPI4 running linux cnc.
On the board there is a config that has what each pin is and what type.
The project has an encoder module that outputs the following to linux cnc. (github.com/scottalford75/Remora/blob/mai...encoder/PRUencoder.c)
phase-Z
index-enable
reset
raw_count
position-scale
position
velocity
The creator has helped me create a hal file to control the spindle and encoder.
But when reading and looking at other examples i am unable to make sense to the way remora need it.
So while this is new i think someone with better understanding of HAL could maybe help me with the proper linking of the functions. .
Currently when i run
G90 (set absolute mode)
G0 X1.000 Y1.000 Z0.100 (rapid move to starting position)
S100 M3 (turn on the spindle, 100 RPM)
G33.1 Z-10.0 K0.05 (rigid tap a 20 TPI thread 10.0 deep)
M2 (end program)
Fixed
But once it reaches the bottom the system set the DAC value negative and it stops.
The system has a direction pin for clockwise. and when it is not enabled the motor will rotate counter clockwise.
no need for a negative value.
Please Log in or Create an account to join the conversation.
loadrt abs count =1
addf abs.0 servo-thread
net spindle-speed-abs scale.0.out => abs.0.in
net spindle-speed-DAC abs.0.out => remora.sp.3
And my system only counting up was a pull up resistor came off my encoder.
I can now complete a full G33.1
The last bit is trying to get a PID setup in place.
I am looking at this as an example hoping to adapt it to my setup
forum.linuxcnc.org/media/kunena/attachments/9360/WarcoV2.hal
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Its in a state that it adjust its power the more load i give it but some of the scale values i am unsure on.
Right now i have this system rigged up on my bench trying to understand each thing in isolation.
i think i have lucked on the right numbers for things but i am unsure.
most of the code is copied with me only have a fraction of the understanding needed.
My encoder is a 300pr with Z
I am trying to understand the gain and scale and things like that and why they are the numbers they are.
line 57
setp encoder.0.position-scale 1200.000000 #6
300(pr encoder) x4(for quad encoder) = 1200
line 35-39
are these just converting from seconds to rpm?
line 47
lowpass.1.gain 0.01
Is this just to smooth the displayed output? is there a better value? how is this changing my feedback?
line 81
setp pwmgen.0.pwm-freq 0.0 #was 50 set to zero for PDM
when running a device like remora when there is no base thread i read that this should be set to 0 for PDM
line 82
setp pwmgen.0.scale 5000.0 #4000
Is this just the max steps between 0-1?
Why is PID error and pid feedback only show in increments of 100?
not related to hal but tunning is almost impossible right now.
Remora with the current software encoder cant handle my 300pr encoder.
But that should be fixed once the built in QEM on the chip is added.
so if the system overshoots the current mac speed it can read 1,600rpm its will just max the pwm output as the encoder numbers go out the window at higher RPM
Please Log in or Create an account to join the conversation.
I am trying to understand the gain and scale and things like that and why they are the numbers they are.
With PID tuning you often just need to find the answers by trial and error. In fact if you had a completely characterised system you probably wouldn't use PID at all....
It converts the encoder RPS to RPM.line 35-39
are these just converting from seconds to rpm?
Your HAL only appears to be using scale.2, with scale.0 and scale.1 being unused (maybe they are used in a different HAL file?)
The HAL encoder and the Hostmot2 (Mesa) encoder have a dedicated RPM output now, there is no need to use a scale with those.
I don't know if the same is true for PRUencoder or Remora. If not it is a _very_ easy mod to the code to add it, and I would advocate for that.
As long as the feedback is connected to the raw value, and the filtered value goes only to the GUI display, not at all.line 47
lowpass.1.gain 0.01
Is this just to smooth the displayed output? is there a better value? how is this changing my feedback?
setp pwmgen.0.scale 5000.0 #4000
Is this just the max steps between 0-1?
Sort-of. It means that an input of 5000 give 100% output. An input of 4999 should give 99.98% duty-cycle.
Please Log in or Create an account to join the conversation.
I am using pwm.curr-dc as the source value and using format".2f" but i want to use "0.2%" but when i do a get a sting formatting error.
i want it to take a value say 0.47 and turn it into 47%
Any way to get this working?
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
So now that i have pid working i wanted to try and use the auto tune version.
www.linuxcnc.org/docs/html/man/man9/at_pid.9.html
I have gotten it to work but i am having issues with pid.N.tune-start bit io and my GUI in pyvcp
I cant seem to link it to any button.
i suspect thats because its a IO and not just a input
The error i get is that it is already linked "'pyvcp.button2 , it already has i/o pin pid.0.tune-start"
Is there any way around this?
I am able to make buttons for all the other inputs i need but this one wont work.
My work around so far has been to just net it to a "button2" then use the cmd sets button2 1
Please Log in or Create an account to join the conversation.
Kinda a pain and a kludge but it works...
My thought on that limitation is to make a slider that sets a variable and then see if i can pass that variable when calling a new m101 command that has the setp for effort.
Got some help from JT-shop on IRC
he helped me convert variables so one could use the manual mdi screen to send both the cycle count and effort via m100 cmd and using setp
So now a user can tune and make adjustments without having to do a bunch of typing.
Sadly i cant get it to tune worth a darn....
Why is this so hard?
Am i doing this backwards or crazy?
Please Log in or Create an account to join the conversation.
Sorry if it has wasted your time.
Please Log in or Create an account to join the conversation.