Hello,
I would like to ask for your help.
I am using Flowcode together with an Arduino and would like to read in an analog value and display it on an I2C SSd1306 display.
Problem: No permanent value is displayed.
You can find my program in the attachment.
Thank you for your help.
Analog value with I2C display ssd1306
-
JulianL
- Posts: 3
- http://meble-kuchenne.info.pl
- Joined: Wed Jul 24, 2024 12:01 pm
Analog value with I2C display ssd1306
- Attachments
-
- Display.png (620.78 KiB) Viewed 2726 times
-
- MyProgramm.png (44.49 KiB) Viewed 2726 times
-
mnfisher
- Valued Contributor
- Posts: 1692
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 146 times
- Been thanked: 789 times
Re: Analog value with I2C display ssd1306
You are constantly updating the display in a loop - this means it will refresh very rapidly probably with slightly different values.
Try adding a delay.
Also - if the value's representation changes in length (say '10' then '9') - it will not clear trailing digits. One way round this is to convert the value to a string and append some spaces.
.str = ToString$(.value)
.str = .str + ' '
Display(.str) (PrintString from memory)
where .str is a (in this case local variable) declared as a string.
Martin
Try adding a delay.
Also - if the value's representation changes in length (say '10' then '9') - it will not clear trailing digits. One way round this is to convert the value to a string and append some spaces.
.str = ToString$(.value)
.str = .str + ' '
Display(.str) (PrintString from memory)
where .str is a (in this case local variable) declared as a string.
Martin
-
medelec35
- Matrix Staff
- Posts: 2151
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 662 times
- Been thanked: 725 times
Re: Analog value with I2C display ssd1306
Hello.
In addition to Martin's reply, with he print function you need to have the Transparency Set to 0 and not 1.
This will make sure that that in the same location, the previous digit is overwritten.
What you are showing is all previous digits in the same location remaining.
That will prevent you from seeing what the current digit is.
In addition to Martin's reply, with he print function you need to have the Transparency Set to 0 and not 1.
This will make sure that that in the same location, the previous digit is overwritten.
What you are showing is all previous digits in the same location remaining.
That will prevent you from seeing what the current digit is.
Martin
Re: Analog value with I2C display ssd1306
Hello,
Thanks for your help.
@Martin: Could you show me an example program for your idea using a flowchart? I don't quite understand how I can implement it.
Best regards, Julian
Thanks for your help.
@Martin: Could you show me an example program for your idea using a flowchart? I don't quite understand how I can implement it.
Best regards, Julian
-
mnfisher
- Valued Contributor
- Posts: 1692
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 146 times
- Been thanked: 789 times
Re: Analog value with I2C display ssd1306
Hi Julian,
Something like this - it runs AOK in simulation - in hardware you might need to check the pins used (C0 for ADC for example)
Adding a SetFontScaler(2,2) makes the display easier to read! (from the gLCD component)
Martin
Something like this - it runs AOK in simulation - in hardware you might need to check the pins used (C0 for ADC for example)
Adding a SetFontScaler(2,2) makes the display easier to read! (from the gLCD component)
Martin
- Attachments
-
- UnoADC_Demo.fcfx
- (13.94 KiB) Downloaded 32 times
Re: Analog value with I2C display ssd1306
Hello,
Thanks for your help.
@Martin: Could you show me an example program for your idea using a flowchart? I don't quite understand how I can implement it.
Best regards, Julian
Thanks for your help.
@Martin: Could you show me an example program for your idea using a flowchart? I don't quite understand how I can implement it.
Best regards, Julian
Re: Analog value with I2C display ssd1306
Hi!
I´m new in FC, i´ve come from niple soft, stm32 and pi pico.
I´ve download the file that mnfisher upload, when i´ve try to compile, it says error:
Unknown or missing component: Potentiometer1::GetByte()
Do you know why?
Thx!
I´m new in FC, i´ve come from niple soft, stm32 and pi pico.
I´ve download the file that mnfisher upload, when i´ve try to compile, it says error:
Unknown or missing component: Potentiometer1::GetByte()
Do you know why?
Thx!
-
medelec35
- Matrix Staff
- Posts: 2151
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 662 times
- Been thanked: 725 times
Re: Analog value with I2C display ssd1306
Hello.
For some reason during Flowcode setup the components did not get copied from the DefaultData folder.
I would suggest to run Flowcode, so you see the NEW PROJECT & OPEN PROJECT splash screen.
Select library Updates.
If you do have components shown within the window, select download
Now you can open your project and check Component Libraries ribbon > Inputs > Analogue Inputs for the Potentiometer [2D]
If you can't see the potentiometer, then make sure the Show Components just below File is set to show 2D and 3D.
Look on the 2D Panel as it will have two components placed on it.
gLCD and Potentiometer.
let me know if that still is not the case.
For some reason during Flowcode setup the components did not get copied from the DefaultData folder.
I would suggest to run Flowcode, so you see the NEW PROJECT & OPEN PROJECT splash screen.
Select library Updates.
If you do have components shown within the window, select download
Now you can open your project and check Component Libraries ribbon > Inputs > Analogue Inputs for the Potentiometer [2D]
If you can't see the potentiometer, then make sure the Show Components just below File is set to show 2D and 3D.
Look on the 2D Panel as it will have two components placed on it.
gLCD and Potentiometer.
let me know if that still is not the case.
Martin
Re: Analog value with I2C display ssd1306
Thx for answer Martin!
I´m using C code, and a pic12f675, founded how to run with ssd1306, the example that i´ve found, it´s a volmeter, but i want to made a Resistometer, =).
The mats are:
volt=((unsigned int)ADRESH*256 + ADRESL)*5;
And i´ve add:
res= ((330 * volt) /(5 - volt));
But the value res showed is 0000 in oled...
Volt is correctly showed
Thx again!
I´m using C code, and a pic12f675, founded how to run with ssd1306, the example that i´ve found, it´s a volmeter, but i want to made a Resistometer, =).
The mats are:
volt=((unsigned int)ADRESH*256 + ADRESL)*5;
And i´ve add:
res= ((330 * volt) /(5 - volt));
But the value res showed is 0000 in oled...
Volt is correctly showed
Thx again!
-
medelec35
- Matrix Staff
- Posts: 2151
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 662 times
- Been thanked: 725 times
Re: Analog value with I2C display ssd1306
You're welcome
you can use the built in potentiometers if you now have them.
The reason 0 is shown would be down to typecasting.
If res variable is a float
Try res = ((330.0 * volt) / (5.0 - volt))
If you have an int or byte variable first, then an explicit Type cast is required before the variable.
E.g. ((FLOAT volt 330.0 * ) / (5.0 - volt))
For typecasting see this Wiki page
you can use the built in potentiometers if you now have them.
The reason 0 is shown would be down to typecasting.
If res variable is a float
Try res = ((330.0 * volt) / (5.0 - volt))
If you have an int or byte variable first, then an explicit Type cast is required before the variable.
E.g. ((FLOAT volt 330.0 * ) / (5.0 - volt))
For typecasting see this Wiki page
Martin