Is there any way to....

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
Sparkoids
Posts: 267
Joined: Mon Sep 14, 2009 10:34 am
Has thanked: 30 times
Been thanked: 19 times

Is there any way to....

Post by Sparkoids »

I have some Flowcode that works perfectly getting a variable when the 4 input buttons are set to Active High but the PCB is designed for Active Low :-(

Which means instead of reading 0x0 when no button is pressed it actually reads 0xF - I have logic probed the PCB and all the ports are high as they would be.

Does anyone know if there is a simple way to "reverse" the reading so it acts as if it's Active High as per the Flowchart?

I do not want to set up a IF it = x THEN let it = y because of the number of combinations and the hex is confusing me regarding the calculations required later!

Any ideas please - I'm not sure what I'm actually asking for!!!!

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 63 times
Been thanked: 290 times
Contact:

Re: Is there any way to....

Post by JonnyW »

Hello. You want to use exclusive OR:

Code: Select all

Read input
input = input ^ 0xF
This should invert all the bits on your input.

Cheers,

Jonny

Sparkoids
Posts: 267
Joined: Mon Sep 14, 2009 10:34 am
Has thanked: 30 times
Been thanked: 19 times

Re: Is there any way to....

Post by Sparkoids »

Many 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: Is there any way to....

Post by Benj »

The not symbol '~' could also be useful.

input = (~input) & 0x0F

Sparkoids
Posts: 267
Joined: Mon Sep 14, 2009 10:34 am
Has thanked: 30 times
Been thanked: 19 times

Re: Is there any way to....

Post by Sparkoids »

Works with both it appears......

Sparkoids
Posts: 267
Joined: Mon Sep 14, 2009 10:34 am
Has thanked: 30 times
Been thanked: 19 times

Re: Is there any way to....

Post by Sparkoids »

And thank you both for that....

Sparkoids
Posts: 267
Joined: Mon Sep 14, 2009 10:34 am
Has thanked: 30 times
Been thanked: 19 times

Re: Is there any way to....

Post by Sparkoids »

Last remark on the matter.

Apparently it is better to use NOT since it only uses 1 byte and XOR uses 2 bytes I'm told.

Personally I'm just glad it works!

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 63 times
Been thanked: 290 times
Contact:

Re: Is there any way to....

Post by JonnyW »

Hi. Yes - if you just want to invert all bits then 'not' is better than 'xor' - you would tend to use xor to invert a selection of bits, like 0xF, and leave the other bits as they were.

Jonny

Post Reply