.Net Core Library to use with the Servo PWM Pi Raspberry Pi development boards.
Downloading and Installing the .Net Core Libraries
Download the zip archive containing the code demos and libaries from GitHub.
Servo Pi Methods:
Connect()
Connect to the I2C device
Parameters: none
Returns: null
IsConnected()
Check if the device is connected
Parameters: none
Returns: boolean
Dispose()
Dispose of the active I2C device
Parameters: none
Returns: null
SetPWMFreqency(freq)
Set the output frequency of all PWM channels.
The output frequency is programmable from a typical 40Hz to 1000Hz.
Parameters: freq - Integer frequency value
Returns: null
SetPWM(byte channel, short on, short off)
Set the PWM output on a single channel
Parameters: channel - 1 to 16, on - period 0 to 4095, off - period 0 to 4095
Returns: null
SetPWMOnTime(byte channel, short on)
Set the output on time on a single channel
Parameters: channel - 1 to 16, on - period 0 to 4095
Returns: null
SetPWMOnTime(byte channel, short off)
Set the output off time on a single channel
Parameters: channel - 1 to 16, off - period 0 to 4095
Returns: null
SetAllPwm( on, off)
Set the output on all channels
Parameters: on - period 0 to 4095, off - period 0 to 4095
Returns: null
OutputEnable()
Enable the output via the OE pin. Only used when the OE jumper is joined.
Parameters: null
Returns: null
OutputDisable()
Disable the output via the OE pin. Only used when the OE jumper is joined.
Parameters: null
Returns: null
SetAllCallAddress(byte address)
The All Call Address allows all Servo Pi devices on the I2C bus to be controlled at the same time.
Parameters: address - 0x03 to 0x77
Returns: null
EnableAllCallAddress()
Enable the I2C address for the All Call function.
Returns: null
DisableAllCallAddress()
Disable the I2C address for the All Call function.
Returns: null
Servo Pi Parameters
byte Address { get; set; }
I2C address for the Servo Pi bus.
bool InvertOutput { get; set; }
Invert the PWM output on all channels.
true = invert, false = normal.
byte OutputEnablePin { get; set; }
Set the GPIO pin for the output-enable function.
The default GPIO pin 4 is not supported in .net Core so the OE pad will need to be connected to a different GPIO pin.
bool Sleep { get; set; }
Sets or gets the sleep status for the Servo Pi.
Set true to put the device into a sleep state or false to wake the device.
Get true = sleeping, false = awake.
Servo Pi Usage
To use the ServoPi Pi library in your code you must first import the library DLL:
using ABElectronicsUK;
Next, you must initialise the ServoPi class:
ABElectronicsUK.ServoPi servo = new ABElectronicsUK.ServoPi(0x40);
The argument is the I2C addresses of the Servo Pi chip.
Next, we need to connect to the device and wait for the connection
servo.Connect();
while (!servo.IsConnected){}
Set the PWM frequency to 60 Hz and enable the output
servo.SetPWMFreqency(60);
Optional
You can set the enable pin to use the output enable functions and enable or disable the output. The default GPIO pin 4 is not supported in Windows 10 IOT and so the OE pad will need to be connected to a different GPIO pin to use this functionality.
servo.OutputEnablePin = 17; // set to GPIO pin 17
servo.OutputEnable();
Move the servo to a position and exit the application.
servo.SetPWM(1, 0, 300);