Hello. I am trying to implement a closed-loop control system, which depending on the ADC readings, it activates a GPIO pin.
This GPIO pin is the enable of a buffer, and if it's activated, the inner voltage given to the ADC varies. In this picture you will see the scope view in the input of the ADC:
As you can see in the picture above, this is the performance when the system is activating all the time the buffer. Every time the buffer is activated, you see the drop in the voltage, passing from 2.2V to 0.35. If you see the code, in the Int_Handler_ADC1 you will see that every time the buffer is activated, its forced to get disabled at the next lecture of the ADC, resulting in the voltage coming up again to 2.2V.
The problem: When measuring the lectures in hyperterminal, I get the intermediate values between both states: I see almost all the time the correct 2.2V value, or the 0.35V, but I see so many times values between these two measures. This results in my calculus to be wrong, as I need to count how many times the buffer has been activated and I can not know for sure in this case.
What I found interesting is that if I change a little bit my program and I stop the ADC at every reading, I can solve this problem. But this STOP/GO of the ADC involves increasing the time for each measure, resulting a period time between activations of the buffer (Passing from 2.2V to 0.35V) of 1.7ms. Which leads to 550 Hz approximately.
I need to achieve bigger frequency. 1 kHz would be awesome, but as I explained above, without stopping the adc at every lecture I can not read appropiately the lectures in the UART.
Another thing that I found weird is the temporization: as you can see in the picture, every lecture of the ADC takes 256 usecs approximately (time between 0.35V gets to 2.2 again), but the system won't get down again until 750 usecs later. It shouldn't be so long, right?
About this last thing, our view is that the ADC is taking into consideration the values from the previous conversion (taking into consideration the values of the 0.35V pulse) and thus, it delays 3 conversions to have a proper value of voltage. Anyways, we don't know how to solve this.
Any ideas? I would appreciate any help.