How to change PWM Frequency?

More
28 Jan 2021 09:21 #196911 by roland
i need to change the frequency of the pwmgen during runtime.
Unfortunately this does not work. I cannot link hm2_7i92.0.pwmgen.pwm_frequency to a signal.
For that, pwm_frequency would have to be a pin and not a parameter.



How can I change the pwm frequency with a singal?

--
Roland
Attachments:

Please Log in or Create an account to join the conversation.

More
28 Jan 2021 16:59 #196965 by PCW
Replied by PCW on topic How to change PWM Frequency?
Yes, HM2 PWM frequency is a parameter not a pin so it cannot be linked to a signal
If its just changed occasionally you can use a script with setp

What is the application? maybe PWM is not the best solution.

Please Log in or Create an account to join the conversation.

More
28 Jan 2021 17:42 #196978 by roland
Replied by roland on topic How to change PWM Frequency?
A solenoid valve regulates the flow. The valve is opened 10 times per second for a short time.

So far I do this with pwmgen.

PWM Frequency = 10 Hz

Value 0,062 results in a pulse width of 6.2 ms
...
Value 0.014 results in a pulse width of 1.4 ms

Up to here everything is fine.

At Value < 0.014 the pulse width becomes < 1.4 ms.

But a smaller pulse width than 1.4 ms cannot switch the valve.
To be able to work with value < 0.014, the frequency must be reduced here.

Please Log in or Create an account to join the conversation.

More
28 Jan 2021 18:02 - 28 Jan 2021 18:05 #196980 by PCW
Replied by PCW on topic How to change PWM Frequency?
At that low a frequency you are probably better of using software PWM
perhaps siggen and oneshot, or it may be that the software PWM
will work with pwmgen.0.dither-pwm set true (and a 500 Hz thread so
the minimum pulse width is never less than 2 ms)

Another option is using the rcpwmgen (made for RC servos) this has
a rate pin and a .01 to 1KHz PWM rate

man hostmot2
Last edit: 28 Jan 2021 18:05 by PCW.

Please Log in or Create an account to join the conversation.

More
28 Jan 2021 19:06 #196984 by roland
Replied by roland on topic How to change PWM Frequency?
oneshot and siggen I have tested. That works. The problem is that the pulse width is always a multiple of 1 ms. This is too inaccurate.

Is a new bit file necessary for rcpwmgen?

Attached is my current .vhd file. What must be changed here?

File Attachment:

File Name: PIN_7I76_7....vhd.txt
File Size:10 KB
Attachments:

Please Log in or Create an account to join the conversation.

More
28 Jan 2021 19:24 #196985 by PCW
Replied by PCW on topic How to change PWM Frequency?
Basically just the module and the pin name, but I just realized a limitation of the rcpwmgen
that may make it an issue, the maximum pulse width is ~10 ms, what is you maximum pulse width?

Please Log in or Create an account to join the conversation.

More
28 Jan 2021 19:31 #196988 by roland
Replied by roland on topic How to change PWM Frequency?
maximum pulse width is 6.2 ms

Please Log in or Create an account to join the conversation.

More
28 Jan 2021 19:47 #196990 by PCW
Replied by PCW on topic How to change PWM Frequency?
OK then it should work,
The new module line would be:

(RCPWMTag, x"00", ClockLowTag, x"01", RCPWMWidthAddr&PadT, RCPWMNumRegs, x"00", RCPWMMPBitMask),

and the new pin line would be:

IOPortTag & x"00" & RCPWMTag & RCPWMOutPin,

Please Log in or Create an account to join the conversation.

More
28 Jan 2021 20:52 #196992 by roland
Replied by roland on topic How to change PWM Frequency?
I was not able to generate the bitfile.
I get this error message:
ERROR:HDLCompiler:69 - "/home/ise/xilinx/7i92/PIN_7I76_7I85SD_RCPWM_SERVO_34.vhd" Line 82: <rcpwmtag> is not declared.
ERROR:HDLCompiler:69 - "/home/ise/xilinx/7i92/PIN_7I76_7I85SD_RCPWM_SERVO_34.vhd" Line 120: <rcpwmtag> is not declared.
ERROR:HDLCompiler:854 - "/home/ise/xilinx/7i92/PIN_7I76_7I85SD_RCPWM_SERVO_34.vhd" Line 72: Unit <pin_7i76_7i85sd_rcpwm_servo_34> ignored due to previous errors.

Can you support me a bit more?

File Attachment:

File Name: PIN_7I76_7....vhd.txt
File Size:10 KB
Attachments:

Please Log in or Create an account to join the conversation.

More
28 Jan 2021 21:57 #196995 by PCW
Replied by PCW on topic How to change PWM Frequency?
Sounds like you don't have the latest source

constant RCPWMTag : std_logic_vector(7 downto 0) := x"2C";
constant RCPWMOutPin : std_logic_vector(7 downto 0) := x"81";

are in the current IDROMConst.vhd
The following user(s) said Thank You: roland

Please Log in or Create an account to join the conversation.

Time to create page: 0.104 seconds
Powered by Kunena Forum