wired and buttom simulation

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

Moderator: Benj

Post Reply
luibra63
Posts: 36
Joined: Mon Aug 29, 2016 3:21 pm
Has thanked: 3 times
Been thanked: 6 times
Contact:

wired and buttom simulation

Post by luibra63 »

Hi all
I have a simple question:
In my proyct have 3 buttom, the first buttom is connect to porta1, the second buttom connect to porta2, and the third buttom connect to porta1 and porta2 in wired mode with two diode, in simulation mode i don't have a problem for buttom1 and buttom2 but for buttom3 ?.... is it possible push buttom1 and buttom2 in same time or programmed buttom3 in wired and mode for tested?
thanks
best regards

chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: wired and buttom simulation

Post by chipfryer27 »

Hi

I have had similar needs.

FC allows you to assign keymappings whereby you can assign functions to the keyboard. In the attached example I have outputs on A0 and A1 and inputs on B0 and B1

In the example the program loops reading the value of Port B and outputting to Port A. If I click B0 then A0 will illuminate etc and under keymappings (right click on a button) you can see I have also assigned keyboard keys 1 and 2. If I press "1" then A0 illuminates etc.

Keymappings also allows you to create a calculation and you can see that if I press key "3" then I assign a value of 3 to variable "input". However although FC allows this I have never really got it to work well (probably my fault by doing something dumb) unless I have the simulation speed incredibly slow and even then it is very hit and miss. It does actually work but way, way too unreliable.

Instead, if I have a spare port I assign that as a test input. In the example I have used B2. When I read / test for an input and it corresponds to my test port, I then assign a predefined value to my input variable(s). In this case if I press B2 it assigns the value of 3 to "input" which then illuminates A0 and A1 mimicking pressing B0 and B1 simultaneously. I have also keymapped "4" to do the same.

I'm sure someone far cleverer than I will have a better way to do this but this has worked for me during testing.

Regards
Attachments
Flowcode1.fcfx
(12.68 KiB) Downloaded 145 times

luibra63
Posts: 36
Joined: Mon Aug 29, 2016 3:21 pm
Has thanked: 3 times
Been thanked: 6 times
Contact:

Re: wired and buttom simulation

Post by luibra63 »

Hi chipfryer27
Your idea is ok but I use a pic16lf1823 anf I dn't have other free pin.
I have to try if possible to program the button function
thanks
best regards

chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: wired and buttom simulation

Post by chipfryer27 »

Hi

Following on, maybe the attached can give you some ideas?

The most consistent way I can find to simulate two push buttons pressed simultaneously is to loop until the variable assigned to the buttons is greater than zero (in my example it is "x"). The program then breaks away to do whatever.

Whilst it doesn't catch every press of Key "3", looping until one of the options occurs does catch it enough times to be of use. I've never had to press "3" more than a few times to be caught.

I appreciate that in real world you may not wish this but for simulation it may help.

You will see I have buttons on ports A0 and A1. When pressed they illuminate LEDs on C0 and C1 respectively. I have also keymapped keys "1" and "2" to A0 and A1. I then Keymapped a calculation to Key "3" which sets "x = 3".

Hope it helps.

Regards
Attachments
Button Test.fcfx
(12.85 KiB) Downloaded 129 times

Post Reply