Go Down

Topic: (closed) Arduino UNO - AGC with ADC Interrupts - Suggestions needed (Read 1 time) previous topic - next topic

ftf74

Hi Forum!
Perhaps someone can help me to get my thoughts sorted and to convert them into a working code.

One part of my project is a AGC - Automatic Gain Control for an external Receiver.
This means that the value of an PWM Pin (Pin 9 defined as Output) will be slowly increased to be the Vcc of the external Receiver. The higher the Voltage on Pin 9 gets the higher gets the sensitivity of the receiver. This Process will be checked by feeding the Signal Output of the Receiver into Pin A0 of the Arduino. As soon as the Signal Output of the Receiver hits a specific Threshold Value, the PWM increase on Pin 9 will stop. The PWM Value on Pin 9 will then be reduced with a certain factor and so the sensitivity of the Receiver is perfectly adjusted for the specific location.

Then the normal work of the Receiver starts and the Arduino evaluates spikes coming from the Receiver Output.

I already have a running version of this AGC - but only with the analogRead() function for Pin A0 - due to the fact that I started programming Arduino a couple of months ago.

As far as I experienced the analogRead() function just works until 10ksps.
My intention is to sample with about 40ksps.

So I started to program the Registers of the ADC and use the "ADC interrupt" ISR of the Arduino which works.
BUT now I have the problem to adapt this method to my Project and would be thankful for some inputs/ideas from you guys.

If I keep the ADC in freerunning mode no other code will be executed because the ADC interrupt always triggers to collect datas, fills up the value in the registers, and triggers the next conversion.

What woould be a good working method to have about 40ksps of the input signal - then checking if the signal reached the threshold value - if not to increase the PWM Pin as long as the threshold value was reached.

I got stuck in my knowledge and thoughts.
Thank you for some help.
best regards
F.

MarkT

Quote
If I keep the ADC in freerunning mode no other code will be executed because the ADC interrupt always triggers to collect datas, fills up the value in the registers, and triggers the next conversion.
Why do you think that?  There is 110us during a conversion that can be used by
the rest of the program, before a conversion complete interrupt fires.

The normal way of using the ADC in Arduino runtime is not via interrupts, but to set a single
conversion going and busy-wait for it to finishd - that really does waste a lot more CPU time.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

ftf74

thank you for this hint. I am closing this thread and opening another one with a different question becaue I have another approach and other problems ;-)

Thank you!!

Go Up