SEROUT Problem while writing to Memory Stick Datalogger
blackbelt
Posts: 9
I am using bs2p with the prof dev board to datalog 3 temps, room humidity, time in hr[noparse]:min:[/noparse]sec and date mo:day
I have written a multi bank program. I am facing a problem where the program stops at the SEROUT command after working fine for 10 to 20 min. It will sit there indefinetely..
I put a lot of·DEBUG statements to locate where the program was stopping. (If you were wondering why I had to many debug statements)
Earlier Tracy Allen helped me with the format of the SEROUT command.
The SEROUT command is writing out the time and date (from DS1307) using HEX2 format. There are a total of 16 characters that the SEROUT is sending to the datalogger
14 characters for the time,·date, punctuation like "," plus 2 more for CR and LF where $10 in the SEROUT comes from.··· 16 characters==>·(05,30,15,01,21) ==> 5:30:15 Jan 21
As I said earlier program works fine for more than 1 hr collecting 100's of data points and successfully writing to the memory stick. Is there something that I am not aware of because of the HEX format in SEROUT?
The other thing I tried is·putting PAUSE statements to take care of the write delays before and after DEBUG and SEROUT commands. After adding the PAUSES the program run longer than 1 hr before stopping at the same SEROUT statement.
I am attaching the source code for the multi bank program.
0: Main controls the program banks,
1: Initializes datalogger and executed once
2: Temp and humidity data collection thru LTC 1298 ADC and write to the memeory stick
3: Time and date
Data in the memory stick looks like this at each line ---> First 3 are the temps, Rel Humidity, time and date
28.5,70.3,68.5,30.0,05,30,15,01,21
Thank you for your in advance...
··· IOTERM 0
·
··· I2COUT CPORT,DS1307,7,[noparse][[/noparse]$10]·························· ' Enable OSC @ 1Hz
··· GOSUB Get_Clock
··· PAUSE 500
··· DEBUG HEX2 hr, ":", HEX2 minute, ":", HEX2 sec, "·· ",
··· ········· HEX2 month, "/", HEX2 date, CR
···
··· DEBUG "Debug Hex2 Write is over...", CR
··· PAUSE 500
···
··· IOTERM 1
··· PAUSE 200
···
··· DEBUG "IOTERM 1 is done ...", CR
··· PAUSE 200
···
··· DEBUG "Pause is done...", CR
··· PAUSE 500
··· SEROUT TX\CTS, Baud, [noparse][[/noparse]$08, $20, $00, $00, $00, $10, $0D,
········· HEX2 hr, ",", HEX2 minute, ",", HEX2 sec, ",", HEX2 month, ",", HEX2 date, $0D, $0A, $0D]
··· PAUSE 2000
···
··· DEBUG CR, "TimeDate .... Returning to Main......", CR
··· PAUSE 2000
I have written a multi bank program. I am facing a problem where the program stops at the SEROUT command after working fine for 10 to 20 min. It will sit there indefinetely..
I put a lot of·DEBUG statements to locate where the program was stopping. (If you were wondering why I had to many debug statements)
Earlier Tracy Allen helped me with the format of the SEROUT command.
The SEROUT command is writing out the time and date (from DS1307) using HEX2 format. There are a total of 16 characters that the SEROUT is sending to the datalogger
14 characters for the time,·date, punctuation like "," plus 2 more for CR and LF where $10 in the SEROUT comes from.··· 16 characters==>·(05,30,15,01,21) ==> 5:30:15 Jan 21
As I said earlier program works fine for more than 1 hr collecting 100's of data points and successfully writing to the memory stick. Is there something that I am not aware of because of the HEX format in SEROUT?
The other thing I tried is·putting PAUSE statements to take care of the write delays before and after DEBUG and SEROUT commands. After adding the PAUSES the program run longer than 1 hr before stopping at the same SEROUT statement.
I am attaching the source code for the multi bank program.
0: Main controls the program banks,
1: Initializes datalogger and executed once
2: Temp and humidity data collection thru LTC 1298 ADC and write to the memeory stick
3: Time and date
Data in the memory stick looks like this at each line ---> First 3 are the temps, Rel Humidity, time and date
28.5,70.3,68.5,30.0,05,30,15,01,21
Thank you for your in advance...
··· IOTERM 0
·
··· I2COUT CPORT,DS1307,7,[noparse][[/noparse]$10]·························· ' Enable OSC @ 1Hz
··· GOSUB Get_Clock
··· PAUSE 500
··· DEBUG HEX2 hr, ":", HEX2 minute, ":", HEX2 sec, "·· ",
··· ········· HEX2 month, "/", HEX2 date, CR
···
··· DEBUG "Debug Hex2 Write is over...", CR
··· PAUSE 500
···
··· IOTERM 1
··· PAUSE 200
···
··· DEBUG "IOTERM 1 is done ...", CR
··· PAUSE 200
···
··· DEBUG "Pause is done...", CR
··· PAUSE 500
··· SEROUT TX\CTS, Baud, [noparse][[/noparse]$08, $20, $00, $00, $00, $10, $0D,
········· HEX2 hr, ",", HEX2 minute, ",", HEX2 sec, ",", HEX2 month, ",", HEX2 date, $0D, $0A, $0D]
··· PAUSE 2000
···
··· DEBUG CR, "TimeDate .... Returning to Main......", CR
··· PAUSE 2000
bsp
3K
Comments
Thank yuo for the quick reply. I started the program without the \CTS. I will let you in the result in 90 mins. Currently the program is running fine w/o the \CTS.
I thought handshaking makes the communication more robust. Could you pls explain me what is happening with and w/o handshaking?
In my experience, one possible sticking point is, strangely enough, the state of the RTS line. That is the flow control signal that goes with SERIN. The datalogger expects that line to be low (=BS2 ready to receive data), even during the time the Stamp is sending data to the datalogger with a SEROUT. So,
Frankly I am surprised if that resolves the problem, but please try it and let me know if it does. I know there is an issue, but in my experience it arises when a single SEROUT command has more than about 25 characters, and your string has only 16. It might happen at the sector boundaries, which would explain why it works okay 10 or 20 minutes before failing. How much data do you collect in 10 to 20 minutes?
I noticed in your LTC1298 routine
If you count the $0D at the end, there are $15, not $14 characters in the string. I don't think that would be a fatal error. The logger would interpret the $0D as a command instead of part of the string. I don't think that has anything to do with the sticking problem, although the datalogger is generally picky about getting the right amount of data and about unintentional command strings.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
The version of the program without the \CTS in SEROUT that I started last night (as yousuggested) was still running this morning - collecting data. With all the PAUSE statements, I am collecting a set of data in every ~13 sec. I will check it again and let you know tonight when I get back home. THANK YOU FOR YOUR HELP...
Allen: I will implement your suggestions towards finding the root cause of handshake problem this weekend and let you know the outcome. THANK YOU FOR YOUR CONTINUING SUPPORT.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
During normal operation -->
·· CTS pin stayed low at 0V and never·changed status
·· RTS pin was set to low for 56 mili seconds before jumping back to 5V·at the SEROUT command in Timedata.bsp. This happened periodically at 7.2sec - Cycle time it takes to execute the SEROUT command in Timedata.bsp
At the moment where program hung up -->
··· CTS pin was pulled high to 3.3V
··· RTS pin stayed high and never dropped to low
Seems like the issue is the CTS pin going high before the last SEROUT command execution. I can not explain why the CTS pin is going high - Is the datalogger buffer full? If it is, what is causing it to be full? It worked 30 minutes before being full!!
Do you still think that running the following may still help.
I have a lot of datalogging projects in mind with remote data collection and transfer using the wireless receiver and transmitters. I would like to help to debug the issue· (with collecting and documenting data) if you are willing to guide me.
Thank you for yur help.
So far two things have worked:
1) Removing the \CTS option from the SEROUT command
2) Pulling RTS to LOW before the SEROUT command and Raising it to HIGH afterwords.
Another fact is PAUSE statements before and after the SEROUT command does not make the program work. However, 2 second PAUSE extended the program run time to mre than an hour from 10 to 20 minutes.
I am not sure about this but when I connected the scope and the LED's to CTS and RTS pins on the professional development board, it seemed like program run longer before hanging up.
If there is a SERIN rx\rts in your PBASIC program, the rts line will be left at a high level, which says, "not ready". Okay. That brings us to the Vinculum. For some reason that is a mystery to me, the Vinculum sometimes checks the RTS line to see if the Stamp is ready to receive, and that happens even if the Vinculum is not going to send any actual data. If PBASIC tries to send something more than about 25 bytes in one string (I forget the exact number), the Vinculum will at that point check the status of the RTS line, and if it is not low=ready, then the Vinculum will set its cts high to indicate that it is no longer ready to receive data. And your PBASIC program locks up. It has nothing to do with the Vinculum buffer being full. (I don't know how big the buffer is actually, but I think it is much larger than 50 bytes). By setting rts low before the SEROUT, and high afterwards, you are fooling it into thinking that the Stamp is always ready to receive.
I have never seen the Vinculum ever actually send a byte back (look at the rx line on a digital scope), and the documentation has no mention of a handshake. I consider it a bug or annoyance in the Vinculum firmware, which, please note, would not occur if the Stamp had a full duplex serial port.
In your case, you are not sending 25 bytes at each instance and it waits 10 or 20 or 60 minutes before it locks up. But the symptom is the same. The reason I asked about how much data was sent, is that I have seen other puzzling things happen in the Vinculum firmware when the amount of data exceeds 1 sector (512 bytes).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com