8,367
edits
Changes
→PWM test method
# As can be seen from the following table, the available pwm are pwm1, pwm2, pwm3 and pwm4.
<div style="display: flex;">::{| class="wikitable" style="width:390px;margin-right: 20px;text-align: center;"
|-
| '''GPIO NO.'''
| '''Function'''
| '''Pin'''
|-| style="text-align: left;"|| style="text-align: left;"|| '''3.3V'''| '''1'''|-| '''264'''| '''PI8'''| '''TWI1-SDA'''| '''3'''|-| '''263'''| '''PI7'''| '''TWI1-SCL'''| '''5'''|-| '''<span style="color:#FF0000">269</span>'''| '''<span style="color:#FF0000">PI13</span>'''| '''<span style="color:#FF0000">PWM3</span>/UART4_TX'''| '''<span style="color:#FF0000">7</span>'''|-| style="text-align: left;"|| style="text-align: left;"|| '''GND'''| '''9'''|-| '''226'''| '''PH2'''| '''UART5_TX'''| '''11'''|-| '''227'''| '''PH3'''| '''UART5_RX'''| '''13'''|-| '''261'''| '''PI5'''| '''TWI0_SCL/UART2_TX'''| '''15'''|-| style="text-align: left;"|| style="text-align: left;"|| '''3.3V'''| '''17'''|-| '''231'''| '''PH7'''| '''SPI1_MOSI'''| '''19'''|-| '''232'''| '''PH8'''| '''SPI1_MISO'''| '''21'''|-| '''230'''| '''PH6'''| '''SPI1_CLK'''| '''23'''|-| style="text-align: left;"|| style="text-align: left;"|| '''GND'''| '''25'''|-| '''266'''| '''PI10'''| '''TWI2-SDA/UART3_RX'''| '''27'''|-| '''256'''| '''PI0'''| style="text-align: left;"|| '''29'''|-| '''271'''| '''PI15'''| style="text-align: left;"|| '''31'''|-| '''<span style="color:#FF0000">268</span>'''| '''<span style="color:#FF0000">PI12</span>'''| '''<span style="color:#FF0000">PWM2</span>'''| '''<span style="color:#FF0000">33</span>'''|-| '''258'''| '''PI2'''| style="text-align: left;"|| '''35'''|-| '''272'''| '''PI16'''| style="text-align: left;"|| '''37'''|-| style="text-align: left;"|| style="text-align: left;"|| '''GND'''| '''39'''|}{| class="wikitable" style="width:390px;margin-right: 20px;text-align: center;"|-
| '''Pin'''
| '''Function'''
| '''GPIO NO.'''
|-
| '''2'''
| '''5V'''
| style="text-align: left;"|
|-
| '''4'''
| '''5V'''
| style="text-align: left;"|
|-
| '''6'''
| '''GND'''
| style="text-align: left;"|
|-
| '''8'''
| '''UART0_TX'''
| '''224'''
|-
| '''10'''
| '''UART0_RX'''
| '''225'''
|-
| '''12'''
| style="text-align: left;"|
| '''257'''
|-
| '''14'''
| '''GND'''
| style="text-align: left;"|
|-
| '''261'''| '''PI5'''| '''TWI0_SCL<span style="color:#FF0000">16</UART2_TX'''| '''15'''|| '''16span>'''| '''<span style="color:#FF0000">PWM4</span>/UART4_RX'''| '''<span style="color:#FF0000">PI14</span>'''| '''<span style="color:#FF0000">270</span>'''
|-
| '''18'''
| style="text-align: left;"|
| '''228'''
|-
| '''20'''
| '''GND'''
| style="text-align: left;"|
|-
| '''22'''
| '''TWI0_SDA/UART2_RX'''
| '''262'''
|-
| '''24'''
| '''SPI1_CS0'''
| '''229'''
|-
| '''26'''
| '''SPI1_CS1'''
| '''233'''
|-
| '''28'''
| '''TWI2-SCL/UART3_TX'''
| '''265'''
|-
| '''30'''
| '''GND'''
| style="text-align: left;"|
|-
| '''271'''| '''PI15'''| <span style="text-aligncolor: left;#FF0000"|| '''31'''|| '''>32</span>'''| '''<span style="color:#FF0000">PWM1</span>'''| '''<span style="color:#FF0000">PI11</span>'''| '''<span style="color:#FF0000">267</span>'''
|-
| '''34'''
| '''GND'''
| style="text-align: left;"|
|-
| '''36'''
| style="text-align: left;"|
| '''76'''
|-
| '''38'''
| style="text-align: left;"|
| '''260'''
|-
| '''40'''
| style="text-align: left;"|
| '''259'''
|}
</div>
<ol start="2" style="list-style-type: decimal;">
<li><p>pwm is turned off by default in Linux systems and needs to be turned on manually to use it. The opening steps are as follows:</p>
<ol style="list-style-type: lower-alpha;">
<li><p>First run '''orangepi-config'''. Ordinary users remember to add > '''sudo''' permissions.</p>{| class="wikitable" style="width:800px;" |-| <p>orangepi@orangepi:~$ '''sudo orangepi-config'''</p>|}</li>
<li><p>Then select '''System'''</p>
<p>[[File:zero2w-img80.png]]</p></li>
<li><p>Then select '''Hardware'''</p>
<p>[[File:zero2w-img81.png]]</p></li>
<li><p>Then use the keyboard's arrow keys to locate the position shown > in the figure below, and then use the '''space''' to select the > configuration corresponding to the pwm you want to open.</p>
<p>[[File:zero2w-img176.png]]</p></li>
<li><p>Then select '''<Save>''' to save</p>
<li><p>Then select '''<Back>'''</p>
<p>[[File:zero2w-img84.png]]</p></li>
<li><p>Then select '''<Reboot>''' to restart the system to make the > configuration take effect.</p>
<p>[[File:zero2w-img85.png]]</p></li></ol>
</li>
<li><p>After restarting, you can start the PWM test</p>
{| class="wikitable" style="background-color:#ffffdc;width:800px;" |-| <big><p>'''Please execute the following commands under the root user.'''</p></big>|}
<ol style="list-style-type: lower-alpha;">
<li><p>Enter the following command on the command line to make pwm1 > output a 50Hz square wave</p>{| class="wikitable" style="width:800px;" |-|
<p>root@orangepi:~# '''echo 1 > /sys/class/pwm/pwmchip0/export'''</p>
<p>root@orangepi:~# '''echo 20000000 > /sys/class/pwm/pwmchip0/pwm1/period'''</p>
<p>root@orangepi:~# '''echo 1000000 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle'''</p>
<p>root@orangepi:~# '''echo 1 > /sys/class/pwm/pwmchip0/pwm1/enable'''</p>|}</li><li><p>Enter the following command on the command line to make pwm2 > output a 50Hz square wave</p></li></ol></li></ol>{| class="wikitable" style="width:800px;" |-|
root@orangepi:~# '''echo 2 > /sys/class/pwm/pwmchip0/export'''
root@orangepi:~# '''echo 1 > /sys/class/pwm/pwmchip0/pwm2/enable'''
|}</ol>
<ol start="3" style="list-style-type: lower-alpha;">
<li>Enter the following command on the command line to make pwm3 output > a 50Hz square wave</li></ol>{| class="wikitable" style="width:800px;" |-|
root@orangepi:~# '''echo 3 > /sys/class/pwm/pwmchip0/export'''
root@orangepi:~# '''echo 1 > /sys/class/pwm/pwmchip0/pwm3/enable'''
|}</ol>
<ol start="4" style="list-style-type: lower-alpha;">
<li>Enter the following command on the command line to make pwm4 output > a 50Hz square wave</li></ol>{| class="wikitable" style="width:800px;" |-|
root@orangepi:~# '''echo 4 > /sys/class/pwm/pwmchip0/export'''
root@orangepi:~# '''echo 1 > /sys/class/pwm/pwmchip0/pwm4/enable'''
|}
<div class="figure">
[[File:zero2w-img177.png]]
</div></ol></li></ol>
<span id="how-to-install-and-use-wiringop-python"></span>