Contours
V3D V2
V3D V2

8. The Motor Tab

The Motor tab, the last of Axis Setup's tabs, works with the selected axis's motor directly. It has three columns:

  • Terminal, on the left: type CML commands to the motor and read its answers.

  • Program, in the middle: the axis's own motor program, which goes into the motor with Contours' default program.

  • Firmware, on the right: the motor's firmware, and an update to the firmware Contours carries.

Drag the dividers between the columns to change their widths; Contours remembers them. In a narrow window the terminal narrows first, then the Firmware column, so the program always has room.

fig08-1-motor-tab.png

Figure 8.1. The Motor tab: the terminal on the left, the axis's program in the middle, the Firmware card on the right.

Everything on this tab needs the axis's motor connected (see chapter 6), except writing and compiling the program.

The terminal

The terminal sends lines of CML, the Cool Muscle motors' command language, to this axis's motor, and shows what the motor answers. Use it to read or check a motor setting, or to try a command, as you would in Control Room.

  1. Click in the command box at the foot of the terminal.

  2. Type a command and press Enter, or click Send. For example, ?99.1 asks the motor's status, ?96.1 its position, and K37.1 reads its K37 (its resolution).

  3. Your command shows as > K37.1, and the motor's answer under it.

  • Up and Down in the box bring back your last 25 commands.

  • Click a line to choose it (Shift or Ctrl to choose more), and press Ctrl+C to copy the lines.

  • Save to file... in the terminal's heading saves every line as a text file, and Clear empties it.

The terminal shows your commands, the motor's own messages and answers, and the lines of a program as it loads. It doesn't show the messages Contours itself exchanges with the motor all the time (asking its position, the data it sends while a show plays), so they don't bury what you are looking for.

Lines are added only while the Motor tab is open. Each axis keeps its own lines while Contours is open, up to the last 5,000; they aren't saved with the project.

Caution. Commands go straight to the motor as you type them. A command that enables the motor, starts a bank or moves it will move the motor. Don't use the terminal to change what the axis's program sets (its resolution, homing settings, and the other settings listed below under What your program can't do): Contours sets those from Axis Setup, and loading the program puts them back.

The axis's program

Every motor Contours plays shows on needs Contours' default program. Its bank 1 is what plays a show: Run show and every Test run start it, and a motor without it is left out of a run (see chapter 9). The default program also sets the motor up for Contours: its messages, its resolution, its homing settings, and the speed and acceleration it moves to a show's start at.

Under the default program, each axis can have a program of its own: more banks, in Control Room's CMP language, for whatever else the motor should do. Both go into the motor together, and are saved in it.

You don't have to write anything. With no program of its own, an axis's motor gets the default program alone.

The editor

The Program card shows the program as CMP, your code, until you choose CML in its heading.

  • At the top, greyed and read-only, is Contours' default program as it will go into this motor, between two comment lines: Contours' default program, read only and Your program goes below. A load saves both in the motor. It is written for the axis: its resolution from the Units and gearing card, its Run To speed and acceleration, and its homing settings. When you change one of those in Axis Setup, the greyed part changes with it.

  • Under it, type your own program. The editor colours it as you type, and its right-click menu has Undo, Redo, Cut, Copy, Paste and Select All.

The program is saved with the project. Duplicate axis copies it to the new axis.

fig08-2-program-card.png

Figure 8.2. The Program card. Contours' default program, written for this axis, is greyed at the top; the axis's own program goes below it.

Writing a program

CMP is CML with a few additions, the same as in Control Room:

  • comments: // to the end of a line, and /* ... */

  • #define name 100 gives a number a name

  • var name P2 gives a parameter a name.

Numbers used inside a bank are put into N and R registers when the program is compiled. For example, this program defines bank 2, which moves the motor to position 500,000 (10 turns from zero at the default resolution) at 50,000 pulses a second (one turn a second):

/* Bank 2 moves the motor to 10 turns */
#define speed 50000
s2=speed
a2=10
p2=500000

B2
a2,s2,p2    //run to position P2
END

Use bank 2 and up for your own, with P2, S2 and A2 and up, and V5 and up: bank 1, P1, S1, A1 and V1 to V4 are Contours'. Your banks don't run by themselves: start them from the terminal, or from your own logic or an input, as you would in Control Room.

Note. The motor counts positions and speeds in its own pulses, at the resolution set on the Units and gearing card (see chapter 7). At the default, a turn is 50,000 pulses and speeds are in pulses a second.

Compiling

Click Compile to turn your program into CML, the lines the motor reads. The line under the editor says how it went:

  • Compiled: and how many lines of CML it made.

  • No program of its own: a load sends the default program alone.

  • An error such as Line 33: ..., in red. The line is numbered as the editor numbers it, greyed part included, and Contours selects it for you.

To see the CML, click CML in the card's heading; it compiles first, and stays on CMP if the program doesn't compile. The CML is what a load sends: the default program, your compiled program, then the line that saves them in the motor. It is read-only, under a lock and the note Read only: what a load sends, compiled from your program. You can select and copy it. Click Edit in CMP (or CMP) to go back to your code.

fig08-3-cml-view.png

Figure 8.3. The CML view: what a load sends, read-only. Edit in CMP goes back to your code.

What your program can't do

The default program's bank 1 plays your shows, and the settings it makes are the ones Contours relies on. So when you compile or load, Contours refuses a program that would change them, and says which line and why:

Your program can't

Because

Instead

Write bank 1

It plays Contours' shows.

Use bank 2 and up.

Erase every bank (B100)

That erases bank 1 too.

Write over the banks you use.

Set K23

It stays at 9 so Contours can follow the motor.

Leave it.

Set K37, the resolution

Contours sets it from the Units and gearing card.

Choose it there (see chapter 7).

Set the homing settings (K42, K45, K46, K47, K48)

Contours sets them from the Homing tab.

Change them there.

Set S1 or A1

They are the speed and acceleration bank 1 moves to a show's start at, from the Run To card.

Change them there; use S2, A2 and up for your own moves.

Set P1

It is the position bank 1 moves to before a show plays.

Use P2 and up.

Set V1 to V4

They link bank 1 to the motor's show player.

Use V5 and up.

K27, which says what each of the motor's inputs does, is yours to set, outside a bank, as a number of four digits at most, provided the input the Homing tab uses for its home sensor keeps its 2. If it doesn't, the message says why and gives a K27 that keeps it.

Loading the program into the motor

  1. Compile the program, and fix anything it reports.

  2. Click Load to motor. Contours asks first: the load replaces every program in the motor with Contours' default program and yours, and saves them in the motor. Click Load program. (With no program of its own, the question offers Contours' default program alone.)

  3. The lines go to the motor one by one; the terminal shows them and a bar shows how far it has got. The motor then saves them and says so.

  4. The line under the editor says Saved in the motor at and the time, or what went wrong.

Load to motor is unavailable while:

  • the program has changed since its last compile. The line under the editor says Changed since the last compile: compile it to load it. A load sends the compiled program, not the text in the editor, so Contours makes sure what goes into the motor is the program you have checked, never an earlier compile of something you have since changed. Undoing your changes back to the last compile makes it available again.

  • the motor isn't connected, or is waiting for a firmware load

  • a show is playing on any motor, firmware is going into a motor, or another program is loading.

A load is also held, with a message, when the axis's home speed or offset is more than its motor takes at its resolution, or when the resolution is coarser than a motor with version 2 firmware can play shows at.

To load every motor's program at once, with or without its shows, use Load all motors on the Axes panel (see chapter 9). A program loaded on its own doesn't change the shows in the motor, but a change of resolution means loading them again (see chapter 7).

The Firmware card

The Firmware card shows the firmware in the motor and the firmware Contours carries (RT3.14.11B18), and updates a motor whose firmware is older. The motor's parameters, programs and shows are kept.

  • Motor: the motor's firmware, for example RT3.14.10.

  • Contours: the firmware Contours carries.

  • A line under them says what it means: Up to date., Older than the firmware Contours carries: it can be updated., or why an update isn't possible.

SCREENSHOT Figure 8.4: the Firmware card for a motor on older firmware: Motor RT3.14.10, Contours RT3.14.11B18, the state line highlighted and Update firmware available.

Figure 8.4. The Firmware card for a motor whose firmware can be updated.

Updating a motor's firmware

  1. Make sure the motor has power that won't be interrupted, and is connected over a network cable (TCP) or a COM port.

  2. Click Update firmware. Contours asks first: the motor's amplifier is off while the firmware loads, so anything the motor is holding up may drop. Click Update firmware to go ahead.

  3. A progress window shows each step: asking the motor which firmware it runs, loading the flasher, writing the firmware, and waiting for the motor to restart. It can take a few minutes. Don't switch the motor off or disconnect it until it has finished.

  4. When it has finished, a message says, for example, Pan's motor now has firmware RT3.14.11B18, and the card says Up to date.

You can cancel while the flasher loads; once the firmware itself is being written, the update can't be stopped. While it runs, the terminal shows each step and can't be typed in, and no program or shows can be loaded into any motor. If you try to close Contours, it asks first, with Keep Contours open as the safe answer.

If an update is interrupted

If the power or the connection goes while the firmware is being written, the motor waits for a firmware load. Wait 15 seconds, or switch the motor off and on, then connect it again; the card says An update was interrupted, and the motor is waiting for a firmware load. Press Resume update. Click Resume update to load the firmware again.

A motor waiting for a firmware load takes no program or shows, and the load window leaves it out.

Note. Contours can resume an update only while it can still find the motor: in the same session, or while the motor is still linked. If it can't find the motor, for example after Contours has been restarted, load the firmware with Myostat's FWUpdate tool. Use FWUpdate too to update several motors at once, or to load other firmware.

An update isn't offered for a motor connected over UDP (connect it over TCP or a COM port), or for a motor whose board can't take this firmware.