gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS Motion Sensor > Saving accelerometer output to file?

#150720 - nerkle - Mon Feb 11, 2008 11:38 am

Hi

Forgive the n00b q's...

I teach high school physics (in Wales, UK) and keen to use the Motion PAK in class as a crossover between traditional data logging and game-gear.

I am sure the answer to this is yes, but not being a coder (can handle Python at a push!!) wouldn't know where to start.

Is it possible to stream the output from the sensors directly to a file (I have an R4 and 2GB of flash)?
If so, is there homebrew already out there that does this?
If not, how hard would it be to code?

Fake edit:
Also, it grabs me that if the two additional sensor inputs on the Motion Pak could also captured, I would have the makings of a data logger (connect light sensor for example)

Thanks in advance...

Glen

#150742 - nipil - Mon Feb 11, 2008 8:36 pm

Kind of the same answer as i did for your other post, saving is easy using libfat (i guessa any cart could handle 1kB/sec ;)
The data source is even easier to use than temperature, thanks to "ndsmotion.h".
Make a call to motion_init() in your code, check that it returns positive int to be sure the cart is ok, then continuously
(preferably on vblank, so it's 60HZ) poll the motion data using motion_acceleration_{x,y,z} and motion_rotation.

External inputs can be used with motion_{enable,read}_ain_{1,2}.
Beware of the external input voltage, there's some limitations...
But I can't seem to find the relevant post or website... sorry
_________________
NDS Lite Gold/Silver, MK5/R4DS, MSI PC54G2, D-Link DI-624

#150764 - zazery - Tue Feb 12, 2008 7:14 am

About year ago when I first got my motion card I made a small program that would log the data. My goal at the time was to analyze it and see if I could approximate where the DS was relative to where I started recording.

I use vblank for my timing like nipil suggested. I simply store up to 60 seconds of data and then wrote it to the card.

You can find my project here. I can't guarantee that it compiles anymore but the binary should work. The output files are raw binary and can be viewed using MotionPlot

A few results did come of it.
Small circle (sine and cosine looking)
Square plot

#150843 - nerkle - Wed Feb 13, 2008 9:43 am

Thanks all..

After downloading and playing with DevKit I am please to find that all looks sensible and **easy** to understand. I complied a few test progs and played with file out out.

Now to wait for the MotionPAK to find its way from the USA to UK...

Zazery -- mind if I pick apart your source?

Cheers
Glen

#150973 - zazery - Sat Feb 16, 2008 4:44 am

Go right ahead.

I'm interested in seeing what you come up with and how successful it is in class. The only type of data logging that was used when I took physics in high school was an echolocation sensor for a TI83+ calculator.