Trying to Utilize Parallax USB Data Logger
Hello everyone,
My classmate and I are working on a coin donation counter project for our college course. We are trying to utilize a Parallax USB Data Logger with a BS2 to record the total amount of money collected, in addition to the amount of nickels, dimes and quarters collected. We want the data logger to write to the .txt file as follows:
The data logger is initialized with code we grabbed from a Parallax example program:
This is the code for the actual logging process we want to be executed:
A few revisions back in our coding (which we saved) we had the logger actually creating the file, but not writing anything to it. Now, the logger won't even create the file. The code for this part of our program executes one time; when the program revisits the logging portion, the program freezes.
Me and my friend have been trying very hard to understand the Vinculum Documentation, but unfortunately it raises many questions for us. For example, you may have noticed in our code above that we use both a mixture of ASCII and HEX commands (I am sure this is not proper procedure for using the data logger).
We also want the our Coin Donation Counter to read from the text file on start up. We record the total amount of cents donated in a word-sized variable called "total"; we want the logger to load the value of total from the text file, into the RAM of the BS2. Surely, this is just a matter of properly executing a Vinculum command in conjunction with a BS2 variable equation.
We need some assistance in achieving our project goals. I am hoping there is someone on the Parallax forums that can help us understand how the Parallax USB Data Logger operates, at least enough to have it function the way we want it to. Click here to see our entire project code, as per our latest revisions.
Any help is greatly appreciated! If any part of my post is unclear, please let me know so I can try explaining it better.
My classmate and I are working on a coin donation counter project for our college course. We are trying to utilize a Parallax USB Data Logger with a BS2 to record the total amount of money collected, in addition to the amount of nickels, dimes and quarters collected. We want the data logger to write to the .txt file as follows:
T 63335 N 0000 D 0000 Q 0000
The data logger is initialized with code we grabbed from a Parallax example program:
HIGH TX ' Initialize transmit line
LOW RTS ' Take vinculum out of reset
PAUSE 2000 ' Allow time to settle
GOSUB Purge ' Purge buffer
SEROUT 14, 84, ["Syncing USB..."]
index = 0
' For Synchronization send E until echoed back
DO WHILE (index < 1)
PAUSE 500
SEROUT TX\CTS, Baud, ["E", CR] ' Transmit "E CR"
GOSUB Get_Serial_Bytes ' Get returned data
LOOP
GOSUB Purge ' Purge buffer
' Send e to complete synchronization
PAUSE 500
SEROUT TX\CTS, Baud, ["e", CR] ' Transmit "e CR"
GOSUB Get_Serial_Bytes
' Send CR to see if drive is present
PAUSE 500
GOSUB Purge ' Purge buffer
SEROUT TX\CTS, Baud, [CR] ' Send carriage return
GOSUB Get_Serial_Bytes ' Wait for D:\>
IF (buffer(0) = "N") THEN
SEROUT 14, 84, [12, "No drive", 148, "present!"]
STOP
ELSE
SEROUT 14, 84, [12, "Drive D: ready."]
ENDIF
GOSUB Purge ' Purge buffer
RETURN
' ---[ Subroutines for USB Data Logger ]---
Get_Serial_Bytes:
timeout = 1 ' Set timeout indicator flag
index = 0 ' Initialize index
DO WHILE (timeout > 0) ' While timeout has not occurred
ioByte = 0 ' Clear temporary storage
SERIN RX\RTS, Baud, 100, No_Data, [ioByte]
buffer(index) = ioByte ' Save byte received to array
index = index + 1 ' Increment index
IF (index > 14) THEN ' Check for overflow
index = 14 ' Prevent overflow
ENDIF
LOOP
RETURN
Purge:
timeout = 1 ' Set timeout indicator flag
DO WHILE (timeout > 0) ' While timeout has not occurred
PAUSE 50
SERIN RX\RTS, Baud, 500, No_Data, [ioByte]
LOOP
RETURN
No_Data:
timeout = 0 ' Timeout, clear flag
RETURN
This is the code for the actual logging process we want to be executed:
' ---[ Log Data ]-------------------------------------------------------
Log_Data:
DEBUG "Waking", CR
SEROUT TX\CTS, Baud, ["WKD", CR]
GOSUB Get_Serial_Bytes
PAUSE 120
SEROUT TX\CTS, Baud, ["OPW totals.txt", CR] ' Opens the file for
GOSUB Get_Serial_Bytes ' writing
' Write stuff
PAUSE 120
SEROUT TX\CTS, Baud, [$08, $20, $00, $00, $00, $1D, CR, "T :",
DEC5 total, CR, "N ", DEC4 nick, CR, "D ",
DEC4 dime, CR, "Q ", DEC4 quar]
PAUSE 500
GOSUB Get_Serial_Bytes
PAUSE 120
SEROUT TX\CTS, Baud, ["CLF totals.txt", CR] ' Closes the file
GOSUB Get_Serial_Bytes
'GOSUB Purge
PAUSE 120
DEBUG "Sleep", CR
SEROUT TX\CTS, Baud, ["SUD", CR]
GOSUB Get_Serial_Bytes
PAUSE 1500
RETURN
A few revisions back in our coding (which we saved) we had the logger actually creating the file, but not writing anything to it. Now, the logger won't even create the file. The code for this part of our program executes one time; when the program revisits the logging portion, the program freezes.
Me and my friend have been trying very hard to understand the Vinculum Documentation, but unfortunately it raises many questions for us. For example, you may have noticed in our code above that we use both a mixture of ASCII and HEX commands (I am sure this is not proper procedure for using the data logger).
We also want the our Coin Donation Counter to read from the text file on start up. We record the total amount of cents donated in a word-sized variable called "total"; we want the logger to load the value of total from the text file, into the RAM of the BS2. Surely, this is just a matter of properly executing a Vinculum command in conjunction with a BS2 variable equation.
We need some assistance in achieving our project goals. I am hoping there is someone on the Parallax forums that can help us understand how the Parallax USB Data Logger operates, at least enough to have it function the way we want it to. Click here to see our entire project code, as per our latest revisions.
Any help is greatly appreciated! If any part of my post is unclear, please let me know so I can try explaining it better.

Comments
*Technically not true. You can switch between one and the other with the SCS and ECS commands, but I would choose one and stick with it for the entire program.
http://forums.parallax.com/showthread.php?134959-Reducing-write-time-of-USB-Data-Logger-with-BS2p
Jeff T.