Page 1 of 1

I2C OLED Displaying Problem

Posted: Fri Sep 04, 2020 3:48 pm
by AbhijitR
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

Re: I2C OLED Displaying Problem

Posted: Fri Sep 04, 2020 4:07 pm
by stefan.erni
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
Calculation.PNG
Calculation.PNG (27.22 KiB) Viewed 2293 times

Re: I2C OLED Displaying Problem

Posted: Fri Sep 04, 2020 4:45 pm
by AbhijitR
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

Re: I2C OLED Displaying Problem

Posted: Fri Sep 04, 2020 6:54 pm
by mnf
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

Re: I2C OLED Displaying Problem

Posted: Fri Sep 04, 2020 7:22 pm
by AbhijitR
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

Re: I2C OLED Displaying Problem

Posted: Fri Sep 04, 2020 8:27 pm
by AbhijitR
Hello! Stefan, Hello! Martin

I think I got the answer, (could not sleep well :wink: ), 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