Software Overview  |  Sitemap  |  Downloads  |  Developers  |  Forums
Small_clear_logo_llc

Building an Inverter

To see how the Virtual Wiring system works, we'll look at some examples. To get get familiar with the system, we'll start with a simple example - we'll build an inverter. An inverter is a digital device which outputs the opposite of what it sees on its input. It's a kind of Virtual Device, because you don't need anything outside of your computer to build one. That's good, because for this first example, you don't have to buy anything.

Begin by starting up your Virtual Wiring system. Open your browser and click on the "Scripts" selector at the top of your screen. You should see something like this:

Scripts Page

There are a lot of Scripts there, but somewhere on this page there's a Script for adding an "Inverter". You could use your browser's find function and look for "Inverter", but you can also use a filter. Filters help you find a type of device, when you are not really sure what it is called. At the top of the screen, right above the "Scripts" table, there is a "View Filter" selector. Click on the selector and select "Virtual", because we want to see all the Virtual Devices. Now you should see something like this:

Virtual Device Scripts

That's a much shorter read. Right in the middle of the table, there's row that says ".../Virtual/Logic/Combinational/Inverter". To the right of that, there's a box that says, "Run". Click on "Run", and you should see:

Adding Inverter

The dialog box is asking for Script parameters, one of which is the name for the inverter. Every device you add needs a unique name, so you can recognize it after you add it. There are also two other fields filled in for you, inputs: and outputs:, which you should leave alone. If you wanted your inverter to have differently named inputs and outputs or to invert more than one signal, you could edit these fields.

To give your inverter a name, type "my_inverter" after the id: field. Note we have a set of quotes included in what you type. Make sure you enclose your name in quotes, like you see after the inputs and outputs fields. Quotes are important. They mean to the system, "take whatever's in between the quotes and use it as your value". If you don't use quotes, the system will try to evaluate the value and do something called my_inverter, which means nothing in this context (if you want to delve into Script writing at some point, you may need to use unquoted parameter values). Anytime the system gripes at you after trying to create a device, always make sure you have quoted your device names. When creating device names, stick with the characters A-z and underscore(_). You can also include numbers 0-9, but only after starting with one of the other characters.

After filling in the "id" field, click on the "Submit" button. Next, click on "Home", at the top of your web screen. You should see your inverter.

Inverter Page

If you click on the expander to the left of "my_inverter", you can see two terminals on the inverter. They have the names we saw and left alone when adding the inverter.

To see if the inverter works, use the expander to display the inverter's terminals and click on the "1" terminal (that's its input).

Inverter Dialog Box

You'll get a dialog box asking for a value. In the dialog box, type on. This time, make sure the "on" value is not quoted. Why? Because we want the inverter to evaluate and do something with the "on" value. As mentioned above, unquoted values mean evaluate this value, and quoted ones mean just use the value without evaluating it. Here, we are telling our inverter to do something called "on". After typing in an "on" value, click on the "OK" in the dialog box. Now you should see:

Inverter On

Notice that the "1S" terminal has an "off" value - it's inverting its input. Click on terminal "1" again and type off (without quotes) - the output is now "on". Experiment a little. Try other values on the input, both quoted and non-quoted. The inverter only seems to recognize ons and offs and ignores other values. That's because it's a digital device, which means it understands only two values.

Try changing the inverter's output (1S) value. You can change it by clicking on "1S" and filling in the dialog box (similar to the way you changed the input). Changing an output won't hurt anything, and your changed value will persist until the inverter changes its output.

This device may not be all that interesting, but ons and offs are. Most devices in the Virtual Wiring system use ons and offs. That's because many devices are on/off type devices.

If you know a little about digital logic, you could try adding "And" and "Or" devices and experimenting with them.

Go to the next Tutorial to learn about wiring two inverters together.

Catalina Computing, LLC.

Copyright © Catalina Computing, LLC. (2013-2018)




Page last updated: Tue Jul 14 22:58:56 2015 (UTC)