Page 1 of 1

SwitchBank(0) and readstate

Posted: Thu Aug 08, 2013 2:38 am
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.

Re: SwitchBank(0) and readstate

Posted: Thu Aug 08, 2013 9:28 am
by Benj
Hi Errol,

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

Re: SwitchBank(0) and readstate

Posted: Thu Aug 08, 2013 2:44 pm
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

Re: SwitchBank(0) and readstate

Posted: Thu Aug 08, 2013 3:21 pm
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 354 times

Re: SwitchBank(0) and readstate

Posted: Thu Aug 08, 2013 7:18 pm
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

Re: SwitchBank(0) and readstate

Posted: Fri Aug 09, 2013 12:45 am
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" :?:

Re: SwitchBank(0) and readstate

Posted: Fri Aug 09, 2013 7:28 am
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.