|
|||||||
Defining OOPic |
|||||||||||||||||
| OOPic (Pronounced OO-Pic) is an
acronym for: Object-Oriented Programmable
Integrate Circuit. OOPic helps you be more creative by providing you with an Object-oriented language model designed to interact with the electrical hardware components that you attach to the OOPic. You design your hardware interface in software by creating Objects and setting their properties to define their behavior and interaction with hardware. These Objects also can be interconnected to form a Virtual Circuit. You then utilize this hardware interface and its associated Virtual Circuits by writing a program that controls and responds to hardware events that occur. This chapter shows you how to set up the OOPic Software Development Kit on your computer and introduces other parts of the documentation |
|||||||||||||||||
|
|||||||||||||||||
| The chapters of this guide can be grouped into three parts. | |||||||||||||||||
|
|||||||||||||||||
|
|||||||||||||||||
| The list below describes the compatibility of the OOPic language with other common languages. | |||||||||||||||||
|
|||||||||||||||||
|
|||||||||||||||||
| The list below defines some of the common terms used in the OOPic manuals to describe parts of the OOPic programming language used in this manual. | |||||||||||||||||
|
|||||||||||||||||
| If you are new to the Object-oriented and event-driven programming models, you may find some of the terminology a little strange at first. The list below defines some of the common terms used in the OOPic manuals to describe these programming models. | |||||||||||||||||
|
|||||||||||||||||
| Virtual Circuits provide a means in which one can emulate electronic circuits that manipulate values. The list below defines some of the common terms used in the OOPic manuals to describe Virtual Circuits. | |||||||||||||||||
|
|||||||||||||||||
|
|||||||||||||||||
| Items in Brackets: Brackets, [ ],
contain optional items which may be used but are not
required. If the item enclosed in brackets is followed by
three dots [exp...], it means that any number of
expressions may be entered, but none are required. The following table explains the abbreviations used throughout this manual:
|
|||||||||||||||||
|
|||||||||||||||||
Before You Run SetupBefore you install the OOPic Software Development Kit, make sure your computer meets the minimum requirements, and be certain to read the README file, located at the root directory on our installation disk. Check the Hardware and System Requirements.To run the OOPic Software Development Kit, you must have certain hardware and software installed on your computer. The minimum system requirements include:
Read the README FileThe README file lists any changes to the OOPic documentation since its publication. Check the first section of the file for details and new information. Setting UpYou install OOPic Software Development Kit on your computer using the Setup program. The Setup program installs the OOPic Software Development Kit itself, the Help system and sample applications.
When you run the Setup Program, a directory is created for OOPic. All of the required files will be installed within this directory with the exception of the Microsoft® Visual Basic® runtime files. Follow this procedure to install the
OOPic Software Development Kit on your computer.
|
|||||||||||||||||
|
|||||||||||||||||
| In addition to the documentation, the OOPic Software Development Kit includes sample applications that you can load into the OOPic. These applications are excellent learning tools. You can copy any part of them into your own applications, and modify them as necessary. You can find out more about these on our Internet world-wide-web page: http://www.oopic.com | |||||||||||||||||
|
|||||||||||||||||
| You can access Help by choosing the
Contents command form the Help menu. The fastest way to find a particular topic in Help is to use the Search dialog box.
OOPic Internet Support Services
|
|||||||||||||||||
|
|||||||
What is an OOPic Application |
|
| An OOPic application is a computer program written
for the purpose of controlling electronic equipment
connected to an OOPic microcontroller. The program itself
is written and stored on a P.C. style computer where it
is "compiled" into OOPic instructions and
downloaded into an OOPic microcontroller. Once
downloaded, the OOPic runs the program and the P.C. style
computer is no longer needed for it's continued
operation. In this chapter, instructions are given to create a very small program that can be easily implemented. The intent is to familiarize the new users with the procedures involved in the OOPic development environment. |
|
|
|
There are 5 steps involved in creating an application for the OOPic
|
|
|
|
| Clicking the "OOPic Language Compiler"
selection on the Windows Start Menu will start the
OOPics Software Development Kit. When the
OOPics Software Development Kit opens, it will be
in full screen mode with a set of menus, a large program
editor area for you to type in your program, and a list
of current Objects. The menu provides a set of operations that you will need while writing your application including a file save and load selection for you to save the applications that you have written. |
|
|
|
| The first OOPic application is a Blinking LED. This
device will turn an LED on and off once every second. The materials required are as follows:
|
|
|
|
| In an OOPic application, a hardware interface is a
series of Objects configured to interact with the
physical hardware that is connected to the OOPic. In our first application, an LED will be repeatedly turned on and off. This will be done by repeatedly outputting a voltage onto the I/O Line that the LED is connected to. A single Digital Input/Output line will be used for this purpose. Starting at the first line of code, type the following statement: This instructs the OOPic to create an instance of an oDio1 (1-bit digital I/O line) Object with the name "LED". The oDio1 Object is classified as a "Hardware Object". This simply means that the Object will interact with the I/O Lines on the OOPic in some pre-defined way. The function of an oDio1 Object is either to present a voltage onto one of the OOPics I/O lines, or to read the voltage that is present on an I/O Line. Once an instance of an Object has been created, all references to that instance are done by specifying its name, followed by a period, and then the property or method that you want to reference. To specify which I/O line the LED Object uses for its voltage output, we will set some of its properties. At the bottom of the program, add the following statements: The statements SUB MAIN() and END SUB define the beginning and the end of a procedure called MAIN. The procedure called "MAIN" is the procedure that will run first when the OOPic is turned on or reset. The line "LED.IOLine = 31" sets the IOLine property of the Object named LED to 31 and the line "LED.Direction = cvOutput" sets the Direction property to 1 ( the value of cvOutput). After the execution of these two statement, any value written to LED.Value will now be presented on I/O Line 31. If the Value property of the LED Object is set to 0, 0-Volts will be presented and if it is set to 1, 5-Volts will be presented. To cycle the LED.Value property at a rate of 1 blink per second, we will add code that continuously assigns it to the OOPic.Hz1 value. (OOPic.Hz1 is a value that cycles once every second). At the bottom of the program, just before the line that reads "END SUB", Insert three lines and add the following statements: The first statement sets up a looping construct. The second statement sets the Value property of the LED Object to OOPic.Hz1, which cycles every second. The third statement finishes the looping construct and causes the program flow to return to the Do statement. Assigning the LED Object's Value property to OOPic.Hz1 when it is currently set to 1, results in the IOLine to be set to 5 Volts and when the OOPic.Hz1 is currently set to 0, the IOLine will be set to 0 Volts. By using the Do Loop structure, around the assignment statement, the assignment statement is repeated indefinitely. The result of this is that the LED will turn off and on once every second. The following code shows the complete code listing written as instructed in the previous paragraphs. |
|
|
|
| Connect the LED together with the resistor to I/O
Line 31 and Ground as shown. Both I/O Line 31 and Ground can be found on the OOPic's 40-Pin I/O connector. A reference to the OOPic's 40-Pin I/O connector can be found at: http://www.oopic.com/con40.htm |
|
|
|
| Pressing the F5 key will
compile the program and then download the "oex"
file to the OOPic. If any errors are encountered, they
will be reported and the compilation will stop. If no
errors were encountered, an "oex" (OOPic
Executable) file is generated. If you have not saved the
program or you have changed it since the last time you
have saved it, the compiler will ask you to save it. If
this is the first time the program is going to be saved,
the compiler will ask you for a program name. In this
case, call the program FirstApp. Type
"FirstApp" in the "File name" area of
the "Save As" dialog box and hit Enter. In order for the executable to be downloaded to the OOPic, the programming cable must be connected to the PC and properly configured. It also needs to be connected to the OOPic's programming connector and an adequate power supply must be attached to the OOPic. See the "Programming Cable" section for more information. |
|
|
|||||||
What is a Virtual Circuit |
|
| A Virtual Circuit is a function in an OOPic that
appears to be a physical discrete electronic circuit, but
is actually the OOPic operating system emulating the
functionality of the circuit. Virtual Circuits are created by progmatically linking together a set of OOPic Objects in the same methodology as one would physically link together a set of electronic components. Once created, each individual part of the virtual circuit can be manipulated or evaluated by the program providing total computerized control of the entire circuit. Virtual Circuits are used to perform functions that provide continuous processes. A real-world example of a continuous process function would be the electrical circuit between a flashlight's switch and its light bulb. The function of the flashlight's switch is to provide continuous control over its light bulb. In an OOPic application, things that need to be continuously updated or monitored, can be done by using a Virtual Circuit. |
|
|
|
There are 5 steps involved in creating an application for the OOPic
|
|
|
|
| In Chapter 2, an OOPic application was created that
blinks an LED by repeatedly assigning the OOPic.Hz1 property
to the Value
property of an oDio1
Object. The OOPic.Hz1 property changes from 0
to 1 and then back to 0 once every second, while the oDio1 Object was
configured to apply a voltage to the I/O Line that an LED
was connected to resulting in an application that blinked
the LED.. In this chapter, instructions are given on how to modify the application in chapter 2 to use a Virtual Circuit to do some of the work. |
|
|
|
| In the OOPic application in Chapter 2, a process that
continuously assigns the OOPic.Hz1 property
to an oDio1
Object's Value
property takes up the program's time. The function of
this process is similar to that of the electrical circuit
between a light switch and a light. One of the OOPic's Processing Objects, the oGate Object, is capable of providing that same function that the OOPic application is now doing with code, thus modifying the program to use a Virtual Circuit with this Object will allow the application's program to go do other things. |
|
|
|
| When creating a Virtual Circuit, a schematic is the
best way to represent its functionality. Unlike a
program, which uses a flowchart to represent the
program's flow, a circuit Virtual Circuit uses a
schematic to help clarify the function that the Virtual
Circuit performs. For our First Virtual Circuit, an oGate Object will be used to update an oDio1 Object's Value property to the value of the OOPic.Hz1 property. Begin the schematic by drawing the Icon for the OOPic, Next draw the icon for an oGate Object, and lastly, draw the Icon for the oDio1 Object. Next, draw arrows between the Object's properties to represent the data flow between the Objects. First draw an arrow from the OOPic Object to the oGate Object. Label this arrow "Hz1" on the OOPic Object and "Input" on the oGate Object. Next draw an arrow from the oGate Object to the oDio1 Object. Label this arrow "Output" on the oGate Object and "Value" on the oDio1 Object. |
|
|
|
| Adding the Virtual Circuit to the OOPic application
is done progmatically with lines of code. Because this application is a modification of the "First OOPic Application" found in Chapter 2, the final code listing for the OOPic application in Chapter 2, as shown below, will need to be modified. As previously detailed, the Virtual Circuit will use an oGate Object to provide the same function that the OOPic application is now doing with code. Starting at the first line of code, insert a blank line and type the following statement: This instructs the OOPic to create an instance of an oGate Object with the name "WIRE". The oGate Object is classified as a "Processing Object". This simply means that the Object will manipulate the values of other Objects in some pre-defined way. The function of an oGate Object is to read a property from one or more Objects, perform a specified logic function, and store the resulting value of that function into yet another Object's property Next, the application's Do Loop structure needs to be removed because its function is going to be replaced by the Virtual Circuit. Beginning with the Do statement, remove the following 3 lines of code. Replace them with the following 3 lines of code. The first line, "WIRE.Input1.Link(OOPic.Hz1)", instructs the "WIRE" Object to link its Input1 property to the OOPic.Hz1 property. The second line, "WIRE.Output.Link(LED.Value)", instructs the "WIRE" Object to link its Output property to the Value property of the "LED" Object. And the third line, "WIRE.Operate = cvTrue", sets the "WIRE" Object's Operate property to 1 (the value of cvTrue) which instructs it to start operating. After the program executes these 3 lines of code, the Virtual Circuit begins to operate in the following manner;
This procedure operates in the background and will continue to operate until the WIRE.Operate property is set back to a value of 0 (cvOff). The following code shows the complete code listing written as instructed in the previous paragraphs. |
|
|
|
| Downloading and running the Virtual Circuit
Application is no different than download and running any
other OOPic application. Pressing the F5 key will compile the program and then download the "oex" file to the OOPic. If any errors are encountered, they will be reported and the compilation will stop. If no errors were encountered, an "oex" (OOPic Executable) file is generated. If you have not saved the program or you have changed it since the last time you have saved it, the compiler will ask you to save it. If this is the first time the program is going to be saved, the compiler will ask you for a program name. In this case, let's call the program "FirstVC". Type "FirstVC" in the "File name" area of the "Save As" dialog box and hit Enter. In order for the executable to be downloaded to the OOPic, the programming cable must be connected to the PC and properly configured. It also needs to be connected to the OOPic's programming connector and an adequate power supply must be attached to the OOPic. See the "Programming Cable" section for more information. |
|
|
|||||||
What is an Event Driven Program |
||
| An event is defined as any change in
state that is recognized by an Object. An Event Driven
Program is a program where any change in state can cause
a subprocedure to be executed even when the program flow
was not expecting to do so. Therefore, the order in which
your code executes depends on which events occur. In Event Driven Programs, the OOPics oEvent Object is used to execute code in response to an event. |
||
|
||
There are 4 steps involved in creating an application for the OOPic
|
||
|
||
| In Chapter 3, an OOPic application was created that
blinks an LED by using an oGate
Object to assign the OOPic.Hz1 property
to the Value
property of an oDio1
Object. In this chapter, instructions are given on how to modify the application in chapter 3 to be Event Driven. |
||
|
||
| In the OOPic application in Chapter 3, a Virtual
Circuit continuously assigns the OOPic.Hz1 property
to an oDio1
Object's Value
property. The OOPic.Hz1 property
changes state from 0 to 1 and then back to 0 once every
second which results in the LED blinking once every
second. The change in state of the OOPic.Hz1 property can be recognized as an event by the program. Modifying the program to be Event Driven will allow the application's program to call a subprocedure which in turn can do more complex processing. |
||
|
||
| Adding the Event Driven routines to the OOPic
application is done progmatically with lines of code. Because this application is a modification of the "First Virtual Circuit" application, found in Chapter 3, the final code listing for the OOPic application in Chapter 3, as shown below, will need to be modified. As previously detailed, this application will use an oEvent Object to provide more complex processing. Starting at the first line of code, insert a blank line and type the following statement: This instructs the OOPic to create an instance of an oEvent Object with the name "BLINK". The function of an oEvent Object is to call a subprocedure when its Operate property is set to 1. Next, the Virtual Circuit needs to be changed. In the Chapter 3 application, the "WIRE" Object's output was linked to the oDio1 Object's Value property. This needs to be changed so that it is linked to the oEvent Object's Operate property. Locate the line that reads "WIRE.Output.Link(LED.Value)", and change it to read as show: This instructs the "WIRE" Object to link its Output property to the Operate property of the "BLINK" Object. After the program executes this line of code, the Virtual Circuit begins to operate in the following manner; and will continue to operate until WIRE.Operate is set back to a value of 0;
The following code shows the complete code listing written as instructed in the previous paragraphs. |
||
|
||
| Each oEvent
Object has an associated subprocedure that is executed
when the oEvent
Object's Operate
property is set to 1. The name of this routine is the
name of the oEvent
Object followed by "_CODE". At the bottom of the program add the following lines of code: The following code shows the complete code listing written as instructed in the previous paragraphs.
|
||
|
||
| Downloading and running the Virtual Circuit
Application is no different than download and running any
other OOPic application. Pressing the F5 key will compile the program and then download the "oex" file to the OOPic. If any errors are encountered, they will be reported and the compilation will stop. If no errors were encountered, an "oex" (OOPic Executable) file is generated. If you have not saved the program or you have changed it since the last time you have saved it, the compiler will ask you to save it. If this is the first time the program is going to be saved, the compiler will ask you for a program name. In this case, let's call the program "FirstEV". Type "FirstEV" in the "File name" area of the "Save As" dialog box and hit Enter. In order for the executable to be downloaded to the OOPic, the programming cable must be connected to the PC and properly configured. It also needs to be connected to the OOPic's programming connector and an adequate power supply must be attached to the OOPic. See the "Programming Cable" section for more information. |
||
|
|||||||
OOP |
||||
| OOPic Basic syntax is 100% Microsoft
Visual Basic compatible. As with Visual Basic, you
program in OOPic using an OOP (Object-oriented
programming) model. Object-oriented programming (OOP) is a method of programming that seeks to mimic the way we perceive things in the real world. OOP exploits our natural tendencies to generalize and classify and allows us to group logically related portions of an application. In most OOP languages, the OOP language extensions allow you to create extremely complex Object models that can closely mimic real life Objects. With OOPic however, the greatest advantage of using Object-oriented techniques is the ease at which you can interface with the physical hardware components present within the OOPic itself. The software industry defines several fundamental principles that qualify a language as Object-oriented. These principles include encapsulation, inheritance, and polymorphism. Although the OOPic manuals do not refer to these principles often, it is useful to understand them. Encapsulation simply means to group related items together. Rather than treating a number of logically related variables and functions dedicated to manipulating those variables as unrelated pieces of code, encapsulation collects them together in groups called classes. Other parts of the program can then use the variables and functions as a single Object. Once encapsulated, variables are referred to as properties of the Object and the functions are referred to as methods of the Object. Through encapsulation, much of an Object's complexity can be kept internal to the Object. And only the few select methods and properties that need to be available to other parts of a program are exposed. These exposed methods and properties, which can be accessed, are called the Object's interface. The term Data Abstraction refers to the way an Object's interface doesnt reveal the way the Object stores its data or performs its methods. The result of data abstraction is a simple Object interface that interacts with functionality that is considerably more complex. Polymorphism is a term borrowed from the Greek language. It means literally "Having many shapes". In OOP this is the effect of being able to invoke an Object's method without knowing the Object's exact type and having the method perform a different action depending on that Object's type. Inheritance allows you to base one Object type on another and build new derived Objects. Since OOPic's Objects are hardware based and the routines are written in optimized assembly language and stored in PROM, there is no way too physical create a new Object type to inherit the class of another. However, by creating Virtual Circuits, inheritance is accomplished. |
||||
|
||||
| OOPic applications can contain several
different components. The Main procedure. This is the main part of your program. It contains the primary program flow. Sub-procedures. These provide your program with sections of code that can be executed from several different points in you program. Objects. Objects can be thought of as self-contained multitasking code that runs in the background with its own set of variables. They are the way in which all OOPic programs interact with the hardware. Events. Events are actions or situations recognized by an Object that cause subprocedures to get executed in response to the change in an Objects state. For more information on Virtual Circuits. Virtual Circuits are emulated electronic circuits that run in the background. They can connect to, and manipulate any variable's values. |
||||
|
||||
| An event is an action recognized by an
Object. Event-driven applications execute programmer
written code in response to an event. The OOPics oEvent Object is the only Object that has the
capability to execute code in response to an event
action. If any instance of an event Object receives a
signal to activate its event procedure, The OOPic
application invokes the subprocedure with then name of
the oEvent Object instance plus the phrase
"_CODE". Although the oEvent Object is the only Object in the OOPic language that has event capabilities, other Objects can still indirectly trigger events. Other Objects can be linked to the oEvent Object thereby giving any Object event capabilities. When you want your code to respond to an event, you first create an instance of an oEvent Object with the Dim command, write code for that event and point the oEvent Object to that code, and lastly "connect" the oEvent Object to the Object that is triggering the event. The following example shows how a voltage change on one of the OOPics I/O Lines can call an event using an oDio1 Object connected to an event Object to invoke the basic syntax code subprocedure "MYEVENT".
After executing these lines within Sub Main, the applications program flow is idle and you could add code that is free to go and do other things. A "Link" was made when the Input of the oFanout Object was linked to the oDio1 Object and the Output of the oFanout Object was linked to the Operate property of the oEvent Object. Now, if the voltage on the I/O line specified by the oDio1 Objects property changes from 0 to +5 the Value property of the Object named "ThingA" will change from 0 to 1, and thusly, The subprocedure named "MyEvent_Code" will be executed. When the End Sub statement is encountered at the end of the subprocedures code, the program will continue where it left off previously at the time of the event. Event-Driven vs. Traditional ProgrammingIn a traditional or "procedural" application, the application itself rather than an event controls the portions of code that execute. Execution starts with the first line of the program and follows a defined path through the application, branching and calling subprocedures as needed. In comparison with the example above, a traditional application must continuously check the state of the I/O Line in order to determine when to call the subprocedure "MYEVENT_CODE". This takes up processing time for your application and can complicate the programs flow control. In event-driven programs, changes in the hardwares state can cause a subprocedure to be executed even when the program flow was not expecting to do so. Therefore, the order in which your code executes depends on which events occur, which in turn depends on what the hardware does. This is the essence of event-driven programming: your code responds when it needs to. Because the your programs flow control does not dictate when an event will occur, your code must make a few assumptions about the "state of the world" when it executes. Your code may trigger additional events in response to its own interaction with the hardware and so, you should try to structure you application so those possibilities are anticipated. Note: Avoid performing to many events at once. This could cause the stack to overflow. Code that starts at power up.In OOPic Basic Syntax, the subprocedure named "MAIN" in your program is designated as the starting point. When your application powers up or is reset, the program will start executing at the first line within this subprocedure. If you want to stop the program and wait for an event to occur, simply drop out of the "MAIN" subprocedure. Another way to stop the program is by setting the OOPic Objects Operate property to 0 (cvOff). This will also cause the OOPic to shut down all events and go into a low-power mode. Prior to the "MAIN" subprocedure executing, When the OOPic is powered up or is reset, all of the application's Object will be created and their values initialized allowing the "MAIN" subprocedure to access them. Ending an Event-Driven program.An Event-Driven OOPic application stops running when all its oEvent Objects are disconnected from their triggers and no code is executing. Because no code is running and no events will occur that will run a subprocedure, there is no way to re-start the execution of the program code. Even when no code is running, the Objects will still operate in the background until the power is shut off. Since the Operate property can be set to 0 by another Object, or even by another computer via the I2C network, the code does not need to be running to shut down the power. |
||||
|
||||
| The OOPic language is oriented towards
the use of Objects. Objects are a collection of code and
data that works together as a unit. Chapter 6 gives a detailed explanation of Objects. There
are several Object classes that are defined in OOPic and
are available for use in your applications.. In most basic languages, One would find several Basic language statements and functions whose operations deal with a particular subject and are therefore related. For example, the Peek function and the Poke statement both deal with memory. The Peek function returns the value at a specified location and the Poke statement sets a specified memory location to a specified value as seen in the following example.
The syntax of these two procedures is completely dissimilar. In OOPic Basic, these two operations are combined into a single Object called "oRAM". With the oRAM Object, a specified memory location is treated as a single unit and is accessed as if it was a variable. The following example demonstrates the use of an oRAM Object dimensioned with the name "MYRAM".
This code reads better, is more consistent and can be understood more quickly. This language enhancement is one of the benefits of using an Object-oriented language. In OOPic applications an Object is declared (or an instance of it is created) with the Dim statement as follows:
Each Object must have a unique name specified by the programmer. The Object's name is case insensitive and is the identifier that is used by the application to refer to that Object. The same rules apply to naming Objects as are applied to all other identifiers in the OOPic language. |
||||
|
||||
| When writing programs, it is often
necessary to store values temporarily when performing
calculations. For example; to compare the result of
several calculations one would need to retain the result
of each calculation for the comparison. Storing the
values in variables will accomplish this. The OOPic languages, like most programming languages, uses variables for storing values. Variables have a name that you use to refer to the variable. And they have a value, which contains the data. Unlike other programming languages however, OOPics variables are also Objects. This gives OOPic applications some advantages. The most important advantage is the presence of properties that can use to control the behavior of the variable. Another great advantage is that since the Value of the variable is also an Object property, It can be linked to a Virtual Circuit and accessed by other Objects as well as other computers via the I2C network. In OOPic Basic syntax a variable is declared (or an instance of it is created) with the Dim statement as follows:
You should notice that this is the same syntax used to create the instances of any other type of Object. Each variable must have a unique name specified by the programmer. The Object's name is case insensitive and is the identifier that is used by the application to refer to that variable. The same rules apply to naming variables as are applied to all other identifiers in the OOPic languages. |
||||
|
||||
| The programmer can simplify
programming tasks by breaking programs into smaller
logical components called subprocedures. A subprocedure is a section of a program used
to perform a particular function. It is used when a
particular function must be executed several times from
different points within the program. Generally, a
subprocedure can do anything that can be done in the main
code of the program with the addition of returning to the
point in the program that called it. The use of
subprocedures saves program memory, program-entering time
and makes programs easier to read and debug. The Call command instructs the program to branch to the subprocedure. The last line of the subprocedure must be End Sub. The End Sub statement causes the program flow to go back to the next statement following the Call statement. Each subprocedure must have a unique name specified by the programmer. The subprocedure's name is case insensitive and is the identifier that is used by the application to refer to that subprocedure. The only required subprocedure name is "MAIN" which is the subprocedure that is executed when the OOPic is powered up or reset. All variables in OOPic Basic syntax are global. This means that any subprocedure can modify any variable that appears anywhere in the entire program. |
||||
|
||||
The OOPic languages include
system-provided or intrinsic functions, like Sin. A function is a procedure that can take an
argument, perform a calculation and return the value of
its result. To use a function, the procedure name and
its argument in an expression form are typed into
the code. For example, you could use the Sin function to get the Sine of an angle
|
||||
|
||||
Control structures allow you to
control the flow of your programs execution. If
left unchecked by control-flow statements, a
programs flow will "fall" through all of
the statement until reaching the bottom of program. While
some very simple programs can be written with this
unidirectional flow, most of the utility of any
programming language comes from its ability to change the
statements execution order with structures and loops.Flow ControlFlow Control statements allow the program to change the point of execution. The Flow Control structures that OOPic Basic syntax supports are: Decision StructuresDecision Structures are statements that can test conditions and then, depending on the result of that test, perform different operations. The condition is usually a comparison, but it can be any expression that evaluates to a numeric value. The evaluation interprets this value as True or False; a value of 0 is False and a value of not 0 is True. The constants cvTrue and cvFalse can be used in your code in place of 0 or 1. The decision structures that OOPic Basic syntax supports are: Loop StructuresLoop structures allow you to execute one or more lines of code repetitively. The loop structures that OOPic Basic syntax supports are: |
||||
|
||||
| As you write code, you may often wish to include some commentary to the code about the insight you had when you wrote the program. The statement Rem tells an application written in OOPic Basic syntax to do nothing with the words following the Rem statement. Comments can follow a statement, or can occupy an entire line. | ||||
|
|||||||
What is OOP? |
|||||||||||
| OOP is an acronym for Object-Oriented
Programming. It is a term used to identify languages that
are oriented towards the use of Objects. Object-Oriented Programming, in reality, is just a concept. It is an effort to make the task of writing computer programs easier by allowing the programmer to write applications that interact with what appears to be physical objects. Technically speaking, the Objects in an OOP language are combinations of code and data that are treated as a single unit. Each Object has a unique name and all references to that object are done by that name. In OOPic, all the hardware I/O and the Virtual Circuits are done by using Objects, even variables are Objects. |
|||||||||||
|
|||||||||||
An Object-Oriented Programming language is advantageous because humans instinctively know how to interact with physical objects. By arranging a programming language so that a programmer can interact with cyber objects in the same way, the learning curve is reduced significantly. In most computer languages, the processing and program functionality is found in the form of several dozen or so unrelated commands and keywords that need to be memorized. Several of these commands and keywords are proprietary and are not found in any other vendor's languages. This creates a situation where it is difficult to keep up with all the different "flavors" of a language. In OOP languages, all of the processing and functionality has been moved to the Objects. The language itself can then be reduced to just the commands and statements that are necessary to handle the program flow and Object manipulation. This results in a reduced instruction set which in turn results in less to memorize. In older programming languages, the processing was sequential throughout the application. With the processing moved to the Objects, the application becomes multi-tasking with each Object handling its own processing leaving the application to simply managing the Objects. In OOPic, Objects are the fundamental way in which an application interacts with its environment. When an application is being created using OOPic, the programmer only needs to remember a small set of flow-control commands and how to interact with the Objects that his application uses. |
|||||||||||
|
|||||||||||
Because the Objects in the OOPic environment encapsulate the functionality of the hardware found in the PIC16C74 IC, an application can interact with the hardware quickly. This is in contrast to the alternative, which would be working with a long list of memory locations that represent scattered bits and pieces of the same hardware. An Object also provides multitasking code that interacts with the application program, hardware, and other Objects. This essentially provides the programmer with pre-written code libraries. For example, one could use an oA2D Object to read the voltage present at one of the I/O Lines on the OOPic. By simply creating an oA2D Object and setting its properties, the application would have a value available to it that represents a numeric scale of a voltage. There is no need for the programmer to be worried about how to actually do the analog to digital conversion, because the Objects multi-tasking code takes care of that. Because Objects are multi-tasking, an OOPic application can interact with several pieces of hardware at the same time. This means that your applications don't have to stop doing one thing just to go do something else. By linking Objects together, an application can create a Virtual Circuit. A Virtual Circuit is a circuit in an OOPic that appears to be a discrete, physical electronic circuit but is actually the Objects within the OOPic emulating the functionality of the circuit. Virtual Circuits are created by progmatically linking together a set of Objects in the same methodology as one would physically link together a set of electronic components. Once created, each individual part of the virtual circuit can be manipulated or evaluated by the program providing total computerized control of the entire circuit. The following table
describes the types of Objects you can use in OOPic
languages.
|
|||||||||||
|
|||||||||||
A single statement in the application's code creates an Object . In OOPic Basic syntax, the programmer would use the Dim statement in his application to do this. The Dim statement expects the programmer to specify a unique name for the new Object and what kind of Object it should be. Then, when the application is run and it encounters this statement in code, an instance of that type of Object will be created. The following example demonstrates the statement used to create an instance of an Object where the Objects name would be "XYZ" and the Objects type would be oByte. OOPic has several different types of Objects that an application can create. Each one of these different types has what is called an Object class. An Object class defines how each Object works. To understand the relationship between an Object and its class, think of an automobile and its blueprints. The blueprints would be the class, because it defines the characteristics of each car - for instance, size, shape and how the car works. This blueprint is then used to create one or more automobiles and the automobiles that are created, would be the Objects. Each Object that is created from a class is considered to be an instance of that class. When an Object is created, it is an identical copy of its class. Once it exists as an individual Object, it can be customized by changing its properties. For example, if you create 3 Objects using the same class, each one of the 3 new Objects is an identical instance of that class. Each of the 3 new Objects shares a common set of characteristics and capabilities (properties, methods, and events), defined by the class. However, each one must be created with a different name and once created, each Object's properties and methods can be separately controlled. All of the Dim statements are required to be at the beginning of the application's program. When the OOPic is initially powered up, or after the OOPic is reset, the Dim statements will be the first items encountered, thus all of the application's Objects will be created and their values initialized before any other code is executed. |
|||||||||||
|
|||||||||||
In the OOPic Basic syntax programming language, an application must declare its intent to create an instance of an Object by using the Dim command. This statement allocates memory out of the free RAM area to hold the instance of the Object. The programmer gives the new Object a name that the application program will use to identify it with. Any attempt made in the application program to refer to an Object that has not yet been created will result in a compile time error and the compilation will not complete. The following example demonstrates the statement used to create an instance of an Object where the Objects name would be "TheNumberThatWeWant" and the Objects type would be oByte. Object NamesEach Object within an application program must have a unique name so that the application program can refer to it. Object Names can be anything so long as they follow standard naming conventions. The following lists the rules of the standard naming convention:
The name of the Object is not stored in RAM and therefore can be any length (up to 32 characters) with out affecting the amount of RAM that gets allocated for the Object's instance. Object Names are case insensitive. I.E. the names: "ThingOne" and "thingone" are recognized as the same Object. Creating Arrays of ObjectsYou can declare and use arrays of Objects by specifying a subscript value in the Dim statement. In the following example two arrays of Objects are being created, the first is an array of 3 oByte Objects and the second is an array of 6 oDio1 Objects. These Objects are now accessed by including the subscript number. In the following example, All the values in BA(1) through BA(6) are added together in Z. Creating Objects from Classes with a variable sizeThe class definition of the three Objects oBuffer, oGate and oFanout have variable sizes. In the case of the oBuffer Object, the class size specifies how many bytes
long the buffer will be. In the case of the oGate Object, the class size specifies how many
inputs the gate function will have. In the case of the oFanout Object, the class size specifies how many
outputs the fan-out function will have. Refer to the OOPic technical guide for a list of Object classes. |
|||||||||||
|
|||||||||||
| OOPic Objects supports properties,
methods, and events. You can change an Objects
characteristics by changing its properties. In addition
to Properties, Objects have methods. Methods are a part
of Objects just as properties are. Generally, methods are
actions that are perform on the Object, while properties
are the attributes you set or retrieve. Objects also have
events. Events are triggered when some aspect of the
Object is changed and program code is executed in
response to this change. Once an instance of an Object has been created, all references to that instance are done by specifying its name followed by a period and then the property or method that you want to reference. |
|||||||||||
|
|||||||||||
An Objects properties are the
values that it holds. These properties can be numeric
values for storage or specifying what to do or even for
indicating that something was done.Setting Property ValuesYou would set the value of a property when you want to change the behavior of an Object. For example, you change the Direction property of a oDio1 Object to specify whether you want the I/O Line to be an input or an output. To set the value of an Object's property, specify the Object's name followed by a period and then the property to set. The Following shows the syntax of setting an Object's property to a value:
The following example demonstrates a property being set: In this example, an Object named ThingA is told that its IOLine property is to be set to 1 and its Direction property is to be set to 1, (cvInput). cvInput is a constant that equals 1. Therefore, after this example is executed, the Direction property of the Object with the name "ThingA" is equal to 1. When the Direction property of an oDio1 Object is 1, the Value property of that Object is updated with the electrical state of the I/O Line 1. Some Objects have properties that are read only. These Objects generally have done some calculations to derive at the value set in the property and writing to them would only erase these values. Getting Property ValuesReading the value of a property is done when the application program needs to find the state of an Object. For example, a program can determine whether or not a voltage is present at an I/O Line by reading the Value property of a oDio1 Object which points to that I/O Line. To get the value of an Object's property, specify the Object's name followed by a period and then the property to get. The Following shows the syntax of getting an Object's property value:
In the following example the value of one oDio1 is read, and a second oDio1 is set to its value. A property value can also be used in a complex expressions. In the following code example, MyNumber is set to either 0 or 5 depending on whether or not there was a voltage present on the I/O Line at the time the statement is executed. Using Default PropertiesMany Objects have default properties. Default properties can be used to simplify the applications code, because the code does not need to refer explicitly to the default property when setting or retrieving the value. The default property can be set when the Object is dimensioned. For an Object where Value is the default property, the following 2 code fragments are equivalent:
And
Variable and Hardware type Objects will always use Value as the default property. Not all Objects have a default property, in these cases, specifying the properties will always be required. In the following 2 code fragments, the value of the variable Q is incremented by one.
And Objects that are used in a Virtual Circuit and are connected to other Objects will use the default properties of the Objects they are connected to, except in the case of explicitly pointing to an Objects flag properties. Refer to the OOPic technical guide for a list of Object properties. |
|||||||||||
|
|||||||||||
A method is an action that an Object can perform. When invoked, they instruct the Object to do a specified function. Using Methods in CodeYou would use a method when you want the Object to perform a specified function. For example, an Object will increase its Value property by 1 when the Inc method is invoked. To invoke an Object's method, specify the Object's name followed by a period and then the method to invoke. The Following shows the syntax of invoking an Object's method.
The following example demonstrates a method being invoked.: In this example, an Object named ThingA is told that to set its Value property to 1. The Clear method is then invoked which sets the Object's Value property to 0. Refer to the OOPic technical guide for a list of Object methods. |
|||||||||||
|
|||||||||||
An Event is any action that has happened within an Object. Often, an application program will need to perform a procedure when a particular Event has occurred. The oEvent ObjectThe oEvent Object is a special OOPic Object that will execute a specified sub procedure when it's Operate property is set to 1. The oEvent Object's Operate property can be linked to a Virtual Circuit allowing any event in the OOPic to trigger events. |
|||||||||||
|
|||||||||||
Connections between OOPic Objects give the programmer the ability to build a Virtual Circuit within the OOPic. Several of the Objects defined in the OOPic languages are capable of manipulating the properties of other Objects. This gives OOPic applications the power of a Virtual Circuit. Virtual Circuits can exchange data and do calculations in the background while the application program is focussing on what to do with, and how to react to the state of the Virtual Circuit. For example, in the application note "Driving a stepper motor" a Virtual Circuit is defined that will position a stepper motor at an absolute location. A single variable contains the value of that location and when changed, the stepper motor will turn to the new location. The only code that the application program has to do to turn the stepper motor to a particular location, is assign one variable the value of the new location. The following example demonstrates an assignment like this:
The building blocks of Virtual Circuits are the Processing Objects. These Objects retrieve their input values and store their output values in the properties of the Objects that they are linked to. Objects are linked to other Object through pointers. Pointers are a data type that simply tells one Object where to find the other Object. Two types of pointers exist;
A Pointer to a target Object tells the linked Object where the target Object is. A pointer of this type expects to be set to the Object itself. An Object link using this type of pointer will always set or return the target Objects Value property. A Pointer to a target Objects Flag property tells the linked Object where the Flag property is. A pointer of this type expects to be set to an Objects Flag property. An Object link using this type of pointer will always set or return the target Objects Flag property that it was pointed to. A Link is made between Objects when the Processing Objects pointers are linked to the target Object or its Flag properties. In the following example, two inputs of a oGate Object are connected to two oDio1 Objects. Pointer types and the Objects property types must always match. In the previous example, the pointer types are matched. The input properties of an oGate Object must always be connected to Flag properties and the Value property of a oDio1 Object is a Flag type property. |
|||||||||||
|
|||||||||||
The OOPic programming language has the ability to communicate and exchange data with the Objects within an entirely different OOPic. This is helpful when you dedicate one OOPic to do a particular function and want to control its activities from another OOPic or other computer. The OOPic uses the Philips I2C two wire network to transfer information about the values within the Objects to other computers hooked into the I2C network. Up to 127 different components can be collectively connected to this network by attaching 2 wires and a ground reference. No specialized cables or components are required to use the I2C network. For further information on the Philips I2C network, see the link to the Philips web sight at http://www.oopic.com |
|||||||||||
|
|||||||
What are Variables? |
|
| As discussed in Chapter 5,
"Programming Fundamentals", Variables are
used to store values. In most languages, variables are
just a storage area that holds a single value. In the
OOPic languages, however, variables are Objects that
store a value. This is done so that each variable may
have more properties than just its value. This gives
OOPic applications some advantages. The most important
advantage is the presence of properties and methods that
can use to control the behavior of the variable. Another
great advantage is that since the Value of the variable
is a property, other Objects as well as other computers
via the I2C network can access it. (See Chapter 6, "Introduction to
OOP" for more information on how to create
Variable Objects and use their properties and methods.) OOPic provides you with several variables of different sizes and types of Variables to accommodate the needs of your program. |
|
|
|
| The oBit, oNibble, oByte and oWord Variables are
used to store values. Each of the 4 different Variables
types work approximately the same, but the magnitude of
the Value property is of different sizes. Each Variable that is declared in an application will occupy an amount of memory within the OOPic, and it is always best to use the least amount of memory possible in any application. Therefore, to select the type of Variable to use when needing to store a value, determine the highest value that will be needed and select the Variable type with the lowest Bit-size that will still be able to hold that highest value within its magnitude. These Variables all have a Flag-type NonZero property that indicates when the variable is not zero in value. The two Variables, oByte and oWord have a Flag-type MSB property that indicates the state of the Most Significant Bit of the Value Property. The oBit Variable has the unique feature of having its Defalut property also be a Flag-type property. The Flag-type properties can be linked in Virtual Circuits with Flag-Pointers. (See Chapter 9, "Virtual Circuits" For more information on linking Flag-type properties to Virtual Circuits) |
|
|
|
| The oBuffer
Variable is used to store a contiguous group of bytes. It
can be defined with as little as 1 byte or as many as 32
bytes of storage. The Value property of the oBuffer Variable is a 1-byte value that access one of the elements in the contiguious group of bytes. The element that the Value property accesses is specified by the Location property. |
|
|
|
| The oEEProm
Variable is used to store or retrieve data from
non-volatile memory located within the EEPROM memory
chips plugged into the E0 and E1 sockets on the OOPic. Care must be taken when using this Object, as it has the power to access and change the currently running application program. |
|
|
|
| The oRam
Variable is used to access any one of the 256 locations
within the OOPic processor chip. Extreme care must be taken when using this Object, as it has the power to access and change critical OS operations. |
|
|
|
| A Constant is a value that is given a name. Like a Variable, a constant is referred to in code to retrieve its value. However, unlike a Variable, its value can only be defined once within the code and cannot be changed during program execution. | |
|
|||||||
OOPic's Hardware Interface |
||||||||||||||||||||||||||||||||||||
The OOPic is designed to be used in embedded applications. these are applications in which a stand-alone processor is required to control some form of hardware. To accommodate this, the OOPic has thirty-one I/O lines that can be used in various ways. Each of the thirty-one physical I/O lines can both sink and source 25mA. I/O Lines 8 15 have an internal pull-up resistor that can be activated with the Pullup property of the OOPic Object. and I/O Lines 16 31 are Schmidt Trigger type inputs when in the input mode. These I/O lines are controlled by a set of special Objects referred to as Hardware Objects. The Following table shows the electrical characteristics for all the OOPic's I/O lines.
The voltage regulator on the OOPic is a TO-92 case 7805 +5 Volt regulator and is rated at 100 Ma. If more power is needed, a +5 voltage source can be supplied on the +5 lines of the 40 Pin I/O connector. Hardware Objects are Objects that encapsulate the functionality of the physical hardware circuits within the OOPic. They interface with the physical hardware circuits connected to the OOPic and provide an application program with a hardware interface that has the capability of controlling and respond to that hardware. Hardware Objects are the one and only method the OOPic uses to provide hardware I/O. |
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| Like all other Objects, Hardware Objects must be
created before they can be used. In Basic syntax, this is
done with the Dim statement. The Dim statement expects
the programmer to specify a unique name for the Object
and a Class specification to tell what kind of Object to
create. For more information on using the Dim statement,
refer to Chapter 3. There are 11 Classes of Hardware Objects built into the OOPic. The following list shows the 11 different types of Hardware Objects available.
Although more that one instance of any hardware Object is allowed, Only one instance of a Hardware Object will properly interact with any one specific hardware circuit at any given time. |
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| The oDio1 Object class defines an
Objects that uses one of the OOPic's thirty-one
Input/Output Lines. Each dimensioned instance of the oDio1 Object has an IOLine property that specifies which one of the OOPic's thirty-one physical I/O lines it is to use. This property must be set prior to any other property being set. Setting the IOLine property to 0 results in the oDio1 Object entering an dormant state. The following table shows the possible values for the IOLine property.
The Value property of the oDio1 Object continuously reflects the electrical state of the I/O Line specified by the IOLine property. If the Direction property is set to cvInput, then the Value property reflects the physical I/O Line and if the Direction property is set to cvOutput, then the physical I/O Line reflects the Value property. The following table shows the possible values for the Value property.
For more information on the oDio1 Object, See the oDio1 Technical Information. |
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| The oDio4 Object class defines an
Objects that uses a group of 4 consecutive lines of the
OOPic's thirty-one Input/Output Lines. Each dimensioned instance of the oDio4 Object has an IOGroup and a Nibble property that specifies which one of the six possible I/O line configurations it is to use. These property must be set prior to any other property being set. Setting the IOGroup property to 0 results in the oDio4 Object entering an dormant state. The following table shows the possible values for the IOLine property.
The Value property of the oDio4 Object reflects the electrical state of the I/O Lines specified by the IOGroup and Nibble properties. If the Direction property is set to cvInput, then the Value property reflects the physical I/O Lines and if the Direction property is set to cvOutput, then the physical I/O Lines reflect the Value. The following table shows the possible values for the Value property.
For more information on the oDio4 Object, See the oDio4 Technical Information. |
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| The oDio8 Object class defines an
Objects that uses a group of 8 consecutive lines of the
OOPic's thirty-one Input/Output Lines. Each dimensioned instance of the oDio8 Object has an IOGroup property that specifies which one of the three possible I/O line configurations it is to use. This property must be set prior to any other property being set. Setting the IOGroup property to 0 results in the oDio8 Object entering an dormant state. The following table shows the possible values for the IOLine property.
The Value property of the oDio8 Object reflects the electrical state of the I/O Lines specified by the IOGroup property. If the Direction property is set to cvInput, then the Value property reflects the physical I/O Lines and if the Direction property is set to cvOutput, then the physical I/O Lines reflect the Value. The following table shows the possible values for the Value property.
For more information on the oDio8 Object, See the oDio8 Technical Information. |
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| The oDio16
Object class defines an Objects that uses a group of 16
lines of the OOPic's thirty-one Input/Output Lines. Each dimensioned instance of the oDio16 Object has an IOGroup property that specifies if it is using its predetermined I/O line configuration. This property must be set prior to any other property being set. Setting the IOGroup property to 0 results in the oDio16 Object entering an dormant state. The following table shows the possible values for the IOLine property.
The Value property of the oDio16 Object reflects the electrical state of the I/O Lines specified by the IOGroup property. If the Direction property is set to cvInput, then the Value property reflects the physical I/O Lines and if the Direction property is set to cvOutput, then the physical I/O Lines reflect the Value. The following table shows the possible values for the Value property.
For more information on the oDio16 Object, See the oDio16 Technical Information. |
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| The oDio16x
Object class defines an Objects that uses a group of 8
and a group of 3 lines of the OOPic's thirty-one
Input/Output Lines but provides 16 Inputs and 16 outputs
through multiplexing. For more information on the oDio16x Object, See the oDio16x Technical Information. |
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| The oA2D
Object class defines an Objects that uses 1 Input line of
the OOPic's thirty-one Input/Output Lines and
encapsulates the OOPic's analog-to-digital converter
module. The analog-to-digital converter (A/D) module allows conversion of an analog input signal to a corresponding 8-bit digital number. The A/D module has four analog inputs available on the OOPics I/O lines 1 4, which are multiplexed into a single sample and hold register. The sample and hold register is the input into the converter, which generates the result via successive approximation. The ExtVRef property of the OOPic Object determines the analog reference voltage, which is selectable to either 5 volts or the voltage level supplied on the OOPics I/O line 4. For more information on the oA2D Object, See the oA2D Technical Information. |
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| The oPWM
Object class defines an Objects that uses 1 Output line
of the OOPic's thirty-one Input/Output Lines and
encapsulates the OOPic's Pulse-Width-Modulator module. The Pulse-Width-Modulator (PWM) module provides an output that rapidly switches between on and off. The ratio between the On time and the Off time is controllable. The larger the ratio is, the more current will flow from the output and the smaller the ration is, the less current will flow from the output. This creates an output who's output current is controllable. For more information on the oPWM Object, See the oPWM Technical Information. |
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| The oSerial
Object class defines an Objects that uses 1 Input line
and 1 Output line of the OOPic's thirty-one Input/Output
Lines and encapsulates the OOPic's serial communication
(SC) module. The serial communication (SC) module provides a high-speed serial communication port capable of communicating at 1200, 2400, 9600 and 31250 BPS. It can be configured as full duplex asynchronous or synchronous and can communicate with serial devices such as CRT terminals and personal computers. It uses the standard non-return-to-zero (NRZ) format asynchronous mode, (one start bit, eight data bits and one stop bit). The SC module transmits and receives the lowest significant bit first. The SC modules transmitters and receiver are functionally independent but use the same data format and baud rate. The outputs of the SC module are TTL levels. To convert the TTL serial signals of 0 - 5 Volts to the RS232 Serial signals of +/- 12 Volts, any TTL to RS232 chip such as the SN75188 or the MAX203 can be used. For more information on the oSerial Object, See the oSerial Technical Information. |
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| The oTimer
Object class defines an Objects that uses 1 Input line of
the OOPic's thirty-one Input/Output Lines and
encapsulates the OOPic's Timer module. The Timer module provides a 16 bit hardware counter who's input can be configured as an input line on the OOPic. The input line can be used a standard TTL level input or can be configured to drive a crystal. For more information on the oTimer Object, See the oTimer Technical Information. |
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| The oKeypad
Object class defines an Objects that uses 8 lines of the
OOPic's thirty-one Input/Output Lines and encapsulates
the OOPic's Keypad matrix controller module. The Keypad Matrix Controller module provides the matrix scanning pattern needed to read a 4 x 4 matrix keypad. For more information on the oKeypad Object, See the oKeypad Technical Information. |
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| The oServo
Object class defines an Objects that uses 1 Output line
of the OOPic's thirty-one Input/Output Lines and
encapsulates the OOPic's Servo Motor (SM) control module. The Servo Motor (SM) control module provides the PWM control pulse that is required to electrically refresh a servo motor's position. The SM control module can output the PWM control pulse on any of the OOPic's 31 I/O Lines specified by the IOLine property. For more information on the oServo Object, See the oServo Technical Information. |
||||||||||||||||||||||||||||||||||||
|
|||||||
What is a Virtual Circuit? |
|||
| A Virtual Circuit is a circuit in an OOPic that
appears to be a physical discrete electronic circuit, but
is actually the OOPic operating system emulating the
functionality of the circuit. A Virtual Circuit can be comprised of any number of any kind of Objects so long as at least one Processing Object is included. Each individual part of the Virtual Circuit can be manipulated or evaluated by the program providing total computerized control of the entire circuit. |
|||
|
|||
| Virtual Circuits are created by progmatically linking
together a set of Objects in the same methodology as one
would physically link together a set of electronic
components to assemble an electronic circuit. The
application's program can assemble, disassemble, or
reconfigure the structure of a Virtual Circuit at any
time during the execution of the program. The Objects that are used to link together the Virtual Circuits retrieve their input values and store their output values in the properties of other Objects. These Objects are referred to as Processing Objects. These Objects encapsulate various mathematical, logical and other data manipulation functions. When they are linked to other Objects, their encapsulated function is performed on the "Linked" Objects. The Link that specifies what Objects are used, is done with a special Object Property called a Pointer. |
|||
|
|||
| To progmatically link together the Objects of a
Virtual Circuit, The Link
method is used in conjunction with the Objects and
properties that are to be connected. This method creates
a link between a two Objects. Once a link is created, the
linking Object will use the linked property's value. While other methods are used to instruct Objects to perform operations, the Link method is used to instruct a Pointer Property to point to another Object's property. The syntax for the Link method is as follows;
The Link method is only available on properties that are designated as a Pointer Property. |
|||
|
|||
| A Pointer Property is an Object's Property that tells
that Object where to find information in another Object.
It does not store the information itself, instead each
time the information is needed, the Pointer Property is
used to identify where to retrieve the information
from. The Object's property that a Pointer Property is linked to can be changed at any time during the execution of the applications program. Two types of Pointer Properties exist;
When Linking Pointer Properties to Objects properties, the Pointer Property's type and the Object property's type must always match. |
|||
|
|||
| An Object-Pointer is used to link a Processing Object
to the Default Property of another Object. When linking a
Pointer Property of this type, The argument that is
expected inside a set of parentheses after the link
method is the Target Object's Name plus a period and the
Target Object's Default Property or just the Target
Object's Name The Default Property of an Object is the property that will be used if none is specified when referring to that Object. To find out which Object's properties are Default Properties, refer to the Object's Technical Information where each property's Data-Type is specified The following example shows the Object-Pointers of the oMath Object being linked to the default properties of two other Objects.
|
|||
|
|||
| A Flag-Pointer is used to link a Processing Object to
a Flag-type Property of another Object. When
linking a Pointer Property of this type, The argument
that is expected inside a set of parentheses after the
link method is the Target Object's Name plus a period and
the desired Target Object's Flag-type Property. A Flag-type Property is a property that consists of 1-bit and is configured in such a way to be able to be linked to. To find out which Object's properties are Flag-type Properties, refer to the Object's Technical Information where each property's Data-Type is specified The following example shows the Flag-Pointers of the oGate Object being linked to the Flag-type properties of two other Objects.
|
|||
|
|||||||
What is the OOPic Object. |
|
| The OOPic
Object is an intrinsic Object that controls the OOPic's
operating system. Several properties are provided that
either control operating system functions or report
operating system status. The OOPic Object is the only
Object that is intrinsic. Since the OOPic Object is intrinsic, it is always present in every OOPic application and the application programmer does not need to dimension it. |
|
|
|
Four properties are provided to control the OOPic's
Operating System:
The Node property is a value that is used to specify the OOPics network node when two or more OOPics are connected via the I2C network. The Operate property is a value that controls the power mode of the OOPic Chip. The Pause property is a value that suspends the program flow. The Reset property is a value that resets the OOPic when set. |
|
|
|
Three properties are provided that report system
status.
The Hz1 property is a value that cycles every 1hz. The Hz60 property is a value that cycles every 60hz. The StartStat property is a value that indicates the cause of the last OOPic reset. |
|
|
|
Two miscellaneous properties are provided that
control miscellaneous hardware functions.
The ExtVRef property is a value that specifies the source of the voltage reference for the OOPics analog to digital module. The PullUp property is a value that specifies the state of the internal pull-up resisters on I/O lines 8 - 15. |
|
|
|||||||
OOPic Mathematics |
|||||||||||||||
| Any mathematical formula that needs to be solved while an application's program is running, requires that it be written out as an Expression in the program's code. | |||||||||||||||
Expressions |
|||||||||||||||
| An Expression is a written mathematical formula that
details the values, operations and functions as well as
the order that the operations and functions are performed
in order for the formula to be solved. The resulting
value of the mathematical formula is the final value
derived after all of the formulas operations and
functions have been executed. An Expression can be a single value or variable, or it can be comprised of several values and variables separated by Operators and functions. Expressions can be used in the following situations:
If an Expression is comprised of more than one value or variable, then it is evaluated from left to right, performing, in the order of precedence, the operators and functions that it encounters. |
|||||||||||||||
Operators |
|||||||||||||||
| Operators are used to specify that a mathematical
operation needs to be performed between two values. They
are always performed by applying the value on the right
side to the value on the left side in the manner
specified by the operator. The following is a list of Operators.
In the following example, the variable "A" is assigned the value of the Variable "B" plus the value of the variable "C" minus the value of the variable "D"
|
|||||||||||||||
Precedence of Operators |
|||||||||||||||
| The precedence of operators determines the order in
which mathematical operations are executed. OOPic
languages follow the operator precedence rules of
algebraic expressions. These rules dictate that the
expression is scanned from left to right and that no
operation is performed until it encounters an operator of
lower or equal precedence. The following list defines OOPic's order of precedence:
Parenthesized expressions have the highest precedence, so their use is a good way for you to reduce ambiguity and make your programs more readable. In the following example, the variable "A" is assigned the value of the Variable "C" divided by the value of the variable "D" plus the value of the variable "B"
In the following example, the variable "A" is assigned the value of the Variable "B" plus the value of the variable "C" divided by the value of the variable "D"
|
|||||||||||||||
Arithmetic Operators |
|||||||||||||||
The Arithmetic Operators perform basic arithmetic
functions between two values.
|
|||||||||||||||
Logical Operators |
|||||||||||||||
The Logical Operators perform the bitwise logic
functions between two values
|
|||||||||||||||
Relational Operators |
|||||||||||||||
The Relational Operators perform comparisons between
two values.
|
|||||||||||||||
Functions |
|||||||||||||||
| Functions are used to when one value needs to be
convert from one form to another. They are performed by
applying the value within the functions parenthesis to
the conversion process specified by the function. The following is a list of Function.
|
|||||||||||||||
|
|||||||
What is Dynamic Data Exchange? |
|
| Dynamic Data Exchange is a function that allows two
or more OOPics to exchange data. This exchange of data is
accomplished by a Virtual Circuit that utilizes oDDELink Objects
to transfer data over an I2C Network. While other processing Objects are used to create Virtual Circuits that manipulate and exchange data with Objects within the same OOPic, the oDDELink Object is designed to utilize the I2C network to exchange data with other OOPics. |
|
|
|
| The oDDELink
Object is a Processing
Object that dynamically exchanges data between two OOPics
by transmitting data over an I2C network of which both
OOPics are connected. It can be configured to both send
and receive data. Any properly configured oDDELink Object can initiate a data transfer by setting the Sync property to 1 (cvTrue), thereby causing the data to be either sent to or retrieved from other oDDELink Objects in the network depending on the state of its Direction property. |
|
|
|
| A working knowledge of Virtual Circuits is necessary
to understand how the oDDELink
Object functions. If you have not done so already,
read Chapter 3 - Your First
Virtual Circuit and Chapter
9 - Virtual Circuits. In order for a Virtual Circuit to be capable of transferring data over the I2C network, an oDDELink Object must be included and linked to other Objects within the OOPic. Each Occurrence of the oDDELink Object has two pointer properties which are used to link to the Objects which contain the data to be transferred. The oDDELink Object retrieves the data to be transferred from the Object linked to by the Input property and the Output property links to the Object that the transferred data will be stored into. The oDDELink Object's Sync property, which initiates the data transfer, is a Flag type property and can be controlled by the Virtual Circuit by linking it to other Flag-pointer properties within the Virtual Circuit. |
|
|
|
| Each OOPic connected together via an I2C network must
be differentiated by a unique Node number. The OOPic Object's Node
property is used to specify this number. This is
the identifier that the I2C network uses to properly
route the data when an DDELink transfer is made. The OOPic.Node property must be set to a number greater than 0 to turn on the OOPic's network functions. Once the Node number is set, the I2C network is enabled and starts to listen for incoming data packets. If the OOPic.Node property is set back to 0 (cvOff), the I2C network is disabled and any incoming data packets are ignored. It is important to remember to enable the I2C network in both the Master application and the Slave application before the applications attempt to transfer data. The oDDELink Object also has a Node property. This property specifies which OOPic the oDDELink Object is going to be communicating with. |
|
|
|
| When two OOPics exchange information, they do so by
engaging in a DDE conversation. The application that
initiates the conversation is called the
"Master-Application", or just the
"Master"; and the application responding to the
Master is the "Slave-Application", or just the
"Slave". An application can be configured to
engage in several conversations, acting as the Master in
some and the Slave in others. A single oDDELink Object can operate as both the Master and the Slave in a DDELink conversation. In addition, it can act as the Master in a DDELink conversation with one OOPic, and the Slave in an entirely different DDELink conversation with a different OOPic. To initiate a DDELink conversation, the oDDELink Object that is to be used as the Master must be properly configured, pointing to the Node and Location of the Slave oDDELink Object with the Operate property set to 1. Once it is configured, setting the Master's Sync property to 1, initiates the DDELink conversation which synchronizes its data with the Slave. |
|
|
|
| The Master oDDELink
Object always controls the DDE conversation. Whether it
is sending data to, or receiving data from the Slave, the
Master always initiates the conversation. In order for the Master to activate a DDE conversation, it must be configured to specify which OOPic it intends to communicate with and the location of the Slave oDDELink Object within that OOPic. To specify the OOPic that it intends to communicate with, it must set the Master oDDELink Object's Node property to the same number that the Slave application's OOPic.Node property has been set to. To specify the Slave oDDELink Object's location, it must set the Master oDDELink Object's Location property to the same number that the Slave oDDELink Object's Address property is set to. Note: The Address property of all Objects is set when the application is compiled and cannot be changed by the application's program. In order for the Master to send data, its Input property must be linked to the Object that contains the data to send, and in order for it to receive data, its Output property must be linked to the Object to store the received data into. How the Master oDDELink Object operates:When an oDDELink Object's Sync property is set to 1 (cvTrue), it first checks to see if its Operate property is also 1 (cvTrue). If it is not, the oDDELink Object remains dormant. If, on the other hand, the Operate property is 1, then the Node and Location properties are checked. If either property is 0. then the operation is canceled. If, on the other hand, they are set to values of more than 0, then the DDELink conversation is initiated. Once a DDELink conversation begins, the Master checks to see how the Direction property is set. If it is set to 0 (cvSend), then the Master sends data to the Slave, and if it is set 1 (cvReceive), then the Master receives information from the Slave. When the Master sends data to the Slave, it retrieves the data to send from the Object that its Input property was linked to. It then sends this data to the Slave which then stores the data into the Object that its Output property is linked to.. When the Master receives data from the Slave, it first sends a request to the slave, which instructs the slave to retrieve the data out of the Object that its Input property is linked to. The Master then draws this data out of the Slave and stores it in the Object that its Output property is linked to. The following is an example of an OOPic application that uses a Master oDDELink Object in a Simple Virtual Circuit. |
|
|
|
| The Slave oDDELink
Object continuously monitors the I2C network for DDELink
communications from a Master oDDELink
Object. Until it detects a DDELink conversation
request from the Master, it remains dormant. In order for the Slave to engage in an DDELink conversation, it only needs to have its Input and Output properties configured to operate. The Slave's Operate property does not need to be set to 1 (cvTrue) in order to respond to the masters instructions. How the Slave oDDELink operates:When the Slave oDDELink Object is engaged in a DDELink conversation by the Master, it will respond by either sending data to the Master or by receiving data from the Master. If the Master is requesting data from the Slave, then the Slave responds by retrieved data from the Object pointed to by its Input property, which is then sends to the Master. If the Master is sending it data to the Slave, then the Slave will wait until the data packet has been received, Once it has the full packet of data, the Slave DDELink Object will copy that data into the Object pointed to be the Output property. The following is an example of an OOPic application that uses a Slave oDDELink Object in a Simple Virtual Circuit. |
|
|
|
| The I2C network is built in to the hardware of the
OOPic, and runs at 19,200bps. It has 2 5-Pin
Network Connectors available on the OOPic's
circuit board which consists of the 5 lines; I2C Serial
Data (Data), I2C Serial Clock (Clock),
Ground (Gnd), +5 Volts (+5V)
and Reset (Rst). The pin out of the 2
5-Pin Network Connectors are identical and can be used to
daisy chain the networked OOPics together. When connecting OOPics together with the I2C network, the 3 lines; Data, Clock and Gnd must be connected to each OOPic on the network, the 2 lines; +5V and Rst can be optionally connected depending on the applications need's. A 4.7k pull up resistors is required on both the Data & Clock lines for the network to operate properly. If the Rst line is connected to each OOPic on the network, then when any OOPic's Reset button is pressed, all of the connected OOPics will also reset. Note: Setting the OOPic.Reset property to 1 (cvTrue) in any of the network OOPics does not pull the Rst line low, and therefore will not reset all the OOPics on the network. |
|