ATXMEGA32A4U ADC periodic noise

Go To Last Post
76 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Dear Experts,

Hi 

I use the ADC channel of an ATXMEGA32A4U chip to capture audio data and send it via USB port to Computer,

 

The problem is that I see a periodic noise on it that I could not find what is the source of .

 

I disconnect the analog circuit from ADC pin and find that noise still exists,

 

Could you please tell me what is the source of this noise and how I can  remove it.

 

Please listen to attached wave file.

 

But about the Xmega program:

 

1. Micro clock is set to 32MHz.

2. ADC is set to : Signed, 12 bit, right hand side, 200000 clk,  Manual triggered,  ADC_PIN1

3. a timer is set with frequncy of 8000 sps and in every interrupt a manual ADC capture is triggered and samples are put into a circular Queue,

Then by USB port, those data are sent to PC program. 

 

ADC Init code:



#define				MY_ADC					ADCA
#define				MY_ADC_CH				ADC_CH0

static void adc_init(void)
{
	struct adc_config adc_conf;
	struct adc_channel_config adcch_conf;

	memset(&adc_conf, 0, sizeof(struct adc_config));
	
	memset(&adcch_conf, 0, sizeof(struct adc_channel_config));

	adc_set_conversion_parameters(&adc_conf, ADC_SIGN_ON, ADC_RES_12,ADC_REF_VCC);
	adc_set_conversion_trigger(&adc_conf, ADC_TRIG_MANUAL, 1, 0);


	adc_set_clock_rate(&adc_conf, 200000UL);
	adc_write_configuration(&MY_ADC, &adc_conf);
	
	adcch_set_input(&adcch_conf, ADCCH_POS_PIN0, ADCCH_NEG_NONE, 1);
	
	adcch_write_configuration(&MY_ADC, MY_ADC_CH, &adcch_conf);
}

Interrupt routine to capture audio:

 


static void tc_callback(void)
{
	int16_t result;
	
	adc_start_conversion(&MY_ADC, MY_ADC_CH);
	adc_wait_for_interrupt_flag(&MY_ADC, MY_ADC_CH);
	result = adc_get_result(&MY_ADC, MY_ADC_CH);
	if(result < 0)
	{
		result = 0;
	}
	
	result -= 0x0510;
	result *= 16;
		
	SendQ0[wsendidx]= result;
	wsendidx++;
	if( wsendidx >= QSIZE )
	{
		wsendidx = 0;
	}

	tc_clear_overflow(&TCC0);
}

 

 

 

Thanks for you kind help,

Mehrdad,

 

 

 

 

 

 

 

 

 

 

 

 

Attachment(s): 

This topic has a solution.
Last Edited: Tue. Sep 17, 2019 - 04:29 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mehrdad_58 wrote:

if(result < 0)
	{
		result = 0;
	}

 

Just a guess on my part, if you don't want signed data, (code above clips neg. input), why set up the ADC for signed capture?

How do you feed the input, can you show your circuit for the input to the ADC pin?

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

Last Edited: Wed. Sep 11, 2019 - 08:19 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

ADC_REF_VCC!

it looks like you just hear the voltage inside the cpu.

try a different voltage reference

Last Edited: Wed. Sep 11, 2019 - 08:28 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Or "bias" your input audio signal to VCC/2

Jim

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't hear anything on the wave file, and I'm not opening a wave editor...

 

I'd suggest / ask:

 

What frequency is the periodic noise?

Need to see an O'scope of the output signal.

What board, commercial or your own design?

What power supply?

Linear or switching?

Is the power supply properly filtered?

What is the output signal when the input pin is grounded?

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I never face the above problem, signal mean value is 1296 and it never get less than 0. 

As you can see in interrupt routine, after getting the signal I have to decrease 0x0510  from it to remove the DC signal.

Last Edited: Thu. Sep 12, 2019 - 05:01 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please Consider that : 

 

ADC_REF_VCC = VCC divided by 1.6.

 

Thus using ADC_REF_VCC is equal to  3.3/1.6 which equals to 2.06 V.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

About the questions:

 

What frequency is the periodic noise?                 --> Please  listen to the audio, the period is near 2 seconds, each 2 seconds, a hum signal cab be seen on the line.

 

Need to see an O'scope of the output signal.      --> I use O'scope, but input signal to the ADC pin is quit clean, I think it is a matter of ADC of micro controller.

 

What board, commercial or your own design?    --> board is designed by me.

 

What power supply?

 

Board is connected to USB port of PC and power is get from PC. Then by using a LF33, I produce the 3.3V voltage and feed it to the uC.

 

Linear or switching? I think it is linear

 

Is the power supply properly filtered? --> Yes I use bypass capacitors and the quality of 3.3V and 5V signals are good.

 

I also use a inductor between AVCC and VCC(3.3V) power supplies.

 

What is the output signal when the input pin is grounded?  --> The audio that I uploaded is captured when nothing is connected to the ADC signal. 

 

 

You asked very nice questions, I hope we have a brain storming here that results to bug removal.

 

Thanks a lot

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I also add the following picture which is the audio file after amplification by 24 DB using audacity software.

 

As you can see a periodic noise can be seen in the profile of the audio.

 

 

 

 

periodic noise file

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can't make out the scale on that picture - so what is the width of those pulses, and the rate/period?

 

could they correspond, perhaps, to USB activity ... ?

 

I'd use a scope to probe around and see if that pattern is occurring anywhere else ...

 

You haven't answered DocJC's questions in #5:

 

DocJC wrote:

What frequency is the periodic noise?

Need to see an O'scope of the output signal.

What board, commercial or your own design?

What power supply?

Linear or switching?

Is the power supply properly filtered?

What is the output signal when the input pin is grounded?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please see the attached wave file in above 

 

The period is 1.65 seconds.

 

active duration of noise is 220 milli seconds.

 

 

Is the power supply properly filtered?    --> I just use bypass capacitors for 5V and 3.3V power supplies.

 

What is the output signal when the input pin is grounded?  -->  I have to use another ADC pin which is connected to ground and capture data from it and find that noise still exists. 

 

could they correspond, perhaps, to USB activity ... ?

 

I read data from USB port 1000 times per second and in each transaction I read 34 bytes,

I also write data to USB endpoint 1000 times per second and in each transaction I write 34 bytes.

 

Both input and output endpoints are set to work in isochronous mode.

 

I try to use scope to find a clue and report it here. 

 

Please give me all your ideas to speed up the bug removal phase.

 

Best wishes,

Mehrdad, 

 

 

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It seems that usb transactions has an effect on noise.

What to do now?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mehrdad_58 wrote:
What to do now?

So you need to find out how that noise is getting into your audio.

 

You still haven't answered DocJC's questions - particularly with regard to what hardware you're using.

 

If it is noise from the USB, it is likely a hardware issue.

 

Are your analogue supplies well isolated from the digital supplies ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Thu. Sep 12, 2019 - 04:37 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
Are your analogue supplies well isolated from the digital supplies ?

I think the OP said he was using USB as power source!

 

mehrdad_58 wrote:

What power supply?

 

Board is connected to USB port of PC and power is get from PC. Then by using a LF33, I produce the 3.3V voltage and feed it to the uC.

 

First lesson for any audio engineer is power supply is critical to success!

 

Jim

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

Last Edited: Thu. Sep 12, 2019 - 06:25 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So (some of) the noise could be on the power coming from the PC.

 

But people do make bus-powered USB audio interfaces - so it must be possible ...

 

Would need both good filtering on the incoming 5V from the PC and good isolation of the analogue & digital stuff around the AVR

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The "noise" could be as subtle as a dropped USB message! It might be useful to POST an image of the recovered audio as seen on an oscilloscope screen with enough detail to show both the "big picture" and the individual noisy samples. 

 

As an example, something like a buffer over-run could happen periodically and appear asynchronous to the audio.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your invaluable comments.

 

Let me show you the power supply of the board

 

VBUS from USB port is low pass filtered to remove the noise and a 5V power supply is produced.

 

The ground of the board is connected to the GND of USB port by using a ferrite bead.

 

Then this 5V is feed into a LF33 regulator to produce a clean 3.3V to feed into uC.

 

 

 

Power supply of the uC is depicted in above picture,

 

AVCC is connected to 3.3V by using a ferrite bead.

 

and all decoupling capacitors are also depicted.

 

I think the power quality is good because there is no glitches on Oscope.

 

And also I do not see any glitches on the audio input of the ADC channel.

 

I think buffer overrun may be an issue.

 

I try tho change the buffer size to see if the behavior of noise is going to change or not.

 

Then share the result here.

 

Thanks a lot

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Use the second LF33 to form only AVCC, one 10 mF electrolytic capacitor and 100 nF near the AVCC pin.
Or just replace the ferrite bead F4 with a schottky diode (BAT54 for example) and the capacitors near the AVCC pin are required.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I totally removed the  ferrite bead and connect the AVCC to 3.3V and the amount of noise decreases a lot.

Now I am looking to find a big capacitor for bypass and use it to see if get better results.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mehrdad_58 wrote:

I totally removed the  ferrite bead and connect the AVCC to 3.3V and the amount of noise decreases a lot.

This is not enough.
There is no decoupling between VCC and AVCC.
Install a schottky diode between VCC and AVCC and a  electrolytic capacitor after diode.

 

But, an additional LDO, even in the SOT-23-3 package, is the best choice.

Last Edited: Fri. Sep 13, 2019 - 01:56 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

also needs proper PCB layout ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

 

Hi again,

 

Could you please give me a small schematic that I use in my circuit.

 

You can easily design it by pbrush in windows or design it on paper and take a picture and share it here. 

 

if you give me part numbers then it would be great and I could find it in the market. 

 

As you know I am not a electronic man I need a step by step help to proceed.

 

Currently I fabricated a sample PCB and I would like to get answer from all parts before getting designing second PCB and fabricate it. 

 

There is another point that I would like you to know. 

 

I have create a 2V reference voltage to be used for output scaling of ADC input and it is created by using AVCC power supply.

 

 

Then I use that 2V power supply to scale the input of ADC pin to be in the range of 0 to 2 volts by using below circuit.

 

 

You know I have very complicated situation. smiley

 

Thanks a lot

 

 

Last Edited: Fri. Sep 13, 2019 - 06:32 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A 2.0V zener is a really poor choice. I'd go for a 2.048V voltage reference. With modest accuracy and modestly low power, you ought to be able to get them pretty inexpensively. Mouser has more than 6 different part numbers close to $0.80 USD. You can get them in a two-terminal form that behaves like a zener and a three-terminal form that is like a micropower voltage regulator (e.g. hooks directly from the power rail to ground and outputs the voltage on a third pin). 

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok Experts, 

 

I applied a lot of changes in hardware and still that noise exists.

 

I doubt that noise is added when USB transaction with PC is in progress. 

 

Please lets change our viewpoint to improve software.

 

As ADC trigger mode is manual and it is run 8000 times in second in a timer  interrupt, Please let me know how to get a better ADC result when USB transaction is in progress. 

 

For example setting a flag or calling a function or doing something when ADC read is in progress.

 

Please remember that I am working with an ATXMEGA32A4U micro Controller

 

Thanks a lot

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Im measuring battery liion voltage in some devices with xmega12a1u and also got "waving" results. No cap or any other settings of measuring solving this. They are crapy adc and thats all imo.

Polandball
 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks a lot,

 

Based on previous comments in this site, I come to the conclusion to use a median filter to get an acceptable result.

 

 

I stop this topic for now, 

 

In future If the quality was not good enough, I open it again. 

 

Thanks for your kind support. 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Always better to stop noise getting in in the first place - rather than try to filter it out after the fact.

 

It does look & sound very much like digital noise getting into your analogue - so should be possible to isolate it.

 

Or, as they say in media production, "just fix it in post"  laugh

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Awneil,

 

The problem is that I am not an analog electronic designer and I try to use ready made circuits over the net. 

 

And when I face a problem I have to use international community sites like avr freaks to resolve it.

 

But when problem does not resolve, I have to proceed to other steps to get more familiar with board and hardware aspects of it, otherwise I get frustrated.

 

Anyway thanks a lot for your valuable comment.

 

 

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does the noise still occur if you remove C15?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mehrdad_58 wrote:
The problem is that I am not an analog electronic designer

Yes, that's a problem - because, most likely, it is an analogue design issue!

 

frown

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does the noise still occur if you remove C15?

 

Yes, I removed the C15 cap and it was that periodic noise on the ADC sampled audio.

 

I think it is a matter of USB data transfer, when the data transfer from USB endpoints is in progress, I find that some noise exists on the line. 

 

I only can access the ADC captured signal from USB device and I read and write from 2 USB endpoints. 

 

when I only use the read process and do not use write process, I find that the duration of noise decreases. 

 

Thus I think it is a matter of USB transactions. 

 

 

 

Last Edited: Wed. Sep 18, 2019 - 11:43 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mehrdad_58 wrote:
VBUS from USB port is low pass filtered to remove the noise and a 5V power supply is produced.
22 ohms * 100uF = 2.2ms

mehrdad_58 wrote:
I think the power quality is good because there is no glitches on Oscope.
Possibly good as oscillations (glitches) will be dependent on the power supply's stability and the load's impedance (a time-variable value)

Power supply stability, noise, and efficiency can be measured and evaluated.

 

XMEGA don't have a PSRR.

XMEGA ADC noise data is typical (not bounded)

 

STM LF33 is a near low noise LDO; what's the noise of the LF33's 5V input?

(USB VBUS ... oh ... am recalling my memories of certain USB wall warts ... 500mV peak-to-peak spec ripple and noise during the warranty's duration ... noise plus the SMPS's primary frequency and a few harmonics)

The power supply's noise may be an issue; supply the XMEGA's power from a battery or cell.

An 18650 Li-ion cell dropped though a rectifier diode is unconditionally stable, very low noise (low frequency noise due to cell's discharge), and a near match for XMEGA VCC range.

LF33 input is 16V max.

Power the LF33 from a 12V automotive battery.

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Re 5V's R49 : instead, typical is a ferrite bead as XMEGA are excellent current peakers (conducted emissions generators) and to reduce voltage drop (give LF33 some head room as USB VBUS is 4.4V .. 5.25V, LF33 input is 4.3V min per its SVR [PSRR] spec)

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The power supply's noise may be an issue; supply the XMEGA's power from a battery or cell.

An 18650 Li-ion cell dropped though a rectifier diode is unconditionally stable, very low noise (low frequency noise due to cell's discharge), and a near match for XMEGA VCC range.

LF33 input is 16V max.

Power the LF33 from a 12V automotive battery.

 

Dear gchapman,

 

Thanks for your comments, 

 

To reduce USB power supply noise, I use a battery powered Laptop  and the quality of power is good but USB noise still exists. 

 

I faced this problem in previous phases and resolved it by low pass filtering the USB power. 

 

Please concentrate on micro controller USB transactions that produce noise and give me a way to get rid of it.

 

Thanks a lot,

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mehrdad_58 wrote:
Please concentrate on micro controller USB transactions that produce noise and give me a way to get rid of it.

But we don't know for sure that is the source?

 

You really need to identify the source before thinking about ways to fix this.

 

A scope would be a key tool in this investigation ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Indeed, there are still quite a few possible sources of noise on the table. Here is one that has NOT been considered, I think.

 

Taking a very simple case as an example, suppose that you have one thing that happens every, lets say 100 CPU clock cycles. And you have another thing that happens every 101 CPU clock cycles. Then, every 101*100 clock cycles (if I did my algebra right), the two things will happen on the same clock cycle. Here is a possible source of "noise" that much, much, lower in frequency than any of the internal processes. Its source is hardware, but the frequency of its recurrence is controlled by software and events that set internal rates. It is called "aliasing", but also other names that are unprintable in polite discourse.

 

You can debug THIS possible source by changing repetition rates by a very small increment. But, be careful when you do this with the ADC because there can also be aliasing between the ADC measurement rate and signal present at the ADC input. If the frequency of the low frequency noise changes when you change the sample rate or the ADC clock rate by a very small amount, then you still have to sort out whether it is internal or external. Shorting the ADC input to ground is usually sufficient to remove external sources via the ADC input. NB - disconnecting an ADC input pin and just letting it float is NOT a valid test.

 

There are other noise source that can be very sneaky. Very high in the list is switching power supplies. These make power supply noise that is hard to track and even harder to do something about, And, it lends itself, very nicely, to the sort of aliasing described, above. Have you tried replacing your power source with something that is known "clean", such as a battery?

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I think the first challenge is finding out how the noise is finding its way into the adc. Of course, the assumption here is that it is the adc - what tests have been done to prove/disprove this?

Once we are clear of how the noise finds its way to the adc, then we can look at circuit design and layout - both of which I’ve not seen enough information. We have no idea if any fundamental design principles are being violated.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
I think the first challenge is finding out how the noise is finding its way into the adc

Absolutely!

 

The obvious step would be to scope the ADC input to see if it is there; if it is, work back towards the source.

 

Also scope the analogue supply & GND.

 

Most of the questions from way back in #5 remain unanswered.

 

 

then we can look at circuit design and layout - both of which I’ve not seen enough information.

We have no idea if any fundamental design principles are being violated.

Indeed.

 

We've just seen snippets of schematic, and no layout at at all.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Wed. Sep 18, 2019 - 09:20 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A known clean power source, such as a battery, would go a long way. It would need to be connected post regulator with the regulator disconnected, Two 1.5V batteries (especially new) should be good enough to provide "3.3" volts.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Thu. Sep 19, 2019 - 12:06 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Boys,

 

Thanks a lot for your invaluable comments,

 

I make a new test and in which, I connected another ADC pin of the micro controller to GND and set it as active ADC instead of one I used before and I find that that periodic noise still exists. 

 

Thus it seems that the source of the noise in not external.

 

As I mentioned in above pictures in previous posts, The noise is periodic and most of the time I do not see that.

 

The device is designed to do followings:

1- read ADC samples and send them to PC via USB isochronous transactions,

2- read data from PC by using isochronous endpoints and send it to DAC channels of Xmega.

 

The program for uC (micro controller) and PC is written in a way that does both Reading and Writing in progress. 

But when I change it in a way that the PC only read data from Xmega, then the duration of noise decreases. 

 

Thus I come to the conclusion that USB transactions may produce noise.

 

Also as board is designed in a way that in gets the power from USB port, It is not possible for me to feed the power from other sources, but I always use a battery powered laptop for board to reduce the amount of noise.

 

above are my observations yet. 

 

 

 

 

 

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If it is not external, then you need to rule out the adc. I would modify the code such that the adc still operates, but rather than read the data from the adc, substitute in known data like from a sine table

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If it is not external, then you need to rule out the adc. I would modify the code such that the adc still operates, but rather than read the data from the adc, substitute in known data like from a sine table

 

 

ANSWER:

I have done it before, It works 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You say it is not external but it is not internal, so where is the problem? Sounds external to me.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think when data is transfered by USB Port, ADC sampling does not work properly.

Also by sine table I mean an array of integer which contains a period of a sine signal and in every sampling, current index of array is returned and index is incremented by one
Sample = table(Idx);
Idx++;
Idx%= table_length;

. Correct me if I am wrong.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What happens at the USB host end if you have a deep buffer, probably circular, that your data goes into and is read out at a standard rate, not at the rate of the data across the USB channel?

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What happens at the USB host end if you have a deep buffer, probably circular, that your data goes into and is read out at a standard rate, not at the rate of the data across the USB channel?

 

Hi Jim,

2 endpoints are set for Xmega device to handle isochronous data transfer.

 

isochronous endpoints are used for real time data transmission in USB devices.

 

Windows OS is responsible to send and receive data from those endpoints

 

for my device Windows reads 1000 packets of 34 bytes and also write 1000 packets of 34 bytes.

 

As Xmega only has 4 killo bytes of data I do not have enough freedom to increase buffer. 

 

Now, buffer size for each channel is 256 short integers which is equal to 512 bytes. 

  

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I was talking about a buffer at the host end, like they do with streaming video so that the pipe is relatively immune to short interruptions.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I was talking about a buffer at the host end, like they do with streaming video so that the pipe is relatively immune to short interruptions.

 

Thanks Jim, 

 

Host side is a simple program based on example code of libusbk project. 

 

There is no problem with it. 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To develop the PCB I have to hire somebody to do it for me. 

 

He does his task very well but today I find that he does not place decoupling capacitors near the VCC and GND pins of micro controller and place it at least 1 cm away from those pins.

 

Could this mistake lead to the noise that I see in ADC samples?

 

 

Last Edited: Fri. Sep 20, 2019 - 07:15 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not likely. The 1cm will mostly effect noise that appears on the supply pins from the MCU, itself (e.g. self-created noise). That should be  absolutely synchronous with the MCU and should not create the kind of noise you are experiencing. A more likely culprit, if it from the power rails, is a switching power supply.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think it would be wise to do some simple tests to help verify (or eliminate) where the noise is coming from.

 

I'd suggest:

 

Power the Xmega from a battery.

Do not use a wall wart.

By-pass any regulators.

(Especially any switching regulators, which need to be Off / Disabled for the test)

The Xmega will run at 3 V, presumably the rest of the circuit will run at this also.

 

Disconnect the USB.

 

Ground the input signal.

 

Now Scope the output as see what it looks like.

Is the periodic noise gone?

 

Now add back in the USB connection and look again for the noise.

 

Now add back in your power supply and look again for the noise.

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:

Now Scope the output

Where's the output?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My impression that the "output" is the audio system in the USB master.

 

But, this raises a suggestion. Output the data to a port and observe it with a 8-wide logic analyzer. OR, feed that data into an 8-bit parallel input DAC and observe it as an actual audio signal.

 

I lay about 40% odds on USB, and 50% odds on the analog conversion process (this encompasses power supply, reference, input signal, and ADC). That leaves 10% for programming, MCU timing, and acts of divine retribution.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks JC,

 

But some facts about my board.

 

1. it is a peripheral device which is connected to a PC via USB cable.

2. The power supply of my device is get form USB port. 

3. data is captured from ADC channels and send to PC via USB out endpoints.

4. data is sent from PC to device and is played on DAC channels via USB in endpoints.

5. The only way that I can see the output of ADC channels is to get them in PC and use an editor software like Audacity to see it. 

6. Thus if I use a battery then how I can transfer data to PC?

7. By using a median filter, the quality of captured ADC signals are better.

8. noise happens in a periodic way and I guess it is from USB transactions with PC.

9. when I discard USB write transactions from PC side and just read ADC samples, the duration of noise decreases which gives me a clue that USB transactions may be in charge .

10. as decoupling capacitors are away from power pins of Xmega micro controller, I am afraid if urgent current can not be feed to micro Controller when USB transactions are in progress and those noises happens.

 

Thanks

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can intercept (e.g. break the circuit) the power from the USB connector and provide power to that point via battery or an adjustable clean power power supply.

 

Jim

 

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mehrdad_58 wrote:

10. as decoupling capacitors are away from power pins of Xmega micro controller, I am afraid if urgent current can not be feed to micro Controller when USB transactions are in progress and those noises happens.

 

 

I don't think you understand the purpose of decoupling caps.

I'd be guessing pcb layout is a possible culprit. But you've not shown us this.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks guys.

I have learnt how fix a bug from the discussion.  

শূন্য  - The ZeRo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Try using another USB port on the host.  Try using another host computer.

 

If there is a periodic 1.6 second pulse on VCC, you might be able to see that on your scope.

 

If you can put the result of the ADC out on an Xmega pin, you could disconnect from the host.

 

The numbers you get from the ADC should be much higher during the periodic noise.  You could look at the numbers.  When the numbers are low, set a digital output pin low.  When the numbers are high, set the digital pin high.  Look at that pin with with a scope or even a DMM to see if the 1.6 second pulse is there when not using the USB.  

 

You could also export the ADC result on an analog pin by using the DAC.  Look at that pin when not using the USB.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't think you understand the purpose of decoupling caps.

I'd be guessing pcb layout is a possible culprit. But you've not shown us this.

 

Let me show a picture from PCB part of my design.

 

 

Those 2 white circles are decoupling capacitors that was designed to be placed near VCC and GND

pins of micro controller. 

There are 2 other ones that is not in this shot and are far far far away wink laugh

 

The board is a 2 layer one.

 

Apparent that micro controller is that 44 pin TQFP in the center of picture.

 

 

Last Edited: Sun. Sep 22, 2019 - 03:53 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You could also export the ADC result on an analog pin by using the DAC.  Look at that pin when not using the USB.

 

 

Above sentence is one the most professional sentences that I have heard yet. wink

 

Thanks steve17, You prove that you are very professional. 

 

Before this, I always think of my board as a Black box,  Now you open some windows on the walls of it. 

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mehrdad_58 wrote:

Those 2 white circles are decoupling capacitors that was designed to be placed near VCC and GND

pins of micro controller. 

Ouch. I think I see a massive ground loop. The GND pins on the micro all come together under the chip, but then the only connection I see is by a blue track to the left and then it disappears in the upper left corner. Presumably it loops all the way around the PCB, and then come back down to the decoupling cap on the right side.

If that is so, then your GND connection is more like a H-field antenna that can pick up all sorts of noise from the surrounding circuitry.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mehrdad_58 wrote:
Let me show a picture from PCB part of my design.

This is crazy.
cryingno

Sorry for my English.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I’d throw that pcb in the bin. The power routing is suspect at best. It could be the regulator oscillating occasionally. Showing us a small part of the pcb is not going to be too conclusive as the problem is probably not in the area you’ve shown.
Tell your pcb guy that putting vias in the middle of pads is not a good idea. Nor is doing copper fills that aren’t tied to a ground plane.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It seems that PCB is not good. 

 

Please give me some hints about routing signals and power and ground.

 

I collected more that 10 changes till now. 

 

Please give me some hints to apply in next step, Please remember that the board is a 2 layer one.

 

I need some design patterns for PCB.

 

 

 

Thanks

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

We’ve got nowhere near enough information. If you want to learn, there’s plenty of tutorials on line. It helps if you understand basic electronics as the pcb is a critical component - not just an interconnect.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I developed this board to be a pilot one and I would like to get as much as possible knowledge from it. 

 

Now that we know the design of PCB is not OK, I would like to apply some changes to it by using some wire soldering and component montage. 

 

I have following ideas:

 

1. Solder a through hole decoupling cap between each VCC and GND pins of micro controller.  (VCC and GND pins in XMega are near each other).

2. solder 4 wire between GND pins of micro controller and some GND pins in different points of board to break current loop. 

 

I do above things because I would like to learn as much as possible from current situation. 

 

 

Please give me any other ideas which may help 

 

Thank you.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Don’t waste your time. The problems can’t be fixed by cutting tracks and adding bits of wire.
Get the design right first. Getting pcbs made is fairly cheap.
Having components on both sides makes assembly expensive. It is usually cheaper to go to a four layer pcb with components on one side only

Last Edited: Mon. Sep 23, 2019 - 12:40 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mehrdad_58 wrote:
Please give me some hints about routing signals and power and ground

Pretty sure Atmel Microchip have App Notes on that.

 

The principles of good grounding, analogue/digital supply separation/isolation, etc are pretty general - not specific to AVR.

So general tutorials on mixed-signal PCB design should help ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gchapman wrote:

(page 13 for "4.7. PCB Layout and Grounding")

Chapter 4.6 is also worth a closer look (Power Supply, Power Routing, and Decoupling Capacitors)

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I do not know how to say thank you. 

 

Now I have some documents to proceed. 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mehrdad_58 wrote:
Please give me some hints about routing signals and power and ground.

Here is a simple project on ATXMEGA32A4U.
I do not like this pcb.
But she is better than the one you showed.
The analog part is not used in this project.

Sorry for my English.

Attachment(s): 

Last Edited: Mon. Sep 23, 2019 - 05:39 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

agentXMEGA wrote:
I do not like this pcb.
You do what you have to do.

Some don't like jumpers or zero ohm resistors as jumpers though the 1-layer PCB of old have some tinned jumper wires.

A PCBA manufacturer might have a jumper machine.

XMEGA32A4U pin 35 is RESET with a trace that has some susceptibility; not an issue if the PCBA is inside its own metal or metallized enclosure that has complete, precise, and correct shielding.

Inside a chassis, above a few megahertz, the references (grounds) will be relative to each; if that's an issue, there are simple solutions.

agentXMEGA wrote:
Sorry for my English.
Please don't be; an Anglophone can be patient.

Thank you for your post.

 


What are the specific PCB/PCBA process reviews?-NOD Electronics

[3/4 page]

5. Jumper on the printed circuit board.

...

https://en.wiktionary.org/wiki/susceptibility

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks friends for you kind support 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are some important lessons here, and more lessons to be learned.

 

1) You have found that your board needs improvement, and some suggestions about what to do. That may be a necessary change, but it MIGHT not be sufficient. How can we say that? Well, partially because there has yet been no way to determine the source of the noise. It MIGHT still be software or something in the USB system or even your desktop hardware and software. Nobody can tell. Yet. Or, it might be that the board upgrade solves it all. You will never know until you try.

 

2) These problems are hard to track down. Really hard. it tends to be a war of attrition rather than a pitched battle followed by a victory celebration. Its just the way the universe works.

 

3) Because it is hard, you have lots of ideas about how to solve. Which one is the solution? Maybe none, maybe one not yet suggested. We can't know. We might never know.

 

4) Suggestion: post the schematic and the layout (with modest component detail where it is not obvious) before you send it out to your board house. You are bound to get some comments. Some of those might even be useful :) This could save you a subsequent board rev or several. 

 

Good luck

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Jim,