Basic commands

The software commands are described using AppleScript syntax. With AppleScript, the deviceID and timeout values can be omitted, provided they are not required.

 

set SERVICE output value X

Sets the digital output to the value X, where 0 ≤ X ≤ 65535.

 

get SERVICE input value

Gives the state of the digital inputs as a decimal value (0-65535).

 

get SERVICE EX value

Gives the state of the analog input EX as a decimal value (0-65535).
At Service USB Plus 0-4095
At Service USB classic 0-1023

 

get SERVICE EY value

Gives the state of the analog input EY as a decimal value (0-65535).
At Service USB Plus 0-4095
At Service USB classic 0-1023

 

get SERVICE output value

Gives the state of the digital output as a decimal value (0-65535). The value given corresponds to the value set previously using set SERVICE output value. This can simplify the program sequence, as the last output value sent to the interface does not need to be stored in the cache, but it can be called up using this value.

 

set SERVICE output value by mask "TXTXTXTX"

Sets the digital output according to the mask in the textstring. The letters refer to the highest and lowest bit in descending order from left to right.
I means: "High" or logical 1. The bit is set
O means: "Low" or logical 0. The bit is reset.
T means: invert the previous state
X does not change the value
The textstring is not case sensitive. The string must have a length of 8 or 16 characters. In some programming environments there is no automatic length reconstruction so you must use the by8BitMask ...by16BitMask ...mask8 ...mask16 instructions

 

set SERVICE output value bit "T" bit 0

This instruction influences a certain bit in the digital output. The bit value ranges from 15-0 and refers to each bit inside the output. The letter indicates how the bit should be influenced.
I means: "High" or logical 1.The bit is set.
O means: "Low" or logical 0. The bit is reset.
T means: invert (toggle) the previous state
X does not change the value

 

get SERVICE input value as mask

Reads the digital input and gives the result as a textstring.
I means : "High" or logical 1. The bit is set.
O means: "Low" or logical 0. The bit is reset.

 

get SERVICE input value bit n

Reads bit n (15-0) of the digital input.
Returns the single character "I" oder "O".

 

test SERVICE input value bit n

Reads bit n (15-0) of the digital input.
Returns TRUE or FALSE. FALSE is 0. TRUE is a value which is not 0.

 

compare SERVICE input value mask "1OOOOOOO"

Compares the digital input with the textmask.
I means: "High" or logical 1. The bit is set.
O means: "Low" or logical 0. The bit is reset.
X indicates the bit should be ignored.
False or True is given in cases of correspondence.

 

pulse SERVICE engine {M1, M2, M3, M4} input value bits {T1,T2, T3, T4}

This command is mainly used for the motor control unit of certain fischertechnik® models. The motors M1 to M4 must each be connected to two outputs for use. M1 between O0 and O1 (Motor 1 to output 0 and output 1) M2 between O2 and O3, M3 between O4 and O5, M4 between AO6 and O7

The motor will continue to rotate after the command has been sent until a certain number of feedback pulses has been detected. Feedback is given via the inputs In7 to In0. Use a small camshaft or a fork light barrier which, mounted on the motor spindle, emits pulses when the motor is rotating. This means that, for example, a gearbox can be moved to a certain place without having to use expensive stepping motors. The command can also be used to move a motor into an end position to a limit switch. Variables M1 to M4 can be positive, zero or negative and indicate the sense of rotation of the motor and the number of pulses.

Negative number: Motor is rotating counter-clockwise
Positive number: Motor is rotating clockwise
Zero: State of the motor remains unchanged

The input value bits T1 to T4 indicate the respective key inputs for motors 1 to 4. The values range from 0 and 7 and refer to inputs In0 to In7.

Example:

Motor 1 should continue to rotate counter-clockwise until key E7 500 has received pulses

SERVICEUSBPulseEngine -500, 0, 0, 0, "7000"

A pulse is a change between logical 0 and logical 1 or between logical 1 and logical 0. When a key is pressed once and then released again, this indicates two pulses. Both the rising and falling edges are counted.

 

pulse SERVICE engine while mouse down {M1,M2,M3,M4} input value bits {T1,T2,T3,T4}

This command manually deduces the number of pulses necessary for the previous command. There is a learning mode in fischertechnik® models, in which a model axle is moved for as long as the user presses on the mouse button. This command counts the pulses while the motor rotates. The motor rotates for as long as the mouse button is pressed.
Example:

SERVICEUSBPulseEngineWhileMouseButton ( 1, 0, 0, 0, "3000")
Rotates motor 1 clockwise and shows the number of pulses counted by In3 after the mouse button has been released.

 

get SERVICE device count

Shows the number of Service USBs currently connected. This command is used in connection with the automatic deviceID deducingfunction.

 

get next SERVICE device id

Gives the deviceID of the next Service USB. This command is firstly carried out with deviceID 0 when the device IDs of all Service USBs are to be deduced. Following this, the command is carried out for each connected interface with the device ID just given. This is how device IDs are obtained for all connected Service USBs.

 

get SERVICE device ROM version

Gives the version number of the firmware.
Starting with firmware version 3 it is possible to identify the type of Service USB, depending on the firmware version number. The last digit corresponds to the model.
3.0.1 = Service USB Plus
3.0.2 = Service USB Core
3.0.3 = Service USB Drawer = Service USB opener
3.0.4 = Service USB Classic (fischertechnik)

 

get SERVICE device driver version

Gives the version number of the Macintosh driver (framework).

 

get SERVICE device serialnr

Gives the serial number of the Interface as character string in hexadecimal notation. The serial number is shown on the interface as a decimal and always corresponds to the device ID.

 

register SERVICE device notification notification type

This command serves to carry out a certain application if the specified condition has been fulfilled. It means that instead of continually polling a condition, for example, that a key is being pressed, an application can be called up, for example, at the press of a key. Compared to the continual polling method, this saves a lot of computing time and is ideal for events where you have to wait for a long time but still have to react immediately. The notification service works only in C-Languages and with some limitation in AppleScript.

Under AppleScript the name of the function to be performed is set as:
on «event SerUNoRe» (theNotificationType)
end «event SerUNoRe»

The application that is to be performed can itself be defined in the framework version. Only one event can be monitored at any one time. If the command is repeatedly called up, the conditions of the previous call will be overwritten.

Conditions which can be polled are:
- notification type input value mask "XXXXXXIX"
Letters from left to right refer to the highest through to the lowest bit value respectively.
I means: high or logic 1.
O means: low or logic 0.
X means: the state of the bit has not been evaluated.
T means: "toggle". The condition is fulfilled when the status of the bit changes.
The above condition is true if bit 1 is at logic 1, i.e. when the key at input E2 is pressed.
Examples in AppleScript:
register SERVICE device notification notification type input
value mask notification value "XXXXXXIX"

- notification type ex value greater X
- notification type ex value less X
- notification type ey value greater X
- notification type ey value less X

These polling conditions refer to the analog inputs. The value for X must be between 0 and 4095 for Service USB plus and between 0 and 1023 for Service USB classic.
Example in AppleScript:.
register SERVICE device notification notification type ex value greater notification value 500

 

- notification type no notification

The trigger condition is usually still true after the notified application has been exited again. In this case the application is performed again immediately, which takes up a lot of time and is normally redundant. In order to avoid this, the notification mechanism should be turned off at the outset when the application is run.

Example in AppleScript:

on «event SerUNoRe» (theNotificationType)
register SERVICE device notification notification type no
notification
-- your code
end «event SerUNoRe»

 

send SERVICE vendor request xx wValue yy wIndex zz

This command is generally used for changing certain parameters in the interface. It is used for setting the baud rate of the RS232, parameters for pulse width modulation, the mapping of the analog inputs related to EX,EY and for additional command used in custom made products.

For this function, the three parameters request, wIndex and wValue must be transmitted. While the request is mainly 0, the values vor wIndex and wValue are in the range between 0 and 65535. Sometimes it is more conceptional to use the hexadecimal notation in the range between 0000 and FFFF. If there is no value specified for wValue in the table below, the value has no effect to the function.

wIndex wValue Function
0 Baudrate according to the table set Baudrate
1 HSKi mapped to decimal input
2 HSKi not mapped to decimal input (standard)
3 [origin][substitute] RS232 character replacement
9 Frequency Pulse width modulation different for each output
10 Duty cycle Pulse width modulation common for each output
11 Use digital inputs as outputs
12 Don't use digital inputs as outputs (standard)
13 Input Set analog input for EX
14 Input Set analog input for EY

Use vendor request for additional functions

An in depth description of the vendor request commands sorted by function follows in the next chapters.