Logging multiple sensors

Not sure if this is the right area, here or programming.. Please move if wrong.

So, I have a few sensors working and for testing purposes I want to take a short cut to get some "live"data to work with in Processing3 or VPython.

What do I have working:

GPS, NEO 6M
MPU6050 together with HMC5883L
SD Card
Reading values from my RC RX Receiver.

My plan for testing is to log data from these 3 sources onto the SD so I can:

Plot route in Google Maps
See the relation between throttle/steer and the MPU/HMC setup
Put this info in Processing or Vpython to make it visual.

But, and that's why I post this; I am afraid timing is an issue:

GPS, via interrupt. 1HZ is more than enough. I am not really looking for GPS-Speed readout. Just a location every second.

MPU/HMC/Car behaviour. I am not sure. The car will not be going very fast (30mph max) but will accelerate/drift/brake/do stupid stuff a lot. And that is what I am interested in. How does a normal corner compares to 1 that I spin out of? This will also be controlled by Interrupt. Would 10hz be enough to plot the action?

Then the controlling. What did I DO while driving it ok or had it spin out? 10HZ as well? I could not find a way to do this by interrupt so I will have to do this with a timer.

I am afraid that these timers and interrupts will interfere with each other.

Also, at what point do I write to the card? Do I write al data together in a batch, 1 file? or data from every sensor seperately in different files? (when available --write)?

How to orchestrate this? How would you do this?

GPS, via interrupt.

At 1Hz you definitely need no interrupt!

This will also be controlled by Interrupt.

Why? A simple compare for the millis() value is more than enough.

I am afraid that these timers and interrupts will interfere with each other.

They might interfere and especially the requested actions are not suited for an interrupt. Interrupt handlers should be short, fast and must not call any functionality depending on interrupts (as p.e. serial output).

How to orchestrate this? How would you do this?

Do everything in the loop, use millis() to start every action at the right time. See the BlinkWithoutDelay example to get an impression of how such a loop is done.

Thanks. I know the blink without delay script and the use of it.

Should I write the data separately to SD or once all is complete? That is a bit of the timing I mean.

Should I write 10 times a second? or create a buffer and write once a second?

It is the writing to SD part that I am most confused about.

Should I write the data separately to SD or once all is complete? That is a bit of the timing I mean.

If you don't read all sensors at the same time it's difficult to write everything at once. A UNO has very limited RAM resources, so storing everything in memory until you can write it to SD card might fail.

The SD card will suffer from the many writes but your setup doesn't sound like a long term solution anyway.

Should I write 10 times a second? or create a buffer and write once a second?

That depends on how many data you catch and write to the card. As explained above.

It is the writing to SD part that I am most confused about.

And what exactly confuses you?

Well, it is just the first step to generate some data. Once the project is complete it should be able to log a lot more information.

What confuses me is the moment to write to disk, when should I do that? the lifespan of a SD card does not concern me but the performance does.

I do know how my sensors work (sort of enough) but not how to let them work simultaneously in combination with logging.

For my first few test runs I want to log the time, the controls i give the car (throttle steer), where i have been and how I drove (gps) and how the car handled (Compass/Gyro/accell). All this information has to be stored on the SD.

To be honest I do not have an idea about the intervals. The ones I mentioned seemed ok to me but I dont have experience with that. Sure I can use timers but if the card is busy, the timer has to skip a few "beats", get new data and try again. But will I build up a queue? If so, kill the queue?!

With this data I am going to feed vPython or Processing3 to "recreate my drive so I can adjust the car.

My end goal is even more ambitious but lets cross bridges when I get there;

7 Hall sensors will be added to log 7 rotating parts.
The car has to send almost realtime speed and RPM to my base
The car has to send almost realtime battery status to my base
The car also has to log Max speed, max rpm, RPM per rotating part, time of the driving sessions, distance of the driving session, 0-30mph time, 0-50mph time.
Influence the control (kidmode, not faster than 15mph) etc etc.

Oh, and the base station will be able to switch logging etc on and off. The car will only log data when I tell it to by remote.

The communication is already working based on HC12 tranceivers.

Ofcourse I will not be using only 1 UNO for the end product. For the hallsensors alone I will be using an UNO or NANO, maybe even with its own SD card.

But again, bridge when i get there.

For now, how to gather this information best (situation now, not end project)

For a start you might see if you can get the arduino to read the various sensors in the way you like, then expand from there.

zoomkat:
For a start you might see if you can get the arduino to read the various sensors in the way you like, then expand from there.

Hi Zoomkat,

That is a bit of the point that I am trying to achieve.

I dont have GPS indoors. Indoor data is working fine but I need to see "real data".

Same for the MPU/HMC, wiggeling my breadboard is doing fine but I dont have a 20M USB cable.

Same for Throttle Steering, back and forth in the living room is ok but I cannot correlate that info with the MPU/HMC without at least destroying my living room.

Writing data to SD from a sensor (tested with various ones, DHT11/22, GPS while indoor, remote controle RC) is also working fine.

I really need to go outside and record what and how I set it and get back inside to read it to see if it does like I want. Then change, go out and do it all over again.

Forget the end project for now, I need to record something that I can use to experiment with.

So my question to the experts is not how to read the data but how to get it on the SD as efficient as possible, whatever the sensors spit out. And what is the usual rate for it.

(only the 3 sensors for now, GPS, MPU/HMC and RX control).

I truly hope that you understand what I mean.

Thanks!

Zoomkat?

"I dont have GPS indoors. Indoor data is working fine but I need to see "real data".

If the gps module uses four or less wires, maybe you can get some four conductor ca3 telephone wire connected so you can get to a window.

"Same for Throttle Steering, back and forth in the living room is ok but I cannot correlate that info with the MPU/HMC without at least destroying my living room."

Set it up on blocks.

zoomkat:
"I dont have GPS indoors. Indoor data is working fine but I need to see "real data".

If the gps module uses four or less wires, maybe you can get some four conductor ca3 telephone wire connected so you can get to a window.

"Same for Throttle Steering, back and forth in the living room is ok but I cannot correlate that info with the MPU/HMC without at least destroying my living room."

Set it up on blocks.

I really hope this is your kind of sarcasme. Otherwise, Why??

I have the data and sensors working. But how to log it en when?

If you cannot help, please do not mock me. And yes, I have tried CAT3 cable, my 90 year old neigbour tripped on it and called the police..

On the other hand, you missed the point. how would a car on blocks generate G forces?