-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module: STEPGEN. Timing parameters issue. #59
Comments
I've noticed the comment in:
And therefore closing this for now. I'll get a set of updated (modern?) stepper drives that works and less timing-fancy rather. Mines are way too old anyway [corrosion apparent!!] |
Even if closed, I will follow up on this matter. Would it be helpful for you to be able to set the timing per stepgen separately? What kind of drive rare you using which requires such tight timing, or was the unexpected behavior due to corrosion? I really think it is cool that you checked the timings with the scope. I only had the possibility of running simulations of the FPGA and check timings in the created output. |
My existing Corroded/Old/Expired/Slow/Useless drives are min.10000 steplen. Got a new inexpensive kit currently in the mail, cost almost nothing. Those can pulse at 200Khz (STEPLEN 2500~5000) and so the current firmware will be fine. I think. Should. "Would it be helpful for you to be able to set the timing per stepgen separately?" Yeah, resumed the work onto Litex-Cnc last weekend. Received the hat pcbs a few days ago and finally got the hardware/connectors up, and so probing all the signals to be ready. I'm a week or two from swapping this parallel port for your solution. Honestly can't wait!! |
Unrelated (but related). If you find spare time and fancy toying with the STEPGEN module, see if there is a way to put up a HAL config for it that uses the PID for error comp. So far I'm down to the setup below however I can't make it work reliably. Does work in position mode without PID correction (xx.prediction?) though, but I assume this ain't reliable error comp-wise. Again though, I'm pretty new to all this and so I could be world-size wrong. Just experimenting & testing at the moment. ###INI ###HAL net x-index-enable => pid.x.index-enable #Step Gen signals/setup #Openloop stepper signals (velocity mode) net x-home-sw => joint.0.home-sw-in LITEXCNC.gpio.04.in-not |
To understand your setup better:
If the answer on both answers is
Basically the FPGA is lagging one cycle behind LinuxCNC. So therefore we have to use |
Awesome. You know what you're talking about and obviously thought of everything, and so I'll build my configs based on that. Background: I was left assuming PID was the way to go regardless whether it's open & closed, hence myself chasing my tail in trying to make this work. PID controlled actually does work however only for tiny distances (let's say max 200mm @ +/- 0.02mm error). Clearly lot changed since 2016. Peter, ref to the hal config you've suggested above, what sort of INI requirement(s) is needed for this to work reliably? Do I need the "FERROR = x.xx MIN_FERROR = x.xx" in there? and if so what sort of error is acceptable? |
Thank you for this elaborate research. Have reopened this issue and will investigate. Many thanks for putting a scope on the board! |
``The order of the fields in the firmware is:
In the code the order is:
The order of the fields have been revered. Mea culpa. The corrected line should read:
When I get on a laptop I will create a branch. @hmnijp : would you be able / willing to test this with a scope? |
Will also take this as an opportunity to configure each stepper separately. However, that will will be done is a separate issue / branch. Fixing this bug won't change the communication protocol, so this bug fix can be released under 1.2.4. Adding config for each stepper separately increases the config buffer. Thus this feature should go under version 1.3.x. This also implies that users have to recompile their firmware. This change can be together with #76 |
The fix has been implemented. To install the updated driver for testing purposes:
This should fix the timing issue. If possible, please test. Then I can draft a new release next week. |
I checked - it works) Thank you for the quick fix! There is one more question: @romanetz seems to have told me that a warning should appear when the frequency is high and the timings no longer match (T(1/F) << StepTime+StepSpace) In the example above - stepspace in ini = 7.5 µs, but at a frequency of 245 kHz it turns out (1/245 kHz - steptime) = 1.38 µs.. that is, a “warning” should have appeared, but nothing signals that the steps can become permanently high level... Is this warning no longer there, or has it stopped working due to changes? |
The warning is still there: if (instance->hal.param.max_velocity > (stepgen->data.max_frequency * fabs(instance->hal.param.position_scale))) {
// Limit speed to the maximum. This will lead to joint follow error when the higher speeds are commanded
float max_speed_desired = instance->hal.param.max_velocity;
instance->hal.param.max_velocity = stepgen->data.max_frequency * fabs(instance->hal.param.position_scale);
// Maximum speed is too high, complain about it and modify the value
if (!instance->memo.error_max_speed_printed) {
LITEXCNC_ERR_NO_DEVICE(
"STEPGEN: Channel %zu: The requested maximum velocity of %.2f units/sec is too high.\n",
i,
max_speed_desired);
LITEXCNC_ERR_NO_DEVICE(
"STEPGEN: The maximum possible velocity is %.2f units/second\n",
instance->hal.param.max_velocity);
instance->memo.error_max_speed_printed = true;
}
} So when requesting a speed higher then the ability of the Solved this problem and indeed a warning is displayed in my Axis. |
Going to merge now. On a side note, please note the following definitions of the parameters:
The maximum step frequency is therefore |
Re-opened as enhancement for making the timing specific per driver. |
Closed: making the timing specific per driver will be done in #87 |
Describe the bug
The steplen and dir-hold-time timing are mixed up.
To Reproduce
In the hal config, setting setp xxx.stepgen.00.dir-setup-time 7500 will affect the timing of stepgen.00.steplen, rather than setting up a dir-setup-time of 7500 as it should.
Steps to reproduce the behavior when using LinuxCNC:
The behavior can be observed using an oscilloscope by probing the stepgen step pin output.
Expected behavior
Timing to affect the correct parameter.
Screenshots
Potential suspect at line 374 of:
https://github.com/Peter-van-Tol/LiteX-CNC/blob/main/src/litexcnc/firmware/modules/stepgen.py
372 # - source which stores the value of the counters
373 self.steplen = Signal(10)
374 self.dir_hold_time = Signal(10) <--------
375 self.dir_setup_time = Signal(12)
376 # - counters
377 self.steplen_counter = StepgenCounter(10)
378 self.dir_hold_counter = StepgenCounter(11)
379 self.dir_setup_counter = StepgenCounter(13)
LinuxCNC(please complete the following information):
Additional context
I've yet tested if the timings of stepspace, dir-hold-time and dir-setup-time. Grateful if you could double-check if the parameters are matched correctly in the code while investigating this issue. Happy to support with traces and debug if required.
Thanks.
The text was updated successfully, but these errors were encountered: