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

hrc - rebuilding this one to ruby

For general discussion related FlowStone

hrc - rebuilding this one to ruby

Postby tester » Fri May 24, 2013 9:19 pm

Recently I created a tool for calculating harmonic resonances in multi-freq setup. Consider this as my contribution to FS community.

While the calculator itself works fine, the problem begins in living schematics (calculations are made on static values of course). Calculation points are made via loop generator, and loop generator is made of green stuff. Which means, under even not too heavy load - the whole things slows down, and affects the application.

I have no idea whether this thing could be done on greens only, so I guess this is a task for rubyists.

Can someone help?
Speedy Trog? ;-)

*

Things to do.

There are two concepts related to harmonic points. Midpoint based resonance, and interval based resonance. These two things are calculated separately.

1. Midpoint based part.

a)

Calculate all midpoints between all freqs according to formula: (f1+f2)/2.
Exclude self-calculations (i.e. like f1 and f1) and reversed ones (use abs; f1 with f2 = f2 with f1).
Track labels for all calculations. (f4+f5)/2 <=> "f4~f5" string.
Track ratios between border freqs (=<2, =<4, =<8) and differences (=<br, >=br) and assign additional markings (o1, o2, o3+ for ratios, and br for =<br)

Result: two equal arrays, one made of midpoint numbers, second made of strings/labels

b)

Compare midpoints with freqs.
Exclude self-comparisons (i.e. things like f4 with f4~f6 midpoint).
Track labels of these comparisons. (will give a form of like: "f5 in f7-f9")
End results are according to fomula: X = 2* abs (fN-mid)
[yup, resulting vibration is 2x higher than difference]

2. Interval based part

a)

Create for each freq an interval series (you may exclude fractionals; they duplicate in reversed calc):
x1, x2, x3, x4
x3/2, x5/2, x7/2
x4/3, x5/3, x7/3, x8/3, x10/3, x11/3
x5/4, x7/4, 9/4, x11/4, x13/4, x15/4
[these 4 sets are important, because each one has different recalc ratio]

Use similar formula for label tracking (see how the example works) and ratio based markings.

b)

Compare each input freq with all intervals.
Exclude self comparisons (like f1 with f1-based intervals)
Track labels in similar way like before

The end values however depend on interval series.
for N = x1, for N/2 = 2, for N/3 = 3, for N/4 = 4.

3. Consolidate all, and combine (somehow) with fliterings according to range and type.

If I missed something - everything else is in greens and via example.

p.s.: array size is/was semi-fixed by purpose.
To change it - just add notes, click once to get recalc, and refresh inputs.

*

I know it may sound as "big project", but it isn't. It is complicated only in greens (the difficult part here are array operations, and filters).
Attachments
hrc-rebuild-to-ruby.fsm
(15.02 KiB) Downloaded 859 times
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: hrc - rebuilding this one to ruby

Postby trogluddite » Sat May 25, 2013 5:56 pm

tester wrote:I have no idea whether this thing could be done on greens only, so I guess this is a task for rubyists.

Yes, I would say so too - the way you have broken the task down is very well put, and it highlights several areas where Ruby will offer advantages.
Also, I think, some of those "sub-tasks" are very 'self-contained' and would be good examples in their own right - to learn some Ruby in "small chunks", or to make into toolbox modules (for example, eliminating identical entries from the array - could have many uses). Possibly this would be a more useful approach than to make one big Ruby which only a fellow Rubyist could ever understand and modify.
I don't have a huge amount of "coding time" this weeked, but here is a little list of specific tasks that I think Ruby could handle well...

- Removing duplicate array items - in Ruby this is a single command! (though we must take care here that float rounding errors do not make "false differences")

- Tracking values and labels - no need for them to be separate arrays - Ruby can 'nest' arrays, so that values always live together with their labels - no more need for "cross referencing"; delete a value entry, and his label would be gone too. I see that RJHollins has also asked for an example of "multi-dimensional" arrays, so maybe here is a good place to start?

- Interval series - Ruby can handle fractions (rational numbers) properly, as they have their own special data type. This is very valuable, because floats can have rounding errors, so might not see that "3/2 == 12/8" - but 'Rationals' in Ruby automatically factorise to find the common denominator, so will always correctly identify equivalent fractions.
Also, the 'whole numbers' (3/3, 6/3, 9/3) are not desired - easy with rationals, because they will be re-factored to become (1/1, 2/1, 3/1) - if denominator == 1, delete!

Here is a schematic containing some very basic demonstrations of those principles in action...
Number series - block examples 1.fsm
(4.11 KiB) Downloaded 942 times
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: hrc - rebuilding this one to ruby

Postby RJHollins » Sat May 25, 2013 9:00 pm

ahhh ... the first 'hints' of multi-dim arrays.

Without a doubt, a key function that I need to learn. Thank you TROG!

Using this function [once learned] will have a major impact on schematic design.

:)
RJHollins
 
Posts: 1568
Joined: Thu Mar 08, 2012 7:58 pm


Return to General

Who is online

Users browsing this forum: No registered users and 35 guests

cron