xmegaE5 DAC -> ADC Internally Connected Issue

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

My project involves exciting an external sensor with the E5's DAC providing an amp'd (5KHz Square Wave, 0-~15V) output and reading back an AC coupled, filtered and scaled 0-2.5VDC input to the A/D. I use a clean precision +2.5V external reference for both the DAC and ADC. My external calibration routine drives the A/D incrementally from 0x000 up to 0xFFF(FS) while reading the A/D conversion to see when it saturates (0xFFF result). Then the DAC value becomes my "max" value to excite the sensor (the min being zero). The circuit works great for the application, but I'm trying to figure a good way to "auto-calibrate" the DAC and ADC internally so they track together and then perform the external calibration. Seems simple enough, since the E5 can convert the DAC output in "internal" mode. However, when I switch the A/D to internally convert the DAC DC output, both using the 2.5V ref, all the A/D results hover around mid-way; 0x800'ish. (0x8C1 @0x000 -> 0x935 @0xFFF). By the way, I use single-ended unsigned mode.

 

Anyone done anything similar with an XMEGA with the A/D converting it's own DAC output internally with success?

 

Ken

This topic has a solution.
Last Edited: Thu. Oct 5, 2017 - 12:28 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What is your ADC clock? IIRC all the internal inputs have a fairly narrow range they can work with. I use 125kHz.

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

When I'm using internal inputs like the DAC and Temperature Sensor, I switch to 125KHz (32MHz/256) from my normal 500KHz.

 

In hindsight, I'm not sure I would gain any benefit from internally calibrating the DAC and ADC, but I'd like to know if it works. I'll spend a bit of time stripping my code down to a test loop and post it here with results.

-Ken

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

Oh, one other thing, keep in mind that the DAC can go right to the supply rail, where as the ADC is limited to VCC-0.6.

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

Thanks. I'm using an external 2.5V reference for both and my VCC is 3.29V (measured) so I believe it's in spec. For my test loop code I'll first use the internal 1.1V Bandgap and see what happens. If that works move to the external 2.5V ref. I'll post results and code soon.

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

I once made a small test program, using DAC to ADC, to test oversampling and averaging settings. You can find it here:
http://www.avrfreaks.net/comment/1269986#comment-1269986

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

Svuppe wrote:
I once made a small test program, using DAC to ADC, to test oversampling and averaging settings. You can find it here: http://www.avrfreaks.net/comment...

 

Thank you Svuppe, You've provided hope that this is possible. Your code should be a great help.

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

OK, it seems that you can't have your external DAC output and measure it internally too! (Apologies, I'm an old analog guy from way back, note my avatar) I found that you need to have the IDOEN bit in DAC_CTRLA set for internal measurement which disables the DAC external output. Duh. Thanks to Svuppe, as I used his code to verify. I did try to figure out if having an internal calibration would be useful for my application, but now I think just doing an external calibration is all I need, because it compensates for my external circuitry. I'll know for sure soon, because the machine has 36 heads, each with the same E5 control circuit.

 

Thanks for the input.

 

-Ken