We would like to hear from you!

plaindsp_audio_kit

Dear visitor,

We are very pleased to welcome you at the Arduinoos blog and we would like to hear from you and to get your opinions about our future projects.

Could you please complete this 5-minute online survey to get to know you better ? Thanks for helping.

Best regards,

The Arduinoos team

Click here to start the online survey

Tips and tricks (Part 23)

Previous T&T

Although the situation is not very common, you may face like me the following situation: I needed to read analog signals applied to some of the 6 ports from an Arduino UNO. But some of the readings would use the Vcc reference (so as to say the analogReference(DEFAULT))  and some others would use the 1.1 V internal reference (so as to say the analogReference(INTERNAL)).

Jumping from one reference to another is not without risks of getting very confusing analog measurements. Arduino reference manual says:

After changing the analog reference, the first few readings from analogRead() may not be accurate.

Good point, however how much is “few”? If you drop an eye on the ATMEGA 328 Datasheet, you may read that: “the user must allow the (internal) reference to start up before the output is used…. … Refer to ”Internal Voltage Reference” on page 51 for details on the start-up time.”

So far so good. And well, I decided that I would do something special to make 100% sure that my readings are correct, whatever the operating conditions. The best way to do that would be to use a reference voltage, attach its output to a dedicated analog port and perform measurements as long as the gap between to consecutive measurement is not null. Although this option is bulletproof, it is expensive in terms of addtional components and commissioning of analog ports.

After some more reading in the ATMEGA data sheet, one can read at the MUX section that 6 among the the 14 theoretical ports are used by arduino, one (actually port 8) allows access to the chip temperature (the famous hidden thermometer) and another one (port 14) reads the internal 1.1 V! Hurray! We have a built in reference!

mux

Here is is the function that I wrote to perform the analog to digital startup. The comments in the code should suffice to explain the way it works.

void InitAdc(uint8_t ref)
{
	ADMUX = 0x00; /* Clear register */
	analogReference(ref); /* Set reference */
	analogRead(0); /* Read any channel once in order to set parameters */
	ADMUX |= 0x0E; /* Set channel 14 so as to say 1.1 V ref */
	const uint8_t ADSCmask = (1 << ADSC); /* Compute mask once to save time */
	/* Set comparison parameters */
	const uint8_t maxReadings = 100;
	const uint8_t maxDelta = 4;
	/* Local variables */
	uint8_t readings = 0; /* Readings prevent infinite looping */
	uint16_t lastReading = 0;
	uint16_t reading = 0;
	do {
		delay(1);
		readings += 1; /* Record readings */
		lastReading = reading; /* Record last reading */
		ADCSRA |= (ADSCmask | (1 << ADEN)); /* Start single conversion */
		while((ADCSRA & ADSCmask) == ADSCmask); /* Wait for conversion to complete */
		reading = (ADCL | (ADCH << 8)); /* Compute resulting adc counts */
	} while ((abs(reading - lastReading) > maxDelta) && (readings < maxReadings));		
}

HTH

 

 

Tips and Tricks (Part 22)

Previous Tip & Trick

Here is an update of the Electronics Pinout Sheets originally issued by Arduinoos and now edited by PlainDSP (same team behind the screen!)

elec_pinout_v4

HTH

Next Tip & Trick

 

Doppler Effect

Have you ever wonder why the sound from the honk of a car changes as the car travels next to you. While in the same time, the driver of this same car swears that the sound of his honk did not change a bit while he was sitting in the car! Who is right?

Well, have a look at this post and discover how the Plain DSP audio kit can help in solving this enigma!

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 */
PlainDSP DSP;

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 */
	Serial.begin(115200); 
	/* Set data acquisition parameters */
	DSP.SetAcquisitionEngine(_adcChannel, _refVoltage,  _samplingFrequency, _samples, _options);
	/* Init control LED */
	DDRB |= ctrlLedMask;
}


void loop(void)
{
	/* Acquire data from selected channel */
	DSP.GetScanData(); 
	/* Null offset */
	DSP.ResetOffset();
	/* Weight data */
	DSP.Windowing(DSP_WIN_TYP_HANN, DSP_FORWARD);	
	/* Compute FFT */
	DSP.ComputeForwardFFT();	
	/* Compute amplitudes */
	DSP.ComplexToReal(DSP_SCL_TYP_AMPLITUDE);
	/* 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 */
	delay(onTime);
	PORTB &= ~ctrlLedMask; /* Toggle control led off */
	delay(offTime);
	/* 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:

uno_usb_pb_01

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)

uno_usb_pb_02

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

uno_usb_pb_03

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

uno_usb_pb_04

  • Click on ‘Browse my computer for driver software’

uno_usb_pb_0(

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

uno_usb_pb_06

  • Done! Now run the FLIP application

uno_usb_pb_07

  • Select ‘ATmega16U2′ in the device list

uno_usb_pb_09

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

uno_usb_pb_10

  • 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.

uno_usb_pb_08

  • The FLIP main window looks like this:

uno_usb_pb_12

  • 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.

uno_usb_pb_13

  • 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)

uno_usb_pb_14

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

 

HTH

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”

publication

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.

Arrivee_Projectile_DTAL

“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

45ffe18e-b7b7-480a-bec6-1ee5fb6416ed-large

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?