Page 1 of 1

LOOP -NON_FUNCTIONAL

Posted: Fri Jan 12, 2018 5:55 pm
by DCW
hello... so maybe I am STUPID.. and cannot use the LOOP ICON.. correctly...!!
I have attached two PNG pictures.. of parts of my flowcode.. simply showing.. how I want to make a LOOP work.
So.. I have a variable called BEEP_COUNTER ... which for testing.. is setup as an INT (-32K to +32K) so that the simple number of 12000, or 24000 can be loaded into this variable. So the first PNG shows part of a MAIN loop, where BEEP_COUNTER is.. loaded with say 12000.
The second PNG shows the actual little loops which I made up, so as to BEEP a piezo buzzer connected to a suitable output.

SO when the program is compiled, and programmed into a suitable chip.. and this part of the routine is accessed.. the piezo buzzer... just carries on beeping continuously...

So.. one would expect that .. say a count of 12000 ... would mean I would get only one beep... (See the macro).. and then if I made BEEP_COUNTER to be 24000... I would then get 2 beeps... and 36000 would mean 3 beeps... OKAY.!!

If someone can fiddle with it... say you've got nothing to do... then you could enter the macro... and then make up a MAIN program and call the macro.. and if you solve the problem... WOW... would you mind telling me... please... how STUPID I am... and show me where I am STUPID... cause then maybe I might be able to learn something...
... or else... it's a bug... in the LOOP ICON... software inside flowcode... hmmm...
Many thanks - from DCW ....
download/file.php?mode=view&id=25442
download/file.php?mode=view&id=25441

Re: LOOP -NON_FUNCTIONAL

Posted: Fri Jan 12, 2018 5:59 pm
by Benj
Hi Spencer,

I think I have come across something similar and the code behind the loop is creating the count value as a byte and so is never going to count up to the correct value. With a fixed constant it’s easy for Flowcode to know the variable needs to be say a 16-bit value. I’ll see if it’s something we can improve for the next release.

One workaround is to change the loop type back to “Loop While” put your count variable in as the Expression and inside the loop decrement the count variable using a calculation icon.
loop.jpg
loop.jpg (9.75 KiB) Viewed 2004 times