QTU variables in TCL

The QTU variables are both extensions of the SmartCab structure and are also types of Object variable. The following data elements exist in each QTU variable:

Element name

Read/Write

Description

speed

R/W

Defines how fast a train should travel. Values from 0 (stopped) to 100 (full speed) are allowed.

dir

R/W

Direction. 0 is forward, anything else is reverse. Note that momentum could mean that if you change direction while the train is moving, is might take a while before the power is actually reversed.

brake

R/W

When brake is non-zero the speed sent to the throttle is temporarily set to zero and so the train will slow (gradually if momentum is applied) to a stop. When brake is set back to zero the train will (gradually) resume the speed setting in the speed value.

mom

R/W

Momentum, also called inertia. Defines how rapidly the train can change speed during acceleration, deceleration and braking. Values range from 0 (no inertia, train changes speed instantly) to 255 (quite gentle speed changes). Note that the values differ from those used in CTIs own software (which was 0 to 7). When used with SmartCab modules only the top 3 bits are used. When used with QTU modules only the top 5 bits are used. When used with other throttles Tcc interprets the inertia itself so all 8 bits are used.

cur

R

Current detect. This is a '1' when a train is present, '0' otherwise. The amount of current that is required for this to be a '1' is adjustable in the Q-script.

overload

R

Overload detect. This is a '1' when too much current is being drawn. When in overload the output is foldback-protected and so a meter will show a very low actual current.

fbEnable

R/W

Feedback is enabled for this throttle when set to '1'.

integral

R

The integral of the feedback voltage, as used by the 'Dead-Reckoning' system. This is a 16 bit value.

resetIntegral

R/W

When set to '1' by TCL this resets the integral on the QTU to zero. When the QTU echoes zero this resets itself to '0'.

adcCur

R

The current drawn from this throttle. The value is an 8 bit non-linear, and scaling will depend upon components used in assembly but gives an indication of how much current is drawn.

adcFb

R

The feedback voltage measured for this throttle. This is scaled by the fbScale value in the Q-script. Not normally useful in TCL.

stopAt

R/W

When set to a non-zero value the QTU will gradually slow and stop the train such that the integral roughly equals this 16-bit value. Note that the momentum setting is ignored during a stopAt operation. When set to 0 the train is allowed to proceed. Note that a non-zero stopAt value will hold a train stationary despite having a non-zero speed and zero brake.

curSpeed

R

This is the speed setting used in the QTU, after the application of inertia. It will gradually approach the speed setting.

fbSpeed

R

This is the output voltage as applied to the track after the application of the feedback algorithm if enabled. This voltage will adjust itself so that adcFb (the feedback voltage from the train) matches curSpeed.

sSpeed

R

Script speed. The speed setting can be overridden by the Q-script. This is the value actually used

sDir

R

Script direction, ditto.

sBrake

R

Script brake, ditto.

sMom

R

Script momentum, ditto.

measureTime

R

This 16 bit value is the time in units of 100ms that a duration variable in the Q-script was set to '1'. It can be used to measure the actual time a train took to traverse a known length of track.

channelStatus

 

 

wCurSpeed, wFbSpeed

W

Do not use these values - they are used by the Train objects for copying curSpeed and fbSpeed from one throttle to another so that train speed varies smoothly as a train travels from one section to another.

adcUser

R

Temporary access to one of the user defined analogue input lines. This access will be replaced by a method call soon.

The QTUs can be controlled directly by the TCL script, as advanced throttle units, or they can be managed using Train objects which handle the dead-reckoning functions and automated hand-over between QTU throttles.

QtuCabs:   q1
Actions:
WHEN ... DO q1=30 (BRAKE_OFF)
WHEN q1.integral > 1000 DO ...

In addition to the above data elements, a QTU variable is also a type of Object variable and hence has methods too:

getAdcUser (number)

x = q1.getAdcUser (1)

Returns the voltage reading for the specified analogue input line.

NOT IMPLEMENTED YET.

getScriptData (index)

x = q1.getScriptData (5)

Returns the specified byte of the data area shared between TCL and the Q-script of the QTU that the throttle is part of. Note that all four throttles will return the same values.

NOT IMPLEMENTED YET.

setScriptData (index, value, value)

q1.setScriptData (5, 1, 2, 3)

Stores the values specified starting at the specified index. All 4 throttles in a QTU share the same data.

NOT IMPLEMENTED YET.

addSpeedLimit (position, limit)

q1.addSpeedLimit (190, 50)

Stores a speed limit that comes into effect at the specified position along the track connected to this throttle. The position is measured in your chosen distance, as defined for the dead-reckoning system. The speed limit is measured as throttle setting. A speed limit of zero means no limit. Note that the QTU must be controlled by a train object for this to take effect. Also note that the speed limit remains in effect until countermanded by another limit set elsewhere on the same or other track section. Speed limits are normally set at startup, and not modified during running.

This list of methods is likely to change as operation sophistication improves.

Last updated 26 Sep 2007

© Howard Amos 2006-2007