Qt source code for controlling Omron E5CC

Leave a comment

These 2 weeks I was fiighting with the manual and try to control the device.

In my application, I need to change the temperature super slowly, not jump from 1 point to the other. I heard that there is an internal function called SP-ramp, that seem to fit my purpose, but I don’t really understand the manual….

The program can control most basic functions, record temperature, set the change rate of SP, limit the output (MV).

However, I don’t know how to get the RUN/STOP and AT (Auto-tune) status, so be careful.

The source code is in Github, feel free to download and modify. The program use Modbus for communication, so, you need to set the device.


I also made a simplified manual, but I do not post in here for copyright issue. If you want, leave a massage.


Omron E5CC Modbus RTU in QT 101

Leave a comment

The Omron E5CC temperature PID controller is using modbus RTU(Remote Terminal Unit) to connect.

First, you prepare a USB-to-RS-485 cable. Connect it to the E5CC. Notice that the A port of the E5CC, should be connected to  negative of the RS-485. Don’t follow the E5CC manual. Also the programing manual is extremely for expert of modbus, not for beginner.

In Modbus, the idea is that, your PC (master) send signal over the connected devices (slaves). The signal is a Hex, contained few things

DeviceID + Function-Code + Address + Command-in-Hex + CRC-16

The master send a signal, only the device with matching DeviceID will respond to the signal. Thus, there is no “locking” that link the master-slave.

The Function-Code is modbus function code, it tell the type of the signal. The type can be reading, writing, diagnostic, etc. This function is part of the modbus protocol, which is common for all devices.

The Address is the memory address stored in the device. The address should be provided by the device manufacture.

Then the command-in-Hex follow.

At the end, a 4-digit Hec CRC-16 is used for error check. Qt can calculate CRC-16 for modbus.

Read single value

In the Omron E5CC programing manual. Section 4-4-1, we see that the data structure of a read signal. It is read because the Function-Code is 0x03, which is  “Read Holding Registers” in modbus RTU protocal. For example, reading the temperature (PV) of E5CC,

01 03 00 00 00 02 C4 0B

0x01 is deviceID, this can be set in the E5CC.

0x03 is the function code

0x0000 is the address

0x0002 is number of value we are going to read. In modbus, one value contains 4-digit Hex, or 0xHHHH. In E5CC, each parameter is stored as 8-digit Hex, or 0xHHHHHHHH. Thus the E5CC manual tell us to get 2 values for temperature reading.

0xC408 is the CRC-16

The device return

01 03 04 00 00 03 E8 FA 8D

04 is the number of 8-digit Bin (2-digit Hex = 8-digit Bin). Four of 8-digit Bin = 8-digit Hex.

00 00 03 E8 is the return value of the temperature, converted to DEC is 1000, which is 100.0 ºC.

Write single value

Run/Stop command

01 06 00 00 01 01 49 9A

0x06 is the “Write Single Register” function-Code

0x0000 is the address

0x0101 is the value that start the run/stop for E5CC.

When writing single value in E5CC, only address 0x0000 is allowed. Thus, to write the SV (set value, or SP = Set Point) we have to use write multiple value. (stupid….)

Write multiple value

The set the alarm upper and lower values

01 10 01 0A 00 04 08 00 00 03 E8 FF FF FC 18 8D E9

0x10 is the “Write Multiple Coils”

0x010A is the address of the alarm upper value

0x0004  is the 2 times number of value to be written. In our case, we want to write 2 value, thus the value is 0x4. The address of the next value would be 0x010A + 0x0002 = 0x010C. Since all value use 2 memory slots.

0x08 is the length of the input value. There are 2 value, each value is four 4-digit-Hex, so the input is 0x08.

0x000003E8 is the first value

0xFFFFFC18 is the 2nd value

This structure can also be use to write single value. If we want to change the SV (or Set Point) to 100 ºC. The address is 0x0106.

01 10 01 06 00 02 04 00 00 00 64

In Qt, there is an example for modus, call master. We can use it for simple I/O.

Here is a screenshot.


First, we go to Tools to setup the Setting


In the E5CC, you have to set the communication mod to be modbus. In modbus, the parity, data bits, and stop bits are no used.

Since we use USB, this is serial port. The port number can be found using

const auto infos = QSerialPortInfo::availablePorts();
for (const QSerialPortInfo &info : infos) {
        qDebug("PortName     ="+info.portName())
        qDebug() <<"description  =" << (!info.description().isEmpty() ?  info.description() : blankString);
        qDebug() <<"manufacturer =" << (!info.manufacturer().isEmpty() ? info.manufacturer() : blankString);
        qDebug() <<"serialNumber =" << (!info.serialNumber().isEmpty() ? info.serialNumber() : blankString);
        qDebug() <<"Location     =" << info.systemLocation();
        qDebug() <<"Vendor       =" << (info.vendorIdentifier() ? QString::number(info.vendorIdentifier(), 16) : blankString);
        qDebug() <<"Identifier   =  << (info.productIdentifier() ? QString::number(info.productIdentifier(), 16) : blankString);

In my case, it is COM4, so I put COM4 in the port. Then connect.

The read the temperature. We set the Table (at the lower left corner) to be Holding Register. In the Read (left panel), Start Address is 0, and Number of values to be 2. In the Qt application output, we will see:

qt.modbus: (RTU client) Sent Serial PDU: 0x0300000002
qt.modbus.lowlevel: (RTU client) Sent Serial ADU: 0x010300000002c40b
qt.modbus: (RTU client) Send successful: 0x0300000002
qt.modbus.lowlevel: (RTU client) Response buffer: “010304”
qt.modbus: (RTU client) Incomplete ADU received, ignoring
qt.modbus.lowlevel: (RTU client) Response buffer: “0103040000001cfbfa”
qt.modbus: (RTU client) Received ADU: “0103040000001cfbfa”

The PDU = Protocol Data Unit, ADU = Accessing Data Unit = DeviceID + PDU + CRC-16. In the last line, the received PDU is 0x03040000001c, the value is 0x0000 and 0x001c=28, which is 18 ºC.

The display in the GUI is:


Now, we try to stop the device.

In the write panel, Start address is 0x0000, and according to the E5CC programing manual, the value consist of two part


AA is the command code

BB is the value

From the manual, the command code for RUN/STOP, 0xAA=0x01, and for STOP 0xBB=0x01. Thus, the value is 0x0101. Then we press write.


The Qt application output is

qt.modbus: (RTU client) Sent Serial PDU: 0x0600000101
qt.modbus.lowlevel: (RTU client) Sent Serial ADU: 0x010600000101499a
qt.modbus: (RTU client) Send successful: 0x0600000101
qt.modbus.lowlevel: (RTU client) Response buffer: “01”
qt.modbus: (RTU client) Modbus ADU not complete
qt.modbus.lowlevel: (RTU client) Response buffer: “010600000101499a”
qt.modbus: (RTU client) Received ADU: “010600000101499a”

And we can see there is a STOP display on the E5CC.

We can see, although the Holding Register is the same, in read, the function code is 0x03, in write, the function code is 0x06. In Qt manual, the QModBusPdu Class, we can see a list of Function-Code. (https://doc.qt.io/qt-5/qmodbuspdu.html#FunctionCode-enum)

This program is limited 10 address, so the operation is limited. This introduction is the basic, I think user can can study the Qt code to know how to use modbus, how to read and write signal. And people can read this website for another modbus 101.

Absolute polarization measurement by elastic scattering

Leave a comment

The magnitude of proton polarization can be measured by NMR technique with a reference. Because the NMR gives the free-induction decay signal, which is a voltage or current. For Boltzmann polarization using strong magnetic field and low temperature, the polarization can be calculated. However, when a reference point is not available, the absolute magnitude of proton polarization can be measured using proton-proton elastic scattering. The principle is the nuclear spin-orbital coupling. That creates left-right asymmetry on the scattering cross section.

Because of spin-orbital interaction:

V_{ls}(r) = f(r) \vec{l} \cdot \vec{s} ,

where f(r) is the distance function, \vec{l} is the relative angular momentum, \vec{s} is the spin of the incident proton. In the following picture, the spin of the incident proton can be either out of the plane (\uparrow ) or into the plan (\downarrow). When the proton coming above, the angular momentum is into the plane (\downarrow ). The 4 possible sign of the spin-orbital interaction is shown. We can see, when the spin is up, the spin-orbital force repulses the proton above and attracts the proton below. That creates an asymmetry in the scattering cross section.



The cross section is distorted and characterized using analysing power A_y. Analyzing power is proportional to the difference between left-right cross-section. By symmetry (parity, time-reversal) consideration, A_y = 1 + P sin(2\theta) (why?), in center of mass frame. In past post, the transformation between difference Lorentz frame. The angle in the A_y has to be expressed in lab angle. The cross section and A_y can be obtained from http://gwdac.phys.gwu.edu/ .

In scattering experiment, the number of proton (yield) is counted in left and right detectors. The yield should be difference when either proton is polarized. The yield is

Y(\theta, \phi) = L \epsilon \sigma_0 (1 + cos(\phi)A_y(\theta) P) ,

where L is the luminosity, \epsilon is the detector efficiency, \sigma_0 is the integrated cross-section of un-polarized beam and target of the detector, P is the polarization of either the target or beam. When both target and the beam are polarized, the cross section is

\sigma = \sigma_0 (1 + (P + P_T)A_y + P P_T C_yy),

where C_yy is spin-spin correlation due to spin-spin interaction of nuclear force.

Using the left-right yield difference, the absolute polarization of the target or the beam can be found using,

\displaystyle A_y P = \frac{Y_L - Y_R}{Y_L + Y_R} ,

where Y_L = Y(\phi =0) and Y_R = Y(\phi=\pi) .




Using day and night temperature difference to generate electricity?

Leave a comment

Recently, the temperature difference between day and night is very large, like 10 degrees. What if, we have a heat tank that store the hot air on the day, and release the hot air at night to generate electricity?

I roughly sketched the idea. And the P-T plot is not correct.

An improved version could be a liquid with boiling point like 20 degrees. This tank of liquid will put inside the heat tank. On the day, let the hot air flow and heat up the liquid. A pressure is building up in the tank. At evening, close the heat tank, and insulate it. The hot air in the heat tank can be a buffer for the heat loss. There is another empty liquid tank outside and it is connected with the liquid tank inside with a tube. A turbine is inside the tube. When the temperature dropped at night. the tube was open and the hot gas flow from the liquid tank to release the pressure. This generate electricity. The hot gas meet the cold outdoor liquid tank will cold down and condense. When the sun goes up, the condensed liquid will flow back to the indoor liquid tank and a cycle complete.

In the future, thanks to the global warming, the temperature difference will be larger, and this new energy source harvest the energy in the atmosphere.

An extreme of this heat engine is using the temperature difference between root-top and the basement. Is it as same as the water heating solar panel?


Energies in a nucleus

Leave a comment

There are many kinds of energies, such as single particle energy, potential energy, kinetic energy, separation energy, and Fermi energy. How these energies are related?

I summarized in the following picture that the occupation number as a function of kinetic energy.


Since the nucleus is a highly interactive system, although the temperature of the ground state of a nucleus should be absolute Zero, but the Fermi surface is not sharp but diffusive.

The Fermi energy of a nucleon , which is the maximum kinetic energy of a nucleon, is approximately ~35 MeV.

The potential energy is approximately ~ 50 MeV per nucleon.

There is an additional energy for proton due to Coulomb force, which is a Coulomb barrier.

The separation energy  is the different between the potential energy and Fermi energy.

The single particle energy is the energy for each single particle orbit.

The binding energy for a nucleon is the energy requires to set that nucleon to be free, i.e. the energy difference between the single particle energy and the potential energy.

There is a minimum kinetic energy, using the 3D spherical well as an approximation. The n-th root of the spherical Bessel function can give the energy of n-orbit with angular momentum l, so that.

j_{l}(kR) = 0, k^2=\frac{2 m E}{\hbar^2}

For l=0, j_0(x) = \frac{sin(x)}{x}, the 1-st root is x = \pi/2, then


\frac{2 m E}{\hbar^2} = \frac{\pi^2}{4 R^2}

use R = 1.25 A^{1/3},

E = \frac{\pi^2 \hbar^2}{8 m 1.25^2 A^{2/3}}

use \hbar c = 200 MeV \cdot fm, mc^2 = 940 MeV

E = \frac{33.6}{A^{2/3}} MeV

we can see, for ^{16}O, the minimum KE, which is the 1s-orbit, is about 5 MeV.

on rate equation of para-terphenyl at room temperature

Leave a comment


this report is about the parameter of pulsed laser setting for getting optimum polarization.

we plan to write another paper on a more complete rate equation. based on the density matrix of electron and proton.

i am not sure i posted the electron-proton double resonance in here or not, anyway, i post it again.

CW Solid effect

only the 1st part is finished, and it is only for free electron and proton.

[Pol. p target] Meeting Report (May 26th)

Leave a comment

Meeting report (May 26th)


  1. Thermal Polarization measurement ( BG measurement ) ( x187 set data )
  2. Optimization of the small system
    1. Crystal orientation
    2. Microwave power (3.0 ~ 3.5W)
    3. Time sequences of laser, microwave and field sweep
    4. Laser duty (5%, 10%, 20%, 20%)
  3. 13C polarization transfer.
    1. Double tuning (making coil and tuners) ( circuit diagram and theory needed to be explained)
    2. Circuit changing
      1. NMR tower ( switch to 3.2 MHz for Larmor frequency of 13C )
      2. The proton spin lock and polarization transfer will be done by other circuit


  1. The thermal polarization cannot be distinguished with the background
  2. From the result of 13C polarization transfer, the microwave and the laser may be not at optimization condition.
    1. The trigger (or the on/off) signal may be inverted
  3. The polarization transfer has negative result due to low proton polarization.


  1. Test on the microwave trigger signal (at the end of this week)
  2. Optimization at right condition (at the end of next week, June 3rd)
    1. The ESR frequency should be matched by fine tuning of magnetic field
  3. Spin echo for thermal polarization
  4. Laser linear polarization dependency
  5. 13C polarization transfer


  1. The submission on JSP meeting at Sept.
    1. Title = “ Progress report on proton polarization at room temperature “
  2. The PSTP meeting at Russian
    1. Due to The time conflict, may only participate for from 12th to 14th. Then I have to go back to Japan for joining the JSP meeting on 16th.
  3. Establish a communication perform
    1. A network based –wiki
    2. Whiteboard at the lab
    3. To understand each member status and progress
    4. Ask Kawase San.

Older Entries