linear scale and AC servo set up - sanity check
- chienMouille
- Offline
- Senior Member
Less
More
- Posts: 73
- Thank you received: 3
07 Oct 2022 12:03 #253678
by chienMouille
Replied by chienMouille on topic linear scale and AC servo set up - sanity check
I'm super new to HAL would be kind to show me how to go about adding an extra PID? Any thing else than just the last block of code you posted? I'm imagining I should declare it as an object before and add its variables to INI, isn't it?
Please Log in or Create an account to join the conversation.
07 Oct 2022 12:11 #253679
by andypugh
Replied by andypugh on topic linear scale and AC servo set up - sanity check
Somewhere near the top of the HAL will be "loadrt pid count = 3" (or something like that)
You can just double this number.
Then you need to addf the new pids to the servo-thread (look further down the HAL for lines to copy)
It is possible that your hal uses "loadrt pid names=pid.x,pid.y,pid.z" for named pids, (and you might prefer to change to that, if not) You could use pid.xi, pid.xo etc for inner and outer pid loops for each axis)
In this case you just addf the pids by name to the servo-thread, not by number.
You can just double this number.
Then you need to addf the new pids to the servo-thread (look further down the HAL for lines to copy)
It is possible that your hal uses "loadrt pid names=pid.x,pid.y,pid.z" for named pids, (and you might prefer to change to that, if not) You could use pid.xi, pid.xo etc for inner and outer pid loops for each axis)
In this case you just addf the pids by name to the servo-thread, not by number.
The following user(s) said Thank You: chienMouille
Please Log in or Create an account to join the conversation.
- chienMouille
- Offline
- Senior Member
Less
More
- Posts: 73
- Thank you received: 3
07 Oct 2022 12:29 #253682
by chienMouille
Replied by chienMouille on topic linear scale and AC servo set up - sanity check
Ok I get some errors, probably something stupid:
./cncmilltestclassicladder1.hal:147: Unknown command 'joint.0.motor-pos-cmd'
here is the hal and ini attempts:
./cncmilltestclassicladder1.hal:147: Unknown command 'joint.0.motor-pos-cmd'
here is the hal and ini attempts:
Attachments:
Please Log in or Create an account to join the conversation.
- chienMouille
- Offline
- Senior Member
Less
More
- Posts: 73
- Thank you received: 3
07 Oct 2022 12:50 #253685
by chienMouille
Replied by chienMouille on topic linear scale and AC servo set up - sanity check
ok, I have got it to net give errors, by commenting what seemed doubled and adding signal names. but now the servo won't move on jogs. would you check the setup?
thanks
thanks
Attachments:
Please Log in or Create an account to join the conversation.
07 Oct 2022 13:23 - 07 Oct 2022 13:26 #253692
by andypugh
Replied by andypugh on topic linear scale and AC servo set up - sanity check
#net pid.x.output => stepgen.x.velocity-cmd
Shouldn't be commented out, you need that, but also need to add a signal name
net x-output => stepgen.x.velocity-cmd
(as that is the signal name used above for the pid.x.output)
Shouldn't be commented out, you need that, but also need to add a signal name
net x-output => stepgen.x.velocity-cmd
(as that is the signal name used above for the pid.x.output)
Last edit: 07 Oct 2022 13:26 by andypugh.
Please Log in or Create an account to join the conversation.
- chienMouille
- Offline
- Senior Member
Less
More
- Posts: 73
- Thank you received: 3
07 Oct 2022 13:46 #253696
by chienMouille
Replied by chienMouille on topic linear scale and AC servo set up - sanity check
but isn't it what's connected in line 134?
net x-output => hm2_7i95.0.stepgen.00.velocity-cmd
net x-output => hm2_7i95.0.stepgen.00.velocity-cmd
Please Log in or Create an account to join the conversation.
07 Oct 2022 13:52 #253697
by andypugh
Replied by andypugh on topic linear scale and AC servo set up - sanity check
Sorry, yes.
Maybe that line (referring to a software stepgen, now I look at it) should be deleted rather than commented.
Maybe that line (referring to a software stepgen, now I look at it) should be deleted rather than commented.
Please Log in or Create an account to join the conversation.
- chienMouille
- Offline
- Senior Member
Less
More
- Posts: 73
- Thank you received: 3
07 Oct 2022 14:08 #253698
by chienMouille
Replied by chienMouille on topic linear scale and AC servo set up - sanity check
alright I can do that but why is the servo not moving at all now? I think I probably messed up the hal config between the two PIDs no?
Please Log in or Create an account to join the conversation.
- chienMouille
- Offline
- Senior Member
Less
More
- Posts: 73
- Thank you received: 3
09 Oct 2022 16:16 #253813
by chienMouille
I tried now to clean up and follow your sketch here precisely. But servo still doesn't move. Any idea?
That's how I've connected it:
Replied by chienMouille on topic linear scale and AC servo set up - sanity check
Im running in step/dir from a 7i95 mesa card, with the servo driver set in position mode.
Yes, but you have the stepgen running in vocity mode, so the PID needs to output a velocity.
Now, what you could do (and it would be an interesting experiment) would be to run the normal Mesa-style velocity PID to close the stepgen position loop, and then add an outer loop like I described with the linear scale as feedback.
Parport setup:[/code][/code]joint.N.motor-pos.cmd -> stepgen.N.position-cmd stepgen.N.pos-fb -> joint.N.motor-pos-fb Common Mesa config, using external velocity PID: [code]joint.N.motor-pos.cmd -> pid.N.command pid.N.output - > stepgen.N.velocity-cmd stepgen.N.position-fb -> pid.N.feedback -> joint.N.pos-fb Alternative with scales: [code]joint.N.motor-pos-cmd -> pid.M.command pid.M.output -> pid.N.command pid.N.output - > stepgen.N.velocity-cmd stepgen.N.position-fb -> pid.N.feedback scale.M.position -> pid.M.feedback -> joint.N.motor-pos-fb
I tried now to clean up and follow your sketch here precisely. But servo still doesn't move. Any idea?
That's how I've connected it:
#*******************
# AXIS X JOINT 0
#*******************
setp pid.x.Pgain [JOINT_0]P
setp pid.x.Igain [JOINT_0]I
setp pid.x.Dgain [JOINT_0]D
setp pid.x.bias [JOINT_0]BIAS
setp pid.x.FF0 [JOINT_0]FF0
setp pid.x.FF1 [JOINT_0]FF1
setp pid.x.FF2 [JOINT_0]FF2
setp pid.x.deadband [JOINT_0]DEADBAND
setp pid.x.maxoutput [JOINT_0]MAX_OUTPUT
setp pid.x.error-previous-target true
setp pid.x.maxerrorI [JOINT_0]MAX_ERRORI
setp pid.x_external.Pgain [JOINT_0]P_EX
setp pid.x_external.Igain [JOINT_0]I_EX
setp pid.x_external.Dgain [JOINT_0]D_EX
setp pid.x_external.bias [JOINT_0]BIAS_EX
setp pid.x_external.FF0 [JOINT_0]FF0_EX
setp pid.x_external.FF1 [JOINT_0]FF1_EX
setp pid.x_external.FF2 [JOINT_0]FF2_EX
setp pid.x_external.deadband [JOINT_0]DEADBAND_EX
setp pid.x_external.maxoutput [JOINT_0]MAX_OUTPUT_EX
setp pid.x_external.error-previous-target true
setp pid.x_external.maxerrorI [JOINT_0]MAX_ERRORI_EX
# Step Gen signals/setup
setp hm2_7i95.0.stepgen.00.dirsetup [JOINT_0]DIRSETUP
setp hm2_7i95.0.stepgen.00.dirhold [JOINT_0]DIRHOLD
setp hm2_7i95.0.stepgen.00.steplen [JOINT_0]STEPLEN
setp hm2_7i95.0.stepgen.00.stepspace [JOINT_0]STEPSPACE
setp hm2_7i95.0.stepgen.00.position-scale [JOINT_0]STEP_SCALE
setp hm2_7i95.0.stepgen.00.step_type 0
setp hm2_7i95.0.stepgen.00.control-type 1
setp hm2_7i95.0.stepgen.00.maxaccel [JOINT_0]STEPGEN_MAXACCEL
setp hm2_7i95.0.stepgen.00.maxvel [JOINT_0]STEPGEN_MAXVEL
# -- section to calculate "real following error"
loadrt sum2 count=3
addf sum2.0 servo-thread
setp sum2.0.gain1 -1.0
net x-pos-cmd => sum2.0.in0
#net my-x-pos-fb <= hm2_7i95.0.encoder.00.position => sum2.0.in1
net x-pos-fb => sum2.0.in1
net real-f-error <= sum2.0.out
# This setting is to limit bogus stepgen
# velocity corrections caused by position
# feedback sample time jitter.
setp pid.x.maxerror 0.012700
setp pid.x_external.maxerror 0.012700
net x-index-enable <=> pid.x.index-enable
net x-enable => pid.x.enable
net x-ex-index-enable <=> pid.x_external.index-enable
net x-ex-enable => pid.x_external.enable
net x-pos-fb => pid.x.feedback
net x-ex-pos-fb => pid.x_external.feedback
# ---closedloop stepper signals---
net x-vel-cmd <= joint.0.vel-cmd
net x-pos-ex-cmd <= joint.0.motor-pos-cmd
net x-pos-ex-cmd => pid.x_external.command
net x-ex-output <= pid.x_external.output
net x-ext-output => pid.x.command
net x-output => hm2_7i95.0.stepgen.00.velocity-cmd
net x-pos-fb <= hm2_7i95.0.stepgen.00.position-fb
net x-ex-pos-fb <= hm2_7i95.0.encoder.00.position
net x-ex-pos-fb => joint.0.motor-pos-fb
net x-enable <= joint.0.amp-enable-out
net x-enable => hm2_7i95.0.stepgen.00.enable
# ---Encoder feedback signals/setup---
setp hm2_7i95.0.encoder.00.counter-mode 0
setp hm2_7i95.0.encoder.00.filter 1
setp hm2_7i95.0.encoder.00.index-invert 1
setp hm2_7i95.0.encoder.00.index-mask 0
setp hm2_7i95.0.encoder.00.index-mask-invert 0
setp hm2_7i95.0.encoder.00.scale [JOINT_0]ENCODER_SCALE
#net x-index-enable joint.0.index-enable <=> hm2_7i95.0.encoder.00.index-enable
#net x-pos-rawcounts <= hm2_7i95.0.encoder.00.rawcounts
Please Log in or Create an account to join the conversation.
10 Oct 2022 11:51 #253867
by andypugh
Replied by andypugh on topic linear scale and AC servo set up - sanity check
Sorry to abandon you, I had a bit of a busy weekend.
The first thing that I notice is that I don't think that the pid.x_external PID component is being enabled.
Both PIDs can share the x-enable signal.
change
to
Does the linear scale have index marks? Those would be the best way to home, if they do. Otherwise you might want to remove the x-ex-index-enable net.
The first thing that I notice is that I don't think that the pid.x_external PID component is being enabled.
Both PIDs can share the x-enable signal.
change
net x-ex-index-enable <=> pid.x_external.index-enable
net x-ex-enable => pid.x_external.enable
net x-pos-fb => pid.x.feedback
net x-ex-pos-fb => pid.x_external.feedback
to
net x-ex-index-enable <=> pid.x_external.index-enable
net x-enable => pid.x_external.enable
net x-pos-fb => pid.x.feedback
net x-ex-pos-fb => pid.x_external.feedback
Does the linear scale have index marks? Those would be the best way to home, if they do. Otherwise you might want to remove the x-ex-index-enable net.
Please Log in or Create an account to join the conversation.
Time to create page: 0.148 seconds