cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with generating specific frequency of PWM using TIMER.

PBiał.1
Associate

Hello,

I'm currently preparing a program for steering a telescope at my University. Everything was working fine, until I started to have a problems with generating a specific frequency for one an axis. Generally, the problem is that I cannot set a specific counter period value in the code that would be updated. Surprisingly, everything works correctly in the same code fragment, when changing this value is inside the condition with the button (for speed corrections), but in the "else" condition, which is used to return the telescope to a given specific speed, for example 1065Hz, it no longer works. The change occurs only when I press the button or when I change the counter period value to a significantly different one, for example from 1000 to 500. Then I see on the oscilloscope that the frequency has doubled. When changing from 1000 to 900, nothing changes, it is still exactly 1000Hz. Below is a piece of code that I am unable to cope with. It really seems incredibly strange to me that I can set any counter period in the part where I press the "slewing HA+" and "slewing HA-" buttons and it actually affects the frequency change very accurately, and when it is below in else it is a huge change in this frequency. variable increases the frequency. Thank you for your help, if I need any more information, I will write back as soon as possible.

Best regards,

Paweł

0 REPLIES 0