Kitchen Timer project using 16x LEDs and 2x 74HC595

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

Flowcode v11 Kitchen Timer project using 16x LEDs and 2x 74HC595

Post by andeug »

Hi,


I am working to learn FC11 and am stuck on a project that involves a Click Ring from Mikroe with 32x LEDs (of which I am using only 16x LEDs), connected to an Arduino Nano 328 at 115200 baud. The schematic involves the following block components:
Digital timer with 16x LEDs and 2x 74HC595.pdf
(3.89 MiB) Downloaded 19 times
I had to do the mapping of the segments via ChatGPT, and I received the following, which I tested, and it works:
7seg_combinations.xlsx
(16.15 KiB) Downloaded 18 times
Now I am stuck with the Main macro, on which I need to work with variables, the pushbutton(s) PB1 (and eventually PB3), and time counting.

The way I thought the project was straightforward. They are the following times are pre-configured in Macros:

1 minute
2 minutes
3 minutes
4 minutes
5 minutes
6 minutes
7 minutes
8 minutes
9 minutes
10 minutes
15 minutes
20 minutes
25 minutes (Pomodoro cycle)
30 minutes
45 minutes
60 minutes

How should the timer work? I will explain below:

When I press PB1 once, the timer starts for 1 minute, and after 2 seconds, it begins blinking, indicating it will count 1 minute.
For the 1-minute configuration, I have used "solid" via "T_01min_indicator", and "blinking" state via "T_01min_blink".

When I press PB1 once, the timer starts for 2 minutes, and after 2 seconds, it begins blinking, indicating it will count 2 minutes.
For the 2-minute configuration, I have used "solid" via "T_02min_indicator", and "blinking" state via "T_02min_blink".
For the 2-minute indication, it needs to start with "T_02min_indicator", "T_02min_blink" and then "T_01min_blink".

... and so on. The problem with this approach is that if I am making a mistake in one "minutes" loop, the whole program will not work as expected. Shall I use a different approach instead? Below is what I have created:
Digital timer with 16x LEDs and 2x 74HC595.fcfx
(46.57 KiB) Downloaded 19 times
The kitchen timing in minutes is calculated by looping through the Macros associated with the counted time.

The challenges that I am experiencing are:

- The "Switch" option only has 10x possible states, while I have 16x.
- I do not know if I should use "Switch" or "Decision" while I am pressing the button and toggling through the minutes that I need to have counted.
- Shall I use only the "Buzzer" component, or "PWM", to generate sound on the buzzer with various intensities? (medium or high)
- Shall I use "Keyboard interrupt" for something, given the simplicity of the whole design?

Can someone please help me with this project?


Regards,
Andreas
FC11 Professional + ARD license
Matrix TSL E-blocks2 boards
Mikroe Click boards

andeug
Posts: 53
Joined: Thu Jan 07, 2021 1:42 pm
Location: Stockholm (SE)
Has thanked: 16 times
Been thanked: 2 times

Re: Kitchen Timer project using 16x LEDs and 2x 74HC595

Post by andeug »

The schematic of the LED Ring Click:
Led Ring R Click schematic.pdf
(346.48 KiB) Downloaded 22 times
The schematic of the 2x2 key Click:
2x2 Key Click schematic.pdf
(288.66 KiB) Downloaded 19 times
The picture of the whole assembly (I prefer off-the-shelf components to save time, instead of soldering):
IMG_0429.jpeg
IMG_0429.jpeg (175.62 KiB) Viewed 247 times
FC11 Professional + ARD license
Matrix TSL E-blocks2 boards
Mikroe Click boards

mnfisher
Valued Contributor
Posts: 1765
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 148 times
Been thanked: 831 times

Re: Kitchen Timer project using 16x LEDs and 2x 74HC595

Post by mnfisher »

I don't have access to any hardware (or indeed Flowcode) at the present. However, i would try and create a single macro Blink (count, pattern1, pattern2) rather than using individual macros for each time period.
Select the patterns using a lookup table (either the component or an array) with index as minutes.

Then it is a simple matter to step through the lookup table for each time

To clarify a bit. Button increases time...
.time = 0. // Device off

Increase .time on button press. (One press gives one minute).
.count = lut[1][0]
.pat1 = lut[1][1]
.pat2 = lut [1][2]

Blink(.count, .pat1, .pat2)

Where lut is defined as an array[16][3] for example if you have 16 possible time periods...

Martin

andeug
Posts: 53
Joined: Thu Jan 07, 2021 1:42 pm
Location: Stockholm (SE)
Has thanked: 16 times
Been thanked: 2 times

Re: Kitchen Timer project using 16x LEDs and 2x 74HC595

Post by andeug »

Hi Martin,


Thank you for your feedback. I have managed to build the project using the look-up table that you have suggested.

Now, the problem that I have is with the buzzer - it does not work, and it does not want to respond to the 4,000Hz frequency of the simulation. On the PC it works as a simulation (it acts as an active buzzer), but mine is passive, and it has the product code EPT-14A4005P, made by Sanco Electronics.
BUZZ Click schematic.pdf
(164.86 KiB) Downloaded 3 times
I want the volume to start lower and, after 5 seconds, increase, motivating the user to stop the timer. How do I do this?

Also, the shift registers are being "corrupted" after a few loops, indicating a sync/timing issue in the code. Would you happen to know where the problem is? Any suggestions on optimizing the flow code are welcome.


Andreas
Attachments
Digital timer with 16x LEDs and 2x 74HC595.fcfx
(28.93 KiB) Downloaded 5 times
FC11 Professional + ARD license
Matrix TSL E-blocks2 boards
Mikroe Click boards

chipfryer27
Valued Contributor
Posts: 1794
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 402 times
Been thanked: 618 times

Re: Kitchen Timer project using 16x LEDs and 2x 74HC595

Post by chipfryer27 »

Hi

You have two buzzers connected to the same pin, a piezo buzzer (EPT-14A4005P) and a simple fixed frequency buzzer. Which one do you intend to use?

I assume the piezo, so delete the other one and all related chart icons.

For the piezo to work you will need to use PWM and set it to roughly 3800Hz. In properties you can set the target frequency and FC will attempt to create the closest match. Remember to set "Apply to defaults" to "yes". FC will then calculate how to create this frequency using a timer.

Now you can use the PWM component macros to enable / disable / set duty cycle (to control the volume) etc.

Regards

mnfisher
Valued Contributor
Posts: 1765
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 148 times
Been thanked: 831 times

Re: Kitchen Timer project using 16x LEDs and 2x 74HC595

Post by mnfisher »

HI Andreas,

When you say the buzzer does not work - is that at all / or just has a constant volume?

It looks as though you have a buzzer component - and this would connect to the the GPI pin on the buzzer board - this only provides on or off (with no option to control volume). Using the PWM channel (which should be connected to a different pin) - you can alter the tone / volume by setting the PWM frequency and duty cycle - it might take a bit of fiddling to get a harmonious note? At present you don't seem to use this - but setting the appropriate values and then doing Enable should allow this? (and I think you then use one or other to control the buzzer)

I think the loop logic is slightly wrong - at some point the DisplayTime macro is called with -1 (or 255) (at least in simulation) - which will load the shift register with an unknown value.

Iain's beat me to it....

Martin

Post Reply