The huge popularity of PlainDSP (merge of PlainFFT and PlainADC libraries) and the numerous requests for help drove me to think about a convenient solution for all designers, artists, students, professors, R&D people, prototypists who need to understand, experiment, create systems which feature advanced Digital Signal Processing on Arduino. The result of intense thoughts, design and writing is the collection PlainDSP kits, starting with the audio kit.

So please, pay a visit to plaindsp web site. By getting one of these kits you not only get a desirable product you also support a private initiative for popularizing science. Thank you.


Extremely Low Frequency Electro Magnetic Field Sensing (Part 5)

Part 1234, 5

Time for upgrade. The pretty popular ELFEMF posts were prepared before the obsolescence of PlainADC and PlainFFT libraries.  Next is the revised code for the detection of Extremely Low Frequency Electromagnetic Fields which is compatible with PlainDSP library. So simple and yet powerful application! Enjoy.

	MicroELF_EMF: Electrical radiation measurement
	Revision 03

	Applicable license :

	This program and related documentation are owned by HL2 group SAS. 
	The program is subject to the license GNU GPL version 3. This license 
	allows you to use, reproduce and adapt this program for private, 
	educational, research purposes. 

#include <PlainDSP.h>

/* Create objects */

const uint8_t ctrlLedMask = (1 << PINB5);

/* Acquisition parameters */
const uint16_t _samples = 128; /* Max value depends upon available memory space */
const float _samplingFrequency = 400.0; /* From 0.125 Hz to 80 kHz */
const uint16_t _adcChannel = 0; /* From 0 to 5 on ATmega328 powered Arduino */
const uint16_t _refVoltage = DSP_REF_VOL_INTERNAL; /* Internal: 1.1V */
const uint8_t _options = (DSP_OPT_DIS_TIM_0 | DSP_OPT_DIS_TIM_2 | DSP_OPT_NOI_CANCELLER);
/* Display parameters */
const float _targetFrequency = 50.0;
const float _frequencyTolerance = 5.0;
const uint16_t _maxOnTime = 600;

void setup(void)
	/* Initialize serial comm port */
	/* Set data acquisition parameters */
	DSP.SetAcquisitionEngine(_adcChannel, _refVoltage,  _samplingFrequency, _samples, _options);
	/* Init control LED */
	DDRB |= ctrlLedMask;

void loop(void)
	/* Acquire data from selected channel */
	/* Null offset */
	/* Weight data */
	/* Compute FFT */
	/* Compute amplitudes */
	/* Find target peak */
	struct strPeakProperties targetPeak;
	DSP.TargetPeak(_targetFrequency, _frequencyTolerance, &targetPeak);
	/* Compute blink on/off ratio */
	uint16_t onTime = uint16_t(targetPeak.height);
	if (onTime > _maxOnTime) {
		onTime = _maxOnTime;
	uint16_t offTime = (_maxOnTime - onTime);
	/* Control LED */
	PORTB |= ctrlLedMask; /* Toggle control led on */
	PORTB &= ~ctrlLedMask; /* Toggle control led off */
	/* Optionally print data */
	// Serial.print((millis() / 1000.0), 3);
	// Serial.print(';');
	// Serial.print(targetPeak.height, 2);
	// Serial.println();

Reminder: Just insert the bare end from a piece of insulated wire (~20 cm long) in the analog port 0. Power the arduino board, upload the code. The internally built LED (Digital port 13) will blink according to the magnetic field strength… The closer you get from an AC line or a power distribution point, the longer the on state of the LED.

Warning: Do not touch live power lines, sockets or equipment with the wire!



Bug Of The Day

And this is a strong one!

We are using quite many UNO platforms for fast prototyping. In spite of their relative high price, we always bought boards from Arduino, not because we fear the ‘hall of shame’, but because we understand that that buying these boards contributes to the business model of the Arduino team and helps keeping the heads of this community alive.

So far so good, except for today. We received 6 UNO boards that we bought from FARNELL which is our main supplier. And too bad, only one out of the six boards was working properly!

Connecting a ‘defective’ board through the USB port would systematically trigger the following message:


A known for good board would immediately be recognized, whatever the type (UNO, MEGA, etc.). So what? From the beginning, our assumption was that the firmware on the ATMEGA 16U2 (this little square chip next to the USB port) was corrupted, and we were right! The ATMEGA 16U2 acts as a converter between the USB port and the Serial Communication Port of the microcontroleur (so as to say the ATMEGA 328). It holds some firmware which cares about the conversion.

Upgrading the firmware on the ATMEGA 16U2 is fortunately piece of cake if you follow the next coming instructions:

  • Make sure that you run the latest version of Arduino. The IDE has nothing to do with the described action, however, the latest software versions contains the most update drivers.
  • Download and install the FLIP software from the ATMEL web site (freeware, no registrations). Here is a link with the FLIP page. My version was 3.4.7.
  • Open the device manager and locate the ‘defective’ UNO (My PC is running Windows 7 pro, 64 bits)


  • Shortcircuit the two pins from the ICSP connector for a few seconds. The UNO board is now recognized as


  • Update the driver for this newly created device: double-click on ‘ATmega16U2′, select the ‘Driver’ tab and click on ‘Update Driver…’


  • Click on ‘Browse my computer for driver software’


  • The drivers are located in ‘C:\Program Files (x86)\Atmel\Flip 3.4.7\usb’, click on the ‘Next’ button


  • Done! Now run the FLIP application


  • Select ‘ATmega16U2′ in the device list


  • Select ‘USB’ in the ‘Communication’ ‘Settings’ and open the USB port


  • Load the HEX file from ‘C:\Program Files (x86)\arduino-1.6.0\hardware\arduino\avr\firmwares\atmegaxxu2\arduino-usbserial\Arduino-usbserial-atmega16u2-Uno-Rev3.hex’ and check the ‘HEX file aprsed’ message in the status bar.


  • The FLIP main window looks like this:


  • Click on the Run button, and here is the updated window of FLIP showing successful execution of the Erase, Blank Check, Program and Verify actions.


  • Unplug the Arduino board and plug the USB cable back. The Device Manager shows an ‘Unknow device’ for a little while, finds the driver and finally adds the Arduino board to the list of Ports (COM & LPT)


  •  If your computer fails to self recognize the Arduino board, go through the standard procedure for upgrading the Arduino driver.



Message of the day

Too bad, the NC6000 Compaq laptop that I bought 10 years ago for my wife passed away. The reflow of the Maxim Dallas Power Supply supervisor chip worked for 2 years and no more! As i had no time to spend on fixing this problem again, we went to the mall next door and bought a new laptop from HP, fitted with Windows 8 (blah, no way to downgrade this PC to Windows 7).

As I am a kind person and unfamiliar with rude language, I will skip the description of the multiple attempts of HP, Microsoft and others to make you fall in one of their marketing pitfalls. No thanks, I am not interested in bulshit, I just want to run my computer and do not want to be bothered by mirific offers. Anyway, one message struck me hard during the preparation of my account: “Nous nous occupons de certains points”, full screen and flashing coloured background. This sentence translates to “We care about certain aspects”!

“We care”: who is “we”? I thought that the operating system was responsible for setting user account parameters! This “we” may mean that there is a force task within the operating system? Or does this means that someone, somewhere cares about tweaking my account? NSA or something?

“Certain aspects”: Which aspects? Aspects that i am so stupid that I cannot understand? Or aspects that I foresee so well that they are disguised? Is there a log for “certain aspects” somewhere in windows 8? Shall we get support for “certain aspects”? How come someone be so vague at setting my own private account. Do not worry young man, “We care”. Oh good, I feel fine.

Not at all. I just hate that.


Publication of the day

I am very glad to announce the first official publication involving the PlainDSP kit and the team behind the scene. We also congratulate Kostas and his team for designing such an awesome detector. Although PlainDSP kits can be used in the context of ludic applications, it provides all the means necessary for the design of much more serious games! Enjoy the reading of “HARDWARE IMPLEMENTATION OF A SYSTEM CLASSIFYING THE OPTOACOUSTIC SIGNATURE OF INSECTS WING-FLAP”


Video of the Day

I was still a kid when JFK announced that he wanted an american to walk on the moon. At this time I was reading the adventures written by Jules VERNES and the moon was still this strange disc up in the night sky, intangible and mysterious.


“Arrivée Projectile DTAL ” by François Pannemaker, engraveur ; Henri de Montaut, drawer.

Although I had a weak idea about what was going on around the world, I was impressed by this young American President to whom nothing seemed impossible. Few years later, in the middle of a summer camp, the director called everybody and invited us to see the TV program on the small portable B&W receiver that he managed to get and plug on the battery of his car: Neil ARMSTRONG was walking on the moon! Some times later, Pink floyd then released “The dark Side of the Moon” and the Apollo program came to an end.

What was implicit to the strategists became more and more clear to the public: the lunar program led to the development of safety-critical systems and the practice of software engineering to program those systems. Much of this knowledge was issued from the Apollo program  and formed the basis of modern computing.

Next video brightly illustrates the boosting effect of the space programs on electronics. The author could have named it: “Form Gemini to Arduino” ! Enjoy


Poster of the Day


Although the situation looks critical, it looks like each of the passengers is finding a way to get out of the sinking boat. Everybody’s free to interpret this poster to his taste: Did the boat broke down due to the lack of communication and synergy? Is it an apology of “every man for himself”? Lost for lost, do these individual solutions match better the situation? Is it an advertisement for the DIY? Who knows?

An easy way to print multiple variables

The Serial.print() function is a nice way to print on the serial monitor but it is a bit frustrating to have to type something like :

Serial.print("Hello, I'm ");
Serial.print("and I'm ");
Serial.println(" years old.");
Serial.print("I live in ");
Serial.print(", my hobbies are :")

It could be a good idea to useSerial.print() once, don’t you agree? C/C++ programming – on computers – provides one way to do so : using  the the  printf() function along with the stream operators of printf(). This function is available in C and C++, and it is called this way :

printf("Hello, I'm %s and I'm %d years old.\nI live in %s , my hobbies are : %s", myName, myAge, myCountry, myArduinoHobbies);

Any %s operator will be replaced by the given string and any %d operator will be replaced by the given integer in the order they are given. The ‘\n’ indicates that the cursor must go to a new line (a kind of short Serial.println()).

The stream operator “<<” is C++ specific and may be quite confusing when met for the first time but a simple example is self explainatory :

std::cout << "Hello, I'm " << myName << " and I'm " << myAge << " years old.\nI live in " << myCountry << " , my hobbies are : " << myArduinoHobbies;

std::cout is the terminal, the output of a program which runs on a computer.

Sadly, since these functions directly print to a monitor only available on a computer, it is not possible to use them on an Arduino boards. Some workarounds have been presented on the Arduino playground here and here and of course, Arduinoos provides its own ! It is not the ultimate one but it does the job. PlainPRINT allows you to use the printf() way and the streaming way, as follows :

_printer.Printf("Hello, I'm %s and I'm %d years old.\nI live in %s , my hobbies are : %s", myName, myAge, myCountry, myArduinoHobbies);

and :

_printer << "Hello, I'm " << myName << " and I'm " << myAge << " years old.\nI live in " << myCountry << " , my hobbies are : " << myArduinoHobbies;

The %letter specifiers of Printf() are not as numerous as the ones available from the original function printf(). Here are the different specifiers :

schar*ASCII string
%char "%%" outputs "%"

Using Printf() has an advantage over using the stream operator: you can print an integer value in hexadecimal, octal or binary. Moreover, you can specify the precision of a floating point number, here is an example :

_printer.print("Pi with few decimals %4f", 3.14159); /* output : 3.1416 */

This code shortening library is, as usual, available on request.

Cry of the day

Cabu, the “grand Duduche” “father” has been murdered in Paris today with three cartoonists and seven other persons.


Tips and Tricks (Part 21)

Previous T&T

Convert numerical values in strings of characters.

Converting numerical values into strings of characters is easy as far as Serial functions is concerned . However you  may face one day or another the need for converting a numerical value for insertion within an existing string of characters (e.g. LCD, commands sent through SPI, etc.). Here is a collection of converting functions and their Serial equivalents. But firstly, we need to create a buffer which will contain the output from the conversion functions:

char *_vBuffer;

void setup(void)
	_vBuffer = (char*) malloc(16 * sizeof(char));

These few lines of code constitute the header and the setup section of the code. And here are the converting instructions:

/* Convert signed 32 bits integer */
ltoa(2863311530, _vBuffer, 10);
/* Results in -1431655766 */
/* Same as */

/* Convert unsigned 32 bits integer */
ultoa(2863311530, _vBuffer, 10);
/* Results in 2863311530 */
/* Same as */

/* Convert 32 bits integer to hex */
itoa(2863311530, _vBuffer, 16);
/* Results in AAAAAAAA */
/* Same as */
Serial.println(2863311530, HEX);

/* Convert unsigned 16 bits integer */
utoa(43690, _vBuffer, 10);
/* Results in 43690 */
/* Same as */
/* Convert signed 16 bits integer */
itoa(43690, _vBuffer, 10);
/* Results in -21846 */
/* Same as */
/* Convert integer to hex */
itoa(43690, _vBuffer, 16);
/* Results in AAAA */
/* Same as */
Serial.println(43690, HEX);

/* Convert float using 6 decimals */
dtostrf(M_PI, 8, 6, _vBuffer);
/* Same as */
Serial.println(M_PI, 6);

More details about the converting function here


Arduino on French/German TV

Arduino on French (and German) TV, Arte channel: watch the Future program and enjoy!

Here are a few ideas that I picked up in the presentation:

  • Floriane: “It is fun when it works!”
  • David Cuartielles: Has fun discovering that the makers are ahead of his own imagination
  • It is good to see Arduino entering the conventional education system. However, the working conditions stay the same: two mates sitting at one table and facing the wall. Flip the chairs, tilt the screen and use large, open space tables!
  • Sailing boat driven by Arduino: awesome, however a little bit more expensive than 20€! The meta arduino components can be very expensive!
  • Bye bye Popy, see you at QuaiLab!