本文整理汇总了Python中RPIO.PWM.get_channel_subcycle_time_us方法的典型用法代码示例。如果您正苦于以下问题:Python PWM.get_channel_subcycle_time_us方法的具体用法?Python PWM.get_channel_subcycle_time_us怎么用?Python PWM.get_channel_subcycle_time_us使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RPIO.PWM
的用法示例。
在下文中一共展示了PWM.get_channel_subcycle_time_us方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_velocity
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import get_channel_subcycle_time_us [as 别名]
def set_velocity(self,pwmotor,motor_id):
[pins,dma_ch] = self.motor_list[motor_id]
c = [0,0]
c[0] = PWM.get_channel_subcycle_time_us(dma_ch[0])/(100.0*PWM.get_pulse_incr_us()) #coefficient to convert duty to period
c[1] = PWM.get_channel_subcycle_time_us(dma_ch[1])/(100.0*PWM.get_pulse_incr_us()) #coefficient to convert duty to period
try:
PWM.clear_channel_gpio(dma_ch[0], pins[0])
PWM.clear_channel_gpio(dma_ch[1], pins[1])
except:
pass
if pwmotor>0:
PWM.add_channel_pulse(dma_ch[1],pins[1],0,0)
PWM.add_channel_pulse(dma_ch[0],pins[0],0,int(abs(pwmotor)*c[0]))
else:
PWM.add_channel_pulse(dma_ch[0],pins[0],0,0)
PWM.add_channel_pulse(dma_ch[1],pins[1],0,int(abs(pwmotor)*c[1]))
示例2: set_speed
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import get_channel_subcycle_time_us [as 别名]
def set_speed(pin, chan, speed, speed_0):
pulse_inc = PWM.get_pulse_incr_us()
cycle_dur = PWM.get_channel_subcycle_time_us(chan)
num_pulses = int(cycle_dur * speed / pulse_inc)
if speed >= 0.99:
num_pulses -= 1
PWM.add_channel_pulse(chan, pin, 0, num_pulses)
示例3: setW
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import get_channel_subcycle_time_us [as 别名]
def setW(self, W):
"Checks W% is between limits than sets it"
import RPIO.PWM as PWM
PW = 0
self.__W = W
if self.__W < self.__WMin:
self.__W = self.__WMin
if self.__W > self.__WMax:
self.__W = self.__WMax
#on time[us]/granularity[us]
PW = ((PWM.get_channel_subcycle_time_us(0) * self.__W)/100)/PWM.get_pulse_incr_us()
# Set servo to xxx us
if self.powered:
self.__IO.set_servo(self.__pin, PW)
示例4: print
# 需要导入模块: from RPIO import PWM [as 别名]
# 或者: from RPIO.PWM import get_channel_subcycle_time_us [as 别名]
if PWM.is_setup():
print ("setup canale ", i, "chiamato")
else:
print ("setup canale ", i, " NON chiamato")
try:
while True:
# LED per vedere se tutto funziona
for t in led_time:
for i in gpio_port:
RPIO.output(i, RPIO.HIGH)
sleep(t)
RPIO.output(i, RPIO.LOW)
sleep(t)
for d in canale_dma:
subcycle_T = PWM.get_channel_subcycle_time_us(d)
incr_T = PWM.get_pulse_incr_us()
print("CANALE ", d, "subcycle_T =", subcycle_T, "--- incr_T =", incr_T)
sleep(2)
# if PWM.is_setup(): #è stato fatto il setup d'inizializzazione
# granularity=granularity*10 #se sì: incremento la granularity
# PWM.setup(granularity,0) #rifaccio il setup
except KeyboardInterrupt:
pass
for i in canale_dma:
PWM.clear_channel(i)
PWM.clear_channel_gpio(i,gpio_port(i))
PWM.cleanup()
print "STOP!"
print "Ciao!"