Need help with spindle sync and pid tune

More
26 Apr 2021 19:05 - 27 Apr 2021 14:20 #207156 by Aaroncnc
Hello,
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
All seems well and the Z axis moves with the motor and encoder
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.
Attachments:
Last edit: 27 Apr 2021 14:20 by Aaroncnc.

Please Log in or Create an account to join the conversation.

More
27 Apr 2021 14:17 - 27 Apr 2021 16:27 #207230 by Aaroncnc
Okay after messing about i got the DAC value to stay positive with the following

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
Last edit: 27 Apr 2021 16:27 by Aaroncnc.

Please Log in or Create an account to join the conversation.

More
30 Apr 2021 22:47 #207503 by andypugh
How's it going?

Please Log in or Create an account to join the conversation.

More
04 May 2021 23:06 - 04 May 2021 23:13 #207893 by Aaroncnc
its going but tbh i am a bit unsure.

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
Attachments:
Last edit: 04 May 2021 23:13 by Aaroncnc.

Please Log in or Create an account to join the conversation.

More
05 May 2021 11:50 #207953 by andypugh

Aaroncnc wrote: 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....


line 35-39
are these just converting from seconds to rpm?

It converts the encoder RPS 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.

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?

As long as the feedback is connected to the raw value, and the filtered value goes only to the GUI display, not at all.


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.

More
05 May 2021 16:48 #207987 by Aaroncnc
So i am trying to setup a power bar in pyvcp and i got it working but i want to change the text format.
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.

More
06 May 2021 13:10 #208100 by andypugh
You probably need to use a (HAL) scale to multiply by 100, then put the % sign in as a string separate from the number. (you might need to escape the % too)

Please Log in or Create an account to join the conversation.

More
06 May 2021 13:28 #208104 by Aaroncnc
That would work.

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.

More
06 May 2021 18:00 - 06 May 2021 21:17 #208142 by Aaroncnc
Well i was able to make a button turn on a custom m100 command and that custom m100 command sets the value for me that the button cant.
Kinda a pain and a kludge but it works...
Now i am facing the same problem trying to make the gui set the effort and cycle counts as they are the same type of IO
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?
Last edit: 06 May 2021 21:17 by Aaroncnc.

Please Log in or Create an account to join the conversation.

More
07 May 2021 22:45 #208262 by andypugh
I am of the opinion that we should remove the auto-tune PID. I think that someone wrote it as a college project, but as far as I know no-one has had any luck with it.

Sorry if it has wasted your time.

Please Log in or Create an account to join the conversation.

Time to create page: 0.102 seconds
Powered by Kunena Forum