Hey guys this is what I’m trying to work out:
The data is being delivered at 100 samples per second from an Arduino Uno. I’m using a timer and in the action event use tempBuffer = Serial.ReadAll(). This part works pefectly fine. Now what I need to do is take samples of the data from the string (tempBuffer) and get the average in numeric format of course.
The data looks numeric but of course it not, it a long string. The data is terminated by CR+LF which is what the Adunion ouputs.
eg.
25 <CR+LF>
25 <CR+LF>
25 <CR+LF>
25 <CR+LF>
25 <CR+LF>
25 <CR+LF>
25 <CR+LF>
25 <CR+LF>
25 <CR+LF>
. . . etc all the way up to 100 samples (lines).
The variation of numbers is due to a sensitive load cell being attached to the Arduino.
What I need to do is take a sample of the data and show a consistant number on the screen maybe every second - this number will be used for calibration. Time is not crucial in this instance. It wouldn’t matter if the calculations took 1/10th of a second - but I’m sure it won’t.
For the basic Algorithm, what I’m thinking is to take 50 samples out of the one hundred, perhaps between 25-75 using the <CR+LF> as the delimiter. Add those 50 together then divide by 50 removing any decimal points, this would show the average.
In actual fact it wouldn’t matter if the numbers were just viewed as fruit, ie. Apples, Lemons, Grapes, Oranges providing that I knew which one appeared the most amount of times. Although I still need to use a similar method that does require numbers because of numeric calculations that will be required later.
I believe I have the Algorithm correct - I just don’t know how to convert it to Xojo language. Hope this makes sense. I have done lots reading but still getting nowhere.
Cheers, Steve.