Pizero2.vent: Unterschied zwischen den Versionen

Aus OrgaMon Wiki
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 9: Zeile 9:


  # apt install pigpio
  # apt install pigpio
<code>
#
# KEMO M240
#  PWM Spannung: 3 V bis 24 V
#  PWM Frequenz: 100 Hz bis 10 kHz
#
# Raspberry Pi Zero
#  PWM0 Pin 18 xor 12, 3,3 V 1 kHz
#  PWM1 Pin 13 xor 19, 3,3 V 1 kHz
#
import pigpio
import time
import random
PWM_GPIO = 18
PWM_FREQUENCY = 1000
random.seed()
pi = pigpio.pi()
#
# Start Motor Full Speed for 4 Seconds
#
ret_code = pi.hardware_PWM(PWM_GPIO, PWM_FREQUENCY, 1000000)
print(ret_code)
time.sleep(4)
# print(pi.get_PWM_range(PWM_GPIO))
# print(pi.get_PWM_real_range(PWM_GPIO))
while True:
#pi.set_PWM_dutycycle(PWM_GPIO, 0)
percent = random.randint(0,100)
print("set motor to ", percent, " %")
pi.hardware_PWM(PWM_GPIO, PWM_FREQUENCY, percent * 10000)
time.sleep(15)
</code>

Version vom 30. September 2025, 19:34 Uhr

Boot

# /boot/firmware/config.txt

dtoverlay=pwm-2chan

pwm.py

# apt install pigpio

  1. KEMO M240
  2. PWM Spannung: 3 V bis 24 V
  3. PWM Frequenz: 100 Hz bis 10 kHz
  4. Raspberry Pi Zero
  5. PWM0 Pin 18 xor 12, 3,3 V 1 kHz
  6. PWM1 Pin 13 xor 19, 3,3 V 1 kHz

import pigpio import time import random

PWM_GPIO = 18 PWM_FREQUENCY = 1000

random.seed() pi = pigpio.pi()

  1. Start Motor Full Speed for 4 Seconds

ret_code = pi.hardware_PWM(PWM_GPIO, PWM_FREQUENCY, 1000000) print(ret_code) time.sleep(4)

  1. print(pi.get_PWM_range(PWM_GPIO))
  2. print(pi.get_PWM_real_range(PWM_GPIO))

while True:

#pi.set_PWM_dutycycle(PWM_GPIO, 0)
percent = random.randint(0,100)
print("set motor to ", percent, " %")
pi.hardware_PWM(PWM_GPIO, PWM_FREQUENCY, percent * 10000)
time.sleep(15)