SwitchBank(0) and readstate

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
Errol
Posts: 39
Joined: Wed May 18, 2011 11:15 pm
Has thanked: 9 times
Contact:

SwitchBank(0) and readstate

Post by Errol »

Does anyone know how to use SwitchBank(0) and it's macro "ReadState" I have been working on this for the last 2 hours. No help under HELP :( , no Flowcode 5 examples for SwitchBank/ReadState :( , Did a search only found where there was a problem that was fixed (not sure that is true). The only bit that seems to works is bit 0. I can attach the code but it is very simple.
Component Switchbank(0) select readstate(input) "input is defined a byte" Output (input) to a led array.

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: SwitchBank(0) and readstate

Post by Benj »

Hi Errol,

Please can you attach your program so we can see what your doing.

Errol
Posts: 39
Joined: Wed May 18, 2011 11:15 pm
Has thanked: 9 times
Contact:

Re: SwitchBank(0) and readstate

Post by Errol »

Hi Ben
Here is my FlowCode program . It is the start of a display program that I'm putting together for a Reflow oven project, so it not complete.
Thank for your help
Attachments
Display Thermocouple.fcf
(14.23 KiB) Downloaded 273 times

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: SwitchBank(0) and readstate

Post by dazz »

Hi Errol
TRy the attached code you were almost there comments added to code to show the errors

Regards
Dazz
Display Thermocouple updated.fcf
(14.95 KiB) Downloaded 314 times
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

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: SwitchBank(0) and readstate

Post by medelec35 »

Hi Errol,
The SwitchBank component macro is not being used correctly as you have seen it's not working as expected within your flowchart.
Switch Bank is for reading one switch at a time only!.
If you right click on the swichbank on the control panel and select Ext properties, you will see the numbers from 0 to 7
This is the number you require for reading a switch.
For example if you want to read switch 2 (STORE), then a number 2 or a variable assigned with 2 is placed in WhichSwitch Byte.
The value of pin switch is connected to will be returned in a variable placed Return Value (BYTE).
For example:
switch bank.png
(33.92 KiB) Downloaded 2926 times
If pull up resistors are used and switch is closed.
Then i/p connected to switch 2 will drop to 0V then when the above component macro is accessed, since i/p = 0V then sw_input will be assigned a 0
If switch is opened so i/p increased to 5V, then when above component macro is accessed, since i/p = 5V then sw_input variable will be assigned a 1

So for reading more than 1 switch you either need to use SwitchBank in a loop (see attached flowchart)
Or you take the more common approach and use the input icon like Dazz has posted.
In that flowchart the Switch bank is redundant, so it can be deleted.

Hope this helps :)

Martin
Attachments
Display Thermocouple V1.fcf
Using switch bank command
(17 KiB) Downloaded 293 times
Martin

Errol
Posts: 39
Joined: Wed May 18, 2011 11:15 pm
Has thanked: 9 times
Contact:

Re: SwitchBank(0) and readstate

Post by Errol »

I want to thank Dazz and Medelec35 for the code and the input. :D You both must have spent a lot of time working this out the first time.

Ben: My question to Support is why are there no examples of this component or Help under "HELP" :?:

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: SwitchBank(0) and readstate

Post by medelec35 »

Hi Errol,
Errol wrote:I want to thank Dazz and Medelec35 for the code and the input.
Your welcome.
Errol wrote:Ben: My question to Support is why are there no examples of this component or Help under "HELP"
Have you right clicked on the component on your panel and selected help? :
SwitchBank Help.png
(61.63 KiB) Downloaded 2905 times
Right click help is help for the components.
You don't get information on individual component in the standard top help menu as that's just for help with using Flowcode.
Martin

Post Reply