Ejemplo n.º 1
0
 def __init__(self):
     self.motorA= motor(16, 38,  0, 0)
     self.motorB= motor(20, 39,  1, 1)
     self.motorC= motor(22, 18,  2, 2)
     self.motorD= motor(42, 17,  3, 3)
     
     self.encoderA=encoder(5, 6)
     self.encoderB=encoder(7, 8)
     self.encoderC=encoder(11, 10)
     self.encoderD=encoder(12, 13)
Ejemplo n.º 2
0
# ch = tim.channel(3, Timer.PWM, pin=buzzer)
# ch.pulse_width_percent(90)
# utime.sleep(0.5)
# ch.pulse_width_percent(0)
# utime.sleep(0.5)
# ch.pulse_width_percent(90)
# utime.sleep(0.5)
# ch.pulse_width_percent(0)
# utime.sleep(0.5)

# Set up motorA
DIRA = "X7"
PWMA = "X8"
TIMA = 14
CHANA = 1
motorA = motor_class.motor(PWMA, DIRA, TIMA, CHANA)

# Set up motorB
DIRB = "Y4"
PWMB = "Y3"
TIMB = 10
CHANB = 1
motorB = motor_class.motor(PWMB, DIRB, TIMB, CHANB)

# Set up encoder timers
pin_a = pyb.Pin("X1", pyb.Pin.AF_PP, pull=pyb.Pin.PULL_NONE, af=pyb.Pin.AF1_TIM2)

pin_b = pyb.Pin("X2", pyb.Pin.AF_PP, pull=pyb.Pin.PULL_NONE, af=pyb.Pin.AF1_TIM2)

pin_c = pyb.Pin("X9", pyb.Pin.AF_PP, pull=pyb.Pin.PULL_NONE, af=pyb.Pin.AF2_TIM4)
Ejemplo n.º 3
0
# ch.pulse_width_percent(0)

# while gps_uart.any() >= 0:
#     my_gps.update(chr(gps_uart.readchar()))
#     print('No GPS signal!!!\n')
#     xbee_uart.write('No GPS signal!!!\n')
#     print(my_gps.latitude)
#     if my_gps.latitude[0] != 0:
#         break

# Set up motorA
DIRA = 'X7'
PWMA = 'X8'
TIMA = 14
CHANA = 1
motorA = motor_class.motor(PWMA, DIRA, TIMA, CHANA)

# Set up motorB
DIRB = 'Y4'
PWMB = 'Y3'
TIMB = 10
CHANB = 1
motorB = motor_class.motor(PWMB, DIRB, TIMB, CHANB)

# Set up encoder timers
pin_a = pyb.Pin('X1',
                pyb.Pin.AF_PP,
                pull=pyb.Pin.PULL_NONE,
                af=pyb.Pin.AF1_TIM2)

pin_b = pyb.Pin('X2',
Ejemplo n.º 4
0
import motor_class
import RPi.GPIO as GPIO
import time 

GPIO.setwarnings(False)
Motor = motor_class.motor(5,6,13)

print("motor run")
Motor.go(100)
time.sleep(3)
print("motor stop")
Motor.stop()
time.sleep(3)

GPIO.cleanup()
Ejemplo n.º 5
0
#walking_test.py
#Created:4/10/2017
# -Joseph Fuentes
# [email protected]
from motor_class import motor, encoder
A = motor('P10', 'P11', 0, 0)
B = encoder('P22', 'P21')
B.reset_count()
while True:

    B.trigger('CW')
    A.PHpin(1)
    A.change_speed(0.4)
    if abs(B.count) == 10250:
        del B.count
        A.change_speed(0)
        B.reset_count()
        break