Quantum Servo DSP
(QDSP with detailed description)

Modified: 2010. március 14. vasárnap

Firmware V1.6.0

Declaration of Comformity :
The present document is not the description of complete CNC Controller and contains only the description of the controlling DSP chip. It cannot be regarded as a reference manual for the exact rebuilding of the device. The author does not take the responsibility for any damage caused by this missinterpetation. The control circuit (DSP) mut not be used in vehicles, medical equippment and in any other devices, which - in case of missfunction may become more increasingly dangerous for human body. Present documentation is for people who have the necessary skills. It does not contain the detailed security prescriptions and that of the interference protection, therefore everyone may use it only at his own peril.


Internal build-up and operation:

The software running at full speed in the dsPIC30F4012 microcontroller performs the position movements required by the PC, utilising the most support given by the hardware. The movements are realised by a DC motor with brushes and by an incrementing 2-channel encoder fed-up (closed loop positioning). The movements of the motor are signalled by the encoder back to the DSP, which compares this to the value required by the PC and continually correct this if there is any deviation between them.

The computer makes the motor step through the Step/Dir inputs of DSP. The Step signal is featured with negative logic (makes the motor step at falling edge). At each Step edge the DSP makes its internal error counter step into the direction according to the Dír signal. The measure of the step is also influenced by the Step multiplier register. By this register the incoming Step pulses can be multiplied (1× -10×). It is needed so that motors equipped with high-resolution encoders can also be driven at reasonable revolving number even by CNC softwares able to output relatively low stepping frequencies. The step-multiplying reduces the resolution of the CNC machine, but it raises the available max. revolution number in return. The high encoder resolution ↔ max. speed conflict can be brought into an equilibrium state by this..

The mechanical fed-up is realised by the signals of the encoder mounted onto the motor.
The encoder is realised by a light-passing disc, which contains dark dashes in two lines. The 2 lines are shifted to each-other. By the means of 2 optical photo-electric cells the two lines are read separately and the readouts are transformed into logical signals. By the phase position of the 2 signals the direction of the steps can be stated and the measure of the movement can be calculated from the number of steps.

The DSP can process the Encoder signals in 2 mode: 2× and 4× mode. These two modes influence the resolution that can be achieved by the same encoder.

In 2× mode the DSP handles only the entering edge of the dashes (marked by red). In this case the base resolution of the encoder (PPR) is doubled.
In 4× mode the DSP processes each edge of the dashes. In this case the base resolution of the encoder is quadruopled.

Recommended settings:
In case of 200-1000 PPR, 4×-mode,
above this range 2×-mode is preferred.

In a positionerror-free position the difference between the two signals is 0 (the dirrerence-counter stands at 0). The error signal comes from the difference of the two signals (counters) and their direction. This error signal can be read through the serial port (MON_ ports). The error signal is the starting base for the complicated PID algorithm. The PID prepares the direction and PWM data for the bridge-controller.

The external current-limiting signal can prohibit the PWM data. This signal is the base for several kinds of protection. The PWM generator controls the bridge outputs (PWM_..). Each branch of the „H” bridge is separately controled by the DSP, so in case of normal motor movements PWM regulation, while at emergency stop (see protection), motorbrake mode is realised.
A two-level protection system has been built-up, which protects both the motor and the CNC machine equipped with the DSP. In some cases the protection gives only a signal, in other casesn the DSP is blocked and only the Reset clears this state. Each protection operation sends a message text through the Status register, so the cause of any blow-off can alway be traced exactly. The two LED outputs (LED_A and LED_B) gives information about the current state. Its detailed description can be read at the protection system.
The serial output (MON_RX and MON_TX) is for configuration of the internal registers and monitoring of the Online error-level. Because of its standard RS232 ASCII or binary communication any kind of (independently from the operation system) terminal program can be used. In case of Windows the built-in Hyperterminal or the Quantum Sentinel developed for QDSP is recommended. In case of USB-RS232C converter the communication through USB port is also possible.


Pin assignment of QDSP :

1. - RESET
TTL input with negative logic. At low level it sets DSP into base (default) position. External reset circuit is not necessary, it has an internal one. At high level DSP runs its internal software (normal state).
14. – C_LIMIT
TTL input. Current-limiting input. At high level it prohibits the PWM outputs.
2., 3., 4., - (P, I, D)_AN
Analogue inputs. The voltage levels between 0 – VCC determine the gain of the P. I. D. branches. It is used for setting up the PID parameters.
15. – DIR
TTL input. It determines the direction of the motor rotation.
5. – T_SENSOR
Analogue input. It receives a voltage level between 0 – VCC, linearly increasing with the temperature , which is proportional to the temperature of heat sink. Its current value can be read out through the serial port. It is the base signal for the internal overload protection.
16. – STEP
TTL input with negative logic. It makes the motor (and the internal error register) step at falling egde.
6. – Q_A
TTL input. It is the input of the „A” channel of the Incremental Encoder.
17. – STOP
TTL input with negative logic. At falling edge it prohibits the operation of DSP and generates the motorbrake operation.
7. – Q_B
TTL input. It is the input of the „B” channel of the Incremental Encoder.
18. – FAULT
TTL output. Its high level signals the operation of the protection.
8., 19., 27. – GND
Logical grounding point (negatíve).
21. – LED_A
TTL output with negatíve logic. It is a status indicator, the output of the „A” LED driver.
9. – NC
Not connected.
22. – LED_B
TTL output with negatíve logic. It is a staus indicator, the output of the „B” LED driver.
10. – TEST
TTL input with negatíve logic. It is the input of the Test button (stress button). In case of level changes from High_to_Low_to_High   „Test way” it performs as many unit jumps on the motor as the register content.
23. – PWM_1H
TTL output. It makes the upper FET of the left-side bridge-controller operate in PWM mode.
11. – MON_TX
TTL output. Data output of the serial port for monitor programmes.
24. – PWM_2H
TTL output. It makes the upper FET of the right-side bridge-controller operate in PWM mode.
12. – MON_RX
TTL input. Data input of the serial port for monitor programmes.
25. – PWM_2L
TTL output. It makes the lower FET of the right-side bridge-controller operate in PWM and motorbrake modes.
13., 20., 28. – VCC 26. – PWM_1L
TTL output. It makes the lower FET of the left-side bridge-controller operate in PWM and motorbrake modes.

Bridge control:

The outputs of the bridge control were designed using the IR2112 driver circuit. The Firmware contains an internal „Dead time” generator, which is 4µS. During normal operation the FETs are diagonally controlled. The lower FETs are excited in PWM mode, while the upper ones are excited in static mode. In motorbrake mode the lower FETs are static controlled. The Gate charging capacitors of the upper FETs are kept alive by a 2-second refreshing alogorithm (switchable). A charging capacitor of 47uF is recommended. The charging diode should be BAV21 or a faster type (<100nS). The charging time is 16µS.
The TTL level signal necessary for the overcurrent limiting must be provided by a comparator circuit.
In case of overcurrent limiting all the PWM outputs go into 0 level.

p100 test command (100% PWM into forward direction):


(charging cycle)

1CH = 2L, 2CH = 2H, ΔT= charging time (16µS), charging period=2s.


(dead time)

1CH = 2L, 2CH = 2H, ΔT= dead time (4µS), symmetric.

Description of connections:

(P; I; D)_AN inputs:
Recommended value for potentiometer trimmer 1kOhm (connected between GND and VCC).

T_SENSOR input:
Applicable thermosensor: from the series 640, 4k7 NTK tightly mounted to the heatsink. It must be connected between the input and VCC. It is necessary to connect between the input and GND a resistor of 1kOhm and a capacitor of 100nF in parallel connected.

STEP/DIR inputs:
The STEP signal has negative logic, it makes the internal counter step at falling edge. The DIR signal must be stable 100 nS before the STEP performs stepping. The minimum length of STEP pulse is 5nS.

TEST input:
This input has two jobs.
1. At the level change series of High_LOw_High it will perform unit jump with the size prescribed by the „Test way” register (in terms of Encoder steps). For pulling up to VCC the input, a resistor of 3k Ohm is recommended. It can be directly connected to the push-button (contact bounce-free by software).
2. If it is pushed and hold pushed for 2s, the DSP will restart (reset). The fact of restart is indicated by "flashing " of the two LED outputs too.

STOP input:
It performs an emergency function. It is not contact bounce-free, it has negative logic, it is a TTL input. It causes DSP to prohibit the motor and to switch it into the motorbrake mode as well as it put the FAULT output to high-level. Only Reset can clear this state.

FAULT output:
It is an error-indicating output. It is made to operate by the STOP input and the internal protection system. It is recommended to drive it by an open collector transistor, so that logical OR relation can be formed with the other axes and also with the PC.

LED_A and LED_B outputs:
TTL ouputs with negative logic, they can be applied even to direct drive of LEDs (the LED+ its rersistor must be connected between VCC and the ouputs). They are summarised status-indicating LEDs (Status). In case of operation of the protection the reason can be read out from the read-only „Status” register in text form.

 The two-level protection system of DSP:

1. Independent protection systems. In case of their operation they make the motor stop by motorbrake and prohibit DSP. They give LED ("A" and "B") indication, as well as text messages in the „Status” register. Their operation can only be stopped by restarting DSP. Each independent protection system generates an error signal on the FAULT output. By this signal the CNC control-software running on the PC (e.g. Mach3) can also be stopped.

- Overrun protection of Hard limit (Error*) register (its size can be adjusted):
If the error signal (Error*) exceeds the adjusted value, the DSP will stop the motor by motorbrake and prohibits its further operation.
It performs first of all protection against reverse encoder connection and seizure of the motor.

* Error register = error-level register, which measures the deviation between the required and actual mechanical positions in terms of Encoder steps. If there is no deviation, then its value is 0.

- Overload-protection of the motor:
If the current-limiting of the motor is continually operating and its operating time exceeds the value of "Overcurrent time" register, then the protection stops the motor and prohibits its further operation.

- Overload-protection of the controller:
The temperature of the heatsink is continually measured by a thermo sensor and about at 60/80/100 °C it prohibits the further operation of DSP. It can be adjusted by Service code.

- Stop input active (low level). If it operates, it willmake the DSP prohibit.

2. Protection through the PC. This cannot stop the Controller in itself, it generates only an error level on the FAULT output. If this output is connected to one of the inputs of the PC and the controlling software is properly configured then this signal is able to stop the operation without pulse-loss. In certain conditions the work can be continued witout producing wastes after fixing the error.

- Overrun of the Soft limit (Error*) register. It also produces a signal on the "A" LED as long as this state remains. This signal is first of all to check whether the trace tracking is geometrically true. It continually monitores the synchronism of the motor and the CNC software. When this becomes bad, it stops operation and gives a signal. The Fault indication can be prohibited by service code.

- Motor Peak-current limiting:
The DSP continually checks the status of C_LIMIT input, and if its level is high, the protection limits the PWM outputs. The fact of limiting is indicated by lighting the "B" LED. This signal has no influence to the FAULT output.

LED signals and Fault output table: 

Error

LED_A

LED_B

FAULT

Motorbrake

Status register

Current limit:

-

X

-

-

-

Soft limit:

X

-

-/X

-

-

Hard limit:

X

-

X

X

Message

Motor Overload:

-

X

X

X

Message

Thermal protection:

-

X

X

X

Message

Stop:

t-1*

t-1*

X

X

Message


They stop DSP and only RESET can clear this state.

* t-1 hold the previus state.

MON_TX and MON_RX ports:
For RS232C connection the base schenatic of MAX232 IC is recommended. Its data transmission speed is 115200,8,N,1 without transmission control in ASCII mode. with a USB converter it can also be used with a USB port. Terminal software: any standard ASCII Terminal programme (e.g. Hyperterminal of the Windows or the much more developed Quantum Sentinel).


J3: 1=Vcc; 2=GND; 3=MON_RX; 4=GND; 5=MON_TX


Communication with the QDSP:

The adjustment of the DSP is performed most through its P-I-D _AN analogue inputs with the help of potentiometer trimmers. For the other setting up registers and for the complitated functions serial communication is needed. This communication happens through the MON_RX (receive) és MON_TX (transmit) pins in serial form (115200 bit/sec, 8-bit data, without parity and with 1 stop bit). Its connection to the PC can be realised through an RS232C port (see above) or by an RS232C-USB converter through the USB port.

The software necessary for the setting-up may be a simple terminal programme (e.g. Hyperterminal of the Windows or the much more developed Quantum Sentinel).
With the help of standard ASCII communication the setting-up and the error analysis can be performed under any kind of operation system (DOS, Linux, etc.) using a simple terminal programme. In Windows environment the use of the more developed Quantum Sentinel programme is recommended. The resource demand of Sentinel is substantially larger than that of more simple terminal programmes, therefore it is recommended to run it on a separate PC (e.g. on a laptop). If it is required to run the software on the same PC, then the use of Hyperterminal is recommended.


Usage through Hyperterminal:

After having set-up the communication successfully, if the Terminal is started earlier than the Controller, the following introducing text is displayed following switching on the Controller:


(introducing screen)

The version of the burnt-in DSP Firmware can be read out.
 If the DSP is switched on before the connection has been established, then this screen is not displayed (empty), but pressing once the ENTER key the registers will be listed.

After pressing the ENTER key a detailed help is displayed:


(querry of the actual state)

Here the most important registers and their values are listed. The letters in brackets in the names of the writeable registers are commands by which the values of the registers can be changed.


(writeable registers)

An example:

            m5 (+ENTER)

sets the „Step multiplier” register to 5. Doing so, the Step signal coming from the PC will be multiplied by 5.

If you wish to know the current values at any time, then push only an ENTER.
If incorrect values have been inputted, then the Controller indicates this by an error message and gives the applicable
range of values at the same time. Changing some values the Controller must be restarted, this is also signalled by a message.

In the lower part (Read only regiszters) only read-only registers can be found. These registers inform the user about the current status of the Controller and their value cannot be changed. Their meaning can be found in the later parts.

 The list of special commands can be accessed by  s  (+ENTER) command.

Registers and their configuration:

Writeable-readable registers:

The read-out of the registers can be done by pressing simply the ENTER key.
The values of the registers can be modified by typing in the revelant "letter+new value". E.g.: f4 sets the digital filter of the Encoder to the value of 4. Changing some registers requires the restart of the DSP, and it is also indicated by a message. Their measuring units (interpretation) are indicated by square brackets [ ... ].

Changing some registers is recommended only for experts (this is indicated by red colour).
Modifying the registers during operation is NOT RECOMMENDED.

Registers and their jobs:

e - Frequency of PID evaluation (its period) register. The real speed is: the value of the register multiplied by 95.45uS. Its reciprocal value is the frequency of PID (its base value is 1/(3×95.45us)=3492.22 Hz). The DSP could be adjusted to the time-constant of the motor. Its range is: 1 - 5.
Attention! Changing this value might cause the PID components necessary to be retuned.

n - Encoder usage mode. Two modes are possible: 2×-mode and 4×-mode. The base division of the encoder is doubled (2×) or quadroupled (4×) (e.g. from an encoder with the base division of 500 PPR an encoder with the resolution of 2000 will be in 4×-mode). Changing this value will influence the resolution of the CNC machine and its end-speed. Its range is: 2; 4.
Attention! Changing this value might cause the PID components necessary to be retuned.

f - Value of the encoder digital noise filter (EDF). It is the input noise filter of the encoder, which is responsible for the non-skidding handling. In case of noisy, poorer quality encoder or its dashes, its value must be increased, but it reduces the band-width of the encoder. Only the signal-change exceeding the time of the filter is taken as stabilised encoder-change by the system, changes with shorter time are not taken into account (noise-filtering). Its range is: 1 - 7.
Attention! At a value of 7 the input bandwidth of the Encoder is reduced to 75 kHz.

m - Step-signal multiplier. It multiplies the Step (stepping) signals coming from the PC. With its help, the maximum speed of the CNC controller software can be increased and so it can be optimalised to the system. Chaging the value will influence the resolution and end-speed of the CNC machine. Its range is: 1 - 10.

o - "Soft" error-limit register. If the position error is greater than the value of the register, then the FAULT output of the DSP FAULT will actíve (it is programmable) and the "A" LED will light up. If the FAULT output is connected to the one the inputs of P2B card and the software is properly configured, then this signal will stop the operation of the CNC machine without position skidding (an error which can be corrected). Its value must be lower than the value of „Hard” limit register. Its range is: 1 - 200.

a - "Hard" error-limit register. Its operation is the same as that of the "Soft limit" register, but the later stops the DSP (with motorbrake) and this can only be cleared by restarting the DSP. Its value must be higher than the value of the Soft limit register. Its range is: 1 - 30000.

w - Length of the move caused by the active state of TEST input. The safe length of movement, which the controller performs by pressing the "stress-button" can be adjusted by that (aoviding collision), Its value must be lower than that of the "Hard" error-limit register. Its range is: 1 - 2999

t - Time-limit of the overload. If the current limiting continually remains longer than the value of this register, then the DSP stops and switches off the motor (overload-protection) and it generates FAULT signal. Only by restarting the DSP will clear this state. Its range: 1 - 7.

i - Trigger-level of the binary error-level monitoring, in absolute value (it is used by Sentinel). Its range is: 1 - 100.

l - Measure of the reduction of the motor flickering. Its range: 0 - 4.

Read-only registers:

Proportional, Integral, Derival - values of the potentiometer trimmers belonging to them (P_AN, I_AN, D_AN inputs).

Thermo - the temperature of the sensor (heatsink). Its limiting value may be one of three given values (60, 80, 100 [°C]).

Position error - the value of the current mechanical deviation at the time of read-out.

Current limit sense - the current status of a current-limiting at the time of read-out.

Resolution - the multiplier of the resultant resolution from the current configuration (the current resolution[PPR]= Resolution × base resolution of the Encoder[CRP]).

Status - the current status of the DSP and the things to be done and errors.

Special commands:

s - Lists the special commands.

y1 - starts the real-time position-error monitoring. To quit from that press q + ENTER. The display is a ± direction peak-indicator, with a display time-constant of 3s. Its measuring unit is: PC-Step.


(ASCII mode error-level analysis)

PWM State = The state of PWM duty cycle. In case of OK its value is < 100%, in case of Max. is 100%. More information about the quality of the drive.

p - (directed) duty cycle of the PWM motor excitation using a given value. For fault finding and test purpose. Its range is: 0 ... +-100 [%]

J – (Capital letter J) Service codes. For fault finding and for special configuration purpose (Fuses).

C1 – (Capital letter C) clears all the changes of the register content and and set everything to its default value (reset).

u – It lists the status of the Fuses.

r - P trimmer preamplification. Adjustable trimmer area.

x- D trimmer preamplification. Adjustable trimmer area.

Service codes (Fuses) (J-switches):

1100 : Sends out the value of the current PID periode in ASCII chars (Sentinel),
1028 : AC mode (bridge refresh off),
1027 : DC mode (bridge refresh on),
1026 : Soft limit without FAULT indication (default state),
1025 : Soft limit with FAULT indication,
1024 : blocking of the temporary motor overload-protection,
1023 : setting the temperature protection of the Controller to 60°C (default state),
1022 : setting the temperature protection of the Controller to 80°C,
1021 : setting the temperature protection of the Controller to 100°C,
1002 : Triger mode off (Sentinel),
1001 : Triger mode on (Sentinel),
1000 : Starting of a binary error-level data-stream (Sentinel). To stop it preess q + ENTER.

8 bit (0-255) error-level data. 128 means 0 error (-range <128< +range).
To start it from an external software programme use J1000+CR ASCII data.

Fuses which are stored in the internal EEprom:

1026 or 1025,
1023 or 1022 or 1021,
1001 or 1002.