Okay thank you for the quick reply - I have a 5a75b.
I was only a little bit confused because there are no step and dir pins connected by the joints in the hal file.
I know only a little bit about PID - So for my Understanding the PID gives the command to the FPGA and the FPGA produces the Step/Dir signals which goes to the Buffers- right?
Hi,
the PID part can be confusing and intimidating for the newcomers to this configurations.
I should write more about this part in the documentation.
The simplified background is that in Lcnc the stepgen is a variable frequency pulse generator, this is a choice for having simple fpga code and fast and smooth pulse generation dynamics.
Since the frequency (i.e pulses per second) is the joint velocity scaled by a constant quantity (constant that depend on steps per revolution, gear ratio, lead screw etc) then Lcnc for the stepgen will accept as input the requested joint velocity.
Lcnc is not handling directly position requested, will provide only position feedback (by counting how many steps have been generated).
Usually you need to move the joint to a certain position, and linuxcnc will provide this as commanded position, so the PID here will "translate" the position requested from linuxcnc to velocity command sent to Lcnc, so it sits between Linuxcnc and Lcnc.
But Pid need also to know the actual position of the axis at every instant in order to provide correct calculations.
So to summarize pid need two inputs: position you want to reach and actual joint position, and provides one output: requested joint velocity.
Here the feedback part could generate some confusion, since in your configuration there will have no real world feedback from the axis: you dont have encoders. But the fpga step generator will take some time to move the axis, due to for example acceleration limit imposed in hal, or hardware limits in step rate, and since the acceleration is limited, and so the velocity, the actual position will change in a finite time, and the PID will read this in positon feedback from Lcnc for it's intenal calculations,
In my hal file all this configuration is where you read:
- joint.1.motor-pos-cmd => pid.1.command # here the requested position from linuxcnc is connected to PID input command
- Lcnc.00.stepgen.01.pos-fb => pid.1.feedback # here the actual position feedback of the axis from Lcnc is connected to the PID feedback
- pid.1.output => Lcnc.00.stepgen.01.vel-cmd # here you connect the pid output to Lcnc velocity command
About PID configuration, for the stepgen it is very simple, since the feedback dynamics are very predictable (some reasons here, basically the feedback here is not from the real axis position*, but from stepgen in fpga, so no disturbances from the real world) you can use the parameters you see in the hal file:
setp pid.1.FF1 1.0
setp pid.1.Pgain 200
setp pid.1.Igain 20
setp pid.1.Dgain 0
setp pid.1.deadband 0.01
If I understand correctly TOLP implementation, the position pid part in his software is already embedded in the driver so his implementation hides most of this and your life is simplified.
I prefer to not rewrite a PID logic inside my driver, since we already have a very good PID in ours hal components.
*Note:
If you will ever add encoders to your machine, and modify the board to read inputs, this configuration could easily be modified to accept feedback from encoders instead than from Lcnc, so you will have a full closed loop axis. In this case a proper PID calibration is needed since the PID will be dealing with real world and unpredictable disturbances.