RC Driver
Python Library for PWM Driver, Power Monitor, ADC, Tachometer and PWM Decoder.
Python Library
Turta_RCDriver library is responsible for reading tachometer inputs, analog inputs, PWM decode results, PWM generation, LED lighting control, CPU fan control, reading CPU temperature and measuring battery Voltage.
Initialization
Add the following statement to the top of your Python code.
Then, create an instance of the RCDriver class.
Now you're ready to access the library by calling its instance.
Basic Members
Set PWM Pulse
Sets the PWM pulse length of selected channel at 60Hz.
Parameters
PWM_OUT ch: PWM Output channel.
Int pos: Pulse length. (-128 is 1000us, 0 is 1500us, 128 is 2000us.)
Returns
None
Set All PWM Pulses
Sets all PWM pulse lengths at 60Hz.
Parameters
Int[] pos: Pulse length. (-128 is 1000us, 0 is 1500us, 128 is 2000us), channels S, T, 3 and 4 respectively.
Returns
None
Set Fan Speed
Sets the fan speed.
Parameters
Byte speed: Fan speed. (0 to 100, 0 is off, 100 is full speed.)
Returns
None
Set PWM Pulse
Sets the PWM pulse length of selected channel at 60Hz.
Parameters
PWM_OUT ch: PWM Output channel.
Int pos: Pulse length. (-128 is 1000us, 0 is 1500us, 128 is 2000us.)
Returns
None
Set LED Brightness
Sets the brightness of the selected LED.
Parameters
LED_OUT led: LED channel.
Int b: LED brightness. (0 to 4095, 0 is off, 4095 is full bright.)
Returns
None
Set All LED Brightnesses
Sets the brightnesses of the LEDs.
Parameters
Int[] b: LED brightness. (0 to 4095.) Front, rear, stop, left and right respectively.
Returns
None
Set PWM Pulses Off
Sets controller PWM outputs off. (Steering, Throttle, Aux 3, Aux 4.)
Parameters
None
Returns
None
Set All LEDs Off
Sets all LEDs off.
Parameters
None
Returns
None
Read Battery Voltage
Reads the battery Voltage.
Parameters
None
Returns
Float: Battery Voltage.
Read PWM Pulse
Reads the pulse length of the selected PWM channel.
Parameters
PWM_IN ch: PWM Channel.
Returns
Int: Pulse length in microseconds.
Read All PWM Pulses
Reads the pulse length of the all PWM channels.
Parameters
None
Returns
Int[]: Pulse length in microseconds, channel S, T, 3 and 4 respectively.
Read Analog Input
Reads the analog input of the selected channel.
Parameters
ANALOG_IN ch: Analog input channel.
Returns
Int: 10-Bits analog value. (0 to 1023)
Read All Analog Inputs
Reads the analog inputs of all four channels.
Parameters
None
Returns
Int[]: 10-Bits analog value. (0 to 1023) Channel 1 to 4 respectively.
Read Tachometer Input
Reads the speed of vehicle using the selected tachometer input.
Parameters
TACH_IN ch: Tachometer channel.
Int ticks_per_rev: Ticks per revolution. (Default is 1.)
Int dia_cm: Diameter in cm. (Default none returns RPM.)
Bool mph: True for MPH, False for KMH output. Checked only if dia_cm is set. (Default is False.)
Returns
Float: Vehicle speed or RPM.
Read Both Tachometer Inputs
Reads the speed of vehicle using the tachometer inputs.
Parameters
Int ticks_per_rev: Ticks per revolution. (Default is 1.)
Int dia_cm: Diameter in cm. (Default none returns RPM.)
Bool mph: True for MPH, False for KMH output. Checked only if dia_cm is set. (Default is False.)
Returns
Float[]: Vehicle speed or RPM, left and right respectively.
Read CPU Temperature
Reads the temperature of the Raspberry Pi's CPU.
Parameters
None
Returns
Float: CPU Temperature.
Advanced Members
Test Microcontroller
Sends Who_Am_I command to the MCU, checks if it responses correctly.
Parameters
None
Returns
Bool: True if the device responses with 0xBD, False if not.
Finalizer
When exiting from the program, the library turns off all board functions. (Stops PWM generation, turns LEDs off, turns off LEDs.)
Last updated