Skip to content
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

Add option invert PWM output #76

Closed
Peter-van-Tol opened this issue Jan 23, 2024 · 3 comments · Fixed by #89
Closed

Add option invert PWM output #76

Peter-van-Tol opened this issue Jan 23, 2024 · 3 comments · Fixed by #89
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@Peter-van-Tol
Copy link
Owner

Is your feature request related to a problem? Please describe.
PWM should be able to be inverted without the need for tricks.

Describe alternatives you've considered

  • inverting the output when compiling the firmware. Easiest to implement, however not very flexible
  • inverting the output using a HAL parameter, similar to GPIO which can also be inverted from the HAL. One can choose to:
    • either invert the duty-cycle (thus a duty-cycle of 5% will be send out as 95%, which is effectively the same as inversing the signal, however the start of the signal shifts) NOTE: this is the trick to 'invert' the signal in the current situation, by choosing scale and offset smart;
    • send an extra WORD to the FPGA with the config of the PWM. This case, the start of the PWM (and thus the frequency) is always fixed.

Describe the solution you'd like
Use the most flexible option, by adding an extra WORD to the communication stream.

NOTE: by adding an extra WORD, it is required to re-compile any existing drivers after updating the driver

@Peter-van-Tol
Copy link
Owner Author

Peter-van-Tol commented Feb 19, 2024

This feature is now ready to be tested (note: recompilation of the firmware required)

pip install git+https://https://github.com/Peter-van-Tol/LiteX-CNC@76-add-option-invert-pwm-output
sudo env "PATH=$PATH" litexcnc install_driver
litexcnc build_firmware <JSON_CONFIGURATION> --build -a
cd /<CARD_NAME>/gateware
litexcnc flash_firmware colorlight.svf

@Peter-van-Tol Peter-van-Tol added this to the v1.3.0 milestone Feb 19, 2024
@hmnijp
Copy link

hmnijp commented Feb 20, 2024

This feature is now ready to be tested (note: recompilation of the firmware required)

I tried to quickly test as you asked - I don’t see any problems...
I checked 6 channels from 5Hz to 100kHz, duty from 0.001 to 0.999. (+4 stepgen while moving)
2024-02-20 07-32-29

The only thing I had to deal with was that yosys did too many routing iterations (more than an hour), although there were no problems before this patch.
I didn’t wait for it to finish and ran build on the new version of yosys (0.38) - this got rid of the problem, although there is a warning “Max frequency..”

The install_toolchain.py script still installs v0.24...(this line) From users of a similar project (litehm2) I heard that yosys has made a lot of improvements over the past year.

@Peter-van-Tol
Copy link
Owner Author

Thank you for testing!

Will merge this branch to main and open an additional issue to upgrade Yosys to 0.38.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants