Hi all
I have written a sketch that collects about 10 kS/s (10,000 samples per second) from an ADC. It does so by means of non-blocking code in the loop. By this I mean, I'm not using an ISR in my code, but handling the timing myself; checking once per loop whether the ADC has data ready via its own IRQ pin, and reading it over 15MHz SPI if so, continuing with no delay if not.
I plan to buffer 1s of data in an SRAM array of 10000 elements, then once the array is full, immediately transfer it via ethernet, whilst continuing to collect the next 10 kS into a second array. Hopefully this ethernet transfer can happen within 1 addition second, otherwise we risk overwriting the first array as the process repeats.
I have included the NativeEthernet library and the device connects to ethernet using Ethernet.begin(mac, ip, dns, gateway, subnet); So far I can ping it whilst it's reading from the ADC...
First question: is this buffer->send idea the most sensible approach? Perhaps it's the only approach?
Second question: will I be able to achieve this with TCP or would it be better advised to use UDP? Ideally I would use something higher level like MQTT, although I may just use MQTT for messaging status updates, flags, etc.
Final question: re code efficiency / timing, are there any useful tips, or any gotchas I should be aware of? e.g. implementing some kind of configurable buffer size?
I have written a sketch that collects about 10 kS/s (10,000 samples per second) from an ADC. It does so by means of non-blocking code in the loop. By this I mean, I'm not using an ISR in my code, but handling the timing myself; checking once per loop whether the ADC has data ready via its own IRQ pin, and reading it over 15MHz SPI if so, continuing with no delay if not.
I plan to buffer 1s of data in an SRAM array of 10000 elements, then once the array is full, immediately transfer it via ethernet, whilst continuing to collect the next 10 kS into a second array. Hopefully this ethernet transfer can happen within 1 addition second, otherwise we risk overwriting the first array as the process repeats.
I have included the NativeEthernet library and the device connects to ethernet using Ethernet.begin(mac, ip, dns, gateway, subnet); So far I can ping it whilst it's reading from the ADC...
First question: is this buffer->send idea the most sensible approach? Perhaps it's the only approach?
Second question: will I be able to achieve this with TCP or would it be better advised to use UDP? Ideally I would use something higher level like MQTT, although I may just use MQTT for messaging status updates, flags, etc.
Final question: re code efficiency / timing, are there any useful tips, or any gotchas I should be aware of? e.g. implementing some kind of configurable buffer size?