Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

ON ADC DO_SOMETHING

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
pinkfloyd11

Bascom Member



Joined: 02 Jul 2007
Posts: 247

italy.gif
PostPosted: Mon Oct 15, 2012 4:26 pm    Post subject: ON ADC DO_SOMETHING Reply with quote

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
View user's profile
hgrueneis

Bascom Member



Joined: 04 Apr 2009
Posts: 906
Location: A-4786 Brunnenthal

austria.gif
PostPosted: Mon Oct 15, 2012 7:48 pm    Post subject: Reply with quote

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
View user's profile
MAK3

Bascom Member



Joined: 24 Sep 2010
Posts: 449
Location: Germany

germany.gif
PostPosted: Mon Oct 15, 2012 11:12 pm    Post subject: Reply with quote

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
View user's profile
glena

Bascom Member



Joined: 25 Jul 2007
Posts: 284
Location: PA near Philly

usa.gif
PostPosted: Tue Oct 16, 2012 1:17 am    Post subject: Reply with quote

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! Wink ).

-Glen

_________________
http://bahbots.com
Back to top
View user's profile AIM Address
MAK3

Bascom Member



Joined: 24 Sep 2010
Posts: 449
Location: Germany

germany.gif
PostPosted: Tue Oct 16, 2012 7:45 am    Post subject: Reply with quote

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
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Tue Oct 16, 2012 9:48 am    Post subject: Reply with quote

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
View user's profile
olive2222

Bascom Member



Joined: 31 May 2006
Posts: 88

belgium.gif
PostPosted: Wed Oct 17, 2012 8:42 am    Post subject: Reply with quote

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
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum