Require a FIX for -ve decimal logging
msiriwardena
Posts: 301
I am trying to use Autudatalogger Object(Auther-SRLM) - The object works as it is suppose to but It will not log -ve numbers.
SRLM suggested a fix but it does not work.
Fix suggested to dec_to_ASCII :
The -ve decimal numbers are logged as "95,96,98" etc. instead of " -1.-2,-3" etc.
Thank you for youe help.
Siri
PS: Attached is the Autilogger Object by SRLM
SRLM suggested a fix but it does not work.
Fix suggested to dec_to_ASCII :
dec_to_ASCII 'Converts an unsigned number in a register to an ASCII value 't1 - The decimal number 't2 - The current count of the digits (ie, how many 100's are in 843) 't3 - The current number of digit (1000(4), 10(2), 1(1)) 't4 - (parameter) the number to convert 't5 - (parameter) the number of digits in the number (modified) ' ---too few will result in tuncation of upper digits 'ASCII_num - (result) will contain the number, optional negative (-, counts as digit) dec_to_ASCII movs :main_loop, #decimal cmp t1, #0 wc 'Test if less than 0 if_c neg t1, t1 'make the number +ve if_c add t3, #1 'increment the digit counter if_c mov ASCII_num, "-" 'Save -ve sign if_c movd :write, #ASCII_num + 1 if_nc movd :write, #ASCII_num mov t3, #10 :main_loop mov t1, 0-0 'Copy the decimal number (1, 1000, 10000, etc) into the variable mov t2, #0 'Clear the counter :multiply cmp t4, t1 wc 'Is the number less than the decimal number? if_nc sub t4, t1 'The decimal number is <= than the value if_nc add t2, #1 'increment the digit count if_nc jmp #:multiply add t2, #48 'Increase to ASCII 0 :write mov 0-0, t2 cmp t5, t3 wc 'Should I write move on to the next digit? if_nc add :write, destination_mask'Move on to the next digit in ASCII_num add :main_loop, #1 'Move on to the next digit in decimal djnz t3, #:main_loop dec_to_ASCII_ret retI tried replacing "neg" with "abs" - stiill does not work.
The -ve decimal numbers are logged as "95,96,98" etc. instead of " -1.-2,-3" etc.
Thank you for youe help.
Siri
PS: Attached is the Autilogger Object by SRLM
Comments
I tried your fix - All I got was the fields(Varible field name) but no data logged.
The issue at hand most likely is that The file was never closed.In my project I have it to logg for 1.0 min.and then stop.It did not stop after 1.0 min.- so turned off the Prop ?---> corrupt file,no data
The led was blinking ? indicating receiving data (as it use to do)
The attached file shows the Object with the suggested changes.
This is the code I have in my project which logg 3 variables -"Pressure,Pressure1 and RPM" for 1.0 min
This code runs in its own COG- :
Thank you very much for your help.
Siri
To post code, use:
The indentation an formatting of Spin code gets lost if you just cut and paste into a post.
I copied some code I missed and I ran it.Now I am getting -ve numbers but they are not in the same column.
Hear is the modified code as you suggested.Attached to this post and also the print out of the Data output.
If you look at the pressure.txt file the formatting really gets muddled up- I think that is where the system clock goes -Ve.
Thanks again for your help.
Regards,
Siri
I really don't care about cnt - I use it get an avarage time between two readings - but I like the pressure readings to be signed values(-ve and +ve).
The new version fixes the length issue system counter is ok for my project but no -ve pressure values like the previous version.
Attached is the txt file with tne new version.
Thanks again for tremendous help
Regards,
Siri
P.S :In the "Raw" column are the raw pressure readings-(the pressure sensor reads 31 at atmospheric pressure) so the "Corrected" column
represents pressure reading(Raw-31) - the -ve values are now shown as 95,96 ...85 etc.
Thank you very much,now it works well.
Last time in my haste I forgot to change the new addfield format.
Thanks again
Regards
Siri
P.S:Attached is the NEW Datalogger text file.