View previous topic :: View next topic |
Author |
Message |
pinkfloyd11
Joined: 02 Jul 2007 Posts: 247
|
Posted: Mon Oct 15, 2012 4:26 pm Post subject: ON ADC DO_SOMETHING |
|
|
Hello
I have 3 trimmer connect on 3 different ADC Channel
I want measure adc value only when trimmer change position.
Which is the correct way for do this?
Thanks
Last edited by pinkfloyd11 on Tue Oct 16, 2012 1:18 pm; edited 1 time in total |
|
Back to top |
|
|
hgrueneis
Joined: 04 Apr 2009 Posts: 902 Location: A-4786 Brunnenthal
|
Posted: Mon Oct 15, 2012 7:48 pm Post subject: |
|
|
There is no such way with ADC in AVRs.
If your main MCU is very busy, the solution would be a sub mcu that is polling the 3 trim pots.
With a specific tolerance to the old values you then can determine to give the main MCU a signal with one line (can be polled or int) to read the values from the slave via TWI or SPI (even com port ttl232).
This way you can control the timing of the data read.
Depending on stability and available time an average can be done with the polled ADC data in addition to the chosen tolerance.
Hubert |
|
Back to top |
|
|
MAK3
Joined: 24 Sep 2010 Posts: 449 Location: Germany
|
Posted: Mon Oct 15, 2012 11:12 pm Post subject: |
|
|
Quote: | I have 3 trimmer connect on 3 different ADC Channel
I want measure adc value onli when trimmer change position.
Which is the correct way for do this? |
I would search for a solution with an ATXMEGA (A1 family)
There are many timers which you can connect with the ADC over event system. So you can for example trigger an ADC converson over the event system when there is a predefined timeroverflow.
MAK3 |
|
Back to top |
|
|
glena
Joined: 25 Jul 2007 Posts: 284 Location: PA near Philly
|
Posted: Tue Oct 16, 2012 1:17 am Post subject: |
|
|
pinkfloyd11,
There is no hardware in any of the AVR chips that will trigger an interrupt on ADC level change. What you can do, is create an ISR driven by a timer that will then read the ADC values for each channel you want to use and compare it to a save last level. If it is different then some determind bandgap then set a flag that signals your main loop.
As for the timer triggering the ISR, you should have it trigger to poll only as fast as needed and not too fast. Maybe someware around 50 to 100Hz may work since your looking for changes set by humans (humans are so slow! ).
-Glen _________________ http://bahbots.com |
|
Back to top |
|
|
MAK3
Joined: 24 Sep 2010 Posts: 449 Location: Germany
|
Posted: Tue Oct 16, 2012 7:45 am Post subject: |
|
|
Regarding trimmer: You can do it with one but not with 3 because there is just one ADC compere register where you can write the compare value to.
ATXMEGA128A1 manual:
Quote: | Interrupt requests and events can be generated either when an
ADC conversion is complete or if an ADC measurement is above or below the ADC Compare
register values.
The ADC compare register is a 12-bit register that holds a value representing an analog threshold
voltage. All four ADC result registers (ADC channels) share the same ADC compare register. |
MAK3 |
|
Back to top |
|
|
Luciano
Joined: 29 Nov 2004 Posts: 3149 Location: Italy
|
Posted: Tue Oct 16, 2012 9:48 am Post subject: |
|
|
Hi,
(See first the message posted by Hubert).
You could use a dedicated AVR chip to do that, and in a loop read the ADC
values of the three trim pots and when a change occurs, with a pin of the
same device, trigger an interrupt in the main AVR chip which will detect
it on one of its pins like Int0,...,PCINT0,.....
Or with the same device you can send data (ADC values) which will trigger an
interrupt in the main AVR chip. (TWI, SPI, TTL232, RS232).
You can also use a combinations of both, first an interrupt via a pin and then
have the main AVR chip read the data via TWI, SPI, TTL232, RS232.
The ATtiny24/44/84 are supported by Bascom AVR and have more than two ADC
channels in the PDIP package. (14 pin PDIP package). The chip can run at
1MHz or 8Mhz from its internal RC oscillator or from an external clock.
(External clock, see pin clock output and fuse CKOUT of the main AVR chip).
Best regards,
Luciano |
|
Back to top |
|
|
olive2222
Joined: 31 May 2006 Posts: 88
|
Posted: Wed Oct 17, 2012 8:42 am Post subject: |
|
|
Hi,
As suggested you can connect one trimmer to an Xmega adc.
For the 2 others you can feed an external window comparator with 2 XMEGA DACs output according to the actual trim position.
The window comparator output is to be connected to a regular INT input. The ATXMEGA1281 with 4 DAC channels can be used.
regards,
Olivier |
|
Back to top |
|
|
|