I have been working on an interactive programming extension to Virtual Breadboard I call Touch Logic Control (TLC). The goal of TLC is to make programming as simple as recording your actions and playing them back as a storyboard program.
Here is a preview of TLC in action brilliantly narrated by my son! ( my video's are always so boring.. )
TLC supports all virtual programming but it's even more intuitive when configured to record actual button presses, accelerometer actions etc as programming events. Just like in the video.
Firmata for Arduino Form-Factor Record ModeI am planning to build a course based on the TLC allowing users to get started in tethered mode with their existing Arduino hardware along with a simple TLC Shield starter kit with basic IO for the first several lessons.
For Micro:Bit I rolled a simple custom serial protocol using the online mbed tools but for the Arduino form-factor board I decided to use the Firmata protocol as it's already so well supported..
After implementing the Firmata client in Virtual Breadboard and successfully testing with the Arduino Firmata host firmware I thought about increasing the number of possible boards that can be used with the TLC Shield starter kit so naturally I thought about the Netduino.
Did I mention there is plenty of support for Firmata in the Windows C# universe?
There is even a dedicated C# Firmata Client library in the Microsoft iot samples repository that is used in Windows Remote Arduino. Surely one of the most popular Hackster projects of all time.
So of course when I decided to support the Netduino I had assumed there would be a Firmata host implementation available. However, If it does I couldn't find it!
Firmata Host for NetduinoSince I had already implemented a Firmata client in C# on the Virtual Breadboard side I decided to go ahead and roll a C# Firmata host myself.
You can find my Firmata for Netduino repository here
It is broken into two assemblies Netduino.Firmata and VirtualBreadboard.NETMF
VirtualBreadboard.NETMF is hardware independent with Netduino.Firmata containing the hardware dependent implementations.
Running the HostAssuming you have a Netduino and have Visual Studio configured correctly you should be able to clone the repository and start the application. You might have to clean and rebuild first.
Once you load the project you should be able to launch by ensuring the Netduino.Firmata project is set as the StartUp project. When you launch it should launch into Main
public static void Main()
{
//Connecting to firmata test program
SerialPort comms = new SerialPort(SerialPorts.COM1, 57600, Parity.None, 8, StopBits.One);
comms.Open();
FirmataHost remoteIO = new FirmataHost(new SerialConnection(comms), new Netduino3Board(), FirmataHost.OUTPUT);
remoteIO.Start();
bool running = true;
while (running)
{
//Do other stuff..
Thread.Sleep(250); // sleep for 250ms
}
remoteIO.Start();
}
FirmataHost
is the class of interest and it runs as a background thread.
It takes 3 parameters.
- Connection
- Board
- DefaultPinMode
Connection
Provides the physical data transfer. Only SerialConnection
has been implemented but other Connections such as Ethernet or I2C would add interesting possibilities.
The SerialConnection
is itself initialised with a port and baud. To match the Arduino UNO COM1 on D0, D1 was used but others are possible. COM4 on SDA/SCL could be a good choice to free up pins D0, D1 for example.
Board
Provides the mappings to the pins and also is a provider of the RemotePin implementation. Only the Netduino3Board is available but adding new ones to represent different configurations is a natural next step.
DefaultPinMode
You can choose to assign pins to a default setting. Virtual Breadboard uses NC (not connected) but the firmata test client doesn't recognise this so a default alternate options was added.
Firmata Test ClientMost of my testing was done with the Virtual Breadboard client but Firmata.org provides some links to some basic test clients. I used firmata_test.exe for testing directly with a serial port.
The NetDuino is a 3V3 device so you need a USB:Serial device that has a 3V3 option.
Same as for the Arduino you hook up pins D0 (RX) and D1(TX) and GND. That's it!
Even better you might have a USB : Serial GoBus/Gadgeteer module handy so you don't have wires floating around.
Virtual Breadboard is a UWP App and so serial access is a bit tricky. This is because for security the App needs to declare explicitly which devices can be connected with. Also the USB connection must be a certain type of USB Serial connection. For example the popular FTDI devices are not recognised. Currently only 3 devices are directly supported. The two official Arduino UNO boards from arduino.cc and arduino.org are supported.
Also the Virtual Breadboard IO interface is supported as seen in the following video to connect Virtual Breadboard with our new Netduino Firmata host enabling interactive programming with TLC. Fun!
Future EnhancementsThe Arduino runs using Serial so matching this was the goal of the project. The Connection is abstract so it should prove fairly straightforward to add an Ethernet connection extending the possibilities further.
To make physical connections more robust a GO bus version of the VbbIO device would make a great addition to the Shield KIT for Netduino users.
Stay tuned for a more exhaustive writeup of TLC and interactive programming with Firmata powered Arduino or Netduino!
Comments