Go Down

### Topic: Comparing data (Read 1 time)previous topic - next topic

#### Crebsyn

##### Oct 23, 2012, 08:59 pm
Hello, new to Arduino. I am working on a bike computer, I have the basics worked out on speed, time etc... I have a cycle counter for every time the wheel sensor is made. I want to record the time at lets say every 5 rotations, I believe is is not a problem with an SD card shield. What I want to do is compare an old ride to a new ride. I would like the cycle counter to pull data from the SD card and compare the old time vs the new time. eg start riding, after 5 wheel rotations look up time for the previous recorded 5th cycle of the wheel and compare. Then do this for 10,15,20 etc. Is this possible? and is there any example code for this?

Thanks for your help.

#### Nikarus

#1
##### Oct 23, 2012, 09:42 pm
On the reading bike wheel revolutions, your probably not going to be able to choose to do it once every 5 turns. More like once per turn with some kind of Hall effect sensor. Or more if you have an encoder. Recording data to an SD card is easy enough with the SD library. Easy enough to just write the current time, and number of revolutions so far, to the SD card as comma delineated, or tab delineated (programs like excel can recognize the comma and tab formatting as a spreadsheet and open them).

As far as comparing the 2 times of your previous rides with the current one on the arduino, while your riding... i guess its doable, but id say you want to get some of your data, and results into excel to work before going too far ahead of yourself.

#### Crebsyn

#2
##### Oct 23, 2012, 10:57 pm
My issue is how do i pickup the specific data based on the cycle #. As for a test I could put different integers in, but not sure how to increment the int name. eg
int C1 = 22.34
int C2 = 18.45
etc...

so when the cycle count = 1 read C1 and compare
on the next loop read C2
but i can't put something like (c1 +cycle) = c2

#### Arrch

#3
##### Oct 23, 2012, 11:00 pm

My issue is how do i pickup the specific data based on the cycle #. As for a test I could put different integers in, but not sure how to increment the int name. eg
int C1 = 22.34
int C2 = 18.45

If you need decimal places, you shouldn't be using ints.

Quote

so when the cycle count = 1 read C1 and compare
on the next loop read C2
but i can't put something like (c1 +cycle) = c2

Sounds like you need an array (and a more descriptive variable name).

#### PeterH

#4
##### Oct 23, 2012, 11:51 pm

What I want to do is compare an old ride to a new ride. I would like the cycle counter to pull data from the SD card and compare the old time vs the new time. eg start riding, after 5 wheel rotations look up time for the previous recorded 5th cycle of the wheel and compare. Then do this for 10,15,20 etc. Is this possible?

In its simplest form, it's easy. But to produce anything meaningful I think would be quite hard. I suppose you want to do some sort of comparison of speed versus distance so you can tell whether you went up that hill any faster today than yesterday. The problem is that the start points and distance traveled each time are unlikely to match exactly in the real world, so getting anything more than a rough comparison would be tricky. Your best bet I think would be to save the log of each journey in a CSV file and then load that up to a PC where you can compare and graph the results in a spreadsheet. Make sure you make your sample interval long enough so that you can hold a useful number of logs of your desired length on an SD card.

#### Crebsyn

#5
##### Oct 24, 2012, 12:16 am
PeterH you are right I want to look down at the display and have it tell me if I am ahead or behind of a previous ride. If i record my speed or time from each wheel rotation, in general i should have a good indication of where i am at. I have a bike computer that logs my rides now, but there is nothing that gives me a real time update that reads off a wheel sensor.
Waiting for my SD shield now, just was hoping someone knew how to compare the data in real time.

#### Jimmy60

#6
##### Oct 24, 2012, 12:44 am
You don't need the speed to know where you're at. Just count wheel rotations and multiply by the circumference to get distance travelled. Your speed tells you when you're at. 100 wheel rotations will get you to roughly the same place each time regardless of how fast or slow you go.

If you started the bike ride from exactly the same spot each day wheel rotations should be reasonably accurate but certainly not totally accurate.

Maybe GPS is the solution.

#### PeterH

#7
##### Oct 24, 2012, 03:12 am

PeterH you are right I want to look down at the display and have it tell me if I am ahead or behind of a previous ride.

Well, if that's all you want then it wouldn't be hard to have it display how many seconds you are ahead or behind relative to a previously recorded baseline.

Go Up