Hello!
I am trying to display integer value read from the ADC slider on the OLED display, if I read and display the same value as it is without doing any calculation the value which is read is displayed well in the simulation as well on actual display. If I do one calculation (naming Real Calculation)(which I have disabled for the moment in the chart) on the value read from slider the calculation works well and also display correct in simulation but something goes wrong in the actual display.
May I request someone to correct me where I am going wrong.
Thank you.
Abhi
I2C OLED Displaying Problem
Moderator: Benj
- AbhijitR
- Posts: 300
- Joined: Fri Nov 07, 2014 12:48 pm
- Location: Pune, India
- Has thanked: 283 times
- Been thanked: 80 times
- Contact:
I2C OLED Displaying Problem
- Attachments
-
- Test_18F26K22_OLED_04-09-2020.fcfx
- (12.83 KiB) Downloaded 154 times
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
Re: I2C OLED Displaying Problem
Hi Abhi
I'm not realy shure......
In the first calculation
try to Set set_length to 5
In the second calculation
remove /1023
Maybe it's changes something
regards
Stefan
I'm not realy shure......
In the first calculation
try to Set set_length to 5
In the second calculation
remove /1023
Maybe it's changes something
regards
Stefan
- AbhijitR
- Posts: 300
- Joined: Fri Nov 07, 2014 12:48 pm
- Location: Pune, India
- Has thanked: 283 times
- Been thanked: 80 times
- Contact:
Re: I2C OLED Displaying Problem
Hello! Stefan
Thanks for your answer, your trick worked, the display works well now, but the thing is "Set Length" is user set able parameter (as in the calculation box 5000 mm), and the value is expected to be in millimeters, so it will be any thing between 1 to 9999.
After making the changes you suggested i.e. changing the value to 5 from 5000 and removing the "/1023" the answer is 5115 on the screen, and I expect that to be 5000 mm at full-scale.
Can you suggest what else can be done.
Thank you.
Abhi
Thanks for your answer, your trick worked, the display works well now, but the thing is "Set Length" is user set able parameter (as in the calculation box 5000 mm), and the value is expected to be in millimeters, so it will be any thing between 1 to 9999.
After making the changes you suggested i.e. changing the value to 5 from 5000 and removing the "/1023" the answer is 5115 on the screen, and I expect that to be 5000 mm at full-scale.
Can you suggest what else can be done.
Thank you.
Abhi
-
- Valued Contributor
- Posts: 1200
- Joined: Wed May 31, 2017 11:57 am
- Has thanked: 70 times
- Been thanked: 440 times
- Contact:
Re: I2C OLED Displaying Problem
Hi Abhi,
I think your 'real' calculation fails because of an overflow error - if the value can go to - 5000 * 1023 = 10,230,000 which is too big for a 16 bit calculation..
Either use a 32 bit value or rearrange the maths to avoid this...
Note the simulation doesn't use 16 bits (despite the variable declaration) so works okay.
Martin
I think your 'real' calculation fails because of an overflow error - if the value can go to - 5000 * 1023 = 10,230,000 which is too big for a 16 bit calculation..
Either use a 32 bit value or rearrange the maths to avoid this...
Note the simulation doesn't use 16 bits (despite the variable declaration) so works okay.
Martin
- AbhijitR
- Posts: 300
- Joined: Fri Nov 07, 2014 12:48 pm
- Location: Pune, India
- Has thanked: 283 times
- Been thanked: 80 times
- Contact:
Re: I2C OLED Displaying Problem
Hello! Martin
Thanks to point out that, unfortunately for the moment the Math overflow my brain too,
I shall give a try tomorrow morning and check if I could progress, to be honest I thought this was not that difficult but may be I am wrong, this is my first time I am using "getint" so do not understand correct.
Thank you again.
Abhi
Thanks to point out that, unfortunately for the moment the Math overflow my brain too,
I shall give a try tomorrow morning and check if I could progress, to be honest I thought this was not that difficult but may be I am wrong, this is my first time I am using "getint" so do not understand correct.
Thank you again.
Abhi
- AbhijitR
- Posts: 300
- Joined: Fri Nov 07, 2014 12:48 pm
- Location: Pune, India
- Has thanked: 283 times
- Been thanked: 80 times
- Contact:
Re: I2C OLED Displaying Problem
Hello! Stefan, Hello! Martin
I think I got the answer, (could not sleep well ), one of the post by KERSING, explain the point very clearly, below is the same if you wish to have a look.
https://www.matrixtsl.com/mmforums/view ... 048#p91048
Thank you again to both of you for your time.
Abhi
I think I got the answer, (could not sleep well ), one of the post by KERSING, explain the point very clearly, below is the same if you wish to have a look.
https://www.matrixtsl.com/mmforums/view ... 048#p91048
Thank you again to both of you for your time.
Abhi