The Arduino IDE is the most convenient way to get started with Arduino, but it does obscure the underlying mechanics of building software for an Arduino.
How to do it from scratch? This is my experiement and guide to building software for an Arduino from the command line. I use a Mac and homebrew, so it is somewhat MacOSX-specific.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
My occasional technical diary of thoughts, tips, and tools from some of the more interesting things I'm playing around with at the time. That means all things Web, Open Source, Polyglot-programming, Electronics and Data, or just my latest rant.. who knows!
Monday, July 25, 2016
Wednesday, July 20, 2016
LittleArduinoProjects#219 DS18S20 1-Wire Reading
Another way to measure temperatures, this time the DS18S20 - an inexpensive 1-Wire digital thermometer with a range of -55°C to +125°C, at ±0.5°C accuracy from -10°C to +85°C.
It comes in TO-92 packaging and may be powered directly (using three pins), or take parasitic power from the data line (using two pins). This makes it ideal for pin-starved microcontrollers that need a decent ambient temperature reading. In this project, I'm just exercising the sensor with a simple Arduino sketch.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
It comes in TO-92 packaging and may be powered directly (using three pins), or take parasitic power from the data line (using two pins). This makes it ideal for pin-starved microcontrollers that need a decent ambient temperature reading. In this project, I'm just exercising the sensor with a simple Arduino sketch.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
Labels:
Arduino,
Electronics,
LittleArduinoProjects,
Sensors
Thursday, July 14, 2016
LittleArduinoProjects#218 MPU-6050 3-Axes Accelerometer Gyroscope Module
I'm planning to build a controller that needs motion detection, so got hold of an Invensense MPU-6050 3-Axes Accelerometer Gyroscope Module to see if it would do the trick. The module conveniently operates on 3-5V. All I've done so far is a simple sketch to confirm I can read raw values from the MPU-6050 using the Arduino Wire library.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
Wednesday, July 13, 2016
LittleArduinoProjects#217 Basic AVR-controlled Buck Converter
Buck converters are switching power supplies configured such that the output voltage is lower than the input voltage.
Since the primary components (inductor and capacitor) ideally consume no power, high conversion efficiencies are possible. In practice of course, components are not ideal and there is some power loss. More significant however is any power consumed in the control and feedback circuits.
This circuit is a demonstration and exploration of the basic buck configuration with a fixed load. Since the load is fixed, I have not implemented any feedback control system. Of course there are plenty of buck converter chips and modules on the market and these are so cheap you'd be crazy (or have such precise and unusual requirements) to build your own for a real application. But it's nice to see how they work!
My inspiration for this circuit was DIY Buck Converter by GreatScott! - IMHO the "missing lab" to accompany very good but dry courses such as the Power Electronics Specialisation from University of Colorado Boulder.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
Since the primary components (inductor and capacitor) ideally consume no power, high conversion efficiencies are possible. In practice of course, components are not ideal and there is some power loss. More significant however is any power consumed in the control and feedback circuits.
This circuit is a demonstration and exploration of the basic buck configuration with a fixed load. Since the load is fixed, I have not implemented any feedback control system. Of course there are plenty of buck converter chips and modules on the market and these are so cheap you'd be crazy (or have such precise and unusual requirements) to build your own for a real application. But it's nice to see how they work!
My inspiration for this circuit was DIY Buck Converter by GreatScott! - IMHO the "missing lab" to accompany very good but dry courses such as the Power Electronics Specialisation from University of Colorado Boulder.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
Monday, July 11, 2016
LittleArduinoProjects#216 OSHChip driving SPI LED module
How easy is SPI with the OSHChip? I thought I'd find out by first controlling a module that has a very basic SPI-ish slave interface.
I'm using the LEDx16Module that I designed in the KiCad like a Pro course from Tech Explorations. It has dual 74HC595 shift registers that can be driven with SPI to control 16 onboard LEDs.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
I'm using the LEDx16Module that I designed in the KiCad like a Pro course from Tech Explorations. It has dual 74HC595 shift registers that can be driven with SPI to control 16 onboard LEDs.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
Sunday, July 10, 2016
Feature Lifecycle Analysis with PivotalTracker
Can you trust your agile planning process to deliver the best result over time?
In an ideal world with a well-balanced and high-performing team, theory says it should all be dandy. But what happens when the real world sticks it's nose in and you need to deal with varying degrees of disfunction?
Feature Lifecycle Analysis is a technique I've been experimenting with for a few years. The idea is to visualise how well we are doing as a team at balancing our efforts between new feature development, refinement, maintenance and ultimately feature deprecation.
If you'd like to find out more, and run an analysis on your own projects, try out the Feature Lifecycle Analysis site. It includes some analysis of two real software development projects, and also a tool for analysing your own PivotalTracker projects.
As always, all notes, schematics and code are on GitHub.
In an ideal world with a well-balanced and high-performing team, theory says it should all be dandy. But what happens when the real world sticks it's nose in and you need to deal with varying degrees of disfunction?
Feature Lifecycle Analysis is a technique I've been experimenting with for a few years. The idea is to visualise how well we are doing as a team at balancing our efforts between new feature development, refinement, maintenance and ultimately feature deprecation.
If you'd like to find out more, and run an analysis on your own projects, try out the Feature Lifecycle Analysis site. It includes some analysis of two real software development projects, and also a tool for analysing your own PivotalTracker projects.
As always, all notes, schematics and code are on GitHub.
Labels:
Agile,
Development,
Product Management,
Project Management,
Scrum
Saturday, July 09, 2016
LittleArduinoProjects#215 OSHChip yotta toolchain
After bruising myself on the raw gcc toolchain - and although I got a program running - I think I want my toolchain to do more of the hard work for me!
So next I tried yotta, the software module system used by mbed OS. Building a simple program using the Official Yotta target for OSHChip and gcc on MacOSX proved quite straight-forward.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
So next I tried yotta, the software module system used by mbed OS. Building a simple program using the Official Yotta target for OSHChip and gcc on MacOSX proved quite straight-forward.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
Thursday, July 07, 2016
LittleArduinoProjects#214 OSHChip gcc toolchain
Can I build a program for the OSHChip using the gcc toolchain and Nordic Semi SDK on MacOSX?
Yes..ish!
Here are my notes and scripts for compiling and deploy a simple program, but there remain a few rough edges. There are probably easier ways to do this ... like using the Official Yotta target for OSHChip using gcc ... but I was curious to see how far I could get with just gcc and the Nordic Semi SDK.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
Yes..ish!
Here are my notes and scripts for compiling and deploy a simple program, but there remain a few rough edges. There are probably easier ways to do this ... like using the Official Yotta target for OSHChip using gcc ... but I was curious to see how far I could get with just gcc and the Nordic Semi SDK.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
Wednesday, July 06, 2016
LittleArduinoProjects#213 OSHChip blinky
I heard about the OSHChip on the embedded.fm podcast #146 and immediately wanted one!
An ARM Cortex-M0 32 bit micro processor (nRF51822) with 2.4 GHz Radio and other goodies all in a breadboard-compatible DIP16 package .. how could you say no?!
So far, so good. Literally 5 minutes to the first blinking LED, and hours of fun followed .. this is an awesome little package.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
An ARM Cortex-M0 32 bit micro processor (nRF51822) with 2.4 GHz Radio and other goodies all in a breadboard-compatible DIP16 package .. how could you say no?!
So far, so good. Literally 5 minutes to the first blinking LED, and hours of fun followed .. this is an awesome little package.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
Tuesday, July 05, 2016
LittleArduinoProjects#212 Stay Creative!
A simple project inspired by Make your own LED Sign VU Meter by GreatScott!. The catch-phrase should be familiar if you subscribe to his channel;-)
It's a VU meter, but rather than doing the "bar graph" thing à la LM3915, it pulses the intensity of all LEDs to the volume of the incoming audio.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
It's a VU meter, but rather than doing the "bar graph" thing à la LM3915, it pulses the intensity of all LEDs to the volume of the incoming audio.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
Monday, July 04, 2016
LittleArduinoProjects#211 Buck Converter Modules
There are many super-cheap buck converter modules available, often based on the LM2596S-ADJ. The "BuckConverterModules" project is where I've recorded notes on the individual units I get to see. So far I've tested four. Two perform really well; two are OK but I have my doubts about the specs of the converter chip.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
Sunday, July 03, 2016
LittleArduinoProjects#210 Pump up the Jam!
This is a super cheap amplifier kit built around the TDA7297 15+15W dual bridge amplifier chip. All the other parts in the kit are essentially the basic supporting components for the TDA7297.
Performance is very good, although my impromptu speaker boxes don't do it justice. They need better baffles at least, but I can hardly blame Straits Preserves for not making marmalade boxes to the specification of speaker enclosures!
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
Performance is very good, although my impromptu speaker boxes don't do it justice. They need better baffles at least, but I can hardly blame Straits Preserves for not making marmalade boxes to the specification of speaker enclosures!
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
LittleArduinoProjects#209 a funky little LED display
I found this interesting LED display at Sim Lim Tower, and grabbed one to test. The LED unit combines 7 x 7-segment display (no decimal points) and 7 indicator LEDs (Red-Green-Yellow).
It is marked as "72R02PHIL T9717". I have no idea what that means(!), and of course there's no sign of a datasheet on the net, so pinouts needed a bit of reverse-engineering. All in all, an interesting display unit for a combination of numerical and status display.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
It is marked as "72R02PHIL T9717". I have no idea what that means(!), and of course there's no sign of a datasheet on the net, so pinouts needed a bit of reverse-engineering. All in all, an interesting display unit for a combination of numerical and status display.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
Friday, July 01, 2016
LittleArduinoProjects#208 Single Stage FM Transmitter
I've been experimenting with FM, and the hardest thing to get right tends to be the hand-wound coils. So to get a baseline, I picked up a 1-transistor kit during a recent visit to Sim Lim Tower.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
Thursday, June 30, 2016
LittleArduinoProjects#207 Frequency Counter
Testing a CMOS frequency counter circuit with a 100Hz - 5MHz range.
I found this circuit published in Electronics magazine (Sep 16 1976). It's a classic demonstration of the CD4026 "bucket-brigade" and CD4047 astable oscillator.
The frequency counter is governed by a CD4047 oscillator. Since this offers a clean 50% duty cycle, it is ideal for flipping the circuit between two modes: sampling period; display period.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
I found this circuit published in Electronics magazine (Sep 16 1976). It's a classic demonstration of the CD4026 "bucket-brigade" and CD4047 astable oscillator.
The frequency counter is governed by a CD4047 oscillator. Since this offers a clean 50% duty cycle, it is ideal for flipping the circuit between two modes: sampling period; display period.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
LittleArduinoProjects#206 CD4047 Astable Oscillator
The CD4047 is capable of running in astable or monostable configurations, with operating frequency configured by an external RC network. So in one sense, sounds like the 555 timer!
Unlike the 555, the CD4047 provides a fixed 50% duty cycle with good frequency stability (+/- 2% @ 100KHz).
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
Unlike the 555, the CD4047 provides a fixed 50% duty cycle with good frequency stability (+/- 2% @ 100KHz).
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
Wednesday, June 29, 2016
LittleArduinoProjects#205 Triac Dimmer
A triac is a "bidirectional thyristor" because it conducts in both directions and is typically used in AC applications.
The basic behaviour of a triac can be summarised in two rules:
The basic behaviour of a triac can be summarised in two rules:
- Rule 1. To turn ON, a gate current ≥ IGT must be applied until the load current is ≥ IL (latching current).
- Rule 2. To turn OFF (commutate), the load current must be < IH (holding current) for long enough for the device to return to the blocking state.
Sunday, June 26, 2016
LittleArduinoProjects now with fancy catalog!
I keep finding new uses for GitHub Pages - situations where in the past I would otherwise have spun up a web site on heroku or similar. But if the site can be static, and especially if you are already hosting the git repository at GitHub, Pages are perfect.
For a long time, I've maintained the LittleArduinoProjects project index as a simple table in the README. But it wasn't particularly nice or usable, so I decided to pimp it up and serve the catalog index with pages. Turned out to be a piece of cake (with a few scripts to convert the old index to JSON for the catalog page.
So here it is, Little Electronics & Arduino Projects at leap.tardate.com:
As always - and since the gh-pages code lives in the same repo - all notes and code for the catalog are available in the same Little Electronics & Arduino Projects repo on GitHub.
For a long time, I've maintained the LittleArduinoProjects project index as a simple table in the README. But it wasn't particularly nice or usable, so I decided to pimp it up and serve the catalog index with pages. Turned out to be a piece of cake (with a few scripts to convert the old index to JSON for the catalog page.
So here it is, Little Electronics & Arduino Projects at leap.tardate.com:
As always - and since the gh-pages code lives in the same repo - all notes and code for the catalog are available in the same Little Electronics & Arduino Projects repo on GitHub.
Saturday, June 25, 2016
On "random" CI failures
I closed a bug yesterday that's been kicking around for almost a year as a sometimes fails on CI but no-one can figure out why frustration.
Sooner or later you'll hear someone suspect it must be a problem with CI. Which is ironically funny in a shoot-the-messenger kind of way!
Thankfully our "CI issue" turned into a for-real bug. In short, the code involved many classes with near 100% test coverage. It had been read and re-read and everyone would swear there's no way this could fail.
No, of course we were wrong. The bug was basically a conspiracy of two bits of code in two very different places:
And you can see where this leads: our problem was filtered data ending up by obscure and circuitous means in field1 and field2 ... with a 1 in 7 chance of the record validation failing (never happens on our machines of course). After that it was an easy fix.
So once again we learn the lesson:
I've seen this scenario play out a dozen times in as many years, and CI was always right;-) Since it keeps cropping up, it made me think about how to best knock these on the head. Five things:
It's too easy to give up, find scape-goats or "magic" explanations otherwise.
Take heart in the fact that if you assume CI is right, the odds are on your side.
When we first encountered this issue and failed to find the root cause, we added code to catch the "this is about to fail in that unexpected way" situation and log/report appropriately.
So while the ticket got iced, it's been that "canary" that keeps dying in order to keep the issue alive! So when it died again yesterday, it was a painful reminder to get to the bottom of the issue once and for all.
Always found in the last place to look. So when you've honed in on the code you think is failing, studied it upside down, left to right, and still can't find the issue .. maybe it's time to consider you might be right. Throw out that hypothesis, pull back and fan out instead.
If errors happen infrequently, reproducing them is like trying to win the lottery. The more entries, the better your chances.
So don't run tests a few times, run them millions of times if you have to. Computers are good at this. That's how I diagnosed this latest issue while tweaking logging and the test itself. Bash away:
This sounds so simple that it's easy to overlook.
If things fail randomly .. it only takes a few moments to search the code to see if anything is using something similar to a random function.
Could it be possible that random failures and the use of rand() might be related?!
May be not, but if they are, that's a cheap win!
Sooner or later you'll hear someone suspect it must be a problem with CI. Which is ironically funny in a shoot-the-messenger kind of way!
Thankfully our "CI issue" turned into a for-real bug. In short, the code involved many classes with near 100% test coverage. It had been read and re-read and everyone would swear there's no way this could fail.
No, of course we were wrong. The bug was basically a conspiracy of two bits of code in two very different places:
- a record validation that ensured field1 was not the same as field2
- a data collection routine that could be configured to filter/replace sensitive values with a random ** string: ["*" * rand(4..10)]
And you can see where this leads: our problem was filtered data ending up by obscure and circuitous means in field1 and field2 ... with a 1 in 7 chance of the record validation failing (never happens on our machines of course). After that it was an easy fix.
So once again we learn the lesson:
If CI say red but we can't figure out why, "must be a problem with CI" is 99.999% the wrong answer. It just means we haven't found the bug yet.
I've seen this scenario play out a dozen times in as many years, and CI was always right;-) Since it keeps cropping up, it made me think about how to best knock these on the head. Five things:
start by assuming there is a bug until proven otherwise
It's too easy to give up, find scape-goats or "magic" explanations otherwise.
Take heart in the fact that if you assume CI is right, the odds are on your side.
put a canary in a coalmine
When we first encountered this issue and failed to find the root cause, we added code to catch the "this is about to fail in that unexpected way" situation and log/report appropriately.
So while the ticket got iced, it's been that "canary" that keeps dying in order to keep the issue alive! So when it died again yesterday, it was a painful reminder to get to the bottom of the issue once and for all.
finding bugs .. is like looking for your keys
Always found in the last place to look. So when you've honed in on the code you think is failing, studied it upside down, left to right, and still can't find the issue .. maybe it's time to consider you might be right. Throw out that hypothesis, pull back and fan out instead.
treat random errors like a lottery
If errors happen infrequently, reproducing them is like trying to win the lottery. The more entries, the better your chances.
So don't run tests a few times, run them millions of times if you have to. Computers are good at this. That's how I diagnosed this latest issue while tweaking logging and the test itself. Bash away:
for (( ; ; )) ; do rspec spec/that_wierd_spec.rb if [ $? == 1 ] then echo "JACKPOT!" break fi done
random failures ... might really be random
This sounds so simple that it's easy to overlook.
If things fail randomly .. it only takes a few moments to search the code to see if anything is using something similar to a random function.
Could it be possible that random failures and the use of rand() might be related?!
May be not, but if they are, that's a cheap win!
Wednesday, June 15, 2016
LittleArduinoProjects#204 Type K Temperature Logger
I'm working on an idea where I need to measure temperatures to around 500°C - above those typically supported with semiconductor sensors or thermistors.
This project demonstrates the basic approach using an Arduino as the "temperature logger". I'm using a K Type thermocouple that's rated up to 700°C. Since thermocouples only measure a differential temperature, I'm also using an LM35 to provide the cold-junction baseline. The temperature measurement is displayed on a 5110 LCD.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
This project demonstrates the basic approach using an Arduino as the "temperature logger". I'm using a K Type thermocouple that's rated up to 700°C. Since thermocouples only measure a differential temperature, I'm also using an LM35 to provide the cold-junction baseline. The temperature measurement is displayed on a 5110 LCD.
As always, all notes, schematics and code are in the Little Electronics & Arduino Projects repo on GitHub.
Labels:
Arduino,
Electronics,
LittleArduinoProjects,
Sensors,
Thermocouple
Subscribe to:
Posts (Atom)