Desission question and loop number question

Moderator: Benj

Post Reply
Dutch
Posts: 102
Joined: Mon Aug 19, 2013 8:38 am
Location: Netherlands
Has thanked: 24 times
Been thanked: 5 times
Contact:

Desission question and loop number question

Post by Dutch »

Gentlemen… I need your advice….. I tried and learned a lot in the mean time but now I am at a point where I ‘think’ I have found a few ways to make my ‘layout’ more simple in ‘flowcode-ways’ but not sure if it’s possible ….., (I already found out how to make a Input number as variable delay for the ON and OFF)

1-is possible to have my number of loops in the line respond to a input given from switchB? Now only a given number of counts can be there with no variable so I think it needs to be something like a calculation/ countdown to 0 in the ‘Loop while’ but not sure how.

2 less important ,I tried to feed the ‘desission’ or ‘switch’ arm a OR function so it would choose that route if the input is equal to a given serie of numbers (to work along with the no1 option above).
If I put ‘$portB = 1’ it works. But if I put ‘$portB=1|2’ (1 OR 2) to have it go that route at 1 OR 2 and run the program BUT it selects that route at any given input.. even 0?...
whats wrong? or isn't it possible like this? (don't get a syntax error when I put the numbers)

Thanks for looking !
Attachments
Flowcode1-1.fcf
(20.05 KiB) Downloaded 285 times

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: Desission question and loop number question

Post by medelec35 »

Hi Dutch,
I Have made some same minor modifications to your flowchart so it will only loop for the value of portB (bits 0 to 3)
From that should be able to change the flowchart to suit your needs.

Martin
Attachments
Flowcode1-2.fcf
(20.57 KiB) Downloaded 291 times
Martin

Dutch
Posts: 102
Joined: Mon Aug 19, 2013 8:38 am
Location: Netherlands
Has thanked: 24 times
Been thanked: 5 times
Contact:

Re: Decission question and loop number question

Post by Dutch »

Super thanks Martin!!!!!!

maybe a minor adjustment, but this will save me many lines and gives me so much more variables!
I'm figuring out in a moment what you did to make it happen.

EDIT: really cool solution to have it equates to 0 that way! I also get the decision . but what can I put in the decision (or switch) if I want to have it react on 1 to 15? I'm trying something with ( )

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: Desission question and loop number question

Post by medelec35 »

Hi Dutch,
Your welcome.
Glad to have been able to help.
Dutch wrote:but what can I put in the decision (or switch) if I want to have it react on 1 to 15? I'm trying something with ( )
You can do something like this:

Code: Select all

(ReadPortB > 0) && (ReadPortB <= 15)
use && for AND
In reality this should not be necessary since you you look at your flowchart double click on input icon, you will see I have selected use Masking:
Read port mask1.png
(51.85 KiB) Downloaded 3595 times
This means it will only read the bits that are ticked.
Since only bits 0 to bits 3 (4 bits in total) are ticked then the maximum value retrieved will be 2^(n)-1 = 2^(4)-1 = 16-1 = 15
If you ticked the 4 box then max total = 2^(5)-1 = 31
For those not familiar with maths or scientific calculator:
^ is 'To the power of'.
On my calculator, the button has a x with a white square (called the index) on the upper right to the x.
The x is power.
Other calculators could have a yx button instead.

Martin
Martin

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

Re: Desission question and loop number question

Post by dazz »

Hi
Just a quick one, if you put windows calc into scientific mode, its the Xy button,i didnt realise you could change the mode of windows calc until martin mentioned it a while back

Regards
Dazz
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: Desission question and loop number question

Post by medelec35 »

dazz wrote:windows calc into scientific mode, its the Xy
Typical!
I have two calculators in front of me and windows one has to be different :lol:
Thanks Dazz, I should of mentioned about windows version myself.

One of the calculators I bought from the pound store in the UK
It's a scientific (of course :P ) but it had all the useful functions of conversion to BIN, HEX, DEC.
But as Dazz reminded me the windows calculator can do all thoes functions as will since with win 7 it has a programmers functions.
(View, programmer)
To run calculator click the windows icon, and in search just type:
win
then enter key.
Martin

Dutch
Posts: 102
Joined: Mon Aug 19, 2013 8:38 am
Location: Netherlands
Has thanked: 24 times
Been thanked: 5 times
Contact:

Re: Desission question and loop number question

Post by Dutch »

Thanks again for thinking along Martin. this surely helps... TOP!

As for smart calculators... for my work to explain in a simple way BCD switches and their codes to installers for 'on the road' i have found a very simple and usefull App for the Iphone. there are more but the most elegant one is 'DMXdip'. It shows a 9Bit dipswitch and a numberpad. It converts direct any dipswitch setting to decimal and vice versa. Yeah, because it's free it has a NAG function build in but hé
Attachments
IMG_0802.JPG
(46.5 KiB) Downloaded 1842 times

Post Reply