Electric Longboard Annoying Squeak\Squeal

After a couple hours of riding my longboard it started making a high pitched squeak\squeal which sounded like it was coming from the brushless motor. After some investigation I found that a circlip on the end of my Turnigy Aerodrive SK3-6364-245kv Brushless motor was making the noise. The circlip usually rotates with the shaft of the motor but the motor bracket was stopping this from happening.

photo of circlip end of SK3 motor

Close up photo of circlip on the end of SK3 motor

I used the DIYElectricSkateboard.com website “support chat” and spoke with Dexter the very helpful owner of DIY Electric Skateboards and he suggested trying washers on the 4 x bolts which attach the motor to the bracket.

Longboard Motor Spacer

Longboard Motor with Spacers

I used 4 x M4 washers and the circlip now rotates freely which appears to have fixed the problem.

Electric Longboard devDuino V2 Controller

I really wanted to get the longboard working so I had a look at buying Wiiceiver from AustinDavid.com.

The source code is available on Github and I had a spare devicter devDuino Sensor Node V2 sitting on my desk. With some modification (changing pins numbers and removing all references to the second LED) I got the wiiceiver code running on my devDuino.

The Electronic Speed Controller(ESC) and the plastic lunch box (containing the batteries and devDuino) are attached to the deck with 3M Command adhesive strips. The first set of command adhesive strips I tried were for hanging pictures and had a Velcro quick release system. This approach was a failure and the ESC & electronics box fell off after 10-15 minutes use. The Velcro backing tape was getting pulled in the wrong direction so was unable to hold the weight of the electronics when vibration levels increased. I tried them because a “quick release” capability would be handy but I have gone back to using conventional 3M Command adhesive strips and these are working well.

devDuino V2 and ESC on longboard

devDuino based controller interfaced with ESC and wireless WiiChuk

Initial rides went well, though I need to recalibrate the acceleration and braking ramp up/down settings to suit my hardware and riding style.

Bill of Materials for this project (Prices as at Feb 2015)

  • Single Motor Mechanical Electric Longboard Kit USD223
  • Turnigy Aerodrive SK3-6364-245kv Brushless Outrunner Motor USD70.68
  • HobbyKing 150A High Performance Brushless Car ESC USD68.99
  • ZIPPY Flightmax 5000mAh battery X 2 USD31.99 each
  • HXT4mm Battery Harness 14AWG for 2 Packs in Series USD2.43
  • HXT 4mm Gold Connector with Protector (10pcs/set)
  • devDuino Sensor Node V2 USD15.99
  • Grove Nunchuck adaptor USD2.90
  • Grove Branch Cable for Servo USD4.90
  • Wireless Nunchuck NZD25.00
  • Moose 9.5×42 Longboard Flush Mount Deck Green Stain NZD57

WARNING – Disconnect the power supply pin on the Grove Branch Cable for Servos as the ESC will supply sufficient current to make the batteries on the devDuino go pop. Wrap some tape around the other servo connector so it can’t cause a short circuit.

Thanks to Austin David for making the code for the Wiiciever open source, if anyone is interested in my code I can tidy it up and share.

/*
 * Pin IDs -- NOT LOCATIONS !!!
 * don't change these ever; see "pinLocation" below for
 * actual locations
 */
#define RED_LED_ID   0
//#define GREEN_LED_ID 1

#define ESC_PPM_ID   2
//#define ESC2_PPM_ID   6
#define ESC_GROUND 00     // hard-wired

//#define WII_POWER_ID 3
//#define WII_GROUND 00     // hard-wired

#define WII_SCL_ID   4
#define WII_SDA_ID   5

I made my devDuino look like a V3 wiiceiver

int pinLocation(int pinID) {
  int pinMap[7][3] = {
  // v1, v2, v3
    {8,   8,  9},  // RED_LED     any digital pin
    {7,   6,  8},  // GREEN_LED   any digital pin
    {10,  9,  3},  // ESC_PPM     PWM required
    {9,  11,  5},  // WII_POWER   any digital pin
    {19, 19, 19}, // WII_SCL     A5, don't change
    {18, 18, 18}, // WII_SDA     A4, don't change
    {0,  10, 0}, // ESC2_PPM    PWM required
  };

The rest of my changes were commenting out all references to the Green LED as the devDuino only has one onboard LED.

Azure Event Hub Service Gateway V0.1

My Netduino and Arduino devices can’t do https so I had been looking at different approaches for uploading sensor data to a Microsoft Azure Event Hub. In a previous post I published the “simplest” possible useful program (a console application) which could upload data and this code builds on that.

In this proof of concept I have integrated the core of the console application code into an ASP.NET MVC WebAPI 2 project which acts as a service gateway. My Netduino clients now use a website hosted on my Essentials 2012 home server to forward the requests to a Microsoft Azure Event Hub .

For more detail about how to program the energy monitor shield see these posts about the Nokia 5110 display, nrf24L01 wireless link, and non invasive current sensor algorithm optimisations.

try
{
   using (HttpWebRequest request = (HttpWebRequest)WebRequest.Create( AzureGatewayUrl ))
   {
      string payload = @"{""DeviceId"":" + deviceId + @",""Usage"":" + value + "}";
      byte[] buffer = Encoding.UTF8.GetBytes(payload);
      request.Method = "POST";
      request.ContentLength = buffer.Length;
      request.ContentType = "text/csv";
      request.KeepAlive = false;
      request.Timeout = 5000;
      request.ReadWriteTimeout = 5000;

      using (Stream stream = request.GetRequestStream())
      {
         stream.Write(buffer, 0, buffer.Length);
      }
      using (var response = (HttpWebResponse)request.GetResponse())
      {
         Debug.Print("HTTP Status" + response.StatusCode + " : " + response.StatusDescription);
      }
   }
}
catch (Exception ex)
{
   Debug.Print(ex.Message);
}
Netduino power consumption monitor

Netduino power consumption monitor

Azure Service Bus Explorer by  Paolo Salvatori is great for debugging and testing Service Bus applications like this.

ServiceBus Explorer Displaying event hub power consumption data

ServiceBus Explorer displaying power consumption data

Bill of materials (prices as at Feb 2015)

The Azure Event Hub Service GatewayV0.1 is pretty basic with, no security, doesn’t have a lot of logging. wouldn’t scale terribly well (Though most home systems wouldn’t have a lot of sensors) and is hosted in Internet Information Server(IIS),

In future posts I’ll fix these limitations and make the service gateway secure, easier to install, configure and operate. But, this proof of concept proves the approach is viable

// POST api/eventhub
 public void Post(HttpRequestMessage request)
      {
         try
         {
            string connectionString = ConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString"];
            string eventHubName = ConfigurationManager.AppSettings["Microsoft.ServiceBus.EventHub"];

            NamespaceManager namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);

            EventHubClient client = EventHubClient.Create(eventHubName);

            EventData data = new EventData(request.Content.ReadAsByteArrayAsync().Result);

            // Set user properties if needed
            data.Properties.Add("UploadedAtUTC", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"));
            data.Properties.Add("UploadedBy", "devMobileAzureEventHubGateway");

            client.Send(data);
         }
         catch (Exception ex)
         {
            Debug.WriteLine("Send failed " + ex.Message);
         }
      }

Azure Event Hubs “simplest” possible program

I want to connect several Netduino devices monitoring my house to a Microsoft Azure Event Hub, but the Netudino does not natively support https connections (required for the REST API) and AMQP looked a bit chunky.

The team at Kloud have some great posts about getting Arduino & NetMF devices connected using the Azure python SDK and an Application Request Routing based solution.

I’m going to build an ASP.NET MVC Web API 2 based Azure Event hub gateway. I aiming for a minimal install footprint and resource utilisation as I want to use my Essentials2012  home server or Windows 7 Media Centre box to host the gateway.

My first step is to create a the “simplest” possible program which connects to a Microsoft Azure Event Hub and uploads an event. (Minimal complexity, no async, no threads, and very flat), This console application uploads an event specified in a file to an Microsoft Azure Event Hub. The Azure service bus connection string is configured in the app.config file, the event hub name, file path and partition id are specified on the command line.

using System;
using System.IO;
using System.Configuration;
using Microsoft.ServiceBus;
using Microsoft.ServiceBus.Messaging;

static void Main(string[] args)
{
   if (args.Length != 3)
   {
      Console.WriteLine("Incorrect number of arguments. Expected 3 args <eventhubname> <datafilepath> <partionkey>");
      return;
   }

   string eventHubName = args[0];
   string dataFilePath = args[1];
   string partitionKey = args[2];
   Console.WriteLine("Sending file {0} to EventHub {1} Partition {2}", dataFilePath, eventHubName, partitionKey);

   try
   {
      string connectionString = ConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString"];
      NamespaceManager namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);

      EventHubClient client = EventHubClient.Create(eventHubName);

      using (var dataFileStream = File.Open(dataFilePath, FileMode.Open))
      {
         EventData data = new EventData(dataFileStream)
         {
            PartitionKey = partitionKey,
         };

         // Set user properties if needed
         data.Properties.Add("Acquired", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"));

         DateTime startUtc = DateTime.UtcNow;
         client.Send(data);
         DateTime finishUtc = DateTime.UtcNow;
         TimeSpan duration = finishUtc - startUtc;
         Console.WriteLine("Duration {0:F2} secs", duration.TotalSeconds);
      }
   }
   catch (Exception ex)
   {
      Console.WriteLine("Send failed {0}", ex.Message);
   }
   Console.WriteLine("Press <Enter> to exit");
   Console.ReadLine();
   }
}

Uploading an event takes roughly 2.5 seconds on my ADSL internet connection.