Being able to log data, and lots of it, unlocks a huge array of learning opportunities, such as:
- measure the forces that are at play on a swing, or roundabout, or in a car journey. Or what about taking it to a theme park and using it on the roller-coaster or dodgems :)
- Add a weather sensor and record days worth of temperature and pressure data to validate Gay-Lussac's law
- Combine with GPS and record your walks / runs. Or attach to a balloon / drone to record their path. Add a CO2 monitor for a very useful environmental monitoring device
- Add a light sensor and put it in your garden to record the conditions in your planting areas. Where is the best place to locate your herb garden and where should you grow your tomatoes or chilli plants?
With the IM01 from XinaBox it is VERY easy to log data to a microSD card. With support for up to 32Gigabytes of memory it is now possible to store data sets of almost unlimited size - millions of records are a possibility.
Follow these simple steps to see how to measure the acceleration forces that are at play with a pendulum. The steps can be easily adapted for other types of data.Step 1: Format your memory card
You will need to format the memory card to FAT32.
If your computer does not provide this option then a quick search online will give you links to loads of free utilities that you can use.
Please note - if you are using a low quality microSD card you may experience difficulties. One way to see if you have a suspect microSD card is to check how much memory it says it has (it is usually printed on the card), then compare it to how much memory your computer thinks it has. A discrepancy there is usually an indicator of a poor quality card. I had a very cheap microSD card that worked on my computer but would not work for this experiment. So, if this doesn't work for you the first trouble-shooting tip is to try a different microSD card.Step 2: Insert the memory card into the IM01
On the back of the IM01 there is a slot that takes a microSD card.
Insert your microSD card there. It is a bit fiddly, but with a bit of trial and error you will work it out. Check out the image below:
- Load up MakeCode
- Import the IM01 extension: Advanced / Extensions then type "xinabox/pxt-im01"
- Enter the code below (or click here for the MakeCode project):
Note the following in the code:
- The file we are writing to is called accData.txt. If this file does not exist on the microSD card then it will be created in the On Start block If it already exists then this code will append to the end of it.
- There is no pause between write events in the Forever loop. This is to ensure that we get the very quickest sample rate possible. In testing the sample rate achieved was <3ms, which is very good: we collected 300 data points in 1 minute. A sample rate this quick means experiments with acceleration are viable.
- We do not use the micro:bit LED matrix at all. This ensures all resource is focused on logging the data. Any additional functions we add to the code will slow down the sample rate.
When the code is written flash it on to your micro:bit.
The first time the micro:bit runs the code it will set up a folder on your microSD card (called im01) and will create the accData.txt fileStep 4: Build your hardware rig:
Connect your BBC micro:bit to the IM01 bridge then add the battery pack (but don't plug it in yet - we don't want to start logging data now). I used a rubber band to hold it all together, as shown:
Next tie a piece of string to it - you can see the string I used in the image above. Judge the length of the piece of string so that it is a suitable length for your project.Step 5: Set up your experiment.
I tied mine to a tree, as you can see below.
- Find something suitable to tie the hardware rig to.
- Plug in the battery pack
- Release the hardware rig and let it swing!
- Wait until it stops oscillating or until you have gathered enough data. Remove the power pack to stop recording data.
You could leave it for hours, the microSD card can store days or even weeks of this kind of data.Step 6: Extract and analyse your data
- Remove the microSD card from the IM01
- Put the microSD card into your computer
- Extract the file accData file. It is a .txt file that is CSV compliant, with a comma separator.
- Open Excel, or a similar spreadsheet program
- Import the file.
You can now play around with the data. Make some line charts like the one below:
There are lots of ways to analyse the data, such as:
- Find the periodicity of the peaks and troughs and analyse how the time between them decreases,
- Infer the height of the swing and see how that changes each time.
- We just charted the overall strength of acceleration above, but you could chart the x, y and z accelerations and see how the different forces come into play.
- Investigate and explain discrepancies. In the data I collected, as you can see in the chart, some peaks are a bit higher than preceding ones. In theory they shouldn't be, so why are they? What extraneous variables were at play (in my case it was very windy).
- Repeat the experiment with a few different lengths of string. How is the length related to things like the height of the peak and the periodicity. Extrapolate - estimate the pattern for a particular length of string then repeat the experiment to check your estimates. Similarly experiment with different heights at which you start the pendulum.
- Calculate the total distance travelled in a minute. Could you estimate the distance it will travel in a minute just by the length of the string and the height of the first peak?
Thank you :)