Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

A simple int box. It's driving me crazy! Any tips?

For general discussion related FlowStone

A simple int box. It's driving me crazy! Any tips?

Postby tulamide » Fri Aug 15, 2014 10:19 am

I'm working on a solution for this. I'm almost done. There's just one little thing that prevents posting it...

The following works very well. But, at every start of the loop, the marked integer box needs to be set to -1. That also works very well, as long as I do it manually. But everything I tried to automatically set that box to -1 right before starting the loop just failed. I know that it fails because of the triggers. But if I work with trigger blockers, sample & hold, etc., the results are wrong (mainly because the needed triggers now also don't come through anymore). I can't believe that something so simple, as setting the int to -1 only works manually!

So does anyone have a solution? Or a tip? Anything? :cry:

scheme.jpg
scheme.jpg (227.98 KiB) Viewed 15589 times
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: A simple int box. It's driving me crazy! Any tips?

Postby KG_is_back » Fri Aug 15, 2014 10:36 am

Use green selector, connect -1 to true input and what you have there to false. Then setup comparator to be true on first loop and false on others (I can't see from where to where you're counting) and connect it to the selector.
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: A simple int box. It's driving me crazy! Any tips?

Postby tulamide » Fri Aug 15, 2014 11:11 am

Thank you KG. Unfortunately, as soon as it switches to the false input the select prim sends out triggers. That leads to a second calculation of the already calculated value (the first time the marked int will be 5, the second time it should be 8, in this example). So instead of using 5 (which leads to 8), it recalculates 5, which results to 11 (at least the calculation is correct :lol: ).

It gives me headaches :oops:
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: A simple int box. It's driving me crazy! Any tips?

Postby tester » Fri Aug 15, 2014 12:33 pm

Place somewhere sample and hold prim(s) and retrigger them only once to avoid feedbacks. This will pass values only once. Triggers in this design seem to be "bonded" so to speak (i.e. not separated by timers for example), so they should follow trigger order. In this case the S&H trigger will go from the point (the loop prim?) where the thing starts shooting (remember about trigger order).
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: A simple int box. It's driving me crazy! Any tips?

Postby MyCo » Fri Aug 15, 2014 1:11 pm

The int box is inside a green connection loop (its output is indirectly connected to its input). There is no simple way to fix that, because every trigger that changes the box goes through the "add" primitive and changes the int box again. It needs some S&H primitives and some "Last changed". Unfortunately you posted just an image and not a schematic...
User avatar
MyCo
 
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany

Re: A simple int box. It's driving me crazy! Any tips?

Postby tulamide » Fri Aug 15, 2014 5:02 pm

MyCo wrote:The int box is inside a green connection loop (its output is indirectly connected to its input).

Yes, that's on purpose. The equivalent of "n += somefunction(n) + x". At least that's what I try to achieve :lol:

MyCo wrote:Unfortunately you posted just an image and not a schematic...

Not on purpose this time. I just thought it's something, where the experienced ones just shake their head and say: "come on mate, don't you see that you just need to ..." :oops:

Here it is! And thank you for the descriptions. Although I know what you mean, I couldn't get it working. So, if you have a minute or two...? ;)
Attachments
intboxissue.fsm
(1.46 KiB) Downloaded 855 times
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: A simple int box. It's driving me crazy! Any tips?

Postby trogluddite » Fri Aug 15, 2014 5:47 pm

This has it, I think...
intboxissue FIX.fsm
(2.08 KiB) Downloaded 862 times

As MyCo says - always post a schematic. Fixing a problem like this is not easy without knowing the semantics - exactly WHAT you are trying to achieve. In this case, knowing the purpose has allowed some other optimisations, as well as the fix for the initial problem. The whole thing immediately made sense once the clever 'arrays within an array' structure could be seen (very nifty!).

- The FIX. A 'Last changed switch' that sets the start value - note the trigger order, it is set before the loop begins. A trigger blocker inside the feedback loop prevents runaway triggers - the output from the 'Get' is enough to update the new index.
- The second "get at" is now only triggered when the loop is done, not every single iteration.
- The 'sample and hold' at the end ensure that the final output only triggers once per operation.

Note that there is something odd about the 'Array Section' primitive. Usually a trigger at any primitive input causes all other inputs to update their value - this would suggest the optimisation of trigger blocking the 'start' input. But this particular primitive doesn't seem to do this, so there's no way to update both the start point and the count without it updating its output twice - hence the final sample and hold to ensure "one in - one out" triggering for the module as a whole.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
trogluddite
 
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: A simple int box. It's driving me crazy! Any tips?

Postby tulamide » Fri Aug 15, 2014 8:55 pm

Thanks a ton, trog! I was trying to get this working for 3 days now!

trogluddite wrote:- The FIX. A 'Last changed switch' that sets the start value - note the trigger order, it is set before the loop begins. A trigger blocker inside the feedback loop prevents runaway triggers - the output from the 'Get' is enough to update the new index.
So easy, if you look at it now. I wonder why I couldn't think so logically? Thank you so much.

trogluddite wrote:- The second "get at" is now only triggered when the loop is done, not every single iteration.
Very helpful, again so logical, and again I didn't see it :oops:

trogluddite wrote:- The 'sample and hold' at the end ensure that the final output only triggers once per operation.

Note that there is something odd about the 'Array Section' primitive. Usually a trigger at any primitive input causes all other inputs to update their value - this would suggest the optimisation of trigger blocking the 'start' input. But this particular primitive doesn't seem to do this, so there's no way to update both the start point and the count without it updating its output twice - hence the final sample and hold to ensure "one in - one out" triggering for the module as a whole.
Very important information! I've learned quite a lot from just a small issue! Did I already say thanks?

Well, who cares? Can't be said enough. Thanks! :D
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: A simple int box. It's driving me crazy! Any tips?

Postby MyCo » Fri Aug 15, 2014 9:22 pm

Was playing with it... My version uses the previous value instead of another "Get Array"
Attachments
intboxissue FIX (MyCo).fsm
(791 Bytes) Downloaded 864 times
User avatar
MyCo
 
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany

Re: A simple int box. It's driving me crazy! Any tips?

Postby tulamide » Fri Aug 15, 2014 11:02 pm

Wow! I have no clue, why or how your solution works. Which simply means, I will have a fun time exploring the module! It seems to be a more lightweight solution in terms of cpu load (just guessing from the lower number of elements used). As soon as I understand the inner workings I will incorporate it. Thank you very much for taking the time and showing me optimization :D
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany


Return to General

Who is online

Users browsing this forum: No registered users and 62 guests