OpenVex
0.5.0
|
Functions | |
signed char | pwm_write (unsigned char port, signed char val) |
signed char | pwm_read (unsigned char port) |
signed char pwm_read | ( | unsigned char | port | ) |
Read the PWM value for the specified port from the txdata structure.
port | PWM port to read back. |
NOTE: This does not necessarily indicate the current power setting on the motor/servo. It simply reports the latest value written to this port via pwm_write(). See pwm_write() for details.
signed char pwm_write | ( | unsigned char | port, |
signed char | val | ||
) |
Write a PWM value to the specified port.
port | PWM port to write. |
val | PWM power/position values from -127 to 127. |
For motors, 0 means stop. For servos, 0 is the center position.
Changes made through this function will not take effect until controller_submit_data() is called.
On PIC-based controllers:
It will then take between 0 and 18.5 ms before the submitted data reaches the master processor which controls the motors.
To alter a motor/servo setting, the following must occur:
1. call pwm_write(). This only alters the next packet to be submitted.\n 2. call controller_submit_data(). This queues the altered packet for sending to the master processor.\n 3. The master processor interrupts the user processor every 18.5 ms to send sample data from the RC unit and retrieve the latest data queued by controller_submit_data(). Hence, motor setting will change between 0 and 18.5 ms after your code calls controller_submit_data().