Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

A Single Programmable System on Chip Embedded design Automation for X-ray Diffractometer

Experimental setup

Gokulavasan G.
1
*, Mallika R.
2
, Jayapandian J.
2

1
Electronics and Instrumentation, Birla Institute of Technology and Science, Pilani ,Rajasthan, India ;
2
Materials Science Division, Indira Gandhi Centre for Atomic Research, Kalpakkam ,Tamil Nadu, India
gokulavasan@gmail.com

1. OBJECTIVE: This paper describes a novel embedded design solution for the automation of the X-ray
Diffractometer with the mixed signal array Programmable System-on Chip (PSoC), which includes analog,
digital and communication blocks required for data transfer to the personal computer (PC). The virtual
instrument graphical user interface (GUI) control program for the complete automation, which interacts
with the embedded single PSoC chip, has been designed with the support of LabVIEW, a graphical
language, package ver.7.1.

X-Ray Diffraction is an analytical technique which uses the diffraction pattern produced by bombarding a
crystal with X-rays to solve the crystal structure. The diffraction pattern is recorded and then analyzed to
reveal the nature of the crystal. Using the diffraction pattern, the lattice parameters can be found out. This
helps us in understanding the structure as well as the composition of the sample. Siemens D500
Diffractometer is used in the Materials Science Division at IGCAR for X-Ray Diffraction Studies. The
sample of interest is prepared and kept in the sample table. The source and the detector arm are positioned
adjacent to the sample table and all are in plane. The detector and sample table are the mobile parts while
the source arm remains stationary. The movement of the mobile parts is controlled by stepper motors which
are inside the Diffractometer. For conducting an experiment, different parameters such as start, step, end
angle, time for counting at each step are set using the knobs/switches on the panel of the instrument.
Expertise in handling the instrument is vital. Small errors which can creep in due to some reasons like
wrong angle set, can affect the whole result. For easy acquisition of data, to reduce frequent/constant
human interaction and to eliminate the errors due to lack of expertise in handling the instrument
automation, becomes necessary. The requirements for the automation of this system are as follows.

The instrument must be controlled through an external connector (provided in the Diffractometer)
A Set Function must be initialized remotely in order to bring the system to one of the predefined
positions and thereby we get to know the positions of the 2theta (detector arm) and theta (sample
table) positions.
The Limit Switches kept at 2, 40 and 80 degrees of the detector arm gives a discrete measurement
of the angle positions. After the set function, the set angle must be read using these switches.
Emergency Stop option must be provided if the user wants to stop the experiment in the middle.
Input Parameters of the initial angle of the experiment, step angle, end angle should be collected
from the user.
The preset time for which the counting of the detector pulses is to be carried out should be taken
from the user.
The Stepper Motor must be controlled accurately for the required step angle
Reliable communication protocol must be used in order to control the data flow between the
computer and the controller.
Accurate Time Measurement is needed to keep track of the counting time.
A counter capable of counting large values (running into millions) is needed.
Real-time Graph of the Angle vs. Counts to be displayed to the user.
Saving of the acquired data must be done for future use and option for manual operation needed

If the above requirements are met, the errors from different sources can be reduced and proper control and
automation can be achieved. For achieving the above automation, the Programmable System-on Chip
(PSoC) and the graphical programming language LabVIEW were used.

2. Programmable System on Chip: Integration of all components of an electronic system into a single
chip is known as System-on-Chip (SoC). Digital, analog or mixed-signal functions, all are built in a single
chip. PSoC is a family of mixed-signal array having a microcontroller and integrated analog and digital
peripherals. PSoC Designer was the software that was used in designing and programming of the chip.
CY8C26443 (28 Pin Dual inline), a part of CY8C26000 family was used as the Base Part. Using the PSoC
Designer, we selected and place User Modules and wrote the programming code in C language for the
operation of the PSoC. The following user modules were placed using the PSoC Designer software.

UART For serial communication with PC (LabVIEW)
32-bit Timer For Timing during Counting and for motor control
16-bit Counter For counting the pulse from the detector


Fig. 1 PSoC Designer User Module Placement View

Fig 1 shows the user module placement view in the PSoC Designer. In the first row, the four blocks are
occupied by 32-bit Timer block. In the second row, the two blue colored blocks represent the 16-bit
Counter. The next two blocks in the same row represents the UART Communication blocks. The Timer
block is used for both motor control and timing during counting purpose. The Counter block is used for
counting the Counter Pulse input from the Diffractometer. The input of Counter Pulse comes in the form of
TTL Pulse from Single Channel Analyzer and the connection is made using a BNC cable to prevent
attenuation. For the counting more than million counts using a 16-bit counter, we monitor the terminal
count interrupt of the counter. When the counter interrupts, a number (overflow integer) is incremented and
the Counter continues. When the final count is sent to LabVIEW (after counting for the preset time at a
particular angle), this overflow integer is sent along with the remaining counts.

The 32-bit Timer which controls the movement of the mobile arms (detector arm and the sample table)
gives full accessibility of the 2 theta angle (from 0 to more than 90 degrees) at a stretch. The timer is also
used for counting operation where it can count for more than six and half months at the same angle. This is
more than enough for the actual experiments. The Digital Communication blocks, UART are used to
communicate with the PC / LabVIEW through RS-232 Serial Communication. The TXD and RXD pins of
the chip are connected to the Serial Port (via a MAX232 level translator) which is in turn connected to the
PCs USB Port through a USB-Serial converter. The UART module in the PSoC functions at a baud rate of
19200 bps and requires a clock of 154kHz (approx) which is given by the PSoC internal clock dividers
24V2 and 24V1 (values of 24V1=13 and 24V2=12 and System Clock = 24MHz). Thus it eliminates the
need of counter module for UART clock generation. All the other necessary input/outputs (general purpose
I/O) of the chip are connected to an external connector st3 which is connected to the D500 Diffractometer.

External st3 connector works on active low inputs. When the set function is invoked, the D500 takes in the
inputs for motor control and the direction from the external st3 connector which in turn has been connected
to the PSoC. The internal digital electronics controls the motion of the motor so that it comes to rest at 2, 40
or 80 degrees (detector arm) whichever is nearest. Therefore, it is necessary to float the pins of the motor
control, speed and direction pins so as to allow the Diffractometer to set itself. The Pin should drive the
motor after the set function for the proper operation. To change the drive mode of the pins, we need to
write into the Drive Mode Registers 0 and 1 of the corresponding Ports. The drive mode should be changed
on the run by writing into the two registers of the Ports. The registers can be accessed using the name
PRTxDM0 and PRTxDM1 where x stands for the Port Number. D500 Diffractometer also provides a clock
of 250Hz. This clock is used to achieve synchronous motor control. The detector arm moves by an angle of
0.002 degrees for a single clock pulse and the sample table moves by 0.001 degrees. Since this clock is
available during the entire operation, the same clock was used for the timer during counting. This reduces
the need for an additional clock divider (Counter) module.

The algorithm of operation for PSoC is given below:

1. Wait for the Command from LabVIEW. Till then allow Manual Operation
2. Change the drive of the motor control, speed and direction pins to HighZ
3. Go to External Mode and give Set Function
4. Poll the three limit switches pin corresponding to 2, 40 and 80 degrees until we detect a low on
any of them. This gives us the initial 2theta angle of the Diffractometer.
5. Change the drive of the motor control, speed and direction pins to Strong Drive
6. Read the start, step, final angle and preset time for counting of detector pulse from the Front Panel
of LabVIEW
7. Move the motor to the initial start angle (with the reference of the present angle from Step 4)
8. Start the Counter and load the Timer with the Preset Time Value.
9. Stop the Counter on Timer Interrupt. Send the count value with overflow integer to LabVIEW
10. Check the condition of the Emergency Stop status in LabVIEW
11. If status is true, stop the motor and jump to Step 1
12. Else, move the motor by the required step angle
13. Go to Step5 if the current angle is less than final angle
14. Send the experiment complete byte to LabVIEW
15. Go to Step 1

3. Virtual Instrument: The graphical user interface for the control of the X-Ray Diffractometer is done
using LabVIEW 7.1. The virtual instrument (VI) created using LabVIEW communicates with the PSoC
device using the COM port of the PC (using a USB-to-Serial converter). LabVIEW provides functions with
which the serial communication can be established and data can be written / read. In the front panel VI
(Fig. 2), the user needs to choose the Initial Angle at which the Detector arm must be set, the Step Angle
through which the Motor has to move till after each count and the End angle at which the Detector Arm has
to stop. The File Name with its path where the data has to be stored can be entered in the front panel of the
VI. The Preset Time till which the counting operation has to be performed is also entered. Only when the
user presses the run button on the VI, the PSoC will receive the command to switch to remote operation.
Till then the Instrument can be operated manually without removing the st3 connector from the instrument.
When the user starts the experiment, LabVIEW calculates the approximate time needed for the experiment
to complete and displays it as a message box. When the Ok button is pressed, LabVIEW moves forward
and executes other instructions.

The Set Status will show the status of the set function operation. The Emergency stop switch is provided
to stop the experiment in the middle of an experiment. If switched on, LabVIEW will send the stop byte to
PSoC (at Step 10 in the Algorithm given above), which on receiving it will stop the experiment. The
Status text will show the status of the experiment, whether the experiment is going on (P) or it is
complete (C). On the XY Graph, the user can see the real-time graph drawn between the detector arm
angle and the counts at that particular angle. The current angle and count will show the last received count
corresponding to that angle. The data is written into the file every time the count value is sent so as to
prevent data loss in the event of any power failure. The Automation system was tested on the D500
Diffractometer. The usage of the internal 250 Hz for Motor Control synchronization has given excellent
results. The sample table and the detector arm moves through the exact step angle.

Fig 2. Front Panel of the Virtual Instrument

4. Results: Tests were conducted on a Standard Silicon sample. The graphs of Counts vs. Angle (2theta)
are given in Fig 3. The six prominent Silicon peaks were observed. Since the Silicon sample was placed in
a Tantalum sample holder, the XRD pattern of Tantalum also pops up in the Silicon XRD pattern.


Fig 3. X-Ray Diffraction Pattern of Standard Si Sample

5. Conclusion: The whole setup has provided a complete automation for the Siemens D500 X-Ray
Diffractometer at Materials Science Division, IGCAR. The automation has satisfied all the initial
requirements.

6. Reference:
1. Application Note - AN2374 Wide Dynamic Range Programmable PSoC Counter Timer.
Jayapandian J., July 18, 2006, Cypress Microsystems. www.cypress.com

Keywords: PSoC, Virtual Instrumentation, X-Ray Diffraction, Lab Automation

You might also like