Sunday, May 22, 2016

Controller Extension Tutorial - Part II

Overview

You can read part I at of this post at Controller Extension Tutorial - Part I.

Beyond 5 volt

Some devices will require 8 or 12 volt, therefore we offer a second extension which allow to plug an external source of power like a 9 volt battery.
Both extension use the transistor 2N3904 which support 12 volt, but the current is still limited to 200 mA per external device controlled.

Beyond the USB 500 milliamp


Note that if each device controlled are 5 volts but require 200 mA each, we cannot use the USB to provide the 600 mA. USB 2.0 only allow to consume 500 mA. In this case we need a 5 volt power adapter providing 600 mA or more.


The extension is configured to use an external source of power by default. But we can revert it back to use the USB power, by de-soldering the connection EX_PWR_ON and solder the connection USB_PWR_ON.

Connecting all the pieces

Now, we have 4 items
  1. The Nusbio board
  2. The Controller Extension
  3. The 9 volts lamp
  4. An external source of power, here a 9 volt battery

Plug the extension into Nusbio and
  • The black wire from the device must be plugged into the G0 pin (Ground 0)
  • The red wire from the device must be plugged into the V0 pin (VCC 0, in short VCC mean +)
  • The black wire or negative from the battery into the EX_POWER_PIN negative pin
  • The red wire or positive from the battery into the EX_POWER_PIN positive pin



Programming

The change of voltage  from 5 to 9 volt does not affect the programming.
The shortest code would look like this and will turn on the device for 500 ms and turn it off for another 500 ms.

var serialNumber = Nusbio.Detect();
if (serialNumber == null) // Detect the first Nusbio available
{
    Console.WriteLine("Nusbio not detected"); return;
}
using (var nusbio = new Nusbio(serialNumber)
{
    while(true) {
        nusbio.GPIOS[NusbioGpio.Gpio0].DigitalWrite(true);
        Thread.Sleep(500);
        nusbio.GPIOS[NusbioGpio.Gpio0].DigitalWrite(false);
        Thread.Sleep(500);
    }
}

To learn more

  Transistor Crash Course For Software Developer - PART I - Transistor As Switch  
  Measuring Current with a Digital Multimeter
  YouTube is your friend, if you want to learn electricity

No comments:

Post a Comment