I’m trying to configure the ADC to acquiring data from 4 analog pins (A0,A1,A6 and A7) at high rates below 25 microseconds for all of them. However the analogRead() function available on spark firmware, does not provide this speed acquisition. I has able to improve the analogRead function, to approx half of the processing time needed. But it is yet to much time.
For instance, i was able to do that in Arduino using a interrupt routine
Is there any similar solution for spark?
I have no clue on this but @satishgn or @mohit might be able to take this question.
There’s a function setADCSampleTime that you can use to set the sample time,
That was one of the improvements that already made to reduce the ADC sample time to
ADC_SampleTime_1Cycles5```` and decrease the ````ADC_DMA_BUFFERSIZE to 1. This changes reduces some time but not enough for my application. And i think it is really possible to decrease the time more in the spark STM32 with a 72Mhz core, because i can make it in a ATMEGA644 with only 8MHZ.
@aaraujo, don’t forget that the ADC on the atmel part is only 10 bits whereas the STM32’s is 12bits. This increases the sampling time. Nonetheless, based on the STM32F103 reference manual:
● ADC conversion time:
– STM32F103xx performance line devices: 1 μs at 56 MHz (1.17 μs at 72 MHz)
You may, however, have to configure the ADC yourself to get this fastest conversion rate.
There’s also this pull-request that changes the mode from dual interleaved to independent. You’ll have to build this locally to take it for a spin, but would love to hear if it works for you!
Thanks @mdma, i tried that approach but it didn’t improve that much in my readings. Actually the best reading time that i get was between 5 microseconds and the worst case 11 microseconds. Take in consideration what @peekay123 and what i already read in the stm32 manual, my goal is to reach the 2 microseconds per read, even if the accuracy of readings is not the best.
@aaraujo, this article might help a little. For the highest speed, you will most likely need to use DMA to a circular buffer.
I am using Photon, a Wi-Fi development kit and using six channels of ADC (A0-A6) to capture analog signals. I want to capture all six channels at every 3ms or at 300Hz. And after capturing it I need to send this samples to the PC either using Serial or over TCP.
I tried to send the samples over TCP, but some of the samples are missing at the server end i.e. on Photon side. Can you please help me here?