Saturday, April 22, 2017

Nusbio - UART Api

Overview

The Nusbio v1 USB device which offers
  • 8 gpios with I2C and SPI support 
  • for Windows programmable in any .NET language
is based in the FTDI chip FT232RL. Therefore it can also be used as a UART or serial communication.
This also known as an FTDI friend and can be used to upload code on an Arduino compatible that do not have a UART chip on board like the
  • Diavolino from Evil Mad Scientist
  • Trinket Pro from Adafruit
  • Arduino Pro Mini


Extension

We used to sell the following extension which allows to connect some devices using the following UART pins: TX, RX, CTS,  RTS, VCC and GND.


In case you want to use the Nusbio's 8 GPIOs as USART communication here is the mapping.
  • GPIO 0 - RI
  • GPIO 1 - DSR
  • GPIO 2 - DTR
  • GPIO 3 - DCD
  • GPIO 4 - CTS
  • GPIO 5 - TX
  • GPIO 6 - RX
  • GPIO 7 - RTS
Remember that
  • The pin 8 is VCC and pin 9 is GROUND. 
  • Most Nusbio can be configured to be 5 volt or 3.3 volt

Activation

How do I use the Nusbio as a UART interface ?

Simply plug the device in the Windows machine and do not run any Nusbio code. Once plugged a COMX port should be available on the PC.
Use the general Serial Port class offered with your programming language

Sunday, April 2, 2017

Nusbio GPIO API

Overview


Nubsio is a Windows plug and play USB interface to connect your PC to the external world and control electronic devices with any .NET languages.

Nusbio offers:
  • 8 digital Input/Output pins (or GPIO) with support of the SPI and I2C protocols
  • 8 analog to digital pins (ADC, with the Analog or Sensor extension) 
programmable in any .NET languages


GPIO API


PinMode 

By default the GPIO pins are initialized as output. To change the direction of an GPIO pin, use the following methods from the Nusbio class.
public void SetPinMode(NusbioGpio pin, PinMode mode);
public void SetPinMode(int pin, PinMode mode);

// Sample 

var serialNumber = Nusbio.Detect();
using (var nusbio = new Nusbio(serialNumber: serialNumber))
{
    nusbio.SetPinMode(NusbioGpio.Gpio0, PinMode.Output); // Enum type syntax
    nusbio.SetPinMode(1, PinMode.InputPullUp); // Integer syntax
}

 
The nusbio.GPIOS property allow to access the 8 GPIO pins using the following interface.

public interface GpioPublicApiBase
{
    PinMode Mode { get; }
    string Name { get; }
    PinState PinState { get; }
    bool State { get; set; }

    PinState DigitalRead();
    void DigitalWrite(PinState on);
    void DigitalWrite(bool high);
    void High();
    void Low();
}

// Sample

var serialNumber = Nusbio.Detect();
using (var nusbio = new Nusbio(serialNumber: serialNumber))
{
    nusbio.SetPinMode(NusbioGpio.Gpio0, PinMode.Output); // Enum type syntax
    nusbio.SetPinMode(1, PinMode.InputPullUp); // Integer syntax

    // Turn gpio pin 0 on
    nusbio.GPIOS[NusbioGpio.Gpio0].DigitalWrite(PinState.High);
    nusbio.GPIOS[NusbioGpio.Gpio0].DigitalWrite(true);

    // Read the state for gpio 1
    var state = nusbio[1].DigitalRead();
    state = nusbio[1].DigitalReadDebounced();
}

Code Sample

For more information on using the GPIO pins in output mode see the following samples:
For more information on using the GPIO pins in input mode see the following samples: