Showing posts with label Arduino. Show all posts
Showing posts with label Arduino. Show all posts

Friday, March 14, 2014

Microsmooth : Signal Smoothing Library for Arduino

During the past few months we have started work on our quadcopter platform, unimaginatively called MICAV. The quadcopter is a micro aerial vehicle with a span of less than 45 cm. The MICAV is currently being controlled remotely using the Avionic RCBX7 transmitter receiver. The device is fairly complex allowing for 7 channel control, and contains a lot of inbuilt functionality. The signals are sent to the Arduino Uno from the receiver. These are then processed, and the motor control signals are set.

As we were testing the controls, we noticed a rather odd pattern. The RPM was changing quite audibly on the motors with a high frequency. Our initial guess was that the wiring must be loose somewhere and we went over the entire circuit. Next, we tested out the motors using a control signal being generated via values sent over serial. The motors performed correctly. Nothing wrong with the motors. Phew!

This left only when avenue to explore. The RX-TX itself. We then hooked up it up with the Arduino and observed the input values being received. The results explained the problem. It was noise all along!



Noise was interfering with the control signals far too much. This necessitated the need for some signal processing to be done before sending it further. To resolve, we started exploring libraries in Arduino-verse that deal with signal processing. We found no relevant ones. The ones we did find that could work for us, were too expensive to use in terms of time and space. We then moved to studying the algorithms ourselves and implemented them. Over the course of two weeks, we programmed and tested about 5-6 algorithms with many variations of parameters.

The algorithms that we implemented are:
  • Simple Moving Average
  • Cumulative Moving Average
  • Exponential Moving Average
  • Savitzky Golay Filter
  • Ramer Douglas Peucker Filter
  • Kolmogorov Zurbenko Filter
Some performed surprisingly well, given the time and size constraints that were imposed.

The green signal is the result of the SMA filter applied to the input. This was one of the mediocre performing cases.

Now, given that there were no existing libraries that were suited to this task when we started to look, we felt it was best to release our code in the form of library, to help out others who may travel down this path. So, then Microsmooth came into existence!

Microsmooth hosted on Github, maintained by me and Pranav, is intended to be lightweight and fast for use in time critical Arduino-based applications. Given that none of the code is Arduino specific, it can even be used on other microcontrollers and platforms, but we make no promises. Time optimizations will eventually make us utilise microcontroller specific features, which may make the library tied down to a specific platform.

To use the library, paste the files in the source directory, and add the following include:
    #include "microsmooth.h"    

The library is still in development and we aiming to improve the overall library in many areas.
  • Reduced memory utilization
  • Improved algorithm performance
  • Addition of new filters and greater control over existing parameters
  • Switches to result in smaller footprint of the code

The library will become more stable and flexible in the months to come.

Saturday, March 23, 2013

What is Arduino.SE ?

The Arduino site proposal is now close to reaching the second stage of the site creation process on Area 51. When I had first seen the proposal, it had three followers, and I became the fourth. It has now grown to 160+ followers and over 60 example questions over the course of two months at a steady rate. When I had "followed" the site proposal, I had thought that this site would become to Arduino, what AskUbuntu is to Ubuntu.



Ask Ubuntu Logo
For the uninitiated, Canonical  Ltd. is the project leader of Ubuntu. It is also at the head of a lot of technologies that were developed along with the Ubuntu platform. Canonical and Stack Exchange had together launched and licensed AskUbuntu as the main support Q&A site for Ubuntu. Canonical also maintains a separate support forum along with a host of other online services. The support forum and the Q&A site, both function together as the troubleshooters'. Arduino.cc, the official site, also has a forum site. The Arduino Q&A site is a site that could work alongside the forums, similar to how things work in Ubuntu. This however,would require acceptance and recognition by the Arduino Team of Arduino.SE, which is a pretty big bet, but is possible.

Coming back to the site, the scope of the SE site would basically include everything that is mentioned on Arduino.cc . The site would be the one repository of information about everything Arduino. I had initially posted my idea of the site scope with the aim in mind that Arduino.SE would cater to both beginners and experienced users. Here is my reasoning behind each point that I think should be covered in the site scope :

  1. Arduino Family

    This includes the Uno, Mega, Fio, Lilypad, Nano, BT, Serial, and others.
    Every board that uses the Arduino tag would be on-topic for the site. This includes both past and present boards.
  2. Arduino Derivatives

    This is something that may be a little contentious. There are a lot of Arduino-like products and Arduino derivatives, both of which are distinct in terms of functioning. I strictly refer to Arduino derivative boards such as Paperduino which are listed on the Arduino site and also, boards which are popularly considered derivatives, but may not be listed. Questions about these boards should be on-topic for the site as they are similar to the main platform as well as share a large part of the community.
  3. Software Tools

    This includes the IDEs, plugins, and libraries.
    Software tools are an integral part of the Arduino platform. They are as much a part of the platform, as the micro-controller boards. Software questions, at the moment, can be asked on Electrical Engineering or Stack Overflow, and this will unite them on a single site. Stack Overflow, in my experience on the site, does not handle hardware specific programming problems too well.
  4. Programming Issues

    This is a natural extension of the previous category. If we include, developing and using libraries, then there will be errors and problems. All such issues would be welcome here.
  5. Hardware Tools

    This did not need to be explicitly mentioned. This includes questions regarding help with using any specific tools that may be required for playing around with Arduino boards and circuits.
  6. Basic Circuit Design Problems

    This again, appears to be contentious. This is something that strictly overlaps with EE, however, I believe should be on-topic for Arduino.SE. I refer to the very minimal design issues that may be faced while designing circuits that may involve Arduinos'. Depending on the community we are able to establish, we could also start answering the more tougher and complex design problems. This however, would depend completely on the composition of the community and may or may not be feasible initially. Optimistically, such issues at some point, would become a part of the site completely.
  7. Circuit Component Issues

    This refers to only parts whose selection depends on the presence of an Arduino in the circuit.
    Again, an extension of the previous point. Questions about which register, diode, transistor, IC, resistors, LEDs, motors, power sources, and more would be on-topic. Troubleshooting problems would also be on-topic. There will be significant overlap with EE on this one, and I believe, that questions should be evaluated on a case to case basis, to determine where they should belong.
  8. Hacks of the hardware, and/or Extending the boards

    Possibly, the most contentious of them all. I envision this site to cater to all levels of expertise and knowledge and thus have information, both horizontal and vertical. The site should deal with issues ranging from naming, seeking permissions, trademarks, logos, and basic legal issues (assuming that we are able to get the necessary expertise). Apart from that, making changes to the board, altering characteristics, adding and/or removing components should also be on-topic. I believe this is necessary if we want to become the one repository for Arduino information. This   could make the site become home to discussions about new boards in the Arduino line-up, even
    before they are released.
  9. Hacks of/through the Software

    This is an extension of #3. Questions about changing and improving existing libraries, IDE's and APIs should be on-topic for the site. 
  10. Projects and Applications Issues

    This includes ideas, advice, guidance in specific issues or problems including design.
    Self-explanatory. Questions, about the structure and design of projects should also be welcome. To what extent, though, is something that we will be able to see from the questions that come up.  

The Community that we may be able to establish should/would include users of all levels of experience with the platform. The site should have both electrical engineers as well as software engineers and #8 and #9 are topics that would interest them. Such topics would interest advanced users of the platform as well. Beginners and intermediate users would comprise the major part of the community. The community is expected to be quite diverse having artists, designers, hobbyists as well. All in all, this will make for one interesting and vibrant site.

Wednesday, March 6, 2013

Why am I promoting Arduino at Stack Exchange ?

This is a chat message that I wrote in response to a comment asking me :
 why are you keen on promoting Arduino.SE ?
(In case you were wondering, all this was happening on Area 51)

I started out writing something that turned into a rather long explanation, and I believe is worthy of a blog post. So, here it is :

A combination of reasons. In the few months that I have been on Stack Overflow and Stack Exchange, I have interacted with some amazing individuals right from engineers at Googleplex, California to researchers in UK. I have helped some university students through really awesome project work, some of which I followed up outside of the platform of SE as well. I have answered a few questions and asked some as well and have got excellent responses. Moreover, the different Se sites that exist have made me enjoy this experience even more.

The SE platform is one that the more I use, the more I discover and the more I believe in. I think it has some excellent tried and tested features which make it an excellent platform for technical discourse and learning(to an extent). Look at the toolkit at User Interface as an example. I dont see why we should not provide such tools to different communities and specifically the Arduino Community.

Also, SE inadvertly extends to social interactions as well, which further strengthens the community. There is direct interaction with employees, there is a very responsive Meta.SO community as well. I do think there is scope for a slight bit of an increase in the social aspect of the platform, but thats for another discussion.

Coming to Arduino itself, I started using the platform a year back and have enjoyed using it. I have done a few projects and done some stuff that I probably would not have done if not for the abstraction that the platform offers. The Arduino forums do exist but in the time I have spent there, I have realised that a forum just does not scale up and or work as well as SE when it comes to resouce generation and sharing. There are a lot of questions there for which detailed answers exist but they are extremely hard to find. So, instead you get some quick short answers, but you miss out on that one great answer. Moreover, there usually isn't any closing thread feature as well which is immensely irritating. All this knowledge and expertise, would be much better served on this platform rather the 3-4 major Arduino forums that exist. I am overly optimistic when I think about bringing individuals from dfferent platforms together but I do believe its worth trying.

As far as why not EE goes, I just do not believe that they are serving this community as well as possible.

Knowledge is valuable, but only if it is there for people to find, and in short, this is one of the best ways to share it. I want to contribute to both, SE and Arduino, in more ways than I can just now and this is one way that I can. I will continue to push this forward till it does become a site.