Detecting Taps with an Accelerometer: Disco Bike Light part 4

Tap Control of the Disco Bike Light

In last week’s blog I talked about looking into using an accelerometer output as a user interface for the Disco Bike Light design.  This week I took the next step of actually implementing a method of detecting taps with an accelerometer and using them as an on-off signal.

For a quick refresher, the Disco Bike Light is a design where I’ve decided to replace the guts of a Schwinn bike light with my own electronics. I wanted more color and more brightness.  I put some constraints on myself for the design.  One was that I couldn’t destroy the existing bike light in the process of making my new one.  For on/off/color control I was left with few options…

[Read more…]

Chart Control in Visual Studio 2010



I used the chart control in Visual Studio 2010 (VS2010) last week on a consulting project.  It was a useful means of using my serial communication software to create a visual display of the data being read.  It is relatively easy to bind an array to a chart and display it on a form, so I thought I ‘d share that here.

[Read more…]

Near Field Communication (NFC) with ST Micro CR95HF – Part 2


Near Field Communication (NFC) with ST Micro CR95HF.  A couple of weeks back I started working on a circuit board that holds ST Micro’s CR95HF NFC communication IC.  NFC stands for near field communication, and is basically an very short-range RF data link. Several communication protocol have been adopted for use with NFC hardware.

[Read more…]

Near Field Communication, NFC and the CR95HF


I started work on a Near Field Communication (NFC) module.  The design uses ST Micro’s CR95HF chip.   The module above is the first shot prototype unit.  This device uses a 13.56MHz RF carrier frequency and amplitude-shift keying .  The CR95HF carrier frequency powers the loop antenna shown on the module above and the resulting field couples with a similar loop antenna on an NFC enabled card.  The field coupling, like two loops of a transformer, powers the card.  Powering up the card allows the CR95HF to transmit data to and from NFC cards.  That’s the theory anyway.

[Read more…]

Creating Acrylic Letters with Sketchup and Ponoko


Yesterday I set about to have our new logo produced in acrylic.  I’ve made a few of pieces of a robot chassis out of acrylic using Sketchup (a software program) and Ponoko (a company that does laser cutting).  I hadn’t made letters before, and it turned out to be pretty simple.

[Read more…]

Serial Port Test Software


Last week I wrote some test software that allowed me to test electronics that used serial ports.  In particular I was testing our BM002, BM009, and BM010.  They are RS232 to 485, IR to serial, and USB to serial converters respectively.  I thought I would make it available in case it was of value to anyone else.  You can download the software here.

[Read more…]

Sending Serial Strings With Visual Studio 2010


Yesterday I had to write a program that let me test a serial data path between two electronic designs.  We use Visual Basic around here since it’s quick and easy. The current version of the software we have is Visual Studio 2010.

[Read more…]

National Instruments DAQ Attack


They say no plan survives contact with the enemy.  I think that pearl of wisdom applies to engineering.  In my experience the enemy takes the form of everything with wires as well as software running on anything with wires.
It certainly applies to a project we’re currently working on.  We can’t go into too much project detail, as the design is part of a contract we’ve been hired to complete. But we can cover some of the broad concepts that describe the battle we just survived.

[Read more…]

How to Detect Debug Mode in a PIC Micro



I’ve been posting about my progress in designing a dual motor controller that also reads and outputs RC servo pulses.  For that design I used a PIC16F1829 from Microchip.  It’s a pretty cool little part with lots of features, but also a low pin count.  I was able to get all of the functionality squeezed into my design.  But I did run short of pins and had to multiplex the debugger/programmer connections (PGD and PGC lines).

[Read more…]

A few Microchip 24F series A/D measurement tricks



The Microchip 24F series of microcontrollers has an internal 10-bit A/D. A block diagram of it is shown above. There are a couple of things to note about the diagram – first is that it allows for independent inputs for VREF+ and VREF-. This allows the user to set the dynamic range of the A/D to whatever is appropriate for the input signal. If a very precise and accurate reference is used, accurate absolute A/D measurements can be made. This is a very handy feature. If VREF- is tied to ground, the A/D results are given with the following equation:


So if the Input voltage was 1.250V and Vref was 2.048V, the resulting AD Counts result would be 625. That takes care of the standard ‘vanilla’ use case of the A/D.

Also note in the block diagram there is an internal band-gap reference that can be measured by the A/D: VBG. The information about the band-gap is shown in the table below. It has a +/- 5% accuracy. Unfortunately, this reference cannot be routed to the VREF inputs. An external reference must be used to automatically scale the A/D results.


In cost-sensitive designs, this could cause a problem. Because there is an accurate reference on-board, workaround would be nice.

I ran across this issue just recently. Here is a trick I came up with that allows for using the internal band-gap and alleviating the need for an external reference.

Measuring Vdd

In battery powered designs, it is common for the micro to be powered directly from a battery, without an intervening regulator. In this case, it is common to need to measure the battery voltage to check how much battery life is left. However, if Vdd is used at the Vref, an accurate battery measurement cannot be made. However, if a known voltage is measured the reference voltage (Vdd) can be inferred. The equation below shows how this is done.


In this case, VBG = 1.2V, MaxADCounts = 1024. So, if the A/D Counts = 410, Vdd would be 2.997V. If A/D Counts = 450, Vdd would be 2.73V.


Further Uses

By measuring VBG periodically, Vdd can be determined. If the A/D is used with Vdd as VREF+, accurate absolute measurements can be made by doing ratiometric adjustments. The full equation for this given below.


And Vref is given by


Which gives the complete equation: