Reputation: 3
I have a sensor that sends data at 8Khz to a microcontroller. The microcontroller parse the data and send it to the high level controler at 1Khz. I have seen people using ring buffer to collect the data from the sensor to the microcontroler and then take out the data to send it when we need.
If I receive 8 data but I can only send 1, the 7 other data in the ring buffer are useless... I am curious why the use of a ring buffer is necessary/better compare to just wait for a new data and send it to the higher level?
Thank you
Upvotes: 0
Views: 306
Reputation:
If you are receiving the data at 8 KHz rate and forwarding that data at 1 KHz rate, it means you get some data every 125 microseconds and you are forwarding it every 1 milliseconds.
Obviously you will need something to store that data every 125 microseconds and send the accumulated data after every 1 ms. For that you need some buffer kind of mechanism to store it. Hope this explanation helped.
Upvotes: 1