"MeccanIC, the software".
Version 0.5/00/00
Some very preliminary ideas and disclosures.
Copyright 2004 by Harprit Singh Sandhu

23 March 2004:
All rights to the word and logos for
MeccanIC are reserved by Harprit Singh Sandhu of Champaign IL USA. The information in this system description is the copyrighted intellectual property of the author but may be reproduced without permission if proper credit of ownership is included in the copy or any portion thereof. All the rights associated with it including copyright and trademark rights are reserved by Harprit Singh Sandhu of Champaign Illinois, USA. 2004.

The word MeccanIC is a combination of the Meccano and BASIC and is always written with the I and the C capitalized.

MeccanIC is the language for controlling Meccano mechanisms. Its only purpose is to allow the control of machines and mechanisms developed with the Meccano and similar systems. This description of the language is very preliminary and is intended for distribution over the internet for discussion purposes and for input from the Meccano community.

MeccanIC will be designed to be as English like as possible to make it easy for any English speaking individual to use it with absolutely minimal learning. The way the language is designed will make it easy to implement it in other languages (meaning French, German, Russian etc).

Example: The following four lines of Code would be enough to control the motor connected to port 1 as follows: Turn on the motor at full speed (power), wait one second and reduce the speed to half speed (power).

SPEED 100
TURNON MOTOR 1
WAIT 1 SECOND
SPEED 50
TURNON MOTOR 1


If there were no other commands, the motor would continue to run at half speed (power).

Software Description
Language name.

Eventually we will need a name for our language. I am suggesting
"MeccanIC" which I have coined as a combination of the Meccano and BASIC. I will design this language to be as similar to BASIC as convenient with the added commands to run and respond to our hardware. There are a number of commands in BASIC that have nothing to do what we are trying to do and we will ignore these, others we will simplify. Since it is now possible to run more than one program on a computer and switch and back forth between the programs with a click of the mouse, I am going to suggest that we omit all printing and editing functions from the program. This will make it shorter and easier to develop our language. We can use a myriad of other programs to provide us the printing and editing functions. Our lives will be much simplified if we do it this way. Later on when things get more sophisticated, generations to come can create MeccanIC II which of course will be compatible with MeccanIC.

Lets propose some simple rules:

Rule 1
The first rule is that the
MeccanIC programs will be pure text files and that text case will be ignored. This means that only text can be a part of the program and we don't care if it is lower case of upper case. The program can be written on any text processor that will allow you to create a pure "text only" file. Since there is some confusion as to what one means by "Text File" the official list of acceptable ASCII codes will be provided in an Appendix and may be amended by the committee on MeccanIC standards (which we will constitute at some future date).

Rule 2
Our only concern is with the response to and control of a number of defined devices that we can add to a
Meccano system. In general let us agree that these devices consist of the list above so we can assign proper identification variables to them in the language.

Rule 3
The language must be written a language which has the property that its files can be executed both on a Wintel (Windows/Intel) machine and on a Macintosh without having to change the code. I am going to do all the development in RealBASIC which is available for both the Mac and the PC and the files can be moved back and forth painlessly. Mostly this means that we will not use "C" to write the language. "C" is really powerful and fast but very hard to maintain and understand.

Rule 4
All communications between the computer and the controller shall be RS-232C serial communication at either 9600 or 19200 baud. Communications need to be in both directions simultaneously. Only three wires shall be needed. (ground, transmit, receive)

Rule 5
All of the above may need to be modified when we get to the point of selecting a suitable microprocessor that we can all afford to buy and (very important) for some one, who understands our needs, to program.

Rule 6
We all agree that this is an open system. The listings of all the source code will be in the public domain. The listing will be maintained on this site for now. Downloads will be available on demand. The standard acceptable version will be agreed to the
MeccanIC committee on a yearly basis. Manufacturers will of course have a seat(s) on the committee.

Role 7

Rule 8

Rule 9

Rule 10

We must understand that in the best of all worlds we all want to have as much as possible and we must all understand that if we want our computer do too much (everything) we will not get anything done. The more we want done the slower everything becomes so compromise is not only the key, it is a must.

Software:
Command list


The
MeccanIC language has over --- instructions, commands and functions. As in most machine control languages, these instructions and commands can be broken up into three main families.

Program control statements. Program control instructions control the program flow and decision making process in the program and such they have no direct affect on the mechanism itself.

Mechanism control statements. Mechanism control statement control interaction with the mechanism in some way. They cause something to happen in the hardware, a motor moves, a signal changes, communications take place, etc. Actions are always specified but something that we can see does not have to happen. For example a mechanism already at a certain position should not move if told to move to that position. A switch that is already on remain on.

Functions. Functions are used to perform calculations and manipulate memory. The functions affect neither program flow or mechanism movements directly. They are mathematical and logic functions that we need to make the system more useful and may not need to be implemented in initial versions of the software (Math libraries can usually be purchased).

These three families of commands are listed below.

Program Control Statements
BEEP Makes a beep at the computer
CLS Clears the computer 04screen
DISPLAY (ON MODEL) Displays on the two line display
END PROGRAM Marks end of program
FOR……TO…..NEXT…… Standard looping routine
GOSUB functions Standard subroutine call
GOTO line or name tag Standard go to command
IF……THEN.….. Decision making
IFSWITCH.…..THEN.….. Responding to switch
REM Remark statements
RETURN Return from a function
SEND Sends command to
PRINT Prints on computer screen
WAITFOR…..SECONDS Waits for time interval

Mechanism Control Statements
LED 1 to 32 Refers to an LED
MOTOR 1 to 16 Refers to a motor
INSIGNAL 1 to 32 Refers to signals into computer
OUTSIGNAL 1 to 32 Refers to signals out of the computer
SPEED 1 to 100 Refers to % of motor full speed
TURNOFF any device Makes the device go dormant
TURNON any device Makes the device become active
REVERSE any device Reverses the status of the device

Functions
ACOS These are the standard math functions
ASIN and may not need to be implemented
ATAN immediately, the can be added as time goes
COS on. Libraries of code can be purchased so it is
SIN not a problem
TAN
and of course the STANDARD +. -. *, and / FUNCTIONS


IF condition…THEN…do

FOR variable1 = variable2 to variable3 step variable4
NEXT variable1

GOTO line identification number or name

TURNON MOTOR variable
TURNOFF MOTOR variable
TURNON LED
TURNOFF LED
TURNON OUTPUT
TURNOFF OUTPUT
TURNON RELAY
TURNOFF RELAY
TURNON
TURNOFF
TURNON
TURNOFF

Before we look at the language, let us look at what the hardware that this particular language controls looks like so that we can see how the two tie together. The description of the hardware is very cursory in this instance to keep it as short as possible. Only the information needed to understand what the language is controlling is included. See above.


The rest of this chapter contains a cursory description of each command to give you a feeling for what a machine control language looks like and what it does. In this discussion, the arguments of the commands have been omitted to make the discussion easier to understand. Explanatory paragraphs tell you how the function is useful in the MeccanIC context.

As you study these commands, think about how you might design a language to control any machine and therefore make the language as flexible as possible..

ACOS, ASIN, ATAN Inverse Trig. Functions

These three functions accept arguments and return the appropriate trigonometric value as degrees. Since these are functions, they can not be used as commands by themselves but are to be used in assignment statements and expressions. Having these functions available allows you to make calculations that will then be used to effect the operation of the machine.

BEEP Audio Alert

The BEEP command produces a short tone on the host computer's speaker. This can be used to alert the operator that a process has been completed or it can be used as an error condition indicator. This is similar to the beep provided on all computers.

CLS Clear The Screen

CLS is used to clear the screen of the host computer. Any information previously written to the screen will be erased and the cursor will be positioned at the upper left hand corner of the screen. CLS has no effect while the system is in the TRACE mode because that would erase information that is useful in the current context. The use of the screen to display messages and other status information allows the operator to know what is going on within the system. The CRT screen is also used to display all error messages. The screen is where the machine talks to the operator.

COS, SIN, TAN Trigonometric Functions

These three functions accept arguments in degrees and return the appropriate trigonometric value. The variable used to take the value should be a floating point type, if not, only an integer value will result. Since these are functions, they can not be used as commands by themselves but are to be used in assignment statements and expressions. Functions like these increase the utility of the machine by increasing the control that you have over the machine with the program. This is an important point because it allows more powerful control of the machine.

END End Of Program

The END command is used to mark the end of the program. Although the physical end of the program will also cause your program to end, the END command can be used to terminate execution at any point in the program. The END command is useful when subroutines are to be used because they are often located after the end of a program. Without the END command, the program could unintentionally execute the first subroutine it encounters.

ERROR_CHECK Lists Error Stack Contents

The Error_check command displays all the errors that have been stored in the error stack. After Error_check has been executed the error stack will be empty. It is useful to be able to look back and see what errors have occurred within a program to allow one to debug the program. In a powerful language, some errors will not stop the program because they can be considered non-critical. In these powerful systems it might also be possible to turn the stopping feature on and off.

FOR…..TO……..NEXT Program Loop Control

The FOR TO command controls the execution of a group of program lines located between the FOR. ..TO line and the line containing the NEXT statement. This is the standard looping feature that is provided in almost all computer languages. In a machine language it is useful for doing tasks that have to be repeated a number of times. Stacking and filling boxes are examples that might use this command set.

GOSUB Subroutine Call

The GOSUB command is used to call a labeled subroutine. This is similar to the standard subroutine call feature as is provided in almost all computer languages

GOTO Branch To A Label or line number

GOTO is used to transfer program execution to the line with the label (name) specified in the GOTO statement. It should be mentioned that using GOTO commands in now considered bad programming practice because it creates programs that are hard to follow and debug.

IF...THEN... Conditional Execution

The IF....THEN.. statement is used to test a condition and, if that condition is true, perform the statement after the THEN. If the condition is false, the program execution continues with the line following the IF....THEN statement. The conditions tested for are mathematical or relational conditions. This is similar to the use of this command in standard computer languages.

IFSWITCH THEN Conditional Execution

IFSWITCH is similar to both IF....THEN.... and IFSIG....THEN.... except that it is used to test the state of the microswitches located on the machine and the encoded motor accessories (if they are attached). The command is used to move the motor to the home position. The program should be written to find where the microswitch is actuated from each direction and then find the center as the home position.

IFSIG...THEN... Conditional Execution

IFSIG...THEN... is similar to the other IF commands except that it is used to test the state of the input signals coming in to the controller from other devices attached to the controller. This is how the machine responds to what is happening in its environment.

INPUT Input From Computer Keyboard

INPUT allows the user to input, directly from the computer's keyboard, an integer or decimal numerical constant or string and assign that value to a MeccanIC variable. This is useful for entering information in real time. It is also useful for debugging and for other maintenance needs.

OFFLINE Ignore A Motor

OFFLINE is used to tell the system that one or more of the motors are not available for use. No attempt is made to move the offlined motors even when a move request for that motor is received. This command prevents the system from hanging up (because an absent motor never gets to the location it is supposed to move to etc).

ONLINE Activate An Offlined Motor

ONLINE is used to return a motor, that had previously been OFFLINEd (in the same program), back into service.

OUTSIG Output Signal Line Control

OUTSIG is used to turn the output signal lines on the machine controller ON and OFF. This is how the machine communicates with the machines around it in the output mode. These are signals going out from the machine as opposed to signals coming into the machine.

WAIT or PAUSE Delays Program Execution

WAIT or PAUSE is used to delay execution of your program for the specified period of time. This is useful for coordinating the movement of the machine with other machines and for the time that may be needed to allow the gripper to settle down.


REM Remark, Documentation

REM is used to place a comment or remark into the source code of your program. All text between the REM and the end of the line will be ignored by MeccanIC. Adding remarks makes it easier for a person looking at a program listing to understand what the programmer intended to do. Programs should be well documented so that they can be maintained by end users.

RETURN Subroutine Return Statement

The RETURN statement is used to cause a return from a subroutine. All subroutines must have been called using the GOSUB command. After the RETURN has been executed, program execution will begin with the line immediately following the GOSUB that called the subroutine. This is the standard use of the RETURN command.


SEND string Send String To Controller

The Send command sends a string command to the controller. This allows undocumented commands to be sent to the controller. Commands like this add flexibility to the system

SETI Assignment Function

SETI is used to assign a variable an integer value.

TROFF Turn Trace Mode Off

TROFF is used to turn off the trace facility.

TRON Turn Trace Mode On

TRON is used to activate the trace facility. The trace facility displays the contents of critical section of the memory on the screen as you step through the program. This is used in the debugging process.

PRINT Output To The Screen

TYPE is the general output command in MeccanIC. You can use it to output character strings or numeric values to the screen. There are two forms of the command; one for displaying strings, the other for displaying numbers. MeccanIC implements only the most rudimentary ability to print to the screen. The emphasis on the machine language and not on the ability to manipulate information on the screen though this can be expanded on as we get further along.

SPEED Set Motor Velocity

SPEED sets a specified motor's velocity. Controlling the motor velocity keeps certain move command from over speeding a motor. It is also useful for setting heavy parts down gently.

WAITFOR Wait For Signal Condition to become true

The WAITFOR command is used to suspend program execution until the specified input signal conditions are in the specified state.











HOME     MeccanIC INDEX      PREVIOUS SCREEN     NEXT SCREEN

This page created with Cool Page.  Click to get your own FREE copy of Cool Page!
The initial MeccanIC software language description/disclosure.. 
29 Mar 04