UP/DOWN Counter (0-99) project using Mikroe 7seg Click (2x 74HC595) and Mikroe 2x2 Key Click

Use this section to discuss your embedded Flowcode projects.
Post Reply
andeug
Posts: 101
http://meble-kuchenne.info.pl
Joined: Thu Jan 07, 2021 1:42 pm
Location: Stockholm (SE)
Has thanked: 34 times
Been thanked: 5 times

Flowcode v11 UP/DOWN Counter (0-99) project using Mikroe 7seg Click (2x 74HC595) and Mikroe 2x2 Key Click

Post by andeug »

Hi,


I am slowly learning Flowcode and working on a project that lets me count from 0 to 99 and backward.
The project has four physical buttons on the Mikroe 2x2 Key Click, but I am only using number 1 (UP) and 3 (DOWN).
IMG_0694.jpeg
IMG_0694.jpeg (173.8 KiB) Viewed 97 times
The display shall be blank at start.
Then, if you press the UP button, it will display 1, and not 01... and the same until 9.
When the counter reaches 100, it will continue with 00, 01, 02, 03... 09, 10, 11...
If you press the DOWN button, it will decrement by 1, of course.

The Mikroe 7seg Click has a different segment routing, as you can see in the enclosed schematic, so I have to use a look-up table to remap the segments.
7-seg Click schematic.pdf
(113.59 KiB) Downloaded 12 times
Enclosed is a part of my initial sketch.
Digital counter with 2x 7segs and 2x 74HC595.fcfx
(21.07 KiB) Downloaded 10 times

Regards,
Andreas
FC11 Professional + ARD + AVR + ARM license + Matrix TSL E-blocks2 boards
Mikroe Click boards + Arduino Nano/Uno Click Shield

Bijumon
Posts: 47
Joined: Fri Dec 30, 2022 11:44 am
Has thanked: 19 times
Been thanked: 30 times

Re: UP/DOWN Counter (0-99) project using Mikroe 7seg Click (2x 74HC595) and Mikroe 2x2 Key Click

Post by Bijumon »

Hi Andreas,

I am also a learner like you, I didn't quite catch your exact requirements, but I attached a program for an up/down counter using push buttons.
It can count up to 99 and reset to zero (and vice versa). i hope it will help for your needs.
Before testing, please make sure your connections match your hardware.

Best Regards,
Attachments
Up Down Counter.fcfx
(18.69 KiB) Downloaded 3 times

andeug
Posts: 101
Joined: Thu Jan 07, 2021 1:42 pm
Location: Stockholm (SE)
Has thanked: 34 times
Been thanked: 5 times

Re: UP/DOWN Counter (0-99) project using Mikroe 7seg Click (2x 74HC595) and Mikroe 2x2 Key Click

Post by andeug »

Hi Bijumon,


You can't imagine how much I've been struggling all day trying to make this work, and I haven't managed to yet. Thank you! :)

One thing that does not work as expected is that you have to press the buttons slowly, and the counter does not respond to quick presses (not sure why - maybe some delays must be added somewhere?).

I have loaded your code on my hardware, and it has worked from the first try:
Counter with 2x 7segs and 2x 74HC595.fcfx
(18.69 KiB) Downloaded 3 times
I wanted to know the logic behind the code, as I will need it later for a more complex project.

In my case, the beauty of using Mikroe's Click boards is that they are just plug&play, and I don't get the same annoyance as when I would have to use patch wires. I also use SimpleMind mind-mapping software to visually map what I am building so I remember the right positions of the Click boards on the carrier board. See enclosed an example:
Counter with 2x 7segs and 2x 74HC595.pdf
(1.51 MiB) Downloaded 5 times

Andreas
FC11 Professional + ARD + AVR + ARM license + Matrix TSL E-blocks2 boards
Mikroe Click boards + Arduino Nano/Uno Click Shield

Bijumon
Posts: 47
Joined: Fri Dec 30, 2022 11:44 am
Has thanked: 19 times
Been thanked: 30 times

Re: UP/DOWN Counter (0-99) project using Mikroe 7seg Click (2x 74HC595) and Mikroe 2x2 Key Click

Post by Bijumon »

Hi,

I am happy to hear that my example worked for you.......

Regarding the slow button response: according to the datasheet of the 2x2 Key Click board, it has a hardware debouncing circuit. Additionally, the software (ReadState Macro) has a default debouncing delay of 5ms.

I suspect this combination might be causing the slow response. You can try setting the software debouncing delay to 0 and testing it again, though since it is only 5ms, you may ultimately need to reduce the hardware debouncing capacitor value instead.

Post Reply