Problem with button: bug or my misunderstanding ?

A forums to allow bugs and problems with Flowcode v6 to be reported and resolved.

Moderator: Benj

Post Reply
ITISVARESE
Posts: 56
Joined: Sat Jul 07, 2007 3:00 pm
Has thanked: 9 times
Been thanked: 3 times
Contact:

Problem with button: bug or my misunderstanding ?

Post by ITISVARESE »

Hello,

i have realized a project with some button in flowcode but it don't work like i want:
at the end i realize that or there is a bug or my misunderstanding with button; in attachment a simple flowchart to
explain.

This flowchart, in my intenction, want turn on a led (active high) when i pressed a button (active low) and turn off it if not pressed:
in simulation flowcode work opposite, in real circuit work like i want. If i have understud ReadState is 1 if button pressed
0 if not pressed, and button active low intends that when button is pressed his pin state is 0; if is this there is a bug with button (
reverse state) or i have not understud.

Thanks in advance
Attachments
Cattura.JPG
(87.6 KiB) Downloaded 3373 times

sisasu
Flowcode V4 User
Posts: 8
Joined: Wed Aug 19, 2009 4:14 pm
Been thanked: 1 time
Contact:

Re: Problem with button: bug or my misunderstanding ?

Post by sisasu »

Hello

I think in decisione = "If Stato = 1 (with one = in flowcode!)"

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: Problem with button: bug or my misunderstanding ?

Post by medelec35 »

Hi ITISVARESE,
The way I would look at it is Active High/Active low is for simulation purposes only and it's the state when the switch is pressed (or in the On condition).
It has no effect on your hardware.
So if you choose active low then if switch is not pressed when when switch is read, the simulation will act like there is a pull-up resistor and variable will be assigned with 1.
If switch is pressed then when switch is read, variable will be assigned with 0.
so for active low your hardware requires a pull-up (resistor or internal weak pull-up to) keep it at +5V when switch is not pressed.
The switch will pull the i/p to 0V.
On your flowchart you will need to change decision branch so if variable = 1 (switch not pressed) then LED is off.
If variable = 0 (switch is pressed) then LED is on.
sisasu wrote: I think in decisione = "If Stato = 1 (with one = in flowcode!)"
That's what I normally do.
Or you can leave out the = 1 altogether.
So you can have

Code: Select all

If Stato
Then if value is any value except 0 then condition is true.

Martin
Martin

ITISVARESE
Posts: 56
Joined: Sat Jul 07, 2007 3:00 pm
Has thanked: 9 times
Been thanked: 3 times
Contact:

Re: Problem with button: bug or my misunderstanding ?

Post by ITISVARESE »

Hello,
thanks to all for reply, but, probably for my poor english, what i say is not clear:
yes is simply set flowchart to work in flowcode but this is not work in real circuit;
if i set flowchart to work in real circuit don't work in simulator of flowcode (V6).
For this i thinks that there is a bug in simulator of flowcode or i don't understud somethink.
Please, if someone can, made a real circuit with button (before decide if you want NO or NC button pull up or pull down), made a flowchart, test on simulator of
flowcode and if work transfer on real circuit and, like me, probably don't work like espected....
Medelec i think that active low - high is for hardware because is the way to consider different level when button pressed in real circuit, and
function ReadState is for simulation and flowchart logic ( 1 pressed 0 not pressed)...
Hardware is working: simply there is a discrepance or work in circuit or work in simulator!

ITISVARESE
Posts: 56
Joined: Sat Jul 07, 2007 3:00 pm
Has thanked: 9 times
Been thanked: 3 times
Contact:

Re: Problem with button: bug or my misunderstanding ?

Post by ITISVARESE »

Thanks Medelec35 for contribute; for me is a problem in simulator because if i made a flowchart without
made simulation in flowcode i see it work as i expect in real circuit and for this compilation hex is ok........

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: Problem with button: bug or my misunderstanding ?

Post by medelec35 »

Hi ITISVARESE,
First I was wrong when I said it's for simulation only as Its not.
Sorry for any confusion.

I have just been studying the hardware using both Flowcode V5 and Flowocde V6 and this is how the hardware works:

If you select Active low for your input then when you read hardware, +5 is read as (not true) and 0V is read as (true) so you will need to take that into account when developing hardware.
The help agrees with this:
Help Switch.png
(83.29 KiB) Downloaded 8382 times
I also believe there is a bug with simulator since if you don't press the switch then the logic is true, which would suggest the switch is pressed when it is not.
I would of thought no matter what the active is set on (high or low), only when you press the switch it should be a true condition so variable should not be at 1 when switch is not pressed which is what your saying?
If that is the case, I do agree with you.

Hardware is OK.

So it's one for matix to look at?


Martin
Martin

ITISVARESE
Posts: 56
Joined: Sat Jul 07, 2007 3:00 pm
Has thanked: 9 times
Been thanked: 3 times
Contact:

Re: Problem with button: bug or my misunderstanding ?

Post by ITISVARESE »

Hello Medelec35,
again thanks for Your research on my problem: sorry for my poor english that can't let me explain
exactly.
The right behavior is in blue in your picture and is for hardware(active low and reverse for active high);
readstate for component button give 1 if pressed 0 if not (FC v6) and is ok and is for logical flowcharting.
Problem, for me, is FC simulator that exchanges something: indeed my real circuit works ok according flowchart but is not
simulating ok in flowcode....

Is a pleasure that there is person like You in this forum...

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Problem with button: bug or my misunderstanding ?

Post by Benj »

Hello,

I think this is how it should be working.

Active High:

If your using an input icon directly then you should get 0 for a none pressed switch and 1 for a pressed switch.

If your using a switch macro then you should get a return of 0 for a none pressed switch and 1 for a pressed switch.

Active Low:

If your using an input icon directly then you should get 1 for a none pressed switch and 0 for a pressed switch.

If your using a switch macro then you should get a return of 0 for a none pressed switch and 1 for a pressed switch.


I.e. the switch component will return 1 if the switch is pressed not to represent the state of the I/O.

Is this what your seeing or is there a bug?

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: Problem with button: bug or my misunderstanding ?

Post by medelec35 »

Hi Ben,
Using a switch component set to Active low :
If switch is press then 0 is returned.
If switch is not pressed then 1 is returned.
This is simulation only which I believe is wrong.

Works as expected on hardware.
Martin

ITISVARESE
Posts: 56
Joined: Sat Jul 07, 2007 3:00 pm
Has thanked: 9 times
Been thanked: 3 times
Contact:

Re: Problem with button: bug or my misunderstanding ?

Post by ITISVARESE »

Hello Benj,
Yes i think that it should be like You say but i see this (using FC simulation variable Status of my flowchart):

Active High:
input icon press=1 nopress=0
macro switch press=1 nopress=0

Active low:
input icon press=1 nopress=0
macro switch press=0 nopress=1

Like says Medelec35

I thinks that there is a bug in simulator because in circuit all work as i want but not in simulation.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Problem with button: bug or my misunderstanding ?

Post by Benj »

Ok that's fine, many thanks. I'll look into the bug and see if I can resolve it for you.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Problem with button: bug or my misunderstanding ?

Post by Benj »

Right here is a slightly modified version of the switch base component.
switch.fcpx
(4.8 KiB) Downloaded 256 times
The file needs to be placed here "C:\Program Files (x86)\Flowcode 6\components" before restarting Flowcode.

Let me know how you get on.

ITISVARESE
Posts: 56
Joined: Sat Jul 07, 2007 3:00 pm
Has thanked: 9 times
Been thanked: 3 times
Contact:

Re: Problem with button: bug or my misunderstanding ?

Post by ITISVARESE »

Hello Benj,
for me is not working ok because, according with You before say, if i use macro button ReadState,
when button is pressed (active high and active low) return value must be 1 and when not pressed
must be 0; if i set active low this is not true in simulation of FC....

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Problem with button: bug or my misunderstanding ?

Post by Benj »

Ok thanks,

This seems to be a bit better. the initial state is wrong but then after that it recovers and then works as expected. I'll see if I can make this even better.
Attachments
switch.fcpx
(4.81 KiB) Downloaded 210 times

ITISVARESE
Posts: 56
Joined: Sat Jul 07, 2007 3:00 pm
Has thanked: 9 times
Been thanked: 3 times
Contact:

Re: Problem with button: bug or my misunderstanding ?

Post by ITISVARESE »

Hello Benj,
yes now is better but not fully working (in a complex system with more button is not usable).

ITISVARESE
Posts: 56
Joined: Sat Jul 07, 2007 3:00 pm
Has thanked: 9 times
Been thanked: 3 times
Contact:

Re: Problem with button: bug or my misunderstanding ?

Post by ITISVARESE »

Hello,
any news for a solution to problem?
Thanks

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Problem with button: bug or my misunderstanding ?

Post by Benj »

Hello,

Would it be possible to attach a program that is showing the issue with the component so I know what i'm looking for?

ITISVARESE
Posts: 56
Joined: Sat Jul 07, 2007 3:00 pm
Has thanked: 9 times
Been thanked: 3 times
Contact:

Re: Problem with button: bug or my misunderstanding ?

Post by ITISVARESE »

Hello Benj,

thanks for reply i upload here a very simple flowchart that work in real circuit but
in simulator of flowcode AT FIRST start don't work ok; i send You with PM also a more complex
program that also work in real circuit but not in simulator (yes i known that compilation show some warning
but believe it work ok in circuit).
Attachments
TestPulsanti.fcfx
(5.1 KiB) Downloaded 200 times

ITISVARESE
Posts: 56
Joined: Sat Jul 07, 2007 3:00 pm
Has thanked: 9 times
Been thanked: 3 times
Contact:

Re: Problem with button: bug or my misunderstanding ?

Post by ITISVARESE »

Hello,

today download new version 6.1 but button problem in simulation is not solved (in real circuit all is ok): at first start of program button state is wrong; work ok after first use of button.
Is the same of last temporary patch.. but is not usable.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: Problem with button: bug or my misunderstanding ?

Post by QMESAR »

Hi All

I have the same confusion here with me :D

It really seems that the simulation of a button press has a small issue,In real hardware my FC code is running perfectly only in simulation the If button pressed always execute

from the previous posts it is not clear for Flow Code which is the correct syntax to set the condition for a If Statement

it seems that it should be If ButtonPressed = 0 (Basic language type syntax) and I an used to C If ButtonPressed == 0 what is the correct syntax if some one can help me out with this

I appreciate the help .

PS My button properties are set to be active low
Attachments
2.png
(18.5 KiB) Downloaded 8199 times
12.png
(10.11 KiB) Downloaded 3152 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Problem with button: bug or my misunderstanding ?

Post by Benj »

Hello,
om the previous posts it is not clear for Flow Code which is the correct syntax to set the condition for a If Statement
it seems that it should be If ButtonPressed = 0 (Basic language type syntax) and I an used to C If ButtonPressed == 0 what is the correct syntax if some one can help me out with this
Either syntax is valid.

ButtonPressed = 0

and

ButtonPressed == 0

will both be accepted and generate the correct C code.

berubec
Posts: 18
Joined: Wed Oct 22, 2014 12:32 pm
Been thanked: 6 times
Contact:

Re: Problem with button: bug or my misunderstanding ?

Post by berubec »

Bug not solved in 6.1.1 version. In first start simulation, the toggle and push button active low doesn't have the good state with macro readstate. It's necessary to make this operation:
"step into(F8)"
try all toggle and push button
"step into(F8)"
"Stop(Maj+F5)"
Now, All it's done for next simulation

Post Reply