Adafruit Feather M0 with Atmel Studio

Atmel Start

This is a quick ‘Hello World’ post which shows how to use Atmel Start to create an Atmel Studio project which is compatible with the ARM based  Adafruit Feather M0. It will toggle the Feather’s LED at 500ms intervals.

The motivation is to move away from the Arduino IDE and libraries (I’ve been struggling with I2C misreads and slow serial speed) and instead use Atmel’s excellent and free Atmel Studio. It can be daunting for Arduino users to make the jump but it’s absolute bliss having a professional IDE.

Atmel recently launched an online tool which allows you to create and configure a template solution for a given set of hardware. It has examples projects for a huge range of developer boards (e.g the Xplained Pro series). It also allows you to create your own custom hardware and “graphically” configure clocks,  pin mappings (PINMUX) and also add software ‘drivers’ for things like I2C and USB.

So start with Atmel Start :


Click Create new Project

On the right hand side in the ‘filter on text’ field enter the name of the chip that the Feather M0 uses:  ATSAMD21G18 and then select the QFN48 package (I don’t believe it makes a difference in this case which package you choose as the pin-outs are the same)



You will get a fairly empty looking stack of components. Here’s I’ve just renamed the Application to something more appropriate.


Next, select PINMUX and scroll down and select to  Pin 26 ( PA17). Or you can select it from the graphical image of the chip itself. How cool is that!

Change the Label to LED1 and Pin Mode to Digital Output.

NOTE Atmel Start is SMART. It will only let you select pin modes that are compatible with the chip and pin, e.g. you can select I2C mode for PA22/PA23 but not PA24.


Next click on CLOCKS.  We won’t change any of the defaults. This will run MrBlinky at 1Mhz. But as you can see you have access to the whole world of SAMD21 clocks. You can also add components which depend on clocks.


Back to the dashboard we will add something that will enable us to include a delay in our code, essential for MrBlinkey to blink. There are a huge number of ‘driver’ components to choose from and you can add as many as you need (space allowing). Here we just add a delay component. Click on the (+) next to DRIVERS, scroll down to Dela,  click on the (+)  on the far right to add to the list of new components and finally click Add Component(s).



Now lets get the project into Atmel Studio. Click EXPORT PROJECT , ensure Atmel Studio is ticked and click DOWNLOAD PACK.


In The Studio

Run Atmel Studio and select File->Import->Atmel Start Project

Navigate to where the project pack was downloaded and select it. Update the project & solution name to something sensible.


Select  Build -> Rebuild and there should be no errors or warnings.


While this builds a nice binary file in the project “Output Files” folder and indeed you can flash this to the Feather M0 (instructions coming up below) IT WONT WORK. Why ? Because REASONS:


So we need to tell the linker to link our code to execute at address 2000 rather than 0.

In the Solution Explorer right click on the Project (MrBlinky) and select Properties. Select the Toolchain option on the left hand side and navigate down to the ARM/GNU Linker / Miscellaneous section.

In the Linker Flags field add :    -Wl,–section-start=.text=0x2000


close up:


Blinking LED

open up Main.c and you will see a while loop. Add some code to blink the LED

while (true) {

Note that the delay_ms function is there because we added Delay as a component and LED1 has also been defined for us because we labelled PA17 earlier. This is very handy if you’re designing custom hardware with specific things hanging off of specific pins, such as Chip Enables, leds, PWM outputs, I2C buses…

Rebuild Mr Blinkey.

Flash, ah–ahhhhhh!

To upload the executable to the Feather M0 we can use the build-in Arduino Bootloader.

The Arduino IDE uses a utility called bossac to push the exe up to the target board. You can see what command the Arduino IDE runs by turning on “Show Verbose Output During Upload”  Preferences.  Create a dummy sketch, select the Adafrtui Feather M0 and the bootloader port (double tap the button on the Feather to put it into bootloader mode) and then compile/upload the sketch.

The command line for me is basically :

<path to Arduino tools>/bossac.exe -i -d –port=<COM Port> -U true -i -e -w -v “C:\Users\rob\Documents\Atmel Studio\7.0\MrBlinky\MrBlinky\Debug\MrBlinky.bin” -R

The location of bossac.exe will vary as will the com port that the Feather is on so change accordingly. The location of MyBlinky.bin will also vary (check Output Files under Solution Explorer in Atmel Studio).

Double tap the Feather reset button to put it in bootloader mode. Open up a command prompt and run the above bossac command.

You should see dozens of lines out stuff, with no error messages. And the red light on you Feather should be blinking away.

Should be simple enough to add the bossac command  to Atmel Studio so that the upload can be done from inside the IDE.









EDTracker Pro Beta Firmware – Pick Up And Play

New beta firmware here (EDTracker Pro Only):

Unzip and follow enclosed instructions.

This release of the Pro firmware is aiming for a more ‘Pick Up And Play’ experience, reducing the need to run the auto-bias before starting a gaming session and the need to recenter the view. This release is also more resilient to magnetometer calibration issues.

The key to solid, drift-free view tracking is good magnetometer calibration and a stable magnetic environment. The vast majority of EDTracker Pro users have no problems but for a small number getting a good mag calibration can be a challenge. This can be down the construction of the headset, changes in environment (e.g. headset mic changing position)  or just user error (e.g. calibrating in one place and using in another). This beta firmware is less effected by mag calibration issues.


EDTracker Plus – Extra DOF with a webcam

ADDENDUM 23/02/2016 : new EDTracker UI (Pro version) now available. This now has a tab called “Webcam”  where you set up face tracking and used an alternative webcam library which appears to be more stable/faster.

EDTracker Pro UI

ADDENDUM: You’ll need to install some Microsoft libraries to get this working. Grab them directly from Microsoft here  (download and run   vc_redist.x86.exe  )

ADDENDUM: EDTracker UI (DIY version) now available here : 

EDTracker UI “DIY” Version

EDTracker gives you fast,low latency, high accuracy head tracking (roll/pitch/yaw) without the need for webcams and LEDS.  And that’s great for a large number of folks but there are sims out there were the ability to lean forward or sideways in a cockpit is useful, for example leaning forward to get a better view when pulling out from a junction in American Truck Simulator.

To evaluate the usefulness of this feature I’ve added an experimental option to the EDTracker Pro UI which enables face position tracking with a webcam. No special hat, clips or LEDS are needed. And since we’re just capturing head position rather than orientation it doesn’t have to be fast or super accurate.  It may not work for everyone (webcams can be a pain!) but it’s a nice option to have.

A test version of the UI can be grabbed from here ;   EDTracker Pro Plus Test

(I will be updating the DIY version of the UI over the next few days to add the same feature).

The UI outputs roll/pitch/yaw from the EDTracker combined with x/y/z position from the Webcam. You will need to download the excellent Opentrack utility which enables this data to be sent directly into supported games.  See Opentrack Downloads

How to Use it

Note, The UI talks to Opentrack using UDP protocol. You may be asked by Windows to allow the applications through the Windows firewall. Please say ‘yes’ 🙂

  • Download and run the test EDTracker UI:  EDTracker Pro Plus Test
  • Place the UI in Dev mode by selecting About -> Mode -> Dev.
  • Select a webcam from the drop down list and check ‘Enable Face Tracking’.




  • Download and run Opentrack; OpenTrack Downloads
  • Set the Tracker to “UDP Sender” and the Protocol to “Freetrack 2.0 Enhanced”.



  • Click the […] options button next to “UDP Sender” and set the port number to 5550



  • Click the Options button in the lower right hand side.
  • Ensure “Center at startup” is NOT checked.


In the option dialog tab across to Output.

If you find the head orientation or position works the wrong way round in-game, you can easily flip the output here by clicking “Invert”.  E.g if when looking up the in-game view look down, simply enable Invert on Pitch.

  • Set the Roll Source to Disabled unless you have the screen attached to your face.


N.B   X is side to side motion. Y is Up/Down and Z is forwards/backwards.


You can save these settings as a profile by clicking [Save…] on the main Opentrack windows.

  • Keeping the  EDTracker UI  on screen Click START in OpenTrack.

You should see the Raw Tracker Data and Game Data values change when you move. Also the pink octopus will move too.

N.B Do NOT minimise the EDTracker UI during gameplay  – this will stop it tracking your head.

When you recenter the EDTracker via the UI/Hotkey/Joystick button is will recenter you head position as well.

Happy Tracking!






EDTracker DIY and Arduino IDE 167

One of the EDTracker dudes (Brumster) has sorted out the custom hardware files and sketches for the latest Arduino IDE (1.6.7) :

Brumster has also updated the firmware to be compatible with the latest MPU-9250 (since the 9150 is becoming hard to source).

There are some exciting developments coming along, including a port to fast, fixed-point maths which reduces the already low latency even further.


EDTracker UI for Mac – Alpha

One of the marvelous Elite: Dangerous community members  is making great progress with a Mac version of the EDTracker UI – the application used to configure and calibrate the 9150 (DIY) EDTrackers.

There’s a thread over on the frontier forum.

The alpha test version is available via the forum post or from here.

It look pretty sweet 🙂 There is a know memory leak issue which is being addressed but badwolf77 is keen to get feedback from Mac Commanders.

Screen Shot 2015-11-20 at 23.38.44

Instructions from badwolf77

“Fire up the program, select your serial port and hit open. I’ve had some issues connecting the EDTracker, but it’s infrequent now. If it says connected but there’s no data populating the Data From Serial column, try hitting the ‘Hello’ button. Failing that, close and re-open.

Once the serial is connected the program will start collecting magnetometer data and plotting it. Take the EDTracker to its working position, hit clear, then start rotating it through as many orientations as you can to trace out an ellipsoid on the plot. When satisfied, hit pause to stop additional (potentially errant if you now put down the EDTracker) points being recorded.

Use the offset, scaling and rotation controls to position the yellow ball of dots closely around the ideal sphere (turquoise). If you have an extant setup, hitting ‘Current Values’ will transfer those to the prototype settings to save you some time. ‘Reset Values’ will take you back to identity (ie. default settings).

Once happy with the alignment of the yellow and blue balls, hit ‘Send Calibration Data to EDTracker’. Select your orientation by clicking ‘Mounting Orientation’ until it describes your mounting position.

Don the EDTracker and hit ‘Recentre’ then, sitting very still, hit ‘Autocalibrate Bias’.

Once that’s all done, try moving around and seeing how it responds on the HID graphs. Scaling and Smoothing can be applied now.

If you’re seeing yaw being very sensitive and then springing back, try fiddling with the ‘Blue’ offset setting (up or down) and re-sending the calibration data until it improves.”



Head Tracking in Games – Common Misconceptions

There are a number of  common misconception that I come across talking to EDTracker users and browsing forum posts. These apply to all forms of head tracking; webcam based (IR LED/image tracking) or IMU based.

First a recap on what head tracking does; Head tracking maps a users head movement into a game. With EDTracker if you rotate your head left the view rotates left. If you tilt your head up the view looks up. The cool bit is that the amount the in-game view moves can be scaled up to be more that your real head movement.  So looking left 10 degrees will look left in game by 90, or more. So you can sit in a Jet Fighter and look behind you or above you by just moving you head.

Now then, misconceptions;

1. I need a multi-monitor setup to use EDTracker

EDTracker gives perhaps the most benefit to users with single screens, regardless of screen size. Head Tracking works by scaling up your natural head motion so a small rotation gives a magnified ‘on-screen’ rotation. Unless you can surround yourself with monitors then EDTracker will always give you an advantage.

2. It takes time to learn how to ‘look around’ using head tracking

The brain is a wonderful thing. It has the ability to adapt and map what it sees through the eyes to physical head and eye movement. For the vast majority of users it takes a few seconds to adjust to head tracking. Your eye and head movement just ‘locks in’ to the visual feedback it gets from the game.

3.  Head Roll.

It makes sense to map head yaw (left/right) and pitch (up/down) and have these scales up to allow you look look around 360 degrees in game.  Mapping head roll isn’t needed for this.  If you roll your head over the world rolls in the opposite direction. If you top your head 90 degrees sideways the monitor and hence in-game view is already tipped 90. Mapping and scaling  pitch and yaw overcomes the limitation of having a small window (the monitor) on the game world. That window is constrained to showing a limited field of view but roll isn’t limited at all.

4.  You need to use other 3rd party software to get EDTracker to work

EDTracker will work with many games directly. If a game allows ‘head look’ to be controlled by a joystick then you can just plug EDTracker in, configure it using the EDTracker GUI, and then bind the controls in-game as you would for any other joystick.  Some games do not support this and for those a utility like Opentrack can be used to map the EDTracker outputs into something the game understands.  Opentrack also allows you to do cool things like map some lateral movement to the in-game view when you turn your head beyond a certain point. This reflects how your  head moves when you try to look behind you in real life e.g. “checking your six” .



EDTracker – Latest 9150 Test Firmware

9150DMPTest4 is now available from the EDTracker UI.  If you have a 9150 based EDTracker (bought or DIY) then feel free to give it a whirl.

This test release contains a bug fix over the previous  version (yaw bounce) as well as some minor tweaks. Thanks to everyone who’s been testing and reporting back.

If you’re new to the 9150 firmware then follow these steps, otherwise jump in at step 8.

1. Download the test version of the UI from

2: load EDTracke2Calib
3: Allow device to warm up
4. Wipe Settings.
5: Calculate Bias Values (manually adjust etc)
6: Load 9150DMPCal   – perform magnetometer calibration as per video
7: After sample count is more than 500 click “Save”  and take a screenshot (useful for confirming correct mag calibration)
8: With the tracker flat and stationary, load 9150DMPTest4
9: Keep the tracker still for 20 seconds. It’s performing a start-up calibration every time it’s plugged in.
The UI will not update until calibration is completed (LED also flashes fast then slow once done)
The button on the tracker now performs a FULL 20 second calibration. View reset must now be done with a HotKey.
This firmware requires the orientation to be TOP/USB Left.
The magnetometer is very sensitive to metal and magnets.
Nearby smartphones, screwdrivers, guitars can all effect the accuracy and response.
I’m working on productionising the 9150 sketch and UI changes this week. The firmware will support all top mounted orientation but not side mounted. WIll upload source to github then.
Ta ta