Hi,
I am working on a project with an Arduino Uno, a Mikroe Arduino Uno Click Shield, a Mikroe 7seg Click, and a Mikroe Analog Key Click.
The project should read each button press from the Mikroe Analog Key Click and display its value on the 2nd digit of a 7-segment display; when no button is pressed, the 2nd digit should remain blank.
I have measured with a Fluke calibrated multimeter the values of VOUT (AN) from OPA344NA, and they look as follows:
Button 1 press = 3,27V
Button 2 press = 2,73V
Button 3 press = 2,18V
Button 4 press = 1,63V
Button 5 press = 1,09V
Button 6 press = 0,54V
What I need is a safe mechanism that can determine whether, if I have a VOUT voltage between 3.2V and 3.3V (not the exact value), button 1 is pressed. The same follows for the other buttons. When 0V is measured, nothing is displayed on the 7-segment display.
I don't think that this is how the flow code should be made... Can someone please help me figure out how to make this small project work?
Regards,
Andreas
Potentiometer (6x buttons) on a 7-segment 74HC595 display
-
andeug
- Posts: 91
- http://meble-kuchenne.info.pl
- Joined: Thu Jan 07, 2021 1:42 pm
- Location: Stockholm (SE)
- Has thanked: 30 times
- Been thanked: 4 times
Potentiometer (6x buttons) on a 7-segment 74HC595 display
- Attachments
-
- Address mapping 74HC595 7-segment.xlsx
- (10.29 KiB) Downloaded 34 times
-
- Analog keyboard with display.fcfx
- (16.44 KiB) Downloaded 35 times
FC11 Professional + ARD + AVR + ARM license + Matrix TSL E-blocks2 boards
Mikroe Click boards + Arduino Nano/Uno Click Shield
Mikroe Click boards + Arduino Nano/Uno Click Shield
-
medelec35
- Valued Contributor
- Posts: 2319
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 723 times
- Been thanked: 780 times
Re: Potentiometer (6x buttons) on a 7-segment 74HC595 display
Hello.
GetVoltage requires a float variable, you have got it as an int.
Therefore Voltage will be ints only so no good if you want to check to say 2.3V
You will need to change the Voltage variable to a Float.
With the Decision branches, using just If:Voltage , then every time the voltage is 1V or higher it will be true.
What you will need is If: (Voltage >= 3.2) && (Voltage <= 3.3) to add the hysteresis.
GetVoltage requires a float variable, you have got it as an int.
Therefore Voltage will be ints only so no good if you want to check to say 2.3V
You will need to change the Voltage variable to a Float.
With the Decision branches, using just If:Voltage , then every time the voltage is 1V or higher it will be true.
What you will need is If: (Voltage >= 3.2) && (Voltage <= 3.3) to add the hysteresis.
Martin
-
andeug
- Posts: 91
- Joined: Thu Jan 07, 2021 1:42 pm
- Location: Stockholm (SE)
- Has thanked: 30 times
- Been thanked: 4 times
Re: Potentiometer (6x buttons) on a 7-segment 74HC595 display
Hi,
I have made the changes per your instructions, but the flow code still does not work...
Maybe this isn't the way it should be done?
Andreas
I have made the changes per your instructions, but the flow code still does not work...
Maybe this isn't the way it should be done?
Andreas
- Attachments
-
- Analog keyboard with display.fcfx
- (16.73 KiB) Downloaded 14 times
FC11 Professional + ARD + AVR + ARM license + Matrix TSL E-blocks2 boards
Mikroe Click boards + Arduino Nano/Uno Click Shield
Mikroe Click boards + Arduino Nano/Uno Click Shield
-
medelec35
- Valued Contributor
- Posts: 2319
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 723 times
- Been thanked: 780 times
Re: Potentiometer (6x buttons) on a 7-segment 74HC595 display
I have modified your project so voltage ranged can be detected.
I'm not sure why you want to show segments rather than digits but you know what you want lol.
I'm not sure why you want to show segments rather than digits but you know what you want lol.
- Attachments
-
- Analog keyboard with display v1,1.fcfx
- (15.84 KiB) Downloaded 12 times
Martin
-
andeug
- Posts: 91
- Joined: Thu Jan 07, 2021 1:42 pm
- Location: Stockholm (SE)
- Has thanked: 30 times
- Been thanked: 4 times
Re: Potentiometer (6x buttons) on a 7-segment 74HC595 display
Thank you for your help, Martin! I have tested the code you gave me, and it works perfectly on my hardware.
Since I have a limited number of I/Os on the Arduino Uno, I will use the Analog Key Click schematic because it requires only one analog input on the ATmega328, allowing me to have 6 different keys.
Since I have a limited number of I/Os on the Arduino Uno, I will use the Analog Key Click schematic because it requires only one analog input on the ATmega328, allowing me to have 6 different keys.
- Attachments
-
- Analog Key Click schematic.pdf
- (209.49 KiB) Downloaded 12 times
FC11 Professional + ARD + AVR + ARM license + Matrix TSL E-blocks2 boards
Mikroe Click boards + Arduino Nano/Uno Click Shield
Mikroe Click boards + Arduino Nano/Uno Click Shield
-
medelec35
- Valued Contributor
- Posts: 2319
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 723 times
- Been thanked: 780 times
Re: Potentiometer (6x buttons) on a 7-segment 74HC595 display
You're welcome.
I'm glad your project is now working as expected.
You can also nest the decision branches and then in the final no branch will be accessed if all the condition are false.ts
Its the C equivalent to a chain of if / else if / else if / ... / else, rather than a series of separate if statements.
E.g if voltage is <0.7 or >3.4.
I would also recommend using a small delay within the main loop.
I'm glad your project is now working as expected.
You can also nest the decision branches and then in the final no branch will be accessed if all the condition are false.ts
Its the C equivalent to a chain of if / else if / else if / ... / else, rather than a series of separate if statements.
E.g if voltage is <0.7 or >3.4.
I would also recommend using a small delay within the main loop.
- Attachments
-
- Main.PNG (59.72 KiB) Viewed 154 times
Martin
-
andeug
- Posts: 91
- Joined: Thu Jan 07, 2021 1:42 pm
- Location: Stockholm (SE)
- Has thanked: 30 times
- Been thanked: 4 times
Re: Potentiometer (6x buttons) on a 7-segment 74HC595 display
Hi,
I have tested your new proposal, and it has been working better than mine. Mine was ghosting some segments after I stopped pressing any buttons, possibly indicating a debouncing issue, but then I realized it disappeared after I added a 100ms delay before the end of the loop. That solved my problem, as you have said in your message.
The schematic of the Mikroe Analog Key Click is optimal for my use case, as I want to use only one analog input for my clock. Even if I press the buttons simultaneously, I do not get any other command than the one for the buttons I have pressed.
Andreas
I have tested your new proposal, and it has been working better than mine. Mine was ghosting some segments after I stopped pressing any buttons, possibly indicating a debouncing issue, but then I realized it disappeared after I added a 100ms delay before the end of the loop. That solved my problem, as you have said in your message.
The schematic of the Mikroe Analog Key Click is optimal for my use case, as I want to use only one analog input for my clock. Even if I press the buttons simultaneously, I do not get any other command than the one for the buttons I have pressed.
Andreas
- Attachments
-
- Keyboard and number - Option 2.fcfx
- (16.16 KiB) Downloaded 9 times
FC11 Professional + ARD + AVR + ARM license + Matrix TSL E-blocks2 boards
Mikroe Click boards + Arduino Nano/Uno Click Shield
Mikroe Click boards + Arduino Nano/Uno Click Shield
-
medelec35
- Valued Contributor
- Posts: 2319
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 723 times
- Been thanked: 780 times
Re: Potentiometer (6x buttons) on a 7-segment 74HC595 display
I'm glad its working even better for you now.
I did have a thought about simulation.
When I created the Potentiometer component, I added the option to display whatever type of read value is used.
E.g GetVoltage you will see the voltage value underneath. GetByte the 0 to 255 will be displayed. GetInt then 0 to 1023 will be displayed etc.
You can add above the GetVoltage a GetByte.
Then single step using F8 to step into each function/icon.
For beginners - red star means component or icon added but project not saved,
I did have a thought about simulation.
When I created the Potentiometer component, I added the option to display whatever type of read value is used.
E.g GetVoltage you will see the voltage value underneath. GetByte the 0 to 255 will be displayed. GetInt then 0 to 1023 will be displayed etc.
You can add above the GetVoltage a GetByte.
Then single step using F8 to step into each function/icon.
For beginners - red star means component or icon added but project not saved,
- Attachments
-
- Keyboard and number - Option 2.fcfx
- (16.16 KiB) Downloaded 12 times
Martin