<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>SIN WAVE GENERATION USING PWM DRIVER</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/65966/sin-wave-generation-using-pwm-driver</link><description>Hi i am using the nRF52dk and i am trying to control a bldc can anyone help me to guide in how i can generate a pwm to get a sin wave 
 best regards Nikolai</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 17 Sep 2020 08:00:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/65966/sin-wave-generation-using-pwm-driver" /><item><title>RE: SIN WAVE GENERATION USING PWM DRIVER</title><link>https://devzone.nordicsemi.com/thread/270000?ContentTypeID=1</link><pubDate>Thu, 17 Sep 2020 08:00:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:356e53ee-2ebf-4aa1-9506-02c9317c6eaa</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Each sample for each channel is a uint16_t, where bit number 15 represent the polarity of the pin and bits 14:0 represents the compare value of the PWM&amp;#39;s internal timer.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;See&amp;nbsp;&lt;a title="PWM" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/hardware_driver_pwm.html?cp=7_1_2_0_8"&gt;PWM&lt;/a&gt;&amp;nbsp;driver documentation,&amp;nbsp;&lt;a title="PWM driver" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrfx__pwm.html?cp=7_1_6_8_0_24_1"&gt;PWM driver&lt;/a&gt;&amp;nbsp;API,&amp;nbsp;&lt;a title="PWM HAL" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrf__pwm__hal.html?cp=7_1_6_8_0_24_2"&gt;PWM HAL&lt;/a&gt;&amp;nbsp;API, and&amp;nbsp;the &lt;a title="PWM Driver Example" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/pwm_hw_example.html?cp=7_1_4_6_24"&gt;PWM Driver Example&lt;/a&gt; in nrf5sdk_17\example\peripheral\pwm_driver.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;note that you need &amp;#39;individual&amp;#39; loading of channel samples.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SIN WAVE GENERATION USING PWM DRIVER</title><link>https://devzone.nordicsemi.com/thread/269832?ContentTypeID=1</link><pubDate>Wed, 16 Sep 2020 11:05:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:736b0b17-2eca-421d-87cd-fe2063d4933d</guid><dc:creator>NikTheNordicUser</dc:creator><description>&lt;p&gt;hi Haakonsh&lt;/p&gt;
&lt;p&gt;thank you for your very fast response.. would it be possible to provide me how it would look liike in the sequence values array functions as im still abit confused. thank you so much&lt;/p&gt;
&lt;p&gt;bes regards&lt;/p&gt;
&lt;p&gt;nikolai&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SIN WAVE GENERATION USING PWM DRIVER</title><link>https://devzone.nordicsemi.com/thread/269808?ContentTypeID=1</link><pubDate>Wed, 16 Sep 2020 09:43:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc4d9aff-3716-4a52-85a9-21e39423e595</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Use the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/pwm.html?cp=4_2_0_46#concept_pzc_1pw_nr"&gt;PWM — Pulse width modulation&lt;/a&gt;&amp;nbsp;peripheral, read the spec before you continue.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Generate PWM sequences with the sine wave equation, y(t) = A * sin(af*t +p) , where y is&amp;nbsp;the sequence value, A is the &lt;a title="  COUNTERTOP  " href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/pwm.html?cp=4_2_0_46_4_6#register.COUNTERTOP"&gt;COUNTERTOP&lt;/a&gt;&amp;nbsp;value, af is your angluar frequency, t is the period of the PWM peripheral, p is phase.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;t = u(x) = x * 1 / PWM frequency,&lt;span&gt;&amp;nbsp;where x is the sequence number. &lt;br /&gt;&lt;br /&gt;PWM frequency&amp;nbsp;=&amp;nbsp;PWM_CLK / 2^&lt;a title="  PRESCALER  " href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/pwm.html?cp=4_2_0_46_4_7#register.PRESCALER"&gt;PRESCALER&lt;/a&gt;&amp;nbsp;/ COUNTERTOP, where PWM_CLK is fixed at 16MHz.&lt;br /&gt;&lt;/span&gt;&lt;span&gt;&lt;br /&gt;A PRESCALER of 4(DIV_16) and COUNTERTOP of 100&amp;nbsp;gives a frequency of 10kHz: t(x) = x / (16MHz / 2^4 /100) = x / 10kHz. Note that the value of COUNTERTOP defines the PWM&amp;#39;s amplitude resolution.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Generate three sets of sequences with a phase offset of 2*pi/3 from the previous set.&lt;br /&gt;&lt;br /&gt;The angular frequency defines the advance of the motor == rpm, depending on the number of poles/steps in your motor you set the desired angular frequency to get the desired rpm of the motor.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Other settings:&lt;br /&gt;&lt;a title="  MODE  " href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/pwm.html?cp=4_2_0_46_4_5#register.MODE"&gt;MODE&lt;/a&gt;&amp;nbsp;= 0 // up&lt;br /&gt;&lt;a title="  DECODER  " href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/pwm.html?cp=4_2_0_46_4_8#register.DECODER"&gt;DECODER&lt;/a&gt;.LOAD = Individual //needed to load individual sequence samples&lt;br /&gt;DECODER.MODE = 0 // &lt;span&gt;SEQ[n].REFRESH is used to determine loading internal compare registers.&amp;nbsp;Amount of additional PWM periods between samples loaded into compare register (load every REFRESH.CNT+1 PWM periods)&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>