k8055m_set_servor, k8055m_get_servo -- Control and query the pulse width and direction of a digital output port, that is in mode K8055M_DIGITAL_OUT_MODE_SERVO.
k8055-pic18f access library
#include "k8055m.h" int k8055m_set_servo(int cardNumber, int port, float pulseWidth, int pulseHigh); int k8055m_get_servo(int cardNumber, int port, float *pulseWidth, int *pulseHigh);
While a digital output port is set to K8055M_DIGITAL_OUT_MODE_SERVO, the K8055M
will continuously send PWM pulses to the port at a rate of 40 Hz. These pulses are
square wave patterns and their shape is controlled with k8055m_set_servo().
When pulseHigh is TRUE (1), the wave pattern will consist of a logical "0"
base, with logical "1" pulses at the corresponding PORTB output. Since the K8055M's
digital output ports are routed through a darlington transistor array, turning them
into open collector outputs, this is not the most desirable wave pattern. pulseHigh = FALSE
will produce the exact opposite wave pattern, which will allow for a very simple
connection of standard servos with just one pull up resistor per port and the K8055M
sharing common ground with the servo power supply.
The pulseWidth is specified as a floating point value in microseconds (µS).
Timer3, used in the firmware to measure timed events, is running with a 1:1 prescaler,
so the total resolution is 12 MHz. Taking possible interrupt latencies into account,
one can expect the pulse width emitted by the PIC to be within +/- 0.5 µS.
k8055m_set_servo() and k8055m_get_servo() return 0 on success, -1 on error. k8055m_get_servo() will leave the current servo settings in *pwmWidth and *pwmHigh on success.