Lagunmatic 3516-SX Retrofit

More
8 years 2 months ago #115791 by giz
Replied by giz on topic Lagunmatic 3516-SX Retrofit
Tonights update - still there there yet but I think it's getting close.

I standardized on pid.s and pid.1 for velocity and position respectively. I tried using the code above but ran into a couple issues - first it seems like I needed to loadrt pwgen (not sure if I did it correctly) and then once I got past that stage the config loaded with this error:

Code:
Signal 'spindle-cmd' of type 'bit' cannot add pin 'hm2_5i25.0.7i77.0.1.analogout5' of type 'float'

Ok - this didn't seem right so I commented that line out and decided to trace and confirm all the signals just to make sure the logic was happening correctly. Using this diagram I opened all the pertinent HAL Meter boxes and ran two tests:

1. I turned the spindle by hand and ensured all the pins appeared to be reading encoder, velocity, position information correct [PASSED]
2. Feed it codes through the MDI to verify the position/velocity mode logic is working [PASSED]

I took "screenshots" to show the values and confirmation (yes I took a photo of my monitor because I'm completely stupid when it comes to Linux!!) I sent M19 R50 Q20 for the orient command and M3 S400 for the velocity command.

Ok so this seems good so far. At this point I am getting a value out of mux2.0.out fore each scenario but I cannot successfully pass it to hm2_5i25.0.7i77.0.1.analogout5.

For reference, here is the spindle portion of my HAL file. Yes it is a complete disaster from all the cut/paste/comment out experiments.

lagunmatic.hal
Code:
#******************* # SPINDLE S #******************* loadrt pwmgen output_type=0 addf pwmgen.update servo-thread setp pid.s.Pgain [SPINDLE]P setp pid.s.Igain [SPINDLE]I setp pid.s.Dgain [SPINDLE]D setp pid.s.bias [SPINDLE]BIAS setp pid.s.FF0 [SPINDLE]FF0 setp pid.s.FF1 [SPINDLE]FF1 setp pid.s.FF2 [SPINDLE]FF2 setp pid.s.deadband [SPINDLE]DEADBAND setp pid.s.maxoutput [SPINDLE]MAX_OUTPUT setp pid.s.error-previous-target true net spindle-index-enable <=> pid.s.index-enable #net spindle-enable => pid.s.enable #net spindle-vel-cmd-rpm => pid.s.command #net spindle-vel-fb-rpm => pid.s.feedback #net spindle-output <= pid.s.output # ---PWM Generator signals/setup--- setp hm2_5i25.0.7i77.0.1.analogout5-scalemax [SPINDLE]OUTPUT_SCALE setp hm2_5i25.0.7i77.0.1.analogout5-minlim [SPINDLE]OUTPUT_MIN_LIMIT setp hm2_5i25.0.7i77.0.1.analogout5-maxlim [SPINDLE]OUTPUT_MAX_LIMIT #net spindle-output => hm2_5i25.0.7i77.0.1.analogout5 net spindle-enable => hm2_5i25.0.7i77.0.1.spinena ##### net spindle-pos pid.1.feedback orient.0.position net spindle-vel pid.s.feedback hm2_5i25.0.encoder.05.velocity net spindle-vel-cmd motion.spindle-speed-out pid.s.command net spindle-vel-pid pid.s.output mux2.0.in0 net spindle-pos pid.1.feedback orient.0.position near.0.in1 hm2_5i25.0.encoder.05.position net spindle-pos-cmd orient.0.command pid.1.command near.0.in2 net spindle-angle motion.spindle-orient-angle orient.0.angle net spindle-pos-pid pid.1.output mux2.0.in1 setp near.0.difference 0.0005 net spindle-in-pos-raw near.0.out edge.0.in #not needed v2.8+, use orient.0.is-oriented net spindle-in-pos edge.0.out motion.spindle-is-oriented # this switches modes net orient-mode motion.spindle-orient orient.0.enable pid.1.enable mux2.0.sel net velocity-mode motion.spindle-on pid.s.enable pwmgen.0.enable net orient-dir motion.spindle-orient-mode orient.0.mode #loadrt pwmgen output_type=0 #addf pwmgen.update servo-thread #addf pwmgen.make-pulses base-thread #net spindle-speed-cmd motion.spindle-speed-out => pwmgen.0.value #net spindle-on motion.spindle-on => pwmgen.0.enable # Set the spindle's top speed in RPM setp pwmgen.0.scale 10000 net spindle-cmd pwmgen.0.pwm hm2_5i25.0.7i77.0.1.analogout5 # Tune the PID from the INI values setp pid.1.Pgain [SPINDLE]PGAIN_P setp pid.1.Igain [SPINDLE]IGAIN_P setp pid.1.Dgain [SPINDLE]DGAIN_P setp pid.1.FF0 [SPINDLE]FF0_P setp pid.1.FF1 [SPINDLE]FF1_P ##### # ---Encoder feedback signals/setup--- setp hm2_5i25.0.encoder.05.counter-mode 0 setp hm2_5i25.0.encoder.05.filter 1 setp hm2_5i25.0.encoder.05.index-invert 0 setp hm2_5i25.0.encoder.05.index-mask 0 setp hm2_5i25.0.encoder.05.index-mask-invert 0 setp hm2_5i25.0.encoder.05.scale [SPINDLE]ENCODER_SCALE #net spindle-revs <= hm2_5i25.0.encoder.05.position #net spindle-vel-fb-rps <= hm2_5i25.0.encoder.05.velocity net spindle-index-enable <=> hm2_5i25.0.encoder.05.index-enable # ---setup spindle control signals--- net spindle-vel-cmd-rps <= motion.spindle-speed-out-rps net spindle-vel-cmd-rps-abs <= motion.spindle-speed-out-rps-abs #net spindle-vel-cmd-rpm <= motion.spindle-speed-out net spindle-vel-cmd-rpm-abs <= motion.spindle-speed-out-abs #net spindle-enable <= motion.spindle-on net spindle-cw <= motion.spindle-forward net spindle-ccw <= motion.spindle-reverse net spindle-brake <= motion.spindle-brake net spindle-pos => motion.spindle-revs net spindle-at-speed => motion.spindle-at-speed net spindle-vel => motion.spindle-speed-in net spindle-index-enable <=> motion.spindle-index-enable # ---Setup spindle at speed signals--- sets spindle-at-speed true

Please Log in to join the conversation.

More
8 years 2 months ago #115804 by andypugh
You don't need the pwm, just get rid of it.

Make the change I suggested 2 posts back, you don't need the abs, or the other stuff around there.

I don't see any evidence of the mux2 that is used to switch between the two PID control outputs.

Please Log in to join the conversation.

More
8 years 2 months ago #115805 by giz
Replied by giz on topic Lagunmatic 3516-SX Retrofit
My file is a mess but I did get get rid of the abs section and mux2 is in there. In the screenshots mux2.0.out is correctly passing mux2.0.in0 or mux2.0.in1 based on which mode I'm in.

It seems like I should be able to directly assign mux2.0.out to analogout5?

If I get that done, and analogout5 has a single but the spindle does not move, is it reasonable to assume there is an issue with the PID gain values and move on to tweaking those?

Please Log in to join the conversation.

More
8 years 2 months ago #115808 by andypugh

giz wrote: It seems like I should be able to directly assign mux2.0.out to analogout5?


Yes, that is what you need
Code:
net spindle-cmd mux2.0.out

Or, put it on one line
Code:
net spindle-cmd mux2.0.out hm2_5i25.0.7i77.0.0.analogout5

(I am making up the pin names there, you need to check them against your actual HAL)

Is the spindle-enable being set in both cases?

Please Log in to join the conversation.

More
8 years 2 months ago #115818 by giz
Replied by giz on topic Lagunmatic 3516-SX Retrofit
Awesome - thanks for the confirmation andy. I did use that line of code at some point last night but I didn't see movement at the spindle, hence the question about the PID.

I'm fairly certain I checked the status of spindle-enable in both situations but I'll double-check.

If nothing else, this particular struggle has really helped me understand the structure and syntax of LinuxCNC. Definitely feeling more comfortable about what is actually happening

Please Log in to join the conversation.

More
8 years 2 months ago #115840 by giz
Replied by giz on topic Lagunmatic 3516-SX Retrofit
Best update of the night is that I remeasured the height of the machine and, as long as I take off the Z-axis servo, it turns out I will be able to fit this machine into the new house. The garage has 8ft doors the tallest permanent hard spot is about 88". YES!!

Ok - so Andy was right about the spindle enable preventing movement. However, I cannot for the life of me figure out how to incorporate it into the logic. Because I have the velocity-mode signal connected to motion.spindle-on I don't seem to be able to drive hm2_5i25.0.7i77.0.1.spinena with motion.spindle-on (through the spindle-enable signal that is standard).

I've racked my brain over and over but I can't come up with a solution - advice?

To keep progressing, I started my config using the .hal below and used halcmd to sets spindle-enable true. This gave me signal on analogout5 in both modes (success) but only resulted in movement when I was in velocity mode.

So once I can get the spindle enabled in both modes, then I need to:

1) determine why there is no motion in orient mode
2) scale the spindle speed correctly

The two might be related? I found a diagram that shows a similar logic setup for position vs. velocity mode that incorporates some scaling but I haven't fully digested it yet. It seems to be setup differently than how I have it now (where 1 spindle revolution = +1 encoder position).

spindle hal section below. It's been cleaned up, I left my attempt at using an or2 component to flip the spindle-enable but, again, I run into the issue of the pins already being in use.
Code:
#******************* # SPINDLE S #******************* setp pid.s.Pgain [SPINDLE]P setp pid.s.Igain [SPINDLE]I setp pid.s.Dgain [SPINDLE]D setp pid.s.bias [SPINDLE]BIAS setp pid.s.FF0 [SPINDLE]FF0 setp pid.s.FF1 [SPINDLE]FF1 setp pid.s.FF2 [SPINDLE]FF2 setp pid.s.deadband [SPINDLE]DEADBAND setp pid.s.maxoutput [SPINDLE]MAX_OUTPUT setp pid.s.error-previous-target true setp pid.1.Pgain [SPINDLE]PGAIN_P setp pid.1.Igain [SPINDLE]IGAIN_P setp pid.1.Dgain [SPINDLE]DGAIN_P setp pid.1.FF0 [SPINDLE]FF0_P setp pid.1.FF1 [SPINDLE]FF1_P # ---PWM Generator signals/setup--- setp hm2_5i25.0.7i77.0.1.analogout5-scalemax [SPINDLE]OUTPUT_SCALE setp hm2_5i25.0.7i77.0.1.analogout5-minlim [SPINDLE]OUTPUT_MIN_LIMIT setp hm2_5i25.0.7i77.0.1.analogout5-maxlim [SPINDLE]OUTPUT_MAX_LIMIT net spindle-index-enable <=> pid.s.index-enable net spindle-enable => hm2_5i25.0.7i77.0.1.spinena ##### net spindle-pos pid.1.feedback orient.0.position net spindle-vel pid.s.feedback hm2_5i25.0.encoder.05.velocity net spindle-vel-cmd motion.spindle-speed-out pid.s.command #net spindle-vel-cmd motion.spindle-speed-out-rps pid.s.command net spindle-vel-pid pid.s.output mux2.0.in0 net spindle-pos pid.1.feedback orient.0.position near.0.in1 hm2_5i25.0.encoder.05.position net spindle-pos-cmd orient.0.command pid.1.command near.0.in2 net spindle-angle motion.spindle-orient-angle orient.0.angle net spindle-pos-pid pid.1.output mux2.0.in1 setp near.0.difference 0.0005 net spindle-in-pos-raw near.0.out edge.0.in #not needed v2.8+, use orient.0.is-oriented net spindle-in-pos edge.0.out motion.spindle-is-oriented # this switches modes net orient-mode motion.spindle-orient orient.0.enable pid.1.enable mux2.0.sel net velocity-mode motion.spindle-on pid.s.enable #hm2_5i25.0.7i77.0.1.spinena net orient-dir motion.spindle-orient-mode orient.0.mode ##### # ---Encoder feedback signals/setup--- setp hm2_5i25.0.encoder.05.counter-mode 0 setp hm2_5i25.0.encoder.05.filter 1 setp hm2_5i25.0.encoder.05.index-invert 0 setp hm2_5i25.0.encoder.05.index-mask 0 setp hm2_5i25.0.encoder.05.index-mask-invert 0 setp hm2_5i25.0.encoder.05.scale [SPINDLE]ENCODER_SCALE net spindle-cmd mux2.0.out hm2_5i25.0.7i77.0.1.analogout5 net spindle-index-enable <=> hm2_5i25.0.encoder.05.index-enable #loadrt or2 #addf or2.0 servo-thread #net velocity-enable or2.0.in0 pid.s.enable #net position-enable or2.0.in1 pid.1.enable #net spindle-enable or2.0.out # ---setup spindle control signals--- #net spindle-vel-cmd-rps <= motion.spindle-speed-out-rps net spindle-vel-cmd-rps-abs <= motion.spindle-speed-out-rps-abs #net spindle-vel-cmd-rpm <= motion.spindle-speed-out net spindle-vel-cmd-rpm-abs <= motion.spindle-speed-out-abs #net spindle-enable <= motion.spindle-on net spindle-cw <= motion.spindle-forward net spindle-ccw <= motion.spindle-reverse net spindle-brake <= motion.spindle-brake net spindle-pos => motion.spindle-revs net spindle-at-speed => motion.spindle-at-speed net spindle-vel => motion.spindle-speed-in net spindle-index-enable <=> motion.spindle-index-enable # ---Setup spindle at speed signals--- sets spindle-at-speed true

Current spindle PID section for reference. Just playing with numbers right now to see if they affected the motion:
Code:
#******************** # Spindle #******************** [SPINDLE] P = 5 I = 0 D = 0.0 FF0 = 1 FF1 = 0.0 FF2 = 0.0 PGAIN_P = 60 IGAIN_P = 0 DGAIN_P = 0 FF0_P = 1 FF1_P = 0 BIAS = 0.0 DEADBAND = 0.0 MAX_OUTPUT = 10000.0 ENCODER_SCALE = -4096.0 OUTPUT_SCALE = 10000 OUTPUT_MIN_LIMIT = -10000 OUTPUT_MAX_LIMIT = 10000

Please Log in to join the conversation.

More
8 years 2 months ago #115841 by giz
Replied by giz on topic Lagunmatic 3516-SX Retrofit
The lack of movement may also be related to some setting in my VFD. I have noticed that the minimum spindle speed to initiate movement is lower than I expected. As far as the VFD is concerned, it thinks it is running in open loop between a min and max frequency

Please Log in to join the conversation.

More
8 years 2 months ago #115855 by giz
Replied by giz on topic Lagunmatic 3516-SX Retrofit
Here is the schematic I found last night that may be helpful. It seems to address the spindle enable and scaling. I haven't fully digested it yet.

Attachment not found

Please Log in to join the conversation.

More
8 years 2 months ago #115878 by raglanlittlejohn
giz,
I did the schematic earlier this year. I was struggling to understand how the orient component worked, and found it easier to follow a schematic. I did get this working using a new Huangyang vfd which had sensorless vector control. The idea was to orient a lathe spindle. It worked well, getting the position within about 1 degree.
There is no pid for the normal speed, that is controlled by a variable voltage output to the vfd. I planned to use a disc with say 12 holes on the spindle, and a pin that would be engaged in the appropriate hole, when the spindle orientated signal came in. I think that would work, but I have not finished that part of the project yet.

Please Log in to join the conversation.

More
8 years 2 months ago #115890 by giz
Replied by giz on topic Lagunmatic 3516-SX Retrofit
Awesome, thanks John. Funny you mention it - my plan today is to switch the VFD over to closed-loop vector control. It's running v/f right now and I think that might be why I don't see any movement during the M19 cycle (or at least, it isn't helping).

Im looking into how I can possibly use your scaling and logic components to make my current Hal work as intended.

Please Log in to join the conversation.

Time to create page: 0.245 seconds
Powered by Kunena Forum