| Author |
Message |
Gillis55 Newbie
 Joined: 01/02/2018 Location: AustraliaPosts: 21 |
| Posted: 09:20am 02 Feb 2018 |
Copy link to clipboard |
 Print this post |
|
Guys, I'm using a MM+64 Backpack with a 1GB SD card plugged into the LCD SD socket. I have written a fairly simple datalogging program to capture some data over a period of time and to progressively write this data to the SD card, however, all seems to work very well but only to a point. What I'm finding is that when the file on the SD card reaches a length of what fairly consistently appears to be about 2684 characters then the card writing stops, even though the program keeps running ie. Data being displayed on the LCD screen and GUI controls all still remain active . If I also include writing the logged data to the console then the terminal screen (I've tried Terra Term and MM Chat) also stops displaying any further logged data at the same point in time. I am running Windows 10 and communicating to the MM+64 via USB connection. The length of each logged record is about 35 characters and I'm sampling at about once every 5 seconds ie I get about 76 logged records max in my file and that's it. Now wondering if its some sort of buffer or buffer overflow issue I have. Any thoughts you may have to help a very novice Micromite user on the cause of this problem would be much appreciated. |
| |
WhiteWizzard Guru
 Joined: 05/04/2013 Location: United KingdomPosts: 2959 |
| Posted: 09:39am 02 Feb 2018 |
Copy link to clipboard |
 Print this post |
|
@Gillis55
Welcome aboard - great to have another new user
First of all; have you tried a different SD card - ideally bigger than 4GB. The older (smaller capacity) cards have caused issues in the past. This would be my first thing to try.
IF you do not currently have a 4GB (or bigger) card at hand right now; then can I suggest you simply comment out the lines of code in your program that write to the SD card - then see if it still shows the issue - i.e. terminal window still stops displaying the data.
Have you tried using the SD card in the BP64 socket instead - NOTE: you cannot have a card in each simultaneously (not without PCB track modifications anyway!).
So a few things to try - feed back anything you're able to try out!!
My money is on an 'old card'
WW |
| |
Grogster
 Admin Group
 Joined: 31/12/2012 Location: New ZealandPosts: 9750 |
| Posted: 11:54am 02 Feb 2018 |
Copy link to clipboard |
 Print this post |
|
Hi there. As WW says, welcome to the forums. 
I wrote a code to test this on an E64:
D$="12345678901234567890123456789012345" X=0 Open "TEST.TXT" for OUTPUT as #1 Do Print #1,D$ X=X+1 Loop Until X=100 Close #1 Print "Done."
An example of what I get is:
[Quote=MM+] 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 12345678901234567890123456789012345 [/Quote]
The file is 3.7kb in size, and is written in less then a second.
QUESTION: Are you remembering to CLOSE the file? If you don't, NOTHING gets written. What I mean by that is that when you print something to the open file, it just sits in the file buffer in memory, until you issue the CLOSE command.
For example, if I use the above code but remark out the Close #1 line, I will have a file with zero bytes.
I suspect that you are not closing the file somewhere you need to, so the data is not getting flushed to the file when it should. That's my theory anyway. Can you post your code for others to examine? I am 100% sure the members can help you fix this, but we need to see your program to find out where the hiccup is occurring.  Smoke makes things work. When the smoke gets out, it stops! |
| |
Gillis55 Newbie
 Joined: 01/02/2018 Location: AustraliaPosts: 21 |
| Posted: 12:10pm 02 Feb 2018 |
Copy link to clipboard |
 Print this post |
|
WW, Thanks for your thoughts so far. I've just tried a re-formatted 2GB card, and then an 8GB card and the same problem. Unfortunately I don't have a microSD card on hand so could not try the BP64 socket. Therefore, on your next suggestion, I then commented everything out in my program dealing with opening, writing to or closing the file on the SD card and, surprisingly, same problem! That is, on the terminal screen I still only see about 73 of my data records printed then nothing. However, the program is still running as I can see input data being changed on the LCD and I can change GUI switches,spin boxes, pages etc. The final thing I've just tried was communicating to the BP64 via the CON1 console port using a USB to serial converter running a baud rate of 38400. What I got was now only 62 data records being printed......going from bad to worse! I then up this rate to 115200 to see if this had an influence and ended up getting 71 data records printed on the screen. Any further thoughts? |
| |
Grogster
 Admin Group
 Joined: 31/12/2012 Location: New ZealandPosts: 9750 |
| Posted: 12:16pm 02 Feb 2018 |
Copy link to clipboard |
 Print this post |
|
Not without seeing your code. There is a bug somewhere there.  If it WERE an SD card writing issue, the demo code above would have also fallen over at about 2684 bytes, which is why I was writing more then that in one burst.
Also, the fact that the card logging AND the console logging also stop at the same time, strongly suggests a bug within the routine you are using to log to the file, or print to the console - or both. 
Can you post your code? Smoke makes things work. When the smoke gets out, it stops! |
| |
Grogster
 Admin Group
 Joined: 31/12/2012 Location: New ZealandPosts: 9750 |
| Posted: 12:26pm 02 Feb 2018 |
Copy link to clipboard |
 Print this post |
|
QUESTION: Are you trying to save data from a COM port(COM1, COM2 or COM3), to the SD card? The COM ports ARE buffered, but I'm not sure that is your problem. The output buffers are fixed at 256 bytes, the input buffers are configurable. However, if you were overflowing the buffers on a COM port, data would be lost. That does not happen with the SD card. It just buffers whatever you send it till you issue the CLOSE command. So, the data that you are logging - are you getting that from one of the COM ports? Smoke makes things work. When the smoke gets out, it stops! |
| |
matherp Guru
 Joined: 11/12/2012 Location: United KingdomPosts: 10569 |
| Posted: 12:28pm 02 Feb 2018 |
Copy link to clipboard |
 Print this post |
|
Have you configured the touch controller and the TFT display? There is known issue with the XPT2046 corrupting SPI if its CS pin is not held high |
| |
Gillis55 Newbie
 Joined: 01/02/2018 Location: AustraliaPosts: 21 |
| Posted: 12:33pm 02 Feb 2018 |
Copy link to clipboard |
 Print this post |
|
Hi Grogster, I just tried your little program on my BP64 and that works fine.
In my program I'm pretty confident I was closing the file correctly as I get the same data I see on the console in the SD card file. I can then remove the SD card from the BP64 and then read the file successfully on my PC. There appears to be something more sinister I've created in my program I think! Running out of time now but I'll post my code at next opportunity for others to ponder over. |
| |
Gillis55 Newbie
 Joined: 01/02/2018 Location: AustraliaPosts: 21 |
| Posted: 12:58pm 02 Feb 2018 |
Copy link to clipboard |
 Print this post |
|
matherp, thanks for your thoughts. I think I have configured these correctly. My configured options are:
> option list OPTION BAUDRATE 230400 OPTION LCDPANEL ILI9341, RLANDSCAPE, 2, 23, 29 OPTION TOUCH 1, 3 OPTION SDCARD 21
Grogster, no. I'm logging temperature and humidity data measured from an AM2302 module. I'm graphing this on the TFT display and at the same time attempting to write it to the SD card. I thought AM2302 data would be easy to start with as a learning exercise and to get a feel for what the BP64 can do.....or more likely what I can mangle up with my limited abilities! Eventually I'm hoping to be able to log data from a couple of 4-20mA pressure transducers via the analogue input ports. I'm still living in hope. |
| |