Adding Encoder to Microstep Stepper. No position change shown on step response
Hello Tom,
I have been using a setup with stepper motor open loop in microstep mode with decent success for a while.
I am attempting to add a shaft encoder and to use CL-Micro mode.
I have had an identical encoder setup to read spindle speed for some time. I get the quadrature ouput signals in the correct places on the digital I/O screen.
But when I invoke the step response, I get a flat position graph. It seems that the encoder is not being read.
The encoder is 500 step/rev quadrature. Motor is normal 200 count/rev with micro stepping. I think this should give me a gain of 5 on the input. The configuration is as follows: ch4->InputMode=ENCODER_MODE;
ch4->OutputMode=MICROSTEP_MODE;
ch4->Vel=1.5e+006;
ch4->Accel=1e+007;
ch4->Jerk=1e+007;
ch4->P=0;
ch4->I=0;
ch4->D=0;
ch4->FFAccel=0;
ch4->FFVel=0;
ch4->MaxI=2000;
ch4->MaxErr=2000;
ch4->MaxOutput=2000;
ch4->DeadBandGain=1;
ch4->DeadBandRange=0;
ch4->InputChan0=11;
ch4->InputChan1=12;
ch4->OutputChan0=14;
ch4->OutputChan1=15;
ch4->MasterAxis=-1;
ch4->LimitSwitchOptions=0x123;
ch4->LimitSwitchNegBit=75;
ch4->LimitSwitchPosBit=77;
ch4->SoftLimitPos=4000;
ch4->SoftLimitNeg=-1.325e+006;
ch4->InputGain0=5;
ch4->InputGain1=5;
ch4->InputOffset0=0;
ch4->InputOffset1=0;
ch4->OutputGain=1;
ch4->OutputOffset=0;
ch4->SlaveGain=1;
ch4->BacklashMode=BACKLASH_OFF;
ch4->BacklashAmount=0;
ch4->BacklashRate=0;
ch4->invDistPerCycle=0.001;
ch4->Lead=0;
ch4->MaxFollowingError=5000000000;
ch4->StepperAmplitude=239;
ch4->iir[0].B0=1;
ch4->iir[0].B1=0;
ch4->iir[0].B2=0;
ch4->iir[0].A1=0;
ch4->iir[0].A2=0;
ch4->iir[1].B0=1;
ch4->iir[1].B1=0;
ch4->iir[1].B2=0;
ch4->iir[1].A1=0;
ch4->iir[1].A2=0;
ch4->iir[2].B0=1;
ch4->iir[2].B1=0;
ch4->iir[2].B2=0;
ch4->iir[2].A1=0;
ch4->iir[2].A2=0;
http://www.cnczone.com/forums/image/...BJRU5ErkJggg==
Any ideas?
Thanks,
Jake
Happiness Tech LLC
Re: Adding Encoder to Microstep Stepper. No position change shown on step response
Hi Jake,
Did you configure the Axis InputChan0 setting for the Encoder Input channel the encoder is wired to?
What I/Os are toggling in the Digital I/O Screen?
Encoders don't normally have a "steps/rev" specification. Did you mean quadrature cycles/rev? Sometimes labled "lines/rev"?
Regards
Re: Adding Encoder to Microstep Stepper. No position change shown on step response
Quote:
Originally Posted by
TomKerekes
Hi Jake,
Did you configure the Axis InputChan0 setting for the Encoder Input channel the encoder is wired to?
What I/Os are toggling in the Digital I/O Screen?
Encoders don't normally have a "steps/rev" specification. Did you mean quadrature cycles/rev? Sometimes labled "lines/rev"?
Regards
Hi Tom,
The data sheet says 500 Pulse dual channel
Channels are labeled
A-Channel, 500 Pules
B-Channel, 500 Pules
I seem to get a correct speed reading for spindle speed using an identical one.
In the threading box on the mach3 dynomotion plugin I have 2000
Dont know if that helps'
Thanks
Re: Adding Encoder to Microstep Stepper. No position change shown on step response
Hi Jake,
500 Pulses per rev would be 500 x 4 = 2000 quadrature counts/rev so that makes sense.
SnapAmp normally works in units of phase cycles where there are 50 phase cycles/rev for a standard 200 full steps/rev Stepper Motor.
So I think you would want an InputGain0 of 50/2000 = 0.025 to match the encoder to the motor.
But none of that matters if you aren't getting any counts at all.
Please answer the other questions.
Regards
3 Attachment(s)
Re: Adding Encoder to Microstep Stepper. No position change shown on step response
Hi Tom,
Changing input0 to bit 2 gives me counts.
with gain 0.025 as you suggest I get some output
http://www.cnczone.com/forums/image/...AAAElFTkSuQmCC
upping the gain to 25 I get a better match(that is what I am looking for right?)
http://www.cnczone.com/forums/image/...BJRU5ErkJggg==
adding in 0.1 for I I get some output too
http://www.cnczone.com/forums/image/...BJRU5ErkJggg==
mostly this is giving good results.
I can jog and home this axis now. Sometimes though instead of motion I get a buzzing from the motor and have to kill it.
Also I get no readout for this axis on the current graph on the axis dialog when this motor is moving and still.
What;s next?
Thanks,
Jake
Re: Adding Encoder to Microstep Stepper. No position change shown on step response
Sorry images are so bad. Having trouble with the forum editor today.
Re: Adding Encoder to Microstep Stepper. No position change shown on step response
Hi Jake,
Some progress. Sorry I was off by a factor of 1000 :)
Please fix the plots so we can read them. I Ctrl-PrintScreen to capture the window, then paste to Paint, then save as a .png file.
It is also good to save and post the raw data as a txt file so we can plot it.
You can plot the currents on the Step Response Screen.
Your response is bad. We can't see what your settings are but 0.1 I gain is probably way too high. Notice the Output goes immediately to your 10000 limit and stays there. Probably going too fast for the motor to even attempt to respond.
You might "Zero" the axis before the Plot so the numbers are not so huge.
Regards
5 Attachment(s)
Re: Adding Encoder to Microstep Stepper. No position change shown on step response
Quote:
Originally Posted by
TomKerekes
Hi Jake,
Some progress. Sorry I was off by a factor of 1000 :)
Please fix the plots so we can read them. I Ctrl-PrintScreen to capture the window, then paste to Paint, then save as a .png file.
It is also good to save and post the raw data as a txt file so we can plot it.
You can plot the currents on the Step Response Screen.
Your response is bad. We can't see what your settings are but 0.1 I gain is probably way too high. Notice the Output goes immediately to your 10000 limit and stays there. Probably going too fast for the motor to even attempt to respond.
You might "Zero" the axis before the Plot so the numbers are not so huge.
Regards
Hit Move Button
Response I=0
Attachment 305778
I=0.1
Attachment 305780
I=0.01
Attachment 305782
I=0.05
Attachment 305784
Is this helpful?
Here is I=0.01 Stepping UP instead of DOWN
Attachment 305786
Re: Adding Encoder to Microstep Stepper. No position change shown on step response
Hi Jake,
Can you see that in some of the plots you start off with the red an blue plots matching (at zero) and some you don't. When you enable a closed loop system you should always be sure that the target destination matches where you physically are. If you don't then the servo will see a huge error and make a violent reaction. That is why we see the green correction plot attempt to make a huge instant maximum correction that the motor can't possibly respond to. You should probably "Zero" before each "Move".
I=0.01 in your last plot appears to be still way too big. As soon as small errors develop the over correction is so strong it stalls the motor. Imagine you are driving down the road and notice your car 1 inch to the right and this causes you to turn the steering wheel 100 degrees/sec to the left. That causes a skid, and the steering wheel ends up pegged to the hard stop. Try I= 0.0001 to see if that is at least stable. If so gradually increase it.
Try and put more effort into your responses so we can get some idea about what parts you understand to better help you.
Regards
2 Attachment(s)
Re: Adding Encoder to Microstep Stepper. No position change shown on step response
Quote:
Originally Posted by
TomKerekes
Hi Jake,
Can you see that in some of the plots you start off with the red an blue plots matching (at zero) and some you don't. When you enable a closed loop system you should always be sure that the target destination matches where you physically are. If you don't then the servo will see a huge error and make a violent reaction. That is why we see the green correction plot attempt to make a huge instant maximum correction that the motor can't possibly respond to. You should probably "Zero" before each "Move".
I=0.01 in your last plot appears to be still way too big. As soon as small errors develop the over correction is so strong it stalls the motor. Imagine you are driving down the road and notice your car 1 inch to the right and this causes you to turn the steering wheel 100 degrees/sec to the left. That causes a skid, and the steering wheel ends up pegged to the hard stop. Try I= 0.0001 to see if that is at least stable. If so gradually increase it.
Try and put more effort into your responses so we can get some idea about what parts you understand to better help you.
Regards
HI Tom,
I understand about zeroing the servo. I will be sure to do so before each trial. It sometimes takes a few clicks on the zero button to get the position all the way to zero on the axis dialog for this channel.
I also understand what you are saying about too much I overloading the stepper so that it simply sits and buzzes at overload.
Years ago I took controls systems and understood it fairly well. It is starting to come back to me. Your patients is awesome.
First here is the baseline with all three terms at 0
Attachment 306094
I have set this first one up with I=0.0001 as you suggest.
Attachment 306090
Here is an order of magnitude smaller. I=0.00001
Attachment 306088
And one at I=0.000001 to see the bounds of what this does.
Attachment 306092
Getting coarser I=0.001 gives a good match
Attachment 306112
This is the data file for this run.
Attachment 306116
I=0.0012
Attachment 306118
data file
Attachment 306120
This is the Quill axis on a CNC bridgeport.
What would you suggest for further tuning?
Thanks and happy day,
Jake
Re: Adding Encoder to Microstep Stepper. No position change shown on step response
Hi Jake,
The feedback is now working and driving the error toward zero in your last plot (the others didn't get uploaded for some reason).
But it indicates an error somewhere in matching motor steps to the encoder resolution. The error is ~4.8%. This causes the huge correction (Green Output) of -8500.
The way to test if the encoder resolution is matched to the motor motion is do a very large open loop move and stop. The encoder should show the position within a full step or so of the commanded position. which I believe in this case is +/- 250 counts.
A common thing that causes this type of error is to think you have a 500 pulse per rev encoder when you actually have a 512 pulse per rev encoder. That would cause a 2.4% error. You seem to have double that for some reason. I can't think of where that would be coming from. Is there any belt or gearing between the motor and the encoder?
Regards
Re: Adding Encoder to Microstep Stepper. No position change shown on step response
Hi Tom,
I have had problems with the forum always logging me out when I am half way done with a post. Then it acts funky when you use the "use auto-recover data" link below the reply box. anyway. . .
I set the output back to microstep and the input back to no input for the test.
After zeroing the axis I executed:
MoveRel4=-1000000
the final position was -982075
17,925 error
1.79%% off
MoveRel4=1000000 brings me back exactly to zero.
I have the docs on the encoder and they are clear about 500 counts.
The encoder is mounted directly to the back shaft of the motor.
It is always off in the same direction so it cant be noise.
thoughts?
Thanks,
Jake
Re: Adding Encoder to Microstep Stepper. No position change shown on step response
Hi Tom,
Looks like a big part of my problem is noise on the encoders.
I have encoder 2 hooked up and watching the digital screen while I slowly turn the motor by hand, I get the two bits flipping as they should but also the second bit from encoder 1 flips back and forth too, so I think I have a noise problem.
I had lots of noise issues when I initially hooked up limits and solved it by switching from J5 to OptoIsolated inputs on the snap amps. Can I wire the encoders through the snap amps somehow?
Thanks and happy day,
Jake
Re: Adding Encoder to Microstep Stepper. No position change shown on step response
Hi Jake,
What type of encoders do you have? Single ended or differential? What are their output specifications. How have you wired them?
See:
Dynomotion Motion Control Boards for CNC Manufacturing and Robotics Applications
Regards
2 Attachment(s)
Re: Adding Encoder to Microstep Stepper. No position change shown on step response
HI Tom,
I have Servo-Tek Single ended. I replaced the cable with one that has twisted pairs individually shielded. With the shield tied to digital ground, my counts are now perfect for big open loop moves.
Now my move response looks like this.
Attachment 308972
The biggest that I can be without overloading the servos is 0.00075
Here is the move response for that.
Attachment 308976
The output is looking much more reasonable now.
Is a filter for the output the next step?
Thanks and happy day,
Jake
Re: Adding Encoder to Microstep Stepper. No position change shown on step response
Hi Jake,
Yes that looks much better except it looks to be right at the point of going unstable.
I'm not sure what your requirements or objective is but the feedback corrections are small at ~4 "steps" your configured for 50,000 steps per rev. Once your position matches the command so well you can't see any difference you should plot errors instead.
A low pass filter may help reduce errors even more although I suspect they are very small already. Are you running unloaded?
See:
Closed Loop Stepper
Regards