Sample circuits

These examples for Service USB plus are shown to deepen the understanding of the inputs and outputs.


Sample circuit for the digital inputs

The digital inputs can be used to get the state of push buttons and switches. Normally they are connected between a digital input and 5V. If there is a greater cable length (more than 1-2 meter), the inputs are connected to 12V instead of 5V. This is to minimise parasitic coupling and voltage drop on long lines. If you want to use the 12V auxiliary voltage, Service USB plus must be powered externally by connecting to a wall outlet.

Sample circuits

Connection of switches and push buttons to Service USB Plus

An open input or an input which is connected to 0V corresponds to logical 0. An input, connected to 5V or 12V corresponds to logical 1.

These eight inputs are represented in a byte which results in a decimal value of 32 from the eight bits 00100000.

This decimal value can be obtained, for example, using the command get SERVICE input value, which in this case, will show 32


Sample circuit for the analog inputs

The analog inputs measure resistance, voltage and current with a resolution of 4096 steps (12 bit). Voltages from 0-4.095V, currents up to 884µA and resistors from 0-200kΩ can be connected directly.


Example of measuring resistance

Resistors and resistance sensors such as, for example, temperature or light sensitive resistors are connected between 5V and EX or EY. The resistance range is between 0 and 200kΩ and is not linear. This means that the measuring resolution is greater in the lower area (0-20kΩ) than in the upper area (100kΩ -200kΩ). Many commercially obtainable sensors are working in the range from 0-5kΩ.

Sample circuits

Connecting resistors to Service USB Plus

Resistance is calculated using the following formula:

R[Ω] = 23200000/D - 4640

R is resistance in ohms, D is the read digital value, where 0 ≤ D ≤ 4095

The value of D can be obtained for the resistance formula using the command "get SERVICE EX value". In many cases the exact resistance value does not matter. Only the change is important. A light-sensitive resistor (LDR03) will therefore have a value of 0 in the dark and 4095 in the light.

Sample circuits

Light resistive sensor of type LDR03


Example of measuring voltage

The voltage is measured between one analog input and 0V.

Sample circuits

Measurement of a battery with Service USB Plus

In this example the charge of a 1.5V battery is controlled. The maximum voltage that can be measured is 4.095V. The internal voltage reference of Service USB plus is 4.095V so that the readout is exactly the measured voltage in milli Volt (mV).

At a battery voltage of 1.5V the analog readout is 1500, using the instruction „get SERVICE EX value”.


Input voltage range enhancement to 10V

Inserting a simple, commercially available resistor, in series to the analog input, the input voltage range can be enhanced.


Analog input voltage range enhancement Service USB Plus

The external 6.8kΩ resistor in series with the internal resistance of 4.7kΩ nominal (4.64kΩ exact) both resistors works as a voltage divider.

Voltage is calculated using the following formula:
U[V] = D/405,68
U is the voltage in volt
D is the read digital value, where 0 ≤ D ≤ 4095


Example of measuring current

The current measuring range is between 200nA and 0,9mA. Current flows from the analog input to the 0V socket via the internal series resistor of 4,7Ω.

Sample circuits

Current measurement with Service USB Plus

Current is calculated using the following formula:
I[A] = D/4640000
I is the current in Ampere
D is the read digital value, where 0 ≤ D ≤ 4095


Example of measuring current up to 1A

Putting a resistor in parallel connection between the analog input and 0V can extend the range. This sample allows current metering up to 1A:

Sample circuits

Input current range enhancement, using a shunt

The current is divided into the EX input and the parallel resistor. The 3.9Ω resistor must bear up a thermal power loss of five Watt. Low cost wire wound resistors are suitable for this.

The current is calculated according to the formula: I [A] = D/3896


Accuracy of analog inputs

The measuring accuracy consists of the accuracy of the reference voltage, the resistance network in the input and the A/D conversion. The reference voltage has an accuracy of 0.1%, The resistance network has an accuracy of 1% and the analog to digital converter has an accuracy of ±2LSB.

If you are measuring voltage, the resistance network has no effect to the accuracy so that the measurement in the range of 0-4.095V is taken with an accuracy of 0.15% = 6LSB.

If you measure resistance or current, the input resistance network has additional effect to the accuracy. In addition the +5V auxiliary voltage supplied by USB must be considered.

The formula for resistance calculation assumes that the +5V auxiliary voltage is exact 5.00 Volt. With reference to the USB specification, the USB voltage may be between 4.75V and 5.25V and can descent down to 4.4 volt if Service USB is supplied by a self powered hub (e.g. the keyboard). If resistance measurements must be made with high accuracy, the voltage between +5V and 0V should be checked. If this is not possible, an accuracy of 5% for resistance measurement can be assumed.


Sample circuit for the digital outputs

Relays and lamps are connected between 0V and one of the eight outputs. A multitude of motors, relays and lamps can be connected directly. If you need to switch line voltage, relays must be used.


Sample circuits

Connection of motor, relay and lamp to Service USB Plus


DC-Motor connection

Motors with 12V and a maximum electrical power input of 15W can be used. This is equivalent to a current consumption of 1.3A. Using pulse width modulation, the motor speed can be regulated. A sample program for using pulse width modulation is placed in the folder Xcode/Pulsewidth.

There are different switching techniques for operating motors:

Sample circuits

Connection of four motors to Service USB Plus

Two outputs are connected to one motor.

Advantage: Each motor can be controlled independently of the other motors. Disadvantage: Only four motors can be run.


Sample circuits

Connection of eight motors to one Service USB Plus

One output is connected to one pole of the motor. All other poles on the motor are connected together to 0V.

Advantage: Eight motors can be used at the same time. Disadvantage: The motors cannot change their direction of rotation.




Connection of seven motors to one Service USB Plus

One output is connected to one pole of the motor. All other poles are connected together at Out7.

Advantage: Seven motors can be used with possibility of choosing the rotation direction. Disadvantage: The motors cannot be used simultaneously with changing sense of rotation.


Stepper Motor connection

Best choice is to use a 12V stepper motor with four connection wires and maximum current of 0.6A per winding.

A motor with an operating voltage of more than 12V can be operated, but the full motor power is not reached. Thus it will be possible to operate 24V motors with reduced torque.

If the nominal voltage of a motor is less than 12V and the motor is in continuous operating it will overheat . Motors with nominal operating voltage down to 10V can be operated for some minutes, if there is a longer cooling pause between the operating cycles.

Turning on the pulse width operating mode of the Service USB, motors with less operating voltage can be operated in continuous mode. For example, a motor with 6V can be operated at 50% pulse width without overheating.

If only the current consumption and the winding resistance is known, use the formula ( Ohm´s Law ) U = R * I

The voltage is calculated by multiplying the current with the resistance. If the voltage is higher than 12V, continuous operating is possible with reduced torque. If the voltage is less than 12V use pulse width modulation. Both could not be overstrained, but nearly every stepping motor in the range of 4-24V can be operated.

Service USB allows operation in full step and half step mode. In full step mode only one winding is powered at one time. In half step mode, both windings are powered while half step is in effect, so that the overall current consumption is doubled for that short time.

The digital outputs can provide a maximum current of 1.3A either on one output or as the total sum of all outputs.

If the motor is operated only in full step mode, a motor with a current of 1.3A per winding may be chosen. For half step mode a motor with 0.6A per winding may be chosen.

Example: The manufacturer of the motor declares a current of 1.1A and a resistance of 8.8Ω per winding.
U = R * I = 8,8Ω * 1,1A = 9,7V

The voltage is slightly below 12V so that a direct operating with some pause for cooling purposes or a pulse width modulation for continuous operating mode can be used.
9.7V is approximately 80% of 12V. Pulse width modulation should be turned on at 80%

The terminal assignment is shown in the manufacturers data sheet. A stepper motor has two windings which are powered alternating.



Connection of a stepper motor to Service USB Plus

Every stepper motor is always connected with four wires to Service USB.

If the motor has six wires, two of them which are the middle tap of the winding are not used.

If the motor has eight wires there are two partial windings inside the motor. Depending on the intended use they are connected in series or parallel, so that there are only 4 wires to connect the motor.

If there is no documentation about the wires, a continuity checker (Ohm-meter) is used to find out which pair of wires are working together. Only an ohm-meter can help to sort out the middle tap wires on motors with six connections. For motors with eight wires you need the data sheet or exercise patience to find out the right pair of wires.

Once it is known which pairs of wires are connected to each winding, connect the first pair to Out0/Out1 and the second pair to Out2/Out3.
For now it is irrelevant which is the first and which is the second pair.

The program „StepperMotor" which is found in the folder with the same name helps you with the first steps. It can control the motor in full step and half step and can turn on and off the pulse width modulation.

At first the speed should be set to 10 steps per minute or less. Start the motor by marking the check box „continuous". Use your fingers to feel at the motor axis for smooth and constant rotation. If the motor turns in the wrong direction, interchange one pair of wires, e.g Out0/Out1.

While doing the first steps feel the temperature of the motor regularly. If the motor becomes so hot that you can not touch it, use the pulse width modulation or increase the cooling pause.