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

Combination Circuits/Schematics

For general discussion related FlowStone

Re: Combination Circuits/Schematics

Postby tulamide » Wed Jun 07, 2017 6:57 pm

tiffy wrote:The Ruby Style Guide for best practice Source Code Layout:

Someone on the Forum once recommended that we should follow a "Ruby Style" of best practice rules (i.e. Source Code Layout) so that real-world Ruby programmers can write code that can be maintained by other real-world Ruby programmers.

So, I crawled the Internet and I came across the following webpage:

https://github.com/bbatsov/ruby-style-g ... ethod-bang

From my side (as a beginner) it is only a thought or recommendation not a hard-and-fast-rule. What do you think about the idea?

:?: :?: :?:

I was recommending it. There are three main sources for the style guide. All of them are user-based, because Yukihiro "Matz" Matsumoto, inventor of Ruby, was too busy programming it (he still is). You pointed to one of the three, the one that I am trying to follow is this one:
https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md

But don't worry, they all agree on everything they share, it's just that some guide covers areas the others don't and vice versa.

It's up to you to follow them. But if you write code and expect others to read your code later, it is raising your chances if you at least stick to the very minimum (like indenting, how to set paranthesis, operators etc.)

EDIT: For example, it is a pita to read KG's codes. I only try to read them, because he is a brilliant mind and so his work is always interesting. And he knows his code is ugly. He's just too lazy :lol:
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2687
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Combination Circuits/Schematics

Postby tiffy » Thu Jun 08, 2017 9:43 am

Thanks tulamide, for the link and your comments. I already had a look at it.

However, I thought about this and it is a lot of info to take in at once for someone like me using Ruby only once in a while...therefore I sometimes even forget some Ruby methods etc and have to look it up if I want to write Ruby Code.

Maybe I should make me a "Ruby quick reference note book" or something for those things one use mostly when writing code.

Just something of importance:

For the PASCAL Programming language I got some nice step-by-step structure/layout (in Code, not just a block diagram) with descriptions next to Code lines of importance from a friend (he is a programmer) long ago, which gives clear instruction on how one should start, end, doing loops or branching etc in that language. In the Ruby language I haven't come across something similar and therefore as a non-programmer I feel a bit uncomfortable with Ruby to that extent and thus feel that I am using Ruby more in the sense of a calculator than a true programming language. Unfortunately, in DSP Ruby many things differ from plain Ruby which have to be converted first for it to function in DSP Ruby and there is not much yet on the internet on DSP Ruby. It would be useful if Flowstone Admin could write a short course on DSP Ruby also covering the things I mentioned above and even sell it as a separate ebook...it don't necessarily have to cover every aspect of DSP Ruby, just the most used basics. Maybe, I should put this as a request in the "wishlist" ?
User avatar
tiffy
 
Posts: 400
Joined: Wed May 08, 2013 12:14 pm

Re: Combination Circuits/Schematics

Postby tulamide » Thu Jun 08, 2017 9:12 pm

tiffy wrote:Unfortunately, in DSP Ruby many things differ from plain Ruby which have to be converted first for it to function in DSP Ruby and there is not much yet on the internet on DSP Ruby. It would be useful if Flowstone Admin could write a short course on DSP Ruby also covering the things I mentioned above and even sell it as a separate ebook...it don't necessarily have to cover every aspect of DSP Ruby, just the most used basics. Maybe, I should put this as a request in the "wishlist" ?

Can you go into detail regarding your first sentence? Maybe provide an example?

For the second sentence I can assure you, it already exists. Everything special to DSP Robotics' implementation is covered in great detail in chapter 8 of the user guide. It even covers integration of gems and where to place external files, should you want to make full use of it.

Basically think of DSP Robotics' implementation of Ruby as the whole Ruby core of version 1.9.3 (pretty much everything listed on this page), plus the Win32API (not much to see here, rather refer to chapter 8). So, all other classes or modules you might notice elsewhere that belong to other packages, have to be installed manually. Chapter 8 explains that as well.

In general, if you happen to read code that starts with
Code: Select all
require 'something'
, it relies on code in external files that are not part of the Flowstone implementation -> you have to install those files manually.
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2687
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Combination Circuits/Schematics

Postby pshannon » Mon Jun 12, 2017 1:43 pm

tiffy wrote:Under this heading I may (or may not) in future upload some combination circuits - for those not against it.

The first is a schematic of a Clocked JK Flip-Flop (Basic unit) and a Clocked Master-Slave JK Flip-Flop in one schematic (for Green).

Inside the schematic I also left the GATES Configuration and the Truth table I used the day that I constructed this schematic, long ago, as well as two push buttons, two Clocks and four LED's which are all optional. So, I uploaded it here as is.

Someone on the forum, some time ago, requested a JK Flip-Flop (for Green)... so, here is my Clocked version of it.

# Corrected and uploaded here again: The two input terminals J & K of both JK Flip-Flops (Graphics versions only) were not connected to their corresponding LED's - they were connected the wrong way around. This is now fixed in this version.


Wow, You did a great job on this. I just came across this, I have been working on my versions for a couple of weeks now and clearly we are like minded. Some of your ideas matched mine exactly. I will up load my gates and bit counters some day soon. I wanted to complete several of them first. The difference between yours and mine? I am actually replicating the IC chips that make these circuits and plugging them into each other. Since I am replicating the chips, you should be able to order the chips I am creating from your electronics store and create these circuits. I think there is much power to be tapped into Flowstone.
User avatar
pshannon
 
Posts: 144
Joined: Fri Jan 02, 2015 3:08 am

Re: Combination Circuits/Schematics

Postby tiffy » Mon Jun 19, 2017 6:39 pm

RANGES AS CONDITIONS & STRING INTERPOLATION (RUBY):

In this Ruby example Ranges are used as Conditions.

When the Input score falls within a certain Range, the corresponding Remark is displayed at the Output together with the Input score as a percentage. When the Input score exceeds 100% then the Output will display "Invalid Score" together with the corresponding Input score.

NOTE:

By calling an object to_s method that object can be converted to a string for displaying it on the same output with other strings. In this example, "score" contains a Float Variable which must first be converted to a String prior to displaying it on the same output with other Strings. If you don't do this, Ruby will display a "TypeError: can't convert Float into String".
Attachments
Ranges as Conditions + String Interpolation (Ruby).fsm
(1.6 KiB) Downloaded 1009 times
User avatar
tiffy
 
Posts: 400
Joined: Wed May 08, 2013 12:14 pm

Re: Combination Circuits/Schematics

Postby RJHollins » Mon Jun 19, 2017 8:39 pm

Love it !

I've found the conditional CASE statements a very useful solution.

thx Tiffy

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

Re: Combination Circuits/Schematics

Postby tiffy » Thu Jun 22, 2017 7:30 pm

NOT USING A RUBY “METHOD” AND USING A RUBY “METHOD” - EXAMPLE ONLY

I encountered the following obstacle with Ruby as described below in the two routines. However, I do not understand why the routine 2 which includes a Ruby “method” works absolutely correct by blanking its output on illegal input variables (i.e. 0, negative values, or any string characters) as required, whilst the other routine 1 which does not include a Ruby “method” (only assigned values to the two variables) does not also blank its output although it does not output anything as required when the input variables are 0, negative, or any string character. Anyone to offer an explanation ??? :idea: :?:

Description also inside the schematic.

SCHEMATIC 1, ROUTINE 1 (Not using a Method, only assigned values to the Variables):

Although this works correctly to some extent i.e. it does not output anything when the input variables are illegal i.e. 0, negative or a character string, the output does not change to blank when the input variables are illegal i.e. 0, negative, or a string character.
:shock: :? :shock:


SCHEMATIC 2, ROUTINE 2 (Using a Method):

This works correctly, as the output also change to blank when the input variables are illegal i.e. 0, negative, or a string character.
:D ;) :D
Attachments
Method or No Method (Ruby).fsm
(1.68 KiB) Downloaded 963 times
User avatar
tiffy
 
Posts: 400
Joined: Wed May 08, 2013 12:14 pm

Re: Combination Circuits/Schematics

Postby tulamide » Thu Jun 22, 2017 8:03 pm

Both examples are wrong.

In the first example you don't exit begin-end correctly. You can only rescue or break. Also, you work with local values within begin-end, which causes additional troubles. I'm not sure why you use begin-end at all? It is used to catch errors like this
Code: Select all
begin
  mycode
rescue someerror
  errorhandling
end


The second example defines a method within begin-end, which is also not how begin-end is supposed to be used.

If you want to work without a method definition, do this
Code: Select all
price = @price
qty = @qty
if price.to_f <= 0 || qty.to_f <= 0
  output 0, nil
else
  total = price.to_f * qty.to_f
  output 0, total
end


If you want to work with a method definition, do this
Code: Select all
def total(price,qty)
  return nil if price.to_f <= 0 || qty.to_f <= 0
  return price.to_f * qty.to_f
end

output 0, total(@price,@qty)
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2687
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Combination Circuits/Schematics

Postby tiffy » Thu Jun 22, 2017 8:42 pm

Thank you tulamide, this begin end thing in Ruby confused me. I was not sure when to use it.
User avatar
tiffy
 
Posts: 400
Joined: Wed May 08, 2013 12:14 pm

Re: Combination Circuits/Schematics

Postby tiffy » Wed Jun 28, 2017 5:31 pm

A Photo of a CAMERA with SHUTTER LENSE and FLASHLIGHT as well as a PHOTOGRAPH that slide out when the Camera is activated. The shutter really opens and expose the lense and then close again whilst the flashlight also flashes. I completed this project last night as a fun thing, just to show the many interesting possibilities with Flowstone. Unfortunately due to its size, it is not possible to upload the schematic and my dropbox is still overloaded with internet traffic and therefore temporarily disabled.
Attachments
Camera with Shutter Lense & Flash.png
Camera with Shutter Lense & Flash.png (145.43 KiB) Viewed 29663 times
User avatar
tiffy
 
Posts: 400
Joined: Wed May 08, 2013 12:14 pm

PreviousNext

Return to General

Who is online

Users browsing this forum: No registered users and 31 guests