Advice!

For general Flowcode discussion that does not belong in the other sections.
Post Reply
jgu1
Posts: 813
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 696 times
Been thanked: 183 times

Flowcode v10 Advice!

Post by jgu1 »

Hi all!

I am making a project where I use PWM. I want to adjust the timing with two button. I call these two button by help of pin interrupt to toggle up and down. I in/de crement by one (in the calculation DelayAjd = DelayAjd - 1 and DelayAjd = DelayAjd + 1 But every time I press one of the button the counters step up and down with two? If I change cslculation with 2 it change with 4 ?

Works in simulation. My loop in the interrupt I use for "delay" timer to avoid noice. I know it is not good to use delay component in macro called by interrupt.

Plaese, what am i doing wrong? :roll:

Br jorgen
Attachments
Generator.fcfx
(25.05 KiB) Downloaded 193 times

mnfisher
Valued Contributor
Posts: 1628
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 142 times
Been thanked: 761 times

Re: Advice!

Post by mnfisher »

In Up and Down - you can get an infinite loop.

For example if DelayAdj is 0 when Up is called - then it will loop to connection point A forever.


Can you use a button component?

Martin

jgu1
Posts: 813
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 696 times
Been thanked: 183 times

Re: Advice!

Post by jgu1 »

Hi Martin :D

Honest, I don’t understand,

I dare to ask, Will you please to edit in my program, Then I would be happy :D

mnfisher
Valued Contributor
Posts: 1628
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 142 times
Been thanked: 761 times

Re: Advice!

Post by mnfisher »

A first idea.

Here I read both buttons and then adjust DelayAjd - no change if both buttons pressed.
I just print the value to LCD - so 'works' in simulation. Then wait for buttons to be released (or have a delay for value to increase / decrease whilst button held)

It would be nicer - at least in simulation - to use an interrupt. In simulation button presses can be 'missed' (probably whilst waiting for 'low') - but I don't think this will be an issue on hardware which is rather quicker?

I commented in 'Up' where the infinite loop can occur...

Martin
Attachments
Gen2.fcfx
(29.33 KiB) Downloaded 200 times

jgu1
Posts: 813
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 696 times
Been thanked: 183 times

Re: Advice!

Post by jgu1 »

Thank you Martin, I see now what you mean, and it work. Now I can continue :D

Jorgen

mnfisher
Valued Contributor
Posts: 1628
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 142 times
Been thanked: 761 times

Re: Advice!

Post by mnfisher »

Good to hear you are going again.

Please let us see the project when it's running 👍

jgu1
Posts: 813
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 696 times
Been thanked: 183 times

Re: Advice!

Post by jgu1 »

You Will hear Martin, take a little while. ;)

Post Reply