hi Tom
any news for me?
Beppe
Hi Beppe,
I think you have these values swapped:
should be:Code:#define TAU 1.0 // costante di tempo filtro passa basso #define FINAL_TIME_Z 0.08
The result is instead of converging on the final target and finally making a tiny move to the exact target, it barely begins to move to the target and then makes a large move to the target.Code:#define TAU 0.08 // costante di tempo filtro passa basso #define FINAL_TIME 1.0
It seems that trajectory is somewhat difficult to solve. Maybe due to the small non zero initial velocity. KFLOP checks that the final solution matches the final target to 11 significant digits and if not prints that message. That solution is only accurate to 10.5 digits. We plan to change the limit to 10 digits.
Regards
TK http://dynomotion.com
hi Tom
any news for me?
Beppe
oops... sorry
I didn't read your reply in the new page
hehe
hi Tom
I corrected the TAU and FINAL_TIME values ??of as you suggested but the problem remains. That's: the strange messages have disappeared but the MPG still doesn't work and it is the same for both axis X and Z.
One question: as you have surely understood, by design choice, I have two MPG encoders, one for each axis; when I ordered them I specifically chose the model with differential output and I have connected them to Kanalog input #40,#41,#42#43. Said that, what happens if the chinese seller sold me the encoders with SINGLE ENDED output? The output terminals there are: A-!A and B-!B but I don't have an oscilloscope to verify that the signals are actually present on all the terminals.
What do you think? Could the problem come from there?
Beppe
Hi Beppe,
I assume you meant to say KFLOP Inputs #40... I tested your code by setting those bits as outputs and toggling them. Check the Digital IO Screen to see if the signals are sequencing in a quadrature manner. You might also check with a Voltmeter. I don't understand how you have wired things. If there are 2 mpg encoders there should be two sets of A-!A and B-!B. And all the '!' signals should be left unconnected. You will also need a GND.I have connected them to Kanalog input #40,#41,#42#43. Said that, what happens if the chinese seller sold me the encoders with SINGLE ENDED output? The output terminals there are: A-!A and B-!B but I don't have an oscilloscope to verify that the signals are actually present on all the terminals.
What do you think? Could the problem come from there?
Regards
TK http://dynomotion.com
hi Tom,
I was meaning I connected the encoders output to Kanalog JP-2 channel 6-A/B for X axis and channel 7-A/B for Z axis, all signals, plus and minus, are connected The I signals aren't present; all circuits have a common GND.
Was I wrong?
Beppe
Hi Beppe,
Oh, that would be correct if the encoders actually have differential outouts. Again check the Digital IO Screen to see if the bits toggle properly and also with a voltmeter.
Regards
TK http://dynomotion.com
hi Tom,
I am bit desperate because every time i try to implement something more i get problems.
First: MPG handweels not yet working but, at least, I am sure that MPG encoders are working fine; to check them i have set two fake axis, ch4 and ch5, connected to MPG's Kanalog input channels, #6 and #7, as encoder input and no output_mode: on the axis screen I can read the Position column increasing by 400 steps every 100 MPG clicks.That seems correct because the encoder has 100 pulse/rev.
Said that, the problem can come by code only, or... tell me witch kind of test i can do.
Second: i wrote the spindle management but also here there is something wrong. First time i call M3 or M4 the output Dac goes at the maximum value (1024) and never go to zero even if i do M5, the spindle stop to run just because i leave the inverter_on signal. Also the rotation direction is random: sometime it start on CW, sometime on CCW but in any case always commands the side with which it starts the first time; calling M3 or M4 it starts in the same first direction.
You can check what i wrote from the attached files. Ask me what you want/need to solve the problems
Beppe
Hi Beppe,
It seems you have the MPG code commented outFirst: MPG handweels not yet working but, at least, I am sure that MPG encoders are working fine; to check them i have set two fake axis, ch4 and ch5, connected to MPG's Kanalog input channels, #6 and #7, as encoder input and no output_mode: on the axis screen I can read the Position column increasing by 400 steps every 100 MPG clicks.That seems correct because the encoder has 100 pulse/rev.
Said that, the problem can come by code only, or... tell me witch kind of test i can do.
It seems your Spindle is Axis #2. Did you test Axis #2 to see if it works? It sounds like you have positive feedback causing a runaway. Try revering the Output Gain.Second: i wrote the spindle management but also here there is something wrong. First time i call M3 or M4 the output Dac goes at the maximum value (1024) and never go to zero even if i do M5, the spindle stop to run just because i leave the inverter_on signal. Also the rotation direction is random: sometime it start on CW, sometime on CCW but in any case always commands the side with which it starts the first time; calling M3 or M4 it starts in the same first direction.
Regards
TK http://dynomotion.com
Hi Tom,
"It seems you have the MPG code commented out" : yes it's right. I have commented the MPG code just for test the fake axis, of course when I say "doesn't work" is referred to code uncommented
"Try revering the Output Gain" : if you mean to change the Output Gain sign I have already done this, but the result is that the spindle becomes a pendulum
"Did you test Axis #2 to see if it works?" : if I call M3 or M4 the spindle start to turn at maximum velocity. What test can I do more?
Last edited by geppo_it; 09-16-2021 at 04:27 AM.
Hi Beppe,
Please post the exact code that you are testing without any changes. Describe what happens in detail."It seems you have the MPG code commented out" : yes it's right. I have commented the MPG code just for test the fake axis, of course when I say "doesn't work" is referred to code uncommented
So it oscillates CW and CCW? If so that would be correct except with bad tuning. Reduce gains to make it stable."Try revering the Output Gain" : if you mean to change the Output Gain sign I have already done this, but the result is that the spindle becomes a pendulum
Use KMotion.exe to enable the axis and verify it attempts to hold position and is behaving like a servo. Use Step Response Screen to see its response. Command Jog commands to verify speed can be controlled."Did you test Axis #2 to see if it works?" : if I call M3 or M4 the spindle start to turn at maximum velocity. What test can I do more?
Regards
TK http://dynomotion.com
Hi Tom,
as you said I fixed the spindle problems reversing the Output Gain and setting up the axis Gain: now the spindle works fine.
The MPGs problems not yet fixed and still working bad. You can see from the attached file "lathe_MPG screenshot.png" what is happening in detail; for first I tried to move Z axis, it reacted three times in a weird manner but at real I done 22 MPG encoder clicks (axis #7_Pos = 88 / 4 -> 22 cliks). I said "weird manner" because when the axis react to the click it move of -8.333334 units and back to zero automatically when the Position reached the Dest, without I do anything.
For second i tried to move X axis: it reacted like Z axis three times even though I made 8 clicks (axis #6) and on the ninth click it started to jerk without stopping, forcing me to press "Halt" to stop the tread execution. All that if I turn both MPG very slow, if I turn fast, both axis start jerking without stopping.
I hope you can understand why this is happening
Beppe
Hi Beppe,
That MPG code is counting pulses in software and can handle faster pulse rates than the software sampling rate assuming the pulse rate changes somewhat gradually. It seems your MPG is putting out bursts of 4 counts at a high rate causing it to miss pulses or get confused.
We have other MPG code that counts the encoder signals using hardware at up to 1 million counts per second. In fact as you noted this is already being shown in axes 6 and 7. So it is better to use that method. I changed your code to use that method. See attached. Please try it. Note I removed all the code for the other things on your system besides the MPG. After you get the MPGs working you will need to add that back in.
HTH
Regards
TK http://dynomotion.com
good day Tom
the new code now works, the only problem I have now is that I have lost the movement fluidity. Both axes are very jittery and jerky, especially when the Factor variable is larger. What can I do to make the axes smoother? Could the TAU reduction be a way?
Beppe
hi Tom,
I modified and inserted into my init program the code on file "MPGServiceSmoothHardwareEncFilteredRev3.c" to manage two simultaneous MPG encoders. I noted that:
a) the axis starts the motion only when i stop to turn the MPG encoder
b) the movement take more less one second before to start the acceleration: in the first second the screw turn by 2/3 microsteps and then accelerate to the max velocity
c) the maximum speed and zero speed are reached progressively without jerks (I like very much...)
d) if I command a big distance, for example one entirely encoder turn with the bigger Factor, if i turn again the encoder while the axis is moving, the axis stops suddently and seems the added clicks I made are lost
Did I make mistakes while modifying the code or does it have to work like this? Attached my init file
Beppe
Hi Beppe,
It seems to work properly for me with all your other code from the forever loop removed. You might have something in your other code causing a delay. Remove everything else and check if it works correctly.
Note TAU is defined twice but that shouldn't be the problem.
Regards
TK http://dynomotion.com
Good day Tom,
both MPG controls are now working fine. As always you were right: I had a Delay_sec (0.2) which I thought was performed only under certain conditions which ran continuously and this delayed the starts of the axes.
Said that, I have a curiosity: to test the MPG code outside of thread 1, I put it in thread_7 inside an endless loop and started it manually, what happened was that, when from KmotionCnc I pressed one of the two start spindle buttons, thread_7 interrupted the loop execution and therefore the MPG control became inactive. Is this something expected or unexpected for you too?
More: the StartThread (1-7) statement can be used inside thread_1 to launch another thread, and if so, how can I be sure that thread is not being interrupted by executing some commands?
Beppe
Hi Beppe,
Do you have the Spindle Buttons configured to run a C Program in Thread #7. If so then it would kill any program running in Thread #7. You might read this.I have a curiosity: to test the MPG code outside of thread 1, I put it in thread_7 inside an endless loop and started it manually, what happened was that, when from KmotionCnc I pressed one of the two start spindle buttons, thread_7 interrupted the loop execution and therefore the MPG control became inactive. Is this something expected or unexpected for you too?
I don't fully understand the question or what you mean by "interrupted". You shouldn't launch a Thread unless you know that a valid program has been previously loaded into that Thread. The best approach is to have everything that needs to run continuously into Thread #1. Otherwise another approach is to have a Thread "push" a User Button (possibly hidden) to load and execute a program in another ThreadMore: the StartThread (1-7) statement can be used inside thread_1 to launch another thread, and if so, how can I be sure that thread is not being interrupted by executing some commands?
HTH
Regards
TK http://dynomotion.com
Hi Tom,
_ Do you have the Spindle Buttons configured to run a C Program in Thread #7. If so then it would kill any program running in Thread #7 _
No, as you suggested I moved all controls into thread #1 and the spindle buttons call a C program into thread #3 (OnCWJog.c) and #4 (OnCCWJog.c)
_ I don't fully understand the question or what you mean by "interrupted" _
I said "interrupted" because the never ending loop launched on thread #7 to test MPG code was interrupted by pressing the spindle buttons
Beppe