Microelectronics posts

I have done quite a lot of electronics at the beginning of my PhD, both for building some tools I use in my PhD project and for my own interest. In particular, I used quite a lot Arduino family microcontrollers and Raspberry Pi computers. I think that some of the work I did is quite general and may be used in a wide range of applications. This page summarizes all posts about microelectronics.

Showing pre-processor output of Arduino sketches

Sometimes, one wants to see the pre-processed code obtained by macro extension. In this post I explain you how this can be done for Arduino sketches.

Debug macros for Arduino programming

Debugging is an important part of getting code to work. Debugging on Arduino or other micro controllers is challenging due to the limited ressources available. In this post I present a few macros (released on my github) that can be used to make debugging of Arduino programs easier.

Mod for custom size Arduino serial buffers

In this post, I explain how to add a modified Arduino Uno board to the Arduino IDE in which the size of the RX and TX serial buffers can be separately set. All code is available on my gitHub page.

Using an Arduino as a computer controlled PID controller

In this post, I present some of the possibilities offered by an Arduino board to build a PID controller. I use this excellent Arduino PID library, on which I do a few own modifications for using the microseconds timing ability of the Arduino boards.

The Arduino watchdog: robust programming and gestion of low energy sleep

In this post, I recall the basis to know about watchdogs and I show how to use them for preventing code freezing, for putting an Arduino board into very low power mode or for doing both in the same program. This is also a good place for saying a little about volatile variables.

Tricks for avoiding wrapping effects with timing functions

Using Arduino functions such as millis() or micros() is convenient for timing events in the flow of your program. However, if your program should run flawlessly for a long amount of time, a time will come when you need to care about millis() and micros() wrapping due to overflow. More about this issue and how to solve it with a simple trick here.

Using the Arduino Due

The Arduino Due is a board featuring a much more powerful CPU than for example the UNO. It runs at 84MHz instead of 16MHz, and does 32 bits arithmetics instead of 8 bits. In addition, it features a more accurate (12 bits) and faster ADC, true analog outputs, and many pins. Howevere there are a few changes when using this board, and also maybe the Arduino core library for the Due is less polished than for the UNO. In this post, I help you to get started using the Due.

Getting the best out of Arduino Due PWM

While the Arduino Due is much more powerful than the UNO, many of its nice features are disabled by default to allow backwards compatibility of the code with less powerful Arduino boards. In this previous post, I explained how to get started with the Due and how to obtain 12 bits ADC (it was very easy). Here, I explain how to get the best out of the Due PWM (this is a little bit more work!).

Custom size Serial buffers mod for Arduino Due

I needed to extend quite a bit the RX buffer of the Serial port (the one corresponding to the USB programming port) of the Due. Since all the Due serial ports are built based on the same ring buffer class in the core, I had to define a few complementary classes based on this ring buffer to be able to define separately the size of the Serial RX and TX buffers. More details here.

Watchdog reset on the Arduino Due

Unfortunately the Watchdog of the Arduino Due works a bit differently compared with the watchdog of the Uno and Mega boards. There is no < avr/wdt.h > to import, since the Due is based on an sam architecture, and it seems watchdog support is much less good. On an project I needed to perform a watchdog reset of the Due board, and it proved tricky to find online the piece of code to do this, so I put it here.

Microcontroller-based loggers

Part of my PhD consists in performing measurements in the Arctic. A few companies sell loggers and equipment to be used for Arctic fieldwork, but the high price they charge means that buying off-the-shelf, we could have afforded only one or two instruments. As a consequence, I built the instruments we need in-house (with the help of our laboratory engineer). This is actually a very simple microelectronics and programming task, but getting everything to work reliably for 'professional' use requests a bit of work, which is why I want to share my experience in this post.

A class for helping in bookkeeping of config variables in Arduino programs

Complex Arduino programs may resort to some sort of config variables, with the need to write / read for example to SD, access, and update the configuration. While this can be done with ad-hoc hand coding, I wrote a C++ class and a python script to automate the process, which is especially useful on complex projects when the number of config variables grows. More here!.

Transmit data between Arduino and Python using C++ struct

Transmitting information between an Arduino board and a Python script is often useful. In this post, you will learn how to easily do that.