Giter VIP home page Giter VIP logo

Comments (9)

Peter-van-Tol avatar Peter-van-Tol commented on September 24, 2024 2

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.

Peter-van-Tol avatar Peter-van-Tol commented on September 24, 2024 1

I think these changes can be implemented this week,

from litex-cnc.

Peter-van-Tol avatar Peter-van-Tol commented on September 24, 2024

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.

romanetz avatar romanetz commented on September 24, 2024

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.

Peter-van-Tol avatar Peter-van-Tol commented on September 24, 2024

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.

romanetz avatar romanetz commented on September 24, 2024

My intention was to achieve 1 m/sec speed with resolution of 1000 steps/mm

from litex-cnc.

Peter-van-Tol avatar Peter-van-Tol commented on September 24, 2024

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.

romanetz avatar romanetz commented on September 24, 2024

The issue is fixed

from litex-cnc.

Peter-van-Tol avatar Peter-van-Tol commented on September 24, 2024

Thank you for your feedback.

from litex-cnc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.