How to use the mbed to store the data?

11 Feb 2010

In my project, the analogue signal goes into the mbed and I want this signal information to be stored in somewhere and finally could be transferred into the computer. Is the mbed able to be an memory device? If not, how can I use the mbed to record that information? Or is there any ways to store these signal information using the mbed?(Converting it to digital signal is possibly better)

11 Feb 2010

The best way to store data on the mbed is using an SD card. You can fit tons of information on those cards and the mbed can read and write to it. Using the ADC when you read the value of your analog signal you can just write to a file on the SD card.

11 Feb 2010

Igor Skochinsky wrote:

See LocalFileSystem.

Thanks very much, it is quite useful for me.

I had another problem which is about the C++. I am trying to display the voltage value in the "out.txt" instead of 'Hellow World!'. Would you mind helping me to revise the code below. I am actually confused about that 'fprintf' line.

#include "mbed.h"

AnalogIn xin(p20);
AnalogIn yin(p19);

LocalFileSystem local("local");               // Create the local filesystem under the name "local"

int main() {
float xval;
float yval;

xval=xin.read();
yval=yin.read();

FILE *fp = fopen("/local/out.txt", "w");  // Open "out.txt" on the local file system for writing
fprintf(fp, "Hellow World!");
fclose(fp);
}

 

 

11 Feb 2010

Vlad Cazan wrote:

The best way to store data on the mbed is using an SD card. You can fit tons of information on those cards and the mbed can read and write to it. Using the ADC when you read the value of your analog signal you can just write to a file on the SD card.

The problem is that how I can connect the SD card with the mbed. I mean that they have different interfaces.

11 Feb 2010

Here's a reference for fprintf:

http://www.cplusplus.com/reference/clibrary/cstdio/fprintf/

In your case, you'll need to do something like this:

fprintf(fp, "x: %f, y: %f\n", xval, yval);

11 Feb 2010 . Edited: 11 Feb 2010

Here is the cookbook page for the SD card library: http://mbed.org/projects/cookbook/wiki/SDCard

 

You dont even need a breakout board, you can just solder wires to the SD card its-self to test.

11 Feb 2010

Igor Skochinsky wrote:

Here's a reference for fprintf:

http://www.cplusplus.com/reference/clibrary/cstdio/fprintf/

In your case, you'll need to do something like this:

fprintf(fp, "x: %f, y: %f\n", xval, yval);

Thanks. Another problem is about the function: 'read'

Having looked through the following instructions, I am confused about that how the real voltage value is chaged to the percentage value. Is there any formula between them?

read

float read()

Read the input voltage, represented as a float in the range [0.0, 1.0]

Variables

returns A floating-point value representing the current input voltage, measured as a percentage
11 Feb 2010

0.0 corresponds to 0V, 1.0 corresponds to the reference voltage, which is 3.3V for the mbed board.

11 Feb 2010

I have always wondered if there is some sort of mapping function that can be used to translate the value of the input to the voltage, or for other values without having to find the right formula each time?

Igor Skochinsky wrote:

0.0 corresponds to 0V, 1.0 corresponds to the reference voltage, which is 3.3V for the mbed board.

 

 

11 Feb 2010

Well, you can just multiply it by 3.3 :)

11 Feb 2010

Igor Skochinsky wrote:

0.0 corresponds to 0V, 1.0 corresponds to the reference voltage, which is 3.3V for the mbed board.

I have looked through chapter 27 in the user manual: Analogue-to-Digtial Convector, which specified that the measurement range is 0 to 3 V. Is it 3V or 3.3V actually?

11 Feb 2010

 

Igor Skochinsky wrote:

Well, you can just multiply it by 3.3 :)

Lol well yes, for that example, but I have a gas sensor which gives values from 0.54 to 0.95 (and when I change the resistor these values change as well)

On the arduino there is map(value,fromLow, fromHigh, toLow, toHigh);

Maybe im just to lazy lol

 

 

11 Feb 2010

 

XueTao Yuan wrote:

I have looked through chapter 27 in the user manual: Analogue-to-Digtial Convector, which specified that the measurement range is 0 to 3 V. Is it 3V or 3.3V actually?

 

AnalogOut 1.0 = 3.3 v according to my voltmeter, so I am assuming its the same for AnalogIn

 

11 Feb 2010

While we are on the topic. I have been curious whether the 512K flash memory can be used to store data using the same technique as localfile system, when the lpc chip is in a production system (not on mbed)

 

?

11 Feb 2010

Hmm you could probably rope off a part of the flash as a "virtual disk" and implement read/write operations via IAP calls... Should work, but it's probably somewhat wasteful to use FAT on the internal flash, where you don't really need it for interfacing with other systems.

11 Feb 2010 . Edited: 11 Feb 2010

 

Igor Skochinsky wrote:

Hmm you could probably rope off a part of the flash as a "virtual disk" and implement read/write operations via IAP calls... Should work, but it's probably somewhat wasteful to use FAT on the internal flash, where you don't really need it for interfacing with other systems.

Ok, so please help me understand. If the chip has 512k space, and my binary is 150K. Why can't I use 256K or so to store whatever i want (i.e. log files, etc?). Why would that be wasteful, if the space is just sitting empty otherwise?

11 Feb 2010

What Igor says is that a file-system gives overhead but if you want you can of course use it anyway.
Is your plan to make the flash available to external apps? The you have a problem because how are you going to separate internal and external calls?

In my app I have a similar situation but there is no filesystem because that gives no good communication between internal and external so I use dedicated APIs.

I have yet to implement R/W in the program Flash but it should be doable.

There are unfortunately limits to the number of cycles you can use on the internal Flash.

Anders

11 Feb 2010

Sounds like it might just include an external eeprom on the board.

12 Feb 2010

I just copied the following code into the mbed, then I cant access it. anyone know whats wrong with it? It is accessable until I add the 'while' loop.

#include "mbed.h"

AnalogIn xin(p20);
AnalogIn yin(p19);

LocalFileSystem local("local");               // Create the local filesystem under the name "local"

int main() {
float xval;
float yval;

while(1) {
xval=xin.read();
yval=yin.read();

FILE *fp = fopen("/local/out.txt", "w");  // Open "out.txt" on the local file system for writing
fprintf(fp, "x: %f, y: %f\n", xval, yval);
fclose(fp);
wait_ms(100);
}

}

12 Feb 2010

Vlad Cazan wrote:

Here is the cookbook page for the SD card library: http://mbed.org/projects/cookbook/wiki/SDCard

 

You dont even need a breakout board, you can just solder wires to the SD card its-self to test.

Would you please detail the way to solder wires to the SD card without a breakout board?

26 Feb 2011

Hi,

There is too lite time between the closing of the file and opening it again. The USB drive disconnects from your PC whenever you open a file from within your code. It needs time to be be connected again so you can access the file from PC. I made a logging program that stores the measurements in ram and writes them to the local files system once a minute. Not verry neat when connected to the PC but functional.

Jan Willem