Classes | |
| class | MotorDriver |
| A motor driver designed to work with an H-bridge connected to a Nucleo L476RG running Micropython. More... | |
Variables | |
| pin_nSLEEP = pyb.Pin(pyb.Pin.cpu.A15, pyb.Pin.OUT_PP) | |
| The pin object used for the H-bridge sleep pin. More... | |
| pin_nFAULT = pyb.Pin(pyb.Pin.board.PC13, pyb.Pin.IN) | |
| The pin object used for the motor driver fault pin. More... | |
| pin_IN1 = pyb.Pin(pyb.Pin.cpu.B4) | |
| The pin object used for the Motor 1's H-bridge input 1. More... | |
| pin_IN2 = pyb.Pin(pyb.Pin.cpu.B5) | |
| The pin object used for the Motor 1's H-bridge input 2. More... | |
| pin_IN3 = pyb.Pin(pyb.Pin.cpu.B0) | |
| The pin object used for the Motor 2's H-bridge input 1. More... | |
| pin_IN4 = pyb.Pin(pyb.Pin.cpu.B1) | |
| The pin object used for the Motor 2's H-bridge input 2. More... | |
| tim = pyb.Timer(3,freq=20000); | |
| The timer object used for PWM generation. More... | |
| m1 = MotorDriver(pin_nSLEEP, pin_nFAULT, pin_IN1, 1, pin_IN2, 2, tim, dead_band=(-28,28), debug=True, primary=True) | |
| A motor object passing in the pins and timer. More... | |
| m2 = MotorDriver(pin_nSLEEP, pin_nFAULT, pin_IN3, 3, pin_IN4, 4, tim, dead_band=(-25,25)) | |
| A second motor object passing in the pins and timer. More... | |
| test_type = input('Running test, time test, motion test, fault test? (r/t/m/f): ') | |
| The test type used (running or timed) More... | |
| test_mot = input('Which motor? (A/B): ') | |
| The motor selection for testing. More... | |
| start = utime.ticks_us() | |
| stop = utime.ticks_us() | |
| run_time = utime.ticks_diff(stop,start) | |
| duty = input('Enter a duty percentage (0-100) \n') | |
| m_driver.duty = input('Enter a duty percentage (0-100) \n') |
| m_driver.m1 = MotorDriver(pin_nSLEEP, pin_nFAULT, pin_IN1, 1, pin_IN2, 2, tim, dead_band=(-28,28), debug=True, primary=True) |
A motor object passing in the pins and timer.
| m_driver.m2 = MotorDriver(pin_nSLEEP, pin_nFAULT, pin_IN3, 3, pin_IN4, 4, tim, dead_band=(-25,25)) |
A second motor object passing in the pins and timer.
| m_driver.pin_IN1 = pyb.Pin(pyb.Pin.cpu.B4) |
The pin object used for the Motor 1's H-bridge input 1.
| m_driver.pin_IN2 = pyb.Pin(pyb.Pin.cpu.B5) |
The pin object used for the Motor 1's H-bridge input 2.
| m_driver.pin_IN3 = pyb.Pin(pyb.Pin.cpu.B0) |
The pin object used for the Motor 2's H-bridge input 1.
| m_driver.pin_IN4 = pyb.Pin(pyb.Pin.cpu.B1) |
The pin object used for the Motor 2's H-bridge input 2.
| m_driver.pin_nFAULT = pyb.Pin(pyb.Pin.board.PC13, pyb.Pin.IN) |
The pin object used for the motor driver fault pin.
Here the user-button is used to simulate a fault for testing behavior.
| m_driver.pin_nSLEEP = pyb.Pin(pyb.Pin.cpu.A15, pyb.Pin.OUT_PP) |
The pin object used for the H-bridge sleep pin.
| m_driver.start = utime.ticks_us() |
| m_driver.stop = utime.ticks_us() |
| m_driver.test_mot = input('Which motor? (A/B): ') |
The motor selection for testing.
| m_driver.test_type = input('Running test, time test, motion test, fault test? (r/t/m/f): ') |
The test type used (running or timed)
| m_driver.tim = pyb.Timer(3,freq=20000); |
The timer object used for PWM generation.