Oct 18, 2010

National Instrument - MultiSim - Component details

Hi,

Suggested by Rajesh today, I tried to opt out of using Xilinx, which is too much troublesome (for me at least) and use MultiSim (from National Instrument) instead. By far, it has been much more reliable than Xilinx, with just a little problem when started learning (due to the vast component library).


The software can be downloaded at
https://lumen.ni.com/nicif/us/academicevalmultisim/content.xhtml

Here, I will try to document the components and their usage, hope it serves as a good start.
Also, you may want to refer to this getting started tutorial:
http://www.mediafire.com/?2956aws7pekd20p



Here is the list of components (plz note that the name in bold is the comprehensive one that I give it)
The format will be:



<Component name>
Component Image


Purpose: <Usage of this component>
Group: <Group>
Family: <Family>
Component: <Component Name>
Component value list
  • <Value 1>: <Usage 1>
  • <Value 2>: <Usage 2>
  • ...
  • <Value n>: <Usage n>

List


Selection Switch
Purpose: To Select between two different value, interactively. This correspond to a physical switch.
Group: Basic
Family: Switch
Component: SPDT
Component value list
  • Key for toogle: During simulation, you can toggle between the two values by pressing the key specified here. In this example, pressing "Space" will toggle the switch


VCC


Purpose: 5 Volt Vcc Logic
Group: Sources
Family: Power_Sources
Component: VCC
Component value list: None



Dip Switch Pack


Purpose: Used to toggle voltage input
Group: Basic
Family: Switch
Component: DSWPK_X where X is the number of switches
Component value list
  • Switch 1 key: Toggle switch no.1
  • Switch 2 key: Toggle switch no.2
  • ...
  • Switch X key: Toggle switch no.X
 There is a need for explanation here, as it took me half an hour figuring out the operation of the switches here.
Basically, to perform our desired function, you can't simply connect Vcc and the switch. Since when you turn it OFF (disconnecting the input from the output), you make the ouput become FLOATING (not connected to any electrical sources, and this is not a good thing to do in circuit design).

by connecting the switch with a resistor, you created this schematic:
When the switch is turn ON, pin 1 is connected to Ground, hence, it output 0V
When the switch is turn OFF, pin 1 is connected toVcc via the resistor. Normall, there will be a voltage drop and V1 will be less than Vcc. However, if we choose the resistor to be that of high-impedance (high resistance), the current - as derived form Ohm's law - will be very small. Hence, voltage drop is negligible and V1 is approximately equal to Vcc.

    Oct 14, 2010

    Facade pattern in GUI design

    Today's post will be about Facade pattern and its application in GUI programming.


    I would assume that you guys have already know about GUI basic, like event handling (basically, it's a method that is invoked when something happen to the GUI, either by you or by God, haha). Also, if you have tried to integrate several UI (not just GUI, but include TextUI, mobile apps UI...) for your logic classes, you might see that's it is quite trouble some to keep calling methods in Logic from your GUI.
    If you happen to do so, you might end up with something like this:

    <Sr for the hand writing :P> Basically, each of  TextUI and GUI's event handler A and B is calling method A and B in Logic. It's a bit wrong, technically, since TextUI don't normally have handler.
    This is only for 2 UI classes. imagine i you have more: mobile Apps, Web interface, embedded system interface... if you implement it this way, you will have to write the calling code again and again. Plus, if you change your Logic, then the whole code in UI classes have to change. Plus, your UI have to "know" the structure of Logic class, which is considered a bad design in software.

    Instead, people have proposed a design pattern, called Facade pattern.

    A "facade" class will be made and you will be calling methods in that facade class. then, the facade class will call Logic, get result and return it ot UI.
    It won't shorten much of your work, though. You still have to make a call from UI to facade class and back, but it is helpful since your UI only know about the facade, which acts more or less like an API (correct me if I am wrong here :D). Then UI doesn't of whatever happen in Logic, or even if there is a Logic class at all. This will reduce your load when modifying code inside.


    Basicall, it the new structure will be

    <again, hand writing :P> now, event handler in TextUI and GUI will call methods from facade class, then facade class will call logic. So, if by any chance you need to modify your internal logic w/o changing API, you can do it freely. UI classes now only know up to facade class and no more.
    It will be a good design :D

    If you only have 2 class, then you can also consider splitting the facade in half:
    GUI will have a method that receive info from Logic, then checking that info and distribute to respective UI methods
    Logic will also have a method receiving info from UI, checking it and call appropriate logic methods
    Logic and UI will also have a method that sends info to the other class. This method will be invoked each time info need to be passed.
    Logic and UI will only be communicating through these broadcaster and listener methods

    This is, in my opinion, not a recommended approach though :P but it's fast.

    That's all for today :)