Hi Leigh,
Hope all is well!,
I am struggling with a calculation for a SD Card Saving routine.
I want to concatenate the MAINT1.txt file (I can save my Tag reader Serial/ID Number with no issues but I can only save it once using MAINT1.txt in the calculation) and I would like to use the RTC clock as the concatenation "byte" as I doubt very much that I would ever get any duplication. If I use a standard byte I am sure I would get duplicates especially once the unit switches on/off as I will start at 0 and repeat which is bound to have duplicate files. Perhaps you have a better idea?,
Please calculation below, I am not sure if the below will work?
RTC[8] = 0
RTC[7] = RTC[5]
RTC[6] = RTC[4]
RTC[5] = ':'
RTC[4] = RTC[3]
RTC[3] = RTC[2]
RTC[2] = ':'
RTC[1] = RTC[1]
RTC[0] = RTC[0]
.filename = "MAINT1" + RTC[0] + RTC[1] + RTC[2] + RTC[3] + ".TXT"
.filestring = ""
I have also attached the code of which the above is under the Macro of Save_Data
Any help would be greatly appreciated,
Regards,
Gavin
Calculation problem dspMIAC
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
Re: Calculation problem dspMIAC
I don't think you can mix characters and strings, also concatenation has a few issues,
so try something like this ...
so try something like this ...
Code: Select all
.filename = "MAINT1"
.filename[6] = RTC[0]
.filename[7] = RTC[1]
.filename[8] = RTC[2]
.filename[9] = RTC[3]
.filename[10] = 0 // Add a null to re-create a proper string
.filename = .filename + ".TXT"
Re: Calculation problem dspMIAC
Hi Leigh,
I tried it and it keeps crashing, looks like if I use:
.filename = "MAINT"
.filename[5] = RTC[0]
.filename[6] = RTC[1]
.filename[7] = RTC[2]
.filename[8] = RTC[3]
.filename[9] = 0
.filename = .filename + ".TXT"
.filestring = ""
it doesn't crash but will only write the file "MAINT" no string behind the MAINT,
Any ideas why it would crash using:
.filename = "MAINT1"
.filename[6] = RTC[0]
.filename[7] = RTC[1]
.filename[8] = RTC[2]
.filename[9] = RTC[3]
.filename[10] = 0 // Add a null to re-create a proper string
.filename = .filename + ".TXT"
.filestring = ""
Regards,
Gavin
I tried it and it keeps crashing, looks like if I use:
.filename = "MAINT"
.filename[5] = RTC[0]
.filename[6] = RTC[1]
.filename[7] = RTC[2]
.filename[8] = RTC[3]
.filename[9] = 0
.filename = .filename + ".TXT"
.filestring = ""
it doesn't crash but will only write the file "MAINT" no string behind the MAINT,
Any ideas why it would crash using:
.filename = "MAINT1"
.filename[6] = RTC[0]
.filename[7] = RTC[1]
.filename[8] = RTC[2]
.filename[9] = RTC[3]
.filename[10] = 0 // Add a null to re-create a proper string
.filename = .filename + ".TXT"
.filestring = ""
Regards,
Gavin
-
- Valued Contributor
- Posts: 1208
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
Re: Calculation problem dspMIAC
Hi Gavin,
There is some code here : viewtopic.php?f=63&t=19464&hilit=camera (look for linksprite_camera) which outputs sequentially numbered files (and datestamps them) to an SD card
Several things could be wrong here:
How big is the filename buffer - is there room for all the extras (note in the download it is 20 chars which is big enough - but filename may need to be 8.3 format? - in which case your name is too long?
What is stored in RTC - is it ASCII (ie characters) or is it just 'raw' data which needs converting to ascii? (ie is it a long int - which copying to the filename will just insert invalid characters. There is lots of code converting binary to a string on the forum (for example here: viewtopic.php?f=7&t=20583&hilit=string+binary)
Martin
There is some code here : viewtopic.php?f=63&t=19464&hilit=camera (look for linksprite_camera) which outputs sequentially numbered files (and datestamps them) to an SD card
Several things could be wrong here:
How big is the filename buffer - is there room for all the extras (note in the download it is 20 chars which is big enough - but filename may need to be 8.3 format? - in which case your name is too long?
What is stored in RTC - is it ASCII (ie characters) or is it just 'raw' data which needs converting to ascii? (ie is it a long int - which copying to the filename will just insert invalid characters. There is lots of code converting binary to a string on the forum (for example here: viewtopic.php?f=7&t=20583&hilit=string+binary)
Martin
Re: Calculation problem dspMIAC
Thanks Martin!,
I am still learning and thanks for the help!,
I managed to get it working using:
.filename = "M"
.filename[1] = RTC[0]
.filename[2] = RTC[1]
.filename[3] = RTC[3]
.filename[4] = RTC[4]
.filename[5] = RTC[7]
.filename[7] = RTC[8]
.filename[8] = 0 // Add a null to re-create a proper string
.filename = .filename + ".TXT"
.filestring = ""
Regards,
Gavin
I am still learning and thanks for the help!,
I managed to get it working using:
.filename = "M"
.filename[1] = RTC[0]
.filename[2] = RTC[1]
.filename[3] = RTC[3]
.filename[4] = RTC[4]
.filename[5] = RTC[7]
.filename[7] = RTC[8]
.filename[8] = 0 // Add a null to re-create a proper string
.filename = .filename + ".TXT"
.filestring = ""
Regards,
Gavin