A while ago, Francesca from Element 14 kindly contacted me to ask if I wanted to receive some products from their catalog for review. I said yes and since I already had a wishlist going on (as most electronics guys have) it was easy to pick up some products. I also considered current and future projects when picking the items and so I had 4 items:

I asked for the STM32VLDISCOVERY because I wanted to play with one of these ever since I discovered this STM32 book written by Geoffrey Brown. The book seems so nicely written and from a practical point of view seems like it will get me started and working on the STM32 in no time. I’m also working on a couple of projects right now for which the STM32 might seem like overkill but I might use it anyway just build some experience around this chip.

I asked for the ATXMEGAA3BU-XPLD because it is a nice platform all around. The MCU is the ATxmega256A3BU and you also get some analog sensors, an lcd display and lots of IO’s. Excellent for when you need to throw something together and test it on an Atmel ATXmega. The ATSAM4L-XPRO which I received in error, features Atmel’s ATSAM4LC4C Cortex-M4 MCU which is nonetheless interesting in the industry but isn’t of much use to me on it’s own without some expansion board.

The TPS54231EVM-372 and TPS5450EVM-254 from Texas Instruments were requested because I use both of these in two of my projects and I wanted to have a reference testing platform for comparison to my own implementation in layout and design. I use the TPS54231 in the new Audio Spectrum Analyzer to power the digital/LED section and I use the TPS5450 in my DIY digital power supply as the switching  pre-regulator before going into a linear reg.

More will follow on these as I am going to perform some measurements like output noise on the TPS54231EVM-372 and TPS5450EVM-254 using my entry level scope and compare the results with the ones from the datasheet.

Also if you would like to checkout more products from these manufacturers, see the Newark category pages:

September 14th, 2011

74HC4051 Analog Multiplexer

74hc4051 mux

This was actually the first time I ever needed to multiplex analog channels so it was a good opportunity to learn how to use them. My task was to measure the temperature of 32 thermistors (NTC) with a microcontroller and later process that data. Obviously you cant find that much analog input channels on your common microcontroller so you need to multiplex the signals. First I looked for large analog multiplexers with 16 input channels but those are way too expensive. As it turns out its cheaper to use more smaller 8ch multiplexers(example Digikey pricing: 2pcs 16:1 mux from TI is $7.84 while 3pcs of 8:1 mux from TI is $1.53). I was able to get the 74HC4051 at a good price so I started creating the design around it.

With just four 74HC4051 I can multiplex 32 input channels to 4 outputs. The 74HC4051 has 3 select lines A,B,C and one enable line E. These 4 lines are used for control and they can be tied together like I did for controlling all 4 chips with the same 4 lines. By a combination of state (high/low) for A,B and C you can control which input gets connected to the output. In the schematic you will also find a table with the address select concerning the 3 pins A,B and C. The enable pin is used to disconnect all internal switches (when high) or allow connection (when low) by selecting the appropriate address. Each 74HC4051 got its own 0.1uF decoupling cap close to its supply pins and if you’re design is very sensitive to noise you can further optimize the layout and place more filtering on the supply lines.

To get a more stable reading at the output of the thermistor(actually at the output of the multiplexer) I also placed a low pass filter which later on after assembling and testing turned out to be unnecessary even creating problems because I was switching the lines faster than it took the filter to settle so I left the filter components out during assembly.

The PCB was manufactured at home hence the big vias and it was designed to allow a second board with the microcontroller to be stacked on top of it. Everything was tested on an Arduino and it works perfectly. The schematics and board file are released under CC-BY-SA and can be downloaded from the link bellow.

mux 74hc4051


Eagle schematic and board file.

August 6th, 2011

Include math.h for C32

microchip pic32

I spent the past 3 hours debugging my code that was absolutely fine. So just a quick note for everybody who’s working on pic32’s, if you’re using any math functions you have to include math.h; it is not enough to include the peripheral library (plib.h). The compiler won’t complain but you will get garbage out of your math functions.

And if you’re wondering what I was doing with all that math is just computing the temperature for a thermistor using the Steinhart–Hart equation.


I bought this multimeter(Minipa ET-870C) a while ago for $17, great value. I got it because its nice to have around multiple meters for when you wanna measure both input and output voltage/current. I believe it was advertised to have an auto-off feature for 15 mins but it didn’t. This eventually lead to many drained batteries because I often forgot to turn it off after using it. So during a boring weekend when the weather outside was bad I decided to add this nice feature to the meter. I knew it had to be a small circuit to be able to fit inside the multimeter so I picked the tiny25 the smallest micro I had around.

I quickly put together a simple schematic in Eagle, just the mcu, a voltage regulator a npn transistor and the associated capacitors and resistors. The circuit is powered from the multimeter 9V battery and cuts off the ground path to the meter to turn off its power. No ISP connector was placed on the board to save space but extra long pads were added so I can solder some wires for programming the mcu.


The npn transistor has its base pulled down so when there is no signal coming from the mcu the transistor is off. The pcb was made using the photo etching technique and it was assembled with some solder paste and hot air gun. I also soldered some wires to connect to my MKII programmer and I started writing the code.

To keep track of the time I used Timer0 to generate an overflow interrupt. Knowing the CPU frequency and the prescaler we can find out how often that interrupt will occur. Knowing how often the interrupt will occur we know how many times we need that interrupt to trigger to account for a given time in seconds. This is all calculated inside main.h where you can also specify the time in seconds.

To start the counting process I’m using a tact switch connected on INT0. When the button is pressed the level changed interrupt will trigger on INT0 and we change some flags to start counting as well as turning on the transistor to turn on the multimeter. When the counting reaches the setpoint, the flags reset and the transistor is turned off, thus turning off the meter. At this step the code was running ok except that for a 15 mins period there is ~12s error. I suspect this is because I’m using the internal oscillator which is not very precise.

Since the circuit was intended for extending the battery life, itself had to consume as little as possible. All measurements were made right before the voltage regulator at the battery leads. With no optimization the current draw at 9V was 3.67mA. The tiny25 has 3 sleep modes: Idle, ADC Noise Reduction and Power-down mode. The Idle mode would be good for when we are counting until the setpoint is reached, and the power-down mode for when we are waiting for the button to be pressed(INT0 interrupt trigger). So I’ve added some new lines of code to set the processor into Idle mode when the button is pressed, and to set it to power-down mode the the setpoint is reached and the transistor is turned off.

// Prepare for sleep mode in Idle mode so Timer0 can continue working and providing interrupts


set_sleep_mode(SLEEP_MODE_PWR_DOWN);	// Prepare for sleep mode in Power Down mode

With these new settings the numbers are: in Idle mode the current draw is 3.57mA(only 0.1mA saved) but in power-down mode the current draw is only 17.9 uA(a whopping 3.652mA saved). This will ensure the battery life is not affected by the small timer circuit.

Now that everything was finished all I had to do is mount the small pcb inside the meter. Luckily there was plenty of space between the LCD and the logic board. I attached the pcb with some double sided sticky tape and drilled a hole for the tact switch in a pre marked place(this was probably the place designated for an original on/off-standby button that would of reset the internal auto-turn off feature). The tact switch was fixed in place with some hot glue. The wires were carefully routed on the side of the case and everything was assembled back together.

Now I know what you’re thinking, this mod makes the meter more dangerous with all the wires running so close to the high voltage input jacks but this meter did not have much protection to start with. Only basic 250mA fuse on the small current scale so I don’t think I’ve made it more dangerous than it already was. I really don’t recommend getting this meter if you’re working with high voltages or currents. This is only suitable for small currents/voltages where the input protection isn’t going to make a big difference.

Also you should know that the mod will certainly void your warranty if there is one. I certainly didn’t had any real warranty with this meter.

The source code and Eagle schematics are accessible on github here. As you can see this was also a nice opportunity to get me started with using a code repository. And here are some pictures from the construction/assembly process:

AVR ISP MKII Entering programming mode failed

If you ever get the message “Entering programming mode.. FAILED!” while trying to program your AVR device don’t start messing with your MKII or upgrade its firmware 10 times or messing with the windows drivers like I did, cause that’s probably not the cause and you risk damaging you’re perfectly working MKII. As it turns out its just a faulty connection between the programmer and the target board. This is not likely to happen if you only use the programmer occasionally but I used it for like 50+ times a day and that meant inserting and removing the little 6pin connector a bunch of times. I removed the old 6pin connector, crimped a new one and its working again, so long live the MKII because it is a great tool.

You might be wondering why would I need to use that many times, well its because I’m working on this new project, a quadrocopter based on an atmega64. The microcontroller was chosen because I had a bunch around and ATMEL was kind enough to send me a ATAVRSBIN1 for my project.


The Inertial One System Board delivers a full 9 degree of freedom sensor platform comprising a 3 Axis Magnetometer from AKM (AK8975); 3 Axis Accelerometer from Bosch (BMA150) and a 3 Axis Gyroscope from InvenSense (ITG-3200) connected through an I2C interface.

At $54 its probably the most accessible 9DOF breakout out there and it comes with great sensors. Unfortunately I only managed to test and fly with the ITG-3200 gyro before I had a crash(you crash allot when developing from scratch a new firmware for a quad). Because of the crash a short-circuit happened somewhere on my board and it messed up the ATAVRSBIN1 sensors.

The ITG-3200 is a very good gyro with low noise so to replace the damaged ATAVRSBIN1 and to continue flying I got a wii motion plus which has the ITG3205 inside(its supposed to be just an OEM version of ITG3200). I haven’t done allot of testing with this new ITG3205 but I did notice some problems on the I2C bus, like sometimes the sensor does not respond , which is strange.(maybe the 400KHz freq is too high for the ITG3205 ?).

Anyway enough for now, I’ll post some updates on the project soon.

© 2007-2011 YourITronics | Any logo, trademark and project represented here are property of their respective owners | Wordpress | Privacy Policy    RSS