- 14/05/2018 at 18:56 #3076
Hello my question is short, I am using the FatFs library: ¿how can I write data in the .txt file?, not words. For example, analog-to-digital conversion data is obtained.
I just need to know how I use the f_write function to put a floating number in the .txt file. i tried changing the float to char, but it does not work.
Thank you for yours respons
- 14/05/2018 at 23:51 #3106
It explained in the tutorial, replace “buff” which is the pointer to the data to be written with your variable containing your data (your floating point data).
Change the “Hello world …” with your variable.
- 15/05/2018 at 20:06 #3111
thank you for your answer.
i did it, but the problem is the number of the bytes to write in the SD. it’s necessary to put in this place the exact quantity.
- 15/05/2018 at 23:02 #3112
You can find out how many bytes are in the Float. The other best option so that your data can be readable is to convert it to string, use the function sprintf() to convert Float to string then use The f_printf function writes formatted string to the file.
- 16/05/2018 at 17:57 #3118
Thank you very much for responding again.
I have already managed to write data of 5 bytes, changing them to a variable type “char” and sending the address of this variable.
Now I have had problems simulating. usually the file is created and the data is stored correctly, but in some occasions the image used in the simulation is damaged and the .txt file can not be opened.
Software: MPLAB x IDE v4.05
simulation software: MPLAB x IDE v4.05
program to create and view the image of SD memory: Winimage
Attachments:You must be logged in to view attached files.
- 16/05/2018 at 18:31 #3122
Simulation software: proteus 8 *
- 16/05/2018 at 18:31 #3123
Hi. Good to hear that at least you are managing to write data correctly. Unfortunately our knowledge with winimage is very limited. You can’t advise you why the file gets corrupt. Maybe you can get a better response from winimage Forum or support.
How are you simulating the SD card with MPLAB X IDE?
- 16/05/2018 at 18:35 #3124
the simulation is done in proteus 8.
thanks for everything. see you soon.
- 16/05/2018 at 19:32 #3125
You are welcome!
You must be logged in to reply to this topic.