Controlling switching frequency

Okay. thanks. Could you please check if these values are correct for 66:

33,33.516,34.032,34.548,35.064,35.58,36.096,36.612,37.128,37.644,38.16,38.676,39.192,39.708,
40.224,40.74,41.256,41.772,42.288,42.804,43.32,43.836,44.352,44.868,45.384,45.9,46.416,46.932,
47.448,47.964,48.48,48.996,49.512,50.028,50.544,51.06,51.576,52.092,52.608,53.124,53.64,54.156,
54.672,55.188,55.704,56.22,56.736,57.252,57.768,58.284,58.8,59.316,59.832,60.348,60.864,61.38,
61.896,62.412,62.928,63.444,63.96,64.476,64.992,65.508,64.992,64.476,63.96,63.444,62.928,62.412,
61.896,61.38,60.864,60.348,59.832,59.316,58.8,58.284,57.768,57.252,56.736,56.22,55.704,55.188,
54.672,54.156,53.64,53.124,52.608,52.092,51.576,51.06,50.544,50.028,49.512,48.996,48.48,47.964,
47.448,46.932,46.416,45.9,45.384,44.868,44.352,43.836,43.32,42.804,42.288,41.772,41.256,40.74,
40.224,39.708,39.192,38.676,38.16,37.644,37.128,36.612,36.096,35.58,35.064,34.548,34.032,33.516,
33,32.484,31.968,31.452,30.936,30.42,29.904,29.388,28.872,28.356,27.84,27.324,26.808,26.292,25.776,
25.26,24.744,24.228,23.712,23.196,22.68,22.164,21.648,21.132,20.616,20.1,19.584,19.068,18.552,18.036,
17.52,17.004,16.488,15.972,15.456,14.94,14.424,13.908,13.392,12.876,12.36,11.844,11.328,10.812,10.296,
9.78,9.264,8.748,8.232,7.716,7.2,6.684,6.168,5.652,5.136,4.62,4.104,3.588,3.072,2.556,2.04,1.524,1.008,
0.492,1.008,1.524,2.04,2.556,3.072,3.588,4.104,4.62,5.136,5.652,6.168,6.684,7.2,7.716,8.232,8.748,9.264,
9.78,10.296,10.812,11.328,11.844,12.36,12.876,13.392,13.908,14.424,14.94,15.456,15.972,16.488,17.004,17.52,
18.036,18.552,19.068,19.584,20.1,20.616,21.132,21.648,22.164,22.68,23.196,23.712,24.228,24.744,25.26,25.776,
26.292,26.808,27.324,27.84,28.356,28.872,29.388,29.904,30.42,30.936,31.452,31.968,32.484,33

Or should I round the numbers?

I would round the number to integers because the PWM value is an integer.

The values look reasonable: 33 to 66 to 33 to 0 to 33, representing 0 to 1 to 0 to -1 to 0. I didn't count them to be sure there were 256 numbers.

Okay. Is there any particular tool that you used for calculating the values and giving rounded values?

I used a spreadsheet. Zero through Seven across the top and 0 through 31 down column A. Then this formula in the top-left cell. Fill the left column down, then fill the other columns across.

=ROUND((SIN((($A2*8+B$1)/255) * 2 * PI()) + 1) * 49.5; 0)

The "+1" shifts the sin() up to the 0 to 2 range (from -1 to 1) and then you multiply by half the highest value (49.5 for a TOP of 99).

Thank you. The code worked perfectly

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.