Pages: [1]   Go Down
Author Topic: Stuck on a project  (Read 1227 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 40
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I wanted make a simple bicycle logger. The Hardware would be simple, an arduino one button and one reed switch.
I want the arduino to start logging when i press the button and stop logging when when i press again. The arduino logs how many time the reed switch opens  and the time when it happens so when i go to my computer i can download the data.

Although i have a basic knowledge of arduino coding i dont know how this could be done. Could anyone give me a similar code or some tips on hoe to go about it?
Also, would i need a EEPROM or can the data be stored in the arduino it self?
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 299
Posts: 26196
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The arduino logs how many time the reed switch opens  and the time when it happens so when i go to my computer i can download the data.
You need to tell us more about the likely frequency and volume of such events.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Central Europe
Offline Offline
Edison Member
*
Karma: 7
Posts: 1220
Use the Source, Luke.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Handling the reed switch is easy, just look at the button tutorial. That's all there is to it.

How ever for the storage, you first should think about, what data you want to log and what you're going to do with it later. Do you want to keep track of each single impulse? What kind of timestamps are you going to keep? Do you want to pre-process the impulses into speed and distance before saving?

If the data-volume is a little higher, you're probably better off with a SD-card shield instead of an EEPROM. Those exist ready made - sometimes with useful add ons like a real time clock and you can download working samples on how to use them. Or you could get one of the programmable data-loggers.

Korman
Logged

Humboldt, CA
Offline Offline
Full Member
***
Karma: 2
Posts: 223
Arduino BBB
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you only want to know how many times the reed switch has twitched, and not what time it twitched or how long between twitches, it's pretty simple.
(EDIT: Missed the part where you want the time it twitched.  That changes things!  You could track the number of seconds between the button being pushed the first time and the button being pushed the second time easily enough, that'd give you average speed.)

You need a variable to store whether the on/off button has been pressed, once it has been you enable the interrupt.

Define two variables, lets call them Cycles1 and Cycles2, set up a debounced trigger for the reed switch (or put debouncing inside an interrupt) that adds one to Cycles1.
In that same routine, check Cycles1 to see if it is at 100, if it is at 100 set it to zero, and add one to Cycles2.

When the button is pressed a second time, save Cycles1 into a EEPROM byte, and save Cycles2 into another byte.
If you think you'll ride far enough to need >10k wheel rotations, add Cycles3 the same way Cycles2 works.  That gives you a million revolutions, if you're riding farther than that I salute you!

Then you'll need another section of code to report the values inside the EEPROM bytes through serial or blinky LEDs or something.

If you want to store time along with the number of reed switch triggers, that's rather more complicated.
Logged

Oregon
Offline Offline
Newbie
*
Karma: 0
Posts: 11
Mmm Beerduino
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm thinking you are probably going to want something like this clock board to get real time.

http://www.sparkfun.com/products/99
Logged

Central Europe
Offline Offline
Edison Member
*
Karma: 7
Posts: 1220
Use the Source, Luke.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Probably something like the data logger shield covers the requirement better.
Or use the Seeeduino Stalker
You might also be able to use something like the uLog, but this will require some software hacking to adapt it. That's probably not the solution for a beginner.

Korman
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 40
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It will probably take place 10,000 times. I do not need the real time clock, i need the time between each rotation. What would be the way for the least amount of external parts?
I do not need to pre process anything, just the raw data.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 40
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Bump, can anyone help?
i still dont know if i need an external EEPROM or not
Logged

Central Europe
Offline Offline
Edison Member
*
Karma: 7
Posts: 1220
Use the Source, Luke.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Lets see: Assume you want to save for each datapoint just the timestamp as you read it from millis(), which is an unsigned long taking 4 bytes. You want to store 10000 data points which are 40000 bytes or 40kB (give or take a few). Your Arduino has 2kB RAM and 0.5kB EEPROM. The flash program-memory can't be used for the task. Even if you use some clever data compression mechanism that reduces the average memory used per data point to 1 byte, you're going to need some external memory device.

Korman
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 40
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh, ok. Would the 24C64 EEPROM be fine (I2C EEPROM, 64 kB)?
There is no need for a real time clock though, right?
Logged

Central Europe
Offline Offline
Edison Member
*
Karma: 7
Posts: 1220
Use the Source, Luke.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh, ok. Would the 24C64 EEPROM be fine (I2C EEPROM, 64 kB)?

Careful, those are 64 kbit EEPROM, organises as 8kByte. So no, that one probably won't be enough.

Another thing to consider is what kind of data you have and how much precision you need. My estimate in the previous post was just for storing nothing but the timestamp as it comes out of millis() at millisecond precision. If you need less precision or your data shows strong pattern (eg, the numbers are all about the same value, the values repeat in patterns), the data might need a lot less space than just storing the raw values. If you want help on this aspect, you need to be a bit more specific about the expected data.

There is no need for a real time clock though, right?

If you don't care too much about the feature that the time of the day is correct after reboot, you don't need the RTC.

Korman

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 40
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What if the arduino counts the time taken for a given amount of turns, every 80 turns, which would fit the EEPROM of the arduino, give or take a few.
Logged

Pages: [1]   Go Up
Jump to: