Showing posts with label Netduino. Show all posts
Showing posts with label Netduino. Show all posts

Tuesday, April 15, 2014

Controlling a Netduino Robot with BlueTooth

For our April meeting, we will be controlling our Home-Built robot with a Windows Phone device, this should fun so hang on!

We will be using this Bluetooth Module

http://www.amazon.com/Arduino-Wireless-Bluetooth-Transceiver-Module/dp/B0093XAV4U/ref=sr_1_1?ie=UTF8&qid=1395938505&sr=8-1&keywords=Bluetooth+module

And the following USB Serial Port Adapter

http://www.amazon.com/SunFounder-Arduino-Program-Download-Mega2560/dp/B00GD6GE6O/ref=sr_1_10?ie=UTF8&qid=1395938602&sr=8-10&keywords=USB+232

First thing we need to do is configure our BlueTooth Module.

1) Power your Bluetooth Module with your Netduino

VCC –> +5V (Netduino)
GND –> GND (Netduino)

image

2) Connect your BlueTooth module to your FTDI Serial Adapter

FTDI  Netduino   BlueTooth Module
GND   GND
TX                          RX
RX                          TX

3)  Open up Device Manager, and identify the serial port that is associated with your FTDI adapter, in my case it’s COM16, yours will probably be something like COM4.  A good way to identify your adapter is to unplug, then plug it back in.  The one that disappears and reappears is probably the one you want to look at.
image

3) Download and start RealTerm

4) Configure the initial baud rate of 9600 on the “Port” tab, then press “Change” and “Open”

image

5) Confirm that your port is open and the correct baud rate is set at the bottom of the screen

image

6) If all that looks good, then we can start to configure our BlueTooth module, commands need to be sent very quickly.  The best way to do this is open up Notepad or some other mechanism where you can enter text and then cut and paste it.

a) Open Notepad
b) Type AT
c) Copy those two characters on to the clip board by highlighting them and hit CTRL-C
b) Right mouse click in the terminal area in RealTerm, and click on “Paste to Port”
c) If all goes well you should see OK

image

7) Once you know you are connected, enter the text AT+NAMEXXXXXX in notepad, where XXXXX is the name how you want to identify the bluetooth device.  No CRLF at the end.   Then copy those characters and paste them into RealTerm.

8) Then set the PIN by doing the same thing with AT+PINXXXX where XXXX is the 4 digit PIN used to pair with the device. IMPORTANT NOTE: If you use a PIN code like 1234, or 0000 your phone may try to auto-pair with that value.  To get it to work successfully in your app you will need to enter a more non-traditional code, and then manually enter the PIN code via BlueTooth settings.

9) Once you have completed your screen should look very similar to the following.  Your settings will automatically be saved to the device and you can continue by connecting it to your Netduino.

image

Connect the BlueTooth module to Netduino

10) Now you need to connect your BlueTooth module to your Netduino, you can remove the wires from the USB FDTI and connect them to the Netduino.  See PDF here for a better view of your Netduino

BlueTooth Module  Netduino COM1
RX                              PIN 1 (TX) - D1
TX                              PIN 0 (RX) – D0
VCC                           +5V (from before)
GND                           GND (from before)

11) Next up is to connect to your BlueTooth device from your Windows Phone 8.  You will have to use an actual device, not a simulator.  Hopefully you know how to do this, but click on Settings->BlueTooth, make sure it’s turn on, and find the name of your bluetooth module.  Make sure you enter a PIN code, if it automatically pairs you may have used a known PIN such as 0000 or 1234, try something different in step #8 above.

12 After you have paired your device, download the following Windows Phone 8 application and make sure you can compile it and run it on your device.  Make sure you change the name of the device in MainPage.xaml.cs to match the name of our BlueTooth Device

image

13) Then download the .cs file that has the code, to insert into your .NET Microframeworks project, the code is very straight forward, just cut and paste the appropriate parts into your application.  Also, just populate the code in your project to make the inputs from your phone actually do something.

 

At this point, your little app should be ready to run!

image

 

14) Next download the Windows Phone 8 project.

Enjoy

-twb

Wednesday, August 28, 2013

QuadCopter with Win8 Flight Console Talk

On August 27, 2013, I presented NiVek QC with a Windows 8 Flight Console to the Tampa Bay Robotics and Microcontroller Group.

As promised here are the materials and links.

Mounts were 3D Printed with my Afinia H-Series 3D Printer, but the Arms where from this FlameWheel kit.

Although the Windows 8 Console was built with Visual Studio .NET premium, Windows 8 Apps can be built with VS Express editions that can be downloaded for free.

The .NET equivalent to the Arudino, programmable in C# is the Netduino, they are pretty cheap and easy to get started with.  If you’re a .NET programmer and want to get started playing with hardware, this is a great place to start!

A great source of information and forums is located at the DIY Drones web site.  In addition parts and supplies can be purchased from the 3D Robotics store, I generally get most of my parts from Hobby King (they have a USA warehouse, otherwise shipping from Hong Kong is a week or two.

Finally if you don’t want to start from scratch and spend countless hours and probably thousands of dollars on parts, there are some off the shelf quad copters I can recommend.  The AR Drone 2 is a lot more than I had expected, it’s actually some very serious hardware.  You need to get some additional parts like Motors, ECS’s and a frame, but for a flight controller, you can pickup an Ardupilot APM for relatively cheap.  The firmware can be customized relatively easy.

Hope this gets you going and be sure to let me know if you get something up in the air (or have some awesome crashes in the process).

-twb

Sunday, July 7, 2013

Fermenting Beer with a Netduino, Electric IMP and a Windows 8 App

After my new years resolution, I’ve brewed up a number of batches of beer (primarily IPA’s)WP_20130315_001 for my kegerator. Most turned out relatively good but as summer arrived in Florida it was a little difficult to keep my wort at around 70 degrees during the fermentation process. 

So I ended up investing in a freezer from Lowes for about $200 and added custom controller built from an Electric IMP, Netudino that  uploads data to a cool service called Xively.

The freezer will maintain a consistent temperature of 70 +/-1 degree, perfect for fermenting most ales. 

Here’s a screen capture from my LagoVista home automation app that shows a live capture at 30 second intervals as to the temperature in my fermenter.

wp_ss_20130604_0001

And here’s some pix on the actual controller and unit itself, note the “up-to-code” wiring SmileSomeday I might get around to putting some sort of enclosure around this.

 

WP_20130708_003

This is inside the fermentation chamber.  Note the little gray wire, that has a thermistor on the end that provide variable resistor output where we can measure the voltage and determine the temperature.

WP_20130708_004

If you’d like more info as to how to build one of these things yourself, drop me an email at kevinw@slsys.net.

As an added bonus my controller was a few feet away from my HVAC unit in the garage so I added a couple extra thermistors to to monitor the incoming and outgoing temperatures for the cooling unit. The full feed can be viewed here

https://xively.com/develop/XXKkf_vy-StrfD_YGml7

-twb

Wednesday, January 9, 2013

NiVek GO! QC3 – Status Update

I know it’s been a while since my last status update, but my free time is getting ever so scarce.  I think I can see the light at the end of the tunnel though.  I’ve came a long way since my measly little STM8S103 with a tiny bit of RAM and ROM and I’ve settled on the mighty SMT32F405.  This chip runs at 168Mhz, has tons of RAM and ROM and even has an FPU so I’m no longer scared into using fixed point math everywhere.

This chip is so powerful, my ultimate goal is to lay in a NETMF layer on top of the native C code controlling the Quad Copter.  Also, least we forget the initial early versions that were Netduino GO! modules, this board will also act as a GO! module as well.  One that itself is programmable via NETMF.  So bottom line is my current hardware platform will support the following configurations:

  • Stand-Alone, with either an RC Controller, a Windows Phone 8 or Windows 8 Front End.
  • Stand-Alone, but programmable in C# and controllable with RC/WP8/Windows 8
  • As a C# programmable GO! module with any of the features above.

This platform should provide a very interesting starting point to allow folks that don’t want to get in the mud of low level C and assembler programming the ability to highly customize the software.

In addition as you can see in the picture, I’ve came up with more options for telemetry.  This one uses a 900MHz radio to get get distance of 1KM+.  The other options available are WiFi, Bluetooth and XBee. 

image

Some additional “cool” things I’ve added to this new firmware:

  • Utilization of the FPU, this thing is FAST, and it also is really nice to work in float rather than scaled decimal for all the calculations.  It really cleans up the code
  • All the I2C communications with the sensors can be either sync or async.  In most cases in the past pulling the data from the sensors consisted of about 300-400 uSeconds of I2C communications followed by another 100 - 200 uSeconds seconds of processing. With the async and FPU, this went down to no time at all for the I2C transfer and usually 10-50 uSeconds.  I know a uSecond doesn’t sound like a very long time, but when you do things 200-400 times a second, well it adds up.
  • Using built in sensors FiFo (First-In, First-Out) buffers to really speed up the sample rate for the gyros and accelerometers.  These are now sampled at about 800Hz and the data pulled and processed at 200Hz.  This means each time the data is pulled we pull four samples.  This is why the async process for reading all those bytes via I2C is important.
  • I had another important realization for using the Gyros.  The Gyros read the rate of rotation, not the absolute angle/rotation, therefore the gyros outputs need to be integrated over time to get a good estimate.  In my prior version, I was maintaining the deltaT or time interval used for the integrator, this was even using a scaled decimal approach.  Basically use a timer to find the time between readings and use that as part of the integration.  With this version, I’m just using the sample rate from the gyro, that is to say if that device is internally reading values at 200Hz, my period for integration will always be 5ms, it will always be 5ms.  With an IRQ coming in, I can ensure I always can get a sample.  This is even more important with the FIFO.
  • Implemented the PID controller for all four things I care about, pitch, roll, heading and altitude.
  • Implemented a very clean complementary filter that is 100% configurable via the flight console in Windows 8
  • Implemented a generic filter method that can be configured on via the flight console to filter as either an LPF, Mean, or Moving Average.  This worked out really nice and can be used on any measurement in the sytem.
  • Almost everything in the application is considered a “sensor”.  Each sensor has a set of function pointers for different things like Start, Stop, Process, Init, etc.  Each sensor can also be configured with a sample rate.  This means each “sensor” can be treated as an abstract item that can be configured in a common way.  It’s really do some OO things in low level C.

Anyway, time to stop writing about software and continue to writing the software.  I’ve got everything I need coded, now it’s just time to desk-check everything and see if this thing actually flies.

Stay Tuned!

-twb

Monday, December 10, 2012

Netduino Serial Demo Sample

Last month we ran out of time in our meeting before I could finish up my serial data demo.  At that time I promised to get some sample code out there…all I can say is I’ve been very busy and better late than never.

The demo program I created which was called SerialIODemo is a very simple mechanism to send commands and arguments from the desktop down to the Netduino via a via a FTDI USB Serial port.

Connecting the two is very simple, just run wires as follows

BLACK  FTDI->GND to Netduino GND
GREEN FTDI->TXD to Netduino 0 (On the Digital I/O bank)
YELLOW  FTDI->RXD to Neduino 1 (On the Digital I/O bank)

Then of course you’ll need to connect both of these to your computer via USB.  The following picture should give you a good idea of how this should look.  Note the green wire is in the pin closes to end of the connector.

image

Fully Connected

image

Connection to FTDI

image

image

Connections on Netduino

After you have made your connections and plugged in the USB connections to your computer, you’ll need to check the Serial Port the FTDI is connected to. this can be done via the Device Manager under ports.  In my case, I’m on COM1

image

You’ll need to modify the code to connect to this port (TODO: Could have this configurable through the UI).  This needs to be done in MainWindows.xaml.cs in the DesktopApp project

image

Once you’ve done this you should be ready to go!

To use the app, simply make sure both programs start.  This can easily be done by right mouse clicking on the solution node SerialIODemo and setting both projects to startup.

image

Now start your program, give the Netduino a few seconds to warm up and press Connect.  When you do so, the Netduino should respond back as in the screen below.  If you don’t see this give the Netduino a little longer to start.

image

Extending the App

The idea behind this application is to invoke different commands by sending a string from the computer to the device.  The string will be in the format “command=arg”.  A switch statement in the device code will handle different commands and the args can be used to make those commands work with different “stuff” on the device.

image

image

image

Hope this gets you started on controlling your Netduino with your computer!

-twb

December Tampa Bay NETMF Meeting and Hackathon

When: Meeting - December 20, 6PM-8PM, Hackathon December 21st, 9AM-?
Where: Tampa Microsoft Office, 5426 Bay Center Dr. Suite 700, Tampa FL, 33609

Monthly Membership Meeting

This December we are going to turn our focus to having your small embedded device such as a Netduino communicate to the the Internet.  We will also be looking at the Electric IMP.  Something on the very cutting edge, but also something very cool!

This months geek shopping list

1) Electric Imp and Dev Breakout Board
2) Netduino Plus 2 or Ethernet Shield (Ethernet Shield will attach to your standard Netduino and will require a bit of hacking to get working.  We probably won’t be covering this in our meeting)
3) WiFly and XBee Shield add WiFi to your Netduino, again we won’t be covering this in the meeting but isn’t that difficult to connect and configure.  I’d be happy to answer any questions on this via Email.
4) Pen Type Multi-Meter really helpful once you really start getting into this stuff.

To register for this event, please click here.

NETMF Hackathon

In addition, as a bonus this year, Bill Reiss and I are going to be hosting the Tampa Winter Games and NETMF Hackathon all day on Friday December 21st at the Microsoft office in Tampa.  As we have seen in our nightly meetings, two hours is just enough time to get started with this stuff.  Why not make a full day of it and hang out with some like minded folks getting your “geek" on.  The format will be a couple of talks to kick the day off, you’ll get to hear Bill (great speaker!) get you going on developing games on the Microsoft imagePlatform.  I’ll also give a brief talk on something cool that runs on a very small processor.  Then throughout the day, we’ll have a series of lighting talks to cover small bits and pieces of both gaming and microelectronics.  The primary intent of these events are really just to hang out and work on some cool stuff, along with your peers that might be able to help you if you get stuck on certain areas.  I’ll probably be working on my NiVek QC1 along with some cool new 32 bit hardware and my Windows 8 Ground Station. 

I’ll bring my collection of Netduino Shields and other assorted electronics for folks to play with.

To register for this event click here.

Both events should be a blast, hope to see you there! 

-twb

Saturday, November 10, 2012

NiVek GO! QC1 – Part 6, New MCU

Since my last update about 1 1/2 month ago work client work has been extremely busy, I’ve spent a good chunk of time getting a high-end Windows 8 application ready to submit to the marketplace.  Oh and I spent a week out in Redmond at Build 2012.  Needless to say my “hobby” of building a quad copter suffered from lack of attention.

Since my last update, I did however undertake a major shift in technology.  I went from using three STM8S 8 bit micro controllers to one STM32F0 32 bit micro controller.  In a nut shell my software was working great about 99.999% of the time, however for this type of application, it really needs to be 100%.  Even a failure 1 out of every 100,000 times could be very dangerous with the sharp propellers and uncontrolled flight.  100,000 seems like a pretty high number but considering my flight control loop operates at 200 times a second, it does happen.  I think the problem is that my inter-processor communications was just to chatty, I had considerable amount of code firing and handling messages between the micro-controllers and the .NETMF host.  The communications state machines handling these messages ended up being fairly complex and very timing critical.  To achieve a 200Hz update rate, we needed to have very fast SPI communications.  To achieve very fast SPI communications the interrupt handlers needed to be very efficient.  At one point I was troubleshooting using my data analyzer and measuring the microseconds required to process the data, there just wasn’t much breathing room between bytes.

So enter new hardware and an STM32FO.  My initial prototype board also has an STM32F4 on it.  The idea is to implement the GO! Bus protocol V1.5 and have a fully functional GO! module that is self contained and performs all the functions required to maintain stable flight on the quad copter.  Then periodically send state information such as position, time, pitch, roll, heading back to the GO! main board to allow for creating command and control functionality in C# and NetMF.  This was the primary goal, but in the original three STM8S architecture, the GO! main board primarily acted as a message forwarder.

Here’s my new stand alone Hardware, the STM32F4 running NETMF is in the upper left and the STM32F0 is in the bottom right.

image

So far I have about 80% of the 8 Bit C code for the STM8S’s ported to the STM32F0.  I’m finding that unlike using the three STM8S, most of my code is actually being used to control flight, not handle communications.  It was easier than I had expected and as much as I really don’t like using Eclipse, it’s far better than the ST Visual Developer that I had been using on the STM8.  I found this great article on getting going with 32 bit development for STM using eclipse.

-twb

Tampa Bay NETMF Hacking Group

Announcing Meeting Number 2 of the Tampa Bay NETMF Hacking Group.

To register for the event, please go to http://tbnetmf1211.eventbrite.com

image

Our second meeting will also be held at the Microsoft Office in Tampa on November 21st at 6:30 PM.  This meeting will be in two parts, the first part going from 6:30-8:00 and will  be lecture/hands on.  The second part will be Show-and-Tell as well as freestyle hacking on your hardware.  If you did something cool between the meetings, come prepared to share!

After a brief recap/intro for any new members, this meeting we will explore basic communications and digital signals with your Netduino .NET Microframeworks device.  Although we will be using a NETMF device the same basic principles will apply to other microcontrollers

  • Serial Data Communications to a Host Computer
  • Serial Data Communications between two NETMF devices
  • Controlling a Servo

Here’s a relatively cheap shopping list of parts to help support your geek habit that will be useful for this meeting:

Next month, we will be exploring options for getting these small devices on the internet.  Then in January, we will be looking at the Arduino.  Anyone with experience with this want to present?

Hope to see you there!

-twb

Tuesday, September 18, 2012

NiVek GO! QC1 – Part 5, New Electronics

Over the weekend, I had time to assemble my new electronics module for NiVek.  This one had a more thought-out ground plane, a second gyro (added the STM L3G4200D to compare it’s performance to the ITG-3200) and some other small mods.  The big difference in this board however is a set of female connectors on the bottom of the board to snap onto the Netduino GO! mainboard as seen in the pix below:GO_Bottom

One of the challenges I’m going to have assembling this board is the alignment of the female connectors on the bottom of the board.  They have to be exact so the line up with the sockets on the GO! mainboard.

This new design required the creation of a development-jig to program the micro-controllers as well as hookup the data analyzer.  Here’s an ugly homemade board I whipped together to accomplish this goal until I the ones I ordered come in (note the blue/white glow from the GO! mainboard)

image

Finally a couple pictures of the final assembly, so far all the systems check out. 

image

image

 

I’m anxious to get it installed on my quad and see how it does.  I have high hopes Smile

-twb

Thursday, September 6, 2012

NiVek GO! QC1 – Part 3, Test Fixture/PID Controller

In my continuing effort to get my .NET quad copter off the ground, I’ve created a quick video to demonstrate the test fixture and software I’ll be using to achieve staple flight.

Enjoy!

NiVek GO! QC1–PID Tuning Fixture

-twb

Friday, August 17, 2012

NiVek GO! QC1 - Part 1

As a follow up to my initial post on NiVek GO! QC1, I shot a quick and dirty (read as: one-take and no editing) of the software and hardware working together to control a brushless motor and display sensor outputs from the Gyroscope and Accelerometer.

NiVek GO! QC1–Part 1

-twb