Comments (9)
Also just noticed that there is no safeguard against this. When maximum speed is defined in the stepgen parameters, these will be obeyed. Even when they are above the theoretical maximum of the FPGA. The maximum speed should be limited to the maximum theoretical speed of the FPGA.
The code for getting the max frequency is:
stepgen->data.max_frequency = (double) (*(stepgen->data.clock_frequency)) / (steplen_cycles + stepspace_cycles);
This should be the minium of:
- the above formula, which takes the timing into account
- the max frequency as set by the integer value which is sent to the FPGA
from litex-cnc.
I think these changes can be implemented this week,
from litex-cnc.
Thanks for this issue! I'm going to look into it, but suspect it is due to an overflow situation. Using this comment as first idea:
- 1000 pulses/mm and 15 m/min results in 15,000,000 pulses per minute or 250 kHz pulse train. This should be in the limit of the design of the FPGA (400 kHz).
- The actual error is reported to occur much earlier at 6 m/min. This results in the error occurring at 100 kHz.
The following code is the culprit:
shift = 0
while (soc.clock_frequency / (1 << shift) > 400e3):
shift += 1
The idea was that the maximum step rate would be 400 kHz. But, the shift is off by one, so this will allow for a guaranteed step rate of 200 kHz. If in your case the FPGA clock speed is 30 MHz, your symptoms are completely explained by this mistake. This mistake affects both main
and 11-add-external-extensions-to-litexcnc
branches.
Proposed solution is to change above code with:
shift = 0
while (soc.clock_frequency / (1 << (shift + 1)) > 400e3):
shift += 1
from litex-cnc.
I changed firmware in FPGA and driver like this:
shift = 0
while (soc.clock_frequency / (1 << (shift + 1)) > 1000e3):
shift += 1
This worked for me. Thanks!
from litex-cnc.
In your code I see you both changed shift
to shift + 1
and the maximum frequency to 400. Is the value of 1000 strictly necessary for the correct working?
from litex-cnc.
My intention was to achieve 1 m/sec speed with resolution of 1000 steps/mm
from litex-cnc.
I've resolved this bug in both branches (main
and 11
), could you please try whether the latest version will allow you running at the desired speed?
The value of 1000e3 in your modified code would lead to a max step frequency of 1 MHz. The required speed is 16 kHz (1000 * 1000 / 16), so the default value of 400 kHz is safe. To gain a little on precision/resolution, you can consider to modify the new parameter <card-name>.stepgen.max-driver-freq
to a lower value, for example 100000 (i.e. 100 kHz).
Edited: typos
from litex-cnc.
The issue is fixed
from litex-cnc.
Thank you for your feedback.
from litex-cnc.
Related Issues (20)
- [Feature request]: Add PWM/direction and UP/DOWN to PWM HOT 4
- [Feature request]: Dither PWM
- [Feature request]: Support ENCODER counter-mode
- [Feature request]: add `index-enable` to STEPGEN HOT 1
- Bugfix for RPI5 Support
- Safety: Upcoming change in Watchdog HOT 1
- HUB75HAT Pin-out incorrect
- GPIO does not compile when either all pins are input or output
- Requirement for encoder.<n>.reset (HAL_BIT) HOT 17
- PATH not set on LinuxCNC RPi4 image after installing LitexCNC HOT 2
- Module ENCODER: width of Z-index pulse not taken into account
- Add option invert PWM output HOT 3
- Installation on PC does not detect correct platform HOT 2
- Stepgen only working up to 4 steppers HOT 2
- Reset watchdog on FPGA reset
- New module `shift_in` and `shift_out` for using shift registers HOT 1
- Maximum frequency 375 kHz. HOT 37
- Upgrade toolchain: bring Yosys to version 0.38
- differential step HOT 1
- Litex-cnc on standalone fpga chip?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from litex-cnc.