MC4 Frequently Asked Questions

Questions and answers from the MC4 tech support archives are gathered and catagorized here for everyone's benefit. The most up-to-date copy of this FAQ will be found online at www.MotionCommander.com.

Topics:




Station Design Questions

How do I enter a number into a TEXT ENTRY, multiply it by 20, and send it to PMAC variable P100?

Pmac.P100={this.ValueA%d*20}

The {this.ValueA} is replaced by the contents of the TEXT ENTRY object. The "%d*20" format code tells MC4 to interpret the text as a decimal number and multiply it by 20. See the "Format Codes for Curly-Bracket Queries" section of the "Command Properties" chapter for more info.

I also want to update the TEXT ENTRY if the value of P100 changes.

Use the query command

Pmac.P100%d/20

Is there a complete list of the '%' formatting codes available?

The "Format Codes for Curly-Bracket Queries" section of the "Command Properties" chapter. Look up "printf" in Wikipedia or a C Language programming book for additional details.

I need a LAMP that queries all the time - not just while its panel is shown.

There are three ways to locate the lamp where it will query all the time. Put it on a "navigation/status" panel that is always on the screen, put it on a panel that has "Z Order=Allow Overlap" so that the panel remains "shown" even when other panels are on top of it, or put it on the station background (which is actually a panel that cannot be hidden).

Instruments on other panels require access to the value of a TEXT ENTRY object, but cannot obtain it when its panel is hidden.

Objects on hidden panels do not respond to commands. If an object on panel2 is trying to query a property of an object on hidden panel1 then nothing will be returned. You can either place the object on the station background or change its panel's "Z Order" property to "Allow Overlap" and then it will always stay un-hidden.

I use a button on Panel1 to show Panel2. The button is still pressed when Panel1 is shown again later.

Use the "Release Command" instead of the "Press Command" for all of your navigation buttons. This will eliminate the issue of a button not releasing correctly when its panel is hidden.

Is there any way to have a persistence function with the XY PLOT so old data disappears?

Specify the number of historical data points you want displayed in the "Buffer Size" property and add "this.Redraw" to any one of your trace query commands. NOTE: This will result in MC4 having to redraw the plot field every update cycle, so you will see your CPU useage increase when you make this change.

Another possibility is to have an object send the "Clear" command to the XY PLOT at a specified interval.

How can I rotate text 90 degrees in a label?

You can't. A "rotation" property for labels is on our ToDo list.

How can I use a TEXT DISPLAY to log messages when a PMAC variable is set?

IF ({Pmac.P100} = 1)
   Pmac.P100 = 0  ; one-shot to display the msg only once
   TD_Log.Value += "\nMessage text"
   RETSTR "Message text"
ENDIF

The line in the above example would append the message text to a second text display object (named TD_Log) which would be the log. Note the "\n" newline code. Alternatively, you can use the "g.LogWin" global commands to add the message to MC4's Message Log window.

Is there a migration tool for converting MC3 stations to MC4?

MC4 is a completely new and modern Motion Commander HMI. Unfortunately there is no migration tool. It would be a huge development effort for a hand-full of customers. Most MC3 customers are still using MC3 for duplicating older machines, but using MC4 for their new projects.

How do I log data to a file like the old MC3 Data Recorder did?

The "g.LogFile=filename,message" command appends a line of text to a file. Use it as a query command, and use the curly-bracket queries and % format commands to write any data you want. Here are some LogFile examples:

g.LogFile=C:\MC4\Stations\FName.txt,{Pmac.P1}
g.LogFile=C:\MC4\Stations\FName.txt,{s.TimerM},{Pmac.P1},{Pmac.P2}
g.LogFile=C:\MC4\Stations\FName.txt,{Pmac.P1%f*12.34}
g.LogFile=C:\MC4\Stations\FName.txt,{Pmac.P1%d&$1000}
g.LogFile=C:\MC4\Stations\FName.txt,{g.Time}  P1={Pmac.P1}

How do I program a MC4 button to turn off the computer?

Use the MC4 command "g.WinExec=shutdown.exe". Read all about the Shutdown utility program and its command line options at "http://support.microsoft.com/?kbid=317371". For example, "g.WinExec=shutdown -s -t 0" would force an immediate system shutdown.

How do I start the station timer when station is first opened?

The station's "Open" and "Close" commands are on the "Design" tab of Station Settings - under the "Edit..." button. Sorry. They are NOT easy to find. Put "s.TimerStart" in the station's "Open Command".

I need global variables like the old MC3 Data Tables.

There are no data tables in MC4. Instead, right-click on any object and add one or more "User Properties" to it. For example, if you add the user property "CalcResult" to an object named "MyButton" then any object can set or query the value of "MyButton.CalcResult".

How do I download a text file containing both variables for MC4 and PMAC?

A file of mixed commands can be downloaded to the station using the "s.Down=filename" station command. Every command line must be of the form "object.command" such as "Button1.Color=0,0,128" or "Pmac.P100=1".

How do I set the Tab order?

Read "Determining the Tab Order" near the end of the "Designing a Station" chapter.

Can I run MC4 full screen and prevent access to the windows desktop?

MC4 has both "View|Full Screen" and "View|Always On Top" menu options. MC4 cannot prevent the user from using the Windows key and getting to the Start Menu however.

Can I use hotkeys with MC4?

Yes. A case-sensitive hotkey can be assigned to each button. The button stays down as long as the hotkey is down. Sliders can be adjusted with the standard tab, arrows and page keys as well.

Is there any way to show what objects on a panel have been selected, e.g. if one wishes to move a group of items? Often I think I have selected one or more objects only to find I am actually resizing the whole panel.

Try "Border View" for complex selection operations. It's for exactly this purpose!

Do I use a command line option to load a particular station at startup?

MC4 and MC4R do not use command line options. The global options "re-open stations from last run" and "restore window positions" are for this purpose.

Back to Top


Motion Commander Language (MCL) Questions

Where can I find more example MCL code?

The MS-Word document "MCL Reference.doc" is now included in the MC4 Help system. This chapter from the old Motion Commander III user's manual has been updated for MC4. It describes each MCL keyword in detail and provides plenty of example code.

Is it possible to retain variable values from program cycle to program cycle?

NUMERIC and STRING variables declared in MCL programs are "local", meaning that they only live as long as that instance of the program is running. You want a "global" variable that will persist from run to run. Using a PMAC variable works, but wastes valuable comms. What you want to do is right-click on the MC4 object and add a "User Property" to it. User properties can be accessed from MCL programs just like regular object properties, and make great global variables.

When I declare a local variable in MCL ("NUMERIC i" for example), what is the value assigned to the variable as a result of the declaration?

NUMERIC's start out zero and STRING's start out empty - but good programming practice is always to initialize.

NUMERIC i=0, j=0, k=123.456

How do I zero all the elements in an array?

NUMERIC i=1, array(10)
WHILE (i <= 10)
  array(i)=0
  i=i+1
ENDWHILE

When should a MCL Background Program be used versus a simple list of commands that is controlled by the Query Interval property?

In general, background programs should ONLY be used to perform LONG processes (perhaps controlling some very slow homing maneuver) which would otherwise completely halt the normal MC4 update cycle.

When I use an MCL program to show a panel then all objects that use MCL query programs are disabled when the panel is shown.

A MCL program cannot send any commands that will cause another MCL program to run. This is what is happening since the buttons that show the panels are using little MCL programs to decide whether to show or not. When the panel is shown then all its display objects execute their query commands to display current data. These MCL query commands fail because the button's MCL program is still running. Change these buttons to simple show commands or rewrite this function in JScript and your problem will go away.

Back to Top


PMAC Device Questions

If I give the % command I get no response from PMAC.

The '%' character signals the start of format codes in MC4 commands. However, TWO percent characters will be converted to a single one and sent out. For example, "Pmac.%%100" will be sent out as "Pmac.%100".

How should I do the complete "$$$***" PMAC reset?

Pmac.$$$***
Pmac.!Close
g.Sleep(2000)  ; or maybe more
Pmac.!Open

How do I create a file of variable values for later downloading?

Use a series of "g.LogFile" commands like this:

g.DOS=ERASE C:\MC4\Stations\FName.pmc
g.LogFile=C:\MC4\Stations\FName.pmc,P30={Pmac.p30}
g.LogFile=C:\MC4\Stations\FName.pmc,P31={Pmac.p31}
  (etc)

How do I download a program from MC4 to the PMAC?

The "PMAC Devices" html help page tells all about the three new download commands:

Pmac.!Download=fname
Pmac.!DownContinue=fname
Pmac.!DownSilent=fname

"!Download" displays a progress/cancel dialog and post-download report. "!DownContinue" closes the progress/cancel dialog immediately after the download is complete. "!DownSilent" does not display a progress dialog and should not be used for larger files. "fname" should be a fully-qualified path. A pick-file dialog is opened if the filename is not specified.

How do I send a control character to PMAC?

"Pmac.Ctrl+A" command (as an example) sends a control 'A' character to PMAC. Refer to the "PMAC Devices" chapter for more info.

How do I jog to the position in a TEXT ENTRY?

Let's say that you have an absolute position in a text entry object "TE1". Then send "Pmac.J={TE1.Value}". You can add scaling with format commands like "Pmac.J={TE1.Value%d*100}".

Back to Top


Purchase and Licensing Questions

My 30-day free trial has expired and now I'm getting an "invalid MC4 device type" error message when I open my station.

After MC4's 30-day free trial has expired then the program will no longer recognize PMAC or OPC devices.

I created a station on my laptop in demo mode. I then copied it to the computer that will be installed in the machine and it won't open. I assume that I can open it once I have purchased and licensed MC4?

Yes. A station created by MC4 in demo mode cannot be opened by another demo mode MC4. A licensed copy of MC4 can open any station.

Does the site code change after you enter the license key code?

Yes. The site code changes after each licensing status change. Otherwise, a user could move the license to another computer and then re-enter the same license code to obtain a second license.

What if a computer fails at our customer's site?

If a hard drive crashes, then a replacement license key must be issued by G&M, UNLESS a backup hard drive had been prepared that ALSO has a licensed install of MC4 on it. The licensing library utilizes the hard drive serial number, so a 2nd MC4 license must be purchased for the backup drive. (We can discuss special pricing for backup copies.)

I copied the entire MC4 folder from one computer to the one I am currently working on. Now when I start the MC4, it says "! Invalid Machine Code".

Delete the MC4 subdirectory with the long number for a name. This will delete the licensing files that are specific to the other computer. MC4 will then start in demo mode, and you can use the "Help|Move License" menu option to transfer the license.

In the future, use the MC4 installation archive (downloaded from the website) to install MC4, and just copy the station ".mc4" file to the "Stations" subdirectory.

I replaced my CPU with another to go from Win2K to WinXP. I knew I would have to get a new license from you but when I hit "Help|License MC4", I get the message "! Invalid Machine Code". I can't even send you the site code!

Delete the MC4 subdirectory with the long number for a name. This will delete the licensing files. MC4 will then start in demo mode, and you can email me the new site code.

In the future, use "Help|Move License" to transfer the MC4 license to a temporary machine, upgrade your hardware, and then move the license back.

After I changed the computer's time zone, MC4 reported "Signature error in the file" and switched to demo mode!

Change the time zone back and then follow these steps:
- Transfer the license from the system computer to a temporary computer.
- Close MC4 on the system computer.
- Delete the license subdirectory on the system computer (the one with the long number).
- Change the system computer to correct time zone.
- Run MC4 on the system computer. It will start in demo mode.
- Transfer the license back.

Can I run a MC4 30-day trial on a machine that has MC3 installed?

Yes. MC4 uses a software licensing system instead of a hardware key. You can definitely demo MC4 on a machine with MC3 installed.

Back to Top