Push-Button not working in Momentary

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
HoX123
Posts: 4
Joined: Sat Oct 30, 2021 12:25 pm
Has thanked: 1 time
Been thanked: 1 time
Contact:

Push-Button not working in Momentary

Post by HoX123 »

I need to make a counter that goes from 0-9999 on 7seg quad display,that resets to 0 on 9999 and when the push button (which has to be in momentary state) is pressed it should stop counting ,and when its pressed again it should continue counting.
I have made it to work in Latching,but in momentary its counting only when I hold the button,which isnt the right way.
I'd really appreciate your help with this one
Last edited by HoX123 on Sun Oct 31, 2021 6:58 pm, edited 2 times in total.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Push-Button not working in Momentary

Post by medelec35 »

Hi HoX123.
Welcome to the forums.
Can you follow this post please?
Then if you get stuck we can help you further.
If Flowcode is up-to-date then the first part can of course be ignored.
Martin

HoX123
Posts: 4
Joined: Sat Oct 30, 2021 12:25 pm
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: Push-Button not working in Momentary

Post by HoX123 »

medelec35 wrote:
Sat Oct 30, 2021 1:09 pm
Hi HoX123.
Welcome to the forums.
Can you follow this post please?
Then if you get stuck we can help you further.
If Flowcode is up-to-date then the first part can of course be ignored.
I cant really use newer versions since my professor requests for us to use same version as him,sorry.
Last edited by HoX123 on Sun Oct 31, 2021 6:58 pm, edited 1 time in total.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Push-Button not working in Momentary

Post by medelec35 »

HoX123 wrote:
Sat Oct 30, 2021 1:24 pm
I cant really use newer versions since my professor requests for us to use same version as him,sorry.
You posted in the Flowcode V8 section, So it's assumed you are using that version.
What version have you got?
Flowcode V7 will load V8 flowcharts.
HoX123 wrote:
Sat Oct 30, 2021 1:24 pm
but I just cant fix it thats why i turned to this forum in hope you can help me,my grade pretty much depends on this last assigment.
We can't do your assignment for you, we can only steer you in the right direction.
Martin

HoX123
Posts: 4
Joined: Sat Oct 30, 2021 12:25 pm
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: Push-Button not working in Momentary

Post by HoX123 »

medelec35 wrote:
Sat Oct 30, 2021 1:42 pm
HoX123 wrote:
Sat Oct 30, 2021 1:24 pm
I cant really use newer versions since my professor requests for us to use same version as him,sorry.
You posted in the Flowcode V8 section, So it's assumed you are using that version.
What version have you got?
Flowcode V7 will load V8 flowcharts.
HoX123 wrote:
Sat Oct 30, 2021 1:24 pm
but I just cant fix it thats why i turned to this forum in hope you can help me,my grade pretty much depends on this last assigment.
We can't do your assignment for you, we can only steer you in the right direction.

I've never asked anybody to do my assigment,I said help me do it not do it for me.
My flowcode is v6,I've posted here first,and then when I saw that i posted in wrong section I posted it in V6 but only this post got approved and i didnt know how to delete a post that was pending approval

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Push-Button not working in Momentary

Post by medelec35 »

HoX123 wrote:
Sat Oct 30, 2021 1:58 pm
I've never asked anybody to do my assigment,
I never said you did, I just wanted state it in advance.
HoX123 wrote:
Sat Oct 30, 2021 1:58 pm
My flowcode is v6,I've posted here first,and then when I saw that i posted in wrong section I posted it in V6 but only this post got approved and i didnt know how to delete a post that was pending approval
That's not an issue, I have moved the topic to the V6 section.
Regarding latching.
My suggestion would be to look up how logical operators in c work.
One of the logical operators will work with a variable, within a calculation Icon
image_2021-10-30_142711.png
image_2021-10-30_142711.png (3.49 KiB) Viewed 4580 times
to do what you want it to do.

I.e You have an input variable called taster, and that will change (Toggle) each time the switch is pressed.
I have noticed you are reading the whole port.
You don want to do that.
You only need to read 1pin (Bit)
So you need to change the input properties from whole port to Single bit then select the pin that the switch is connected to.
The other thing I would recommend is how to correctly connect switches to microcontrollers.
This page on the wiki shows you how.
Martin

HoX123
Posts: 4
Joined: Sat Oct 30, 2021 12:25 pm
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: Push-Button not working in Momentary

Post by HoX123 »

medelec35 wrote:
Sat Oct 30, 2021 2:28 pm
HoX123 wrote:
Sat Oct 30, 2021 1:58 pm
I've never asked anybody to do my assigment,
I never said you did, I just wanted state it in advance.
HoX123 wrote:
Sat Oct 30, 2021 1:58 pm
My flowcode is v6,I've posted here first,and then when I saw that i posted in wrong section I posted it in V6 but only this post got approved and i didnt know how to delete a post that was pending approval
That's not an issue, I have moved the topic to the V6 section.
Regarding latching.
My suggestion would be to look up how logical operators in c work.
One of the logical operators will work with a variable, within a calculation Icon
Counter_Taster.fcfx
(9.43 KiB) Downloaded 169 times
to do what you want it to do.

I.e You have an input variable called taster, and that will change (Toggle) each time the switch is pressed.
I have noticed you are reading the whole port.
You don want to do that.
You only need to read 1pin (Bit)
So you need to change the input properties from whole port to Single bit then select the pin that the switch is connected to.
The other thing I would recommend is how to correctly connect switches to microcontrollers.
This page on the wiki shows you how.
I'm still at the beggining,tried to figure it out through stopwatch example but we arent allowed to use Interrupt block since we havent done it in class.I've managed to make it start with push button but not to stop when pressed again

EDIT : I've finally managed to get it working using until loops and following ur advice.Only thing I need to fix right now,is when I turn on flowcode first time and run the simulation for the first time it beggins counting without presing taster,and when i stop simulation and run it again it works as intended,waiting my press on button to start counting.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Push-Button not working in Momentary

Post by medelec35 »

That's OK.
I understand you can't jump ahead of what you have not been taught.
Have you been taught about logical operators?
If not, the only other way I can think of is when the switch is detected, get a variable called Enable for example, to equal1, then a delay for say 500ms.
If the switch is detected again get the variable to change back to 0 etc.
Then within the branch that shows

Code: Select all

If:taster = 0
change it to

Code: Select all

If:Enable =1
The important thing is the branch variable can't have the same variable that's in the input icon.

The other thing you need to do is on the system panel, right-click on the switch and select properties.
Change the operation from latching to momentarily.
This is so the simulator can show you if what you have done is working or not.
Martin

HoX123
Posts: 4
Joined: Sat Oct 30, 2021 12:25 pm
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: Push-Button not working in Momentary

Post by HoX123 »

medelec35 wrote:
Sat Oct 30, 2021 8:54 pm
If the switch is detected again get the variable to change back to 0 etc.
What I dont understand,is where and how am I supposed to check if the switch is detected again.If i put it in the same decision as the first check if the switch is pressed,it will use that first time i pressed it so the variable enable will just become 1 and then go back to 0,and the counter wont start at all. Now when I press button it starts counting but stops only while Im holding it.Then without delays it works but u need to click it a between 2-5 times...guess atleast im making some sort of progress :|
Last edited by HoX123 on Tue Nov 02, 2021 8:42 pm, edited 1 time in total.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Push-Button not working in Momentary

Post by medelec35 »

It's not easy to help as I have no way of knowing what you have been taught so far.
Have you been taught about bitwise or logical operations?

Basically, you will be using one variable (taster) within the Input.
The value will depend on if the switch has been pressed or not.
Every time the switch has been pressed, it will change the value of another variable (Enable) between 0 and 1.
If the Enable variable = 1 then counting can commence.
If the Enable variable = 0 then counting can commence.

If you have not been taught how toggle a variable using bit or logical operations, then the only other way I can think of is if the switch is detected (Taster will be 0 if the switch is active low) then add 1 to Enable.
Then you will need to think of a way to make the Enable variable change from a 1 back to a 0 of the value of Taster is 0 as the switch has been detected as pressed.
You can do that with a decision branch and a calculation icon.
Martin

Post Reply