xmega 4 channels signal counter using ACs & DACs

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

hi

this is code for ATXMEGA128A1 "4 channels signal counter using analogue comparators & digital to analogue converters"; DACs are for setting the negative signal level amplitudes of comparators:

ACA0 <- (-)DACA0 , (+)PA5
ACA1 <- (-)DACA1 , (+)PA5
ACB0 <- (-)DACB0 , (+)PB1
ACB1 <- (-)DACB1 , (+)PB1

here, the counters counts out of order of dac levels! where is the problem?

void initACs(void)
{
// Enable Analog comparators, submodule, highspeed
AC_Enable(&ACA, ANALOG_COMPARATOR0, true);
AC_Enable(&ACA, ANALOG_COMPARATOR1, true);
AC_Enable(&ACB, ANALOG_COMPARATOR0, true);
AC_Enable(&ACB, ANALOG_COMPARATOR1, true);

// By defalut the Analog comparators interupt flag triggers on changes on both edges.
AC_ConfigInterrupt( &ACA, ANALOG_COMPARATOR0, AC_INTMODE_RISING_gc, AC_INTLVL_OFF_gc ); 
AC_ConfigInterrupt( &ACA, ANALOG_COMPARATOR1, AC_INTMODE_RISING_gc, AC_INTLVL_OFF_gc ); 
AC_ConfigInterrupt( &ACB, ANALOG_COMPARATOR0, AC_INTMODE_RISING_gc, AC_INTLVL_OFF_gc ); 
AC_ConfigInterrupt( &ACB, ANALOG_COMPARATOR1, AC_INTMODE_RISING_gc, AC_INTLVL_OFF_gc );
	 
// Set up MUXes to sense pin ? and ?. 
AC_ConfigMUX(&ACA, ANALOG_COMPARATOR0, AC_MUXPOS_PIN5_gc, AC_MUXNEG_DAC_gc);
AC_ConfigMUX(&ACA, ANALOG_COMPARATOR1, AC_MUXPOS_PIN5_gc, AC_MUXNEG_DAC_gc);
AC_ConfigMUX(&ACB, ANALOG_COMPARATOR0, AC_MUXPOS_PIN1_gc, AC_MUXNEG_DAC_gc);
AC_ConfigMUX(&ACB, ANALOG_COMPARATOR1, AC_MUXPOS_PIN1_gc, AC_MUXNEG_DAC_gc);

// Set up AC with a small hysteresis. 
AC_ConfigHysteresis(&ACA, ANALOG_COMPARATOR0, AC_HYSMODE_SMALL_gc);
AC_ConfigHysteresis(&ACA, ANALOG_COMPARATOR1, AC_HYSMODE_SMALL_gc);
AC_ConfigHysteresis(&ACB, ANALOG_COMPARATOR0, AC_HYSMODE_SMALL_gc);
AC_ConfigHysteresis(&ACB, ANALOG_COMPARATOR1, AC_HYSMODE_SMALL_gc);

}

Last Edited: Fri. Mar 4, 2011 - 03:29 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

it seems that AC_MUXNEG_DAC_gc does not work!

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

From AVR1302:

Quote:
The necessary few steps to get up and running with comparators is as follows:
1. Configure MUX settings for the comparators you want to use.
2. Configure which interrupt condition to use for each comparator.
3. Configure interrupt levels if you want to use interrupt handlers.
4. Enable the comparators you want to use.

But you have enabled AC before other steps.

Ozhan KD
Knowledge is POWER

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

thanks for post
please check code examples of ACs in application note.
I made your correction but still the problem exists
when I active output pin of DACs channel#1 (PIN3) and use AC_MUXNEG_PIN3_gc instead of AC_MUXNEG_DAC_gc, every thing is good. it shows that DACs and ACs are work good separately; but still there is problem in tying them using AC_MUXNEG_DAC_gc !

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

Maybe this is due to errata of ATXMEGA128A1. For example this can make problem:

Quote:
If the DAC is running in Sample and Hold (S/H) mode and conversion for one channel is done at maximum rate (i.e. the DAC is always busy doing conversion for this channel), this will block refresh signals to the second channel.
Problem fix/Workaround
When using the DAC in S/H mode, ensure that none of the channels is running at maximum conversion rate, or ensure that the conversion rate of both channels is high enough to not require refresh.

What is the DACs conversion rate?

Ozhan KD
Knowledge is POWER

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

it is

   //Given 32 MHz CPU speed, this is configured to 2us separation time and 16us refresh time.
   DAC_DualChannel_Enable( &DACA,
	                        DAC_REFSEL_AVCC_gc,
	                        false,
	                        DAC_CONINTVAL_64CLK_gc,
	                        DAC_REFRESH_512CLK_gc );
   DAC_DualChannel_Enable( &DACB,
	                        DAC_REFSEL_AVCC_gc,
	                        false,
	                        DAC_CONINTVAL_64CLK_gc,
	                        DAC_REFRESH_512CLK_gc );

but it seems that because of dac non-linearity when vcc is above 2.4 (I use AVCC) & possible lots of other issues, still we can not use xMega in complex applications!

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

please help:
hello.I want to use ATXMEGA32A4 DAC with codevision compiler.please guide me.

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

Arsxmega , start your own thread for your problem .

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1