Hi,
I want a value from 5 separate digits,that are feed bye user on 7 segment display.I am using this method
Total = (digit[0] * 10000) + (digit[1] * 1000) + (digit[2] * 100) + (digit[3] * 10) + digit[4]
Total is a ULong (number in the range 0 to 4294967295) 32 bit variable .
This method works fine in Flowcode ,but when i move on proteus Total variabale work like UInt 16 bit variable.when value reached to 65536 Totale variable overflow and start from 0.
I am using 18f14k22 with internal 16MHz oscilator in my application .i have confused,please suggest me wright way.
Best Regards
Digits to ULong number conversion problem
Moderator: Benj
- sysprofessional
- Posts: 54
- Joined: Sat Oct 26, 2013 7:16 pm
- Has thanked: 28 times
- Been thanked: 4 times
- Contact:
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
- Contact:
Re: Digits to ULong number conversion problem
Post your flowchart so we can check it for issues.
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Digits to ULong number conversion problem
On your target, any intermediate/temporary calculations will be 16 bit, so you will need to ensure that any sub-totals are Ulongs too
- sysprofessional
- Posts: 54
- Joined: Sat Oct 26, 2013 7:16 pm
- Has thanked: 28 times
- Been thanked: 4 times
- Contact:
Re: Digits to ULong number conversion problem
Hello kersing,kersing wrote:Post your flowchart so we can check it for issues.
Basically i am using 11 digit in my application using dual MAX7219 and many other features so my flowchart is little lengthy. Here i have design new flowchart for your observation .That is small and easy to understand.
My flowchart, hex, cof, and proteus simulation files attached below in compressed rar format.
Best Regards:
- Attachments
-
- Flowchart+Simulation.rar
- (43.35 KiB) Downloaded 337 times
- sysprofessional
- Posts: 54
- Joined: Sat Oct 26, 2013 7:16 pm
- Has thanked: 28 times
- Been thanked: 4 times
- Contact:
Re: Digits to ULong number conversion problem
I have already ensured that there is no temp or any other variable between calculation,i am using only one 32 bit variable ,and all calculations moves directly into that variable.i have also attached flowchart now ,please see that ,LeighM wrote:On your target, any intermediate/temporary calculations will be 16 bit, so you will need to ensure that any sub-totals are Ulongs too
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Digits to ULong number conversion problem
sorry, I did not explain that too wellOn your target, any intermediate/temporary calculations will be 16 bit, so you will need to ensure that any sub-totals are Ulongs too
Code: Select all
Total = (digit[0] * 10000) + (digit[1] * 1000) + (digit[2] * 100) + (digit[3] * 10) + digit[4]
So you will need to create a Ulong SubTotal variable to force this calculation into 32 bits
Code: Select all
SubTotal = 10000
SubTotal = SubTotal * digit[0]
Total = SubTotal + (digit[1] * 1000) + (digit[2] * 100) + (digit[3] * 10) + digit[4]
Leigh
- sysprofessional
- Posts: 54
- Joined: Sat Oct 26, 2013 7:16 pm
- Has thanked: 28 times
- Been thanked: 4 times
- Contact:
Re: Digits to ULong number conversion problem
Thank you very much LeighM ,
I have well understand now,This method working fine in my application.Good luck to you.
I have well understand now,This method working fine in my application.Good luck to you.