control system for polarimeter

35
Indian Academy of Sciences, Banglore Indian Academy of Sciences, New Delhi Indian Adacemy of Sciences, Allahabad SUMMER RESEARCH FELLOWSHIP PROGRAMME - 2013 CONTROL SYSTEM FOR POLARIMETER ASTRONOMY &ASTROPHYSICS DIVISION PHYSICAL RESEARCH LABORATORY AHMEDABAD. Author: RISHABH SHUKLA PHYS - 1569 Supervisor: DR.SHASHIKIRAN GANESH JULY 26, 2013

Upload: rishabh-shukla

Post on 06-May-2015

152 views

Category:

Engineering


9 download

DESCRIPTION

Linux device driver program.

TRANSCRIPT

Page 1: Control system for polarimeter

Indian Academy of Sciences, BangloreIndian Academy of Sciences, New DelhiIndian Adacemy of Sciences, Allahabad

SUMMER RESEARCH FELLOWSHIP PROGRAMME - 2013

CONTROL SYSTEMFOR

POLARIMETER

ASTRONOMY & ASTROPHYSICS DIVISION

PHYSICAL RESEARCH LABORATORY

AHMEDABAD.

Author:RISHABH SHUKLA

PHYS - 1569

Supervisor:DR. SHASHIKIRAN GANESH

JULY 26, 2013

Page 2: Control system for polarimeter
Page 3: Control system for polarimeter

A B S T R A C T

The detection of polarized light from celestial objects is not new to astron-omy. Polarization studies have greaty influenced our knowlege about thevast cosmos. It has been felt that human knowledge about celestial bodies islargly depended on the technical/instrumental prowess. But within the lastfew decades application of very sensitiver electronic detectiong devices hasrevolutionized and revitalized the study of polarization in celestial objects.Keeping this in mind present project aims to device a more advance and effi-cient control system for Polarimeter based on Physical Research Laboratory’sMt. Abu Observatory.

3

Page 4: Control system for polarimeter

To pioneer of Indian Space program Dr. Vikram Sarabai

Page 5: Control system for polarimeter

A C K N O W L E D G E M E N T S

With great pleasure I wish to express my deep sense of gratitude to Dr. Shashiki-ran Ganesh who introduced me to this project and very kindly gave me theopportunity to work with him. It is really a wonderful experience to rejoice indiscussions with him and to listen his dissecting remarks. His sagacious guid-ance and scholarly advices were always so inspiring and encouraging thatat no stage during the course of project I felt helpless.It was pleasure andhonour to be part of his entourage at Mt. Abu Observatory for taking observa-tions. This project is result of motivation from his earlier work on automationof PRLs Polarimeter.

I am deeply indebted to Rishitosh Sinha, Vijayan & Ranjith Sir for valuablediscussions which I had with them from time to time. Positive inputs fromSunil Chandra for improvement in doucumentational work of project is grate-fully acknowledged.

I am thankful to my friends and colleagues Ashish Mishra, Shivam Patel, Ab-hishek Kumar & Tushar Patel who encouraged and helped me in many waysduring my stay at PRL Thaltej Campus .

Lastly, I would like to thank my parents Sh. Narayan Das Shukla & Smt. UshaShukla for their blessing and wholehearted support towards my higher edu-cation.

Rishabh Shukla

5

Page 6: Control system for polarimeter
Page 7: Control system for polarimeter

D E C L A R AT I O N

This technical report on is a presentation of my original work on CON-TROL SYSTEM FOR POLARIMETER, under the Summer Research FellowshipProgram - 2013, organised by Indian Academy of Sciences. Wherevercontributions of others are involved, every effort is made to indicate thisclearly, with due reference to the literature, and acknowledgement of col-laborative research and discussions. The work was done under the guid-ance of Dr. Shashikiran Ganesh at Physical Reserach Laboratory, Ahmed-abad.

Rishabh ShuklaDept. of Electronics & Communication

RJIT, BSF Academy, Gwalior

In my capacity as supervisor of the candidates project, I certify thatthe above statements are true to the best of my knowledge.

Dr. Shashikiran GaneshAstronomy & Astrophysics Division,

Physical Reserach Laboratory, Ahmedabad

Date: July 26, 2013Place: Ahmedabad

Page 8: Control system for polarimeter
Page 9: Control system for polarimeter

C O N T E N T S

I E X I S T I N G C O N T R O L S Y S T E M F O R P O L A R I M E T E R 151 E A R L I E R U S E D H A R D WA R E 17

1.1 Introduction 171.2 Embedded Control System 17

1.2.1 PC/104 Board 171.2.2 Stepper Motor Driver Board 191.2.3 ONYX Couner Boards 19

1.3 Software 191.3.1 Software for Prometheus Boards 21

1.4 Drawbacks in earlier system 21

II R E V I S E D C O N T R O L S Y S T E M F O R P O L A R I M E T E R 232 H A R D WA R E A N D S O F T WA R E M O D I F I C AT I O N 25

2.1 Intoduction 252.2 Hardware Alterations 25

2.2.1 PCM 3362 Board 252.2.2 MESA 4i22 Board 27

2.3 Software Upgradation 282.3.1 Device Driver Programming 28

III R E S U LT S 313 R E S U LT S 33

3.1 Pulse essential for motor rotation 333.2 Interrupt handling 33

9

Page 10: Control system for polarimeter
Page 11: Control system for polarimeter

L I S T O F F I G U R E S

Figure 1 At Mt. Abu Observatory 18Figure 2 Distributed Control sytem of PRL’s Polarimeter 20Figure 3 Stepper motor with new control system 26Figure 4 Waveforms obtained from CRO 34Figure 5 Interrupt Generation & handling 34

11

Page 12: Control system for polarimeter
Page 13: Control system for polarimeter

A C R O N Y M S

MB Mega Byte

MHz Megaheatz

DDR Dual Data Rate

GNU GNUNot Unix

OS Operating System

GTK GNUs Tool Kit

IC Integrated Circuit

NFS Network File System

VGA Video Graphics Array

USB Universal Serial Bus

CCD Charge Cpupled Device

PMT Photo Multiplier Tube

PCB Printed Circuit Board

BJT Bipolar Junction Transistor

PRL Physical Research Laboratory

RTAI Real Time Application Interface

SATA Serial Advance Technical Atacchment

CMOS Complementary Metal Oxide Semiconductor

SDRAM Synchronous Dynamic Random Access Memory

13

Page 14: Control system for polarimeter
Page 15: Control system for polarimeter

Part I

E X I S T I N G C O N T R O L S Y S T E M F O RP O L A R I M E T E R

Page 16: Control system for polarimeter
Page 17: Control system for polarimeter

1

E A R L I E R U S E D H A R D WA R E

1.1 I N T R O D U C T I O N

Astronomy & Astrophysics Division of Physicsal Research Laboratory (PRL),Ahmedabad operates two telescope with mirrors measuring 1.2m and 0.5min diameter, specializing in Optical/Infrared region observation, installed ad-jacent to Gurushikhar which is highest peak of Aravali Range at an altitudeof 1680m. Out of these two telescopes larger one has been equipped withOptical Polarimeter as backend instrument and is being relied upon for po-larimetric observational purposes since 1987.

1.2 E M B E D D E D C O N T R O L S Y S T E M

Aforementioned polarimeter is controlled by distributed embedded systemconsisting of two PC/104 CPU Boards. This system includes power supply,support electronics, computer boards rendering it completely self-sufficient.For changing aperture and optical filters, electromechanical system drivenby stepper motors is used and thus it reduces human intervention. Anotherstepper motor is used for pulling mirror in and out which directs light eitherto CCD or PMTs.

1.2.1 PC/104 Board

PC/104 (or PC104) is an embedded computer standard as described by PC/104Consortium. In this case Prometheus PC/104 CPU Board is employed, whichis designed for specialized applications where emphasis is laid on reliable dataacquisition despite of extreme environment. It has 10 MHz crystal oscillator

17

Page 18: Control system for polarimeter

E A R L I E R U S E D H A R D WA R E

Figure 1: AtMt. AbuObservatory

18

Page 19: Control system for polarimeter

1.3 S O F T WA R E

with 32 MB RAM, also a solid state IDE flash disk is provided which is suf-ficient for storing entire OS and auxillary softwares. CPU board is equippedwith both male and female bus connectors for interfacing other peripheralcards either on its top/bottom. This board serves as control unit for variousPC/104 cards meant for-VGA display, usually used only during debugging, a5 port 100 Mbps ethernet switch , two ONYX digital I/O and counter/timerboard and an in house developed 8 phase stepper motor driver board.

1.2.2 Stepper Motor Driver Board

As earlier mentioned, system employes three stepper motors for rotating halfwave plate, changing aperture and optical filter. For rotating half wave platean assembly has been designed which which rotates the half wave plate withgears. This motor is operated by PC/104 board developed in house. Thiscard uses 82C54 counter/timer IC. The same IC is also being used as sourceof hardware interrupts which are generated in every 2 msec. These interruptsare used for the enabling and disabling the counters which counts the pulsecoming from PMTs.

1.2.3 ONYX Couner Boards

In present system two ONYX counter are being used. These provide the 16bit counter timer functionality with the use of an 82C54 timer chip. For eachof the two PMTs, two counters of the 8254 on one counter board were used.The hardware interrupt mentioned in earlier section was used for enablingand disabling of the PMTs at 2msec interval. In other words when one counterwas being read and reset, the photon counts were being recorded by the othercounter.

1.3 S O F T WA R E

For controlling the instrument Linux OS was used. This is a unix like op-erating system avaliable for a large variety of microprocessors. It is easilyscalable from 32 bit AVR microprocessor to high end clusters. Resasons forusing Linux operating system are that. its softwares are open source so they

19

Page 20: Control system for polarimeter

E A R L I E R U S E D H A R D WA R E

Figure 2: DistributedControlsytemof PRL’sPolarimeter

20

Page 21: Control system for polarimeter

1.4 D R AW B A C K S I N E A R L I E R S Y S T E M

are freely avaliable and can be custom edited according to ones specifications,also this OS is fully multitasking and network interfacing is built in at the verybasic level.

The instrument was being controlled by a dedicated control PC over LAN. Itwas a Pentium III running CPU at 800MHz with 512 MB RAM equipped withRedhat 7.3 Linux distribution along with all auxillary/devlopmental software.This PC is connected via ethernet cabel to one of the ports of the 5 portEthernet switch of the embedded system.

1.3.1 Software for Prometheus Boards

The Prometheus board runs GNU/Linux with real time extensions RTAI addedto a standard Linux kernel from www.kernel.org. The file system on the 32 MBflash disk is based on white dwarf Linux, the base operating system requiresonly 16 MB. Additional space is taken up by the GTK graphical interface li-braries and the application software. The data recored by the system is savedon the NFS partition mounted as /home on the enbedded Prometheus CPUboard.

1.4 D R AW B A C K S I N E A R L I E R S Y S T E M

The control system for polarimeter was deployed in 1987. Keeping in mindthe needs of research and development all the best in class boards avaliableat that time were used. But within the span of 25 years a lot of advancemtenshave taken place in electronics industry. Earlier used BJT dissipated moreheat as compared to todays CMOS transistor, so packing density was less.During 1990, growth of electronic industry was governed by Moores law, butin coming few years it will surpass the limit of Moore’s law.

Basically, in our project we have used three 8254 IC for counting/timingpurposes, two CPU for contolling CCD and networking respectively. But as perthe avaliability of advanced hardware in market this can be repalced by oneboard conssisting three 82C54, and one standalone single chip CPU powerfulenough to control CCD and facilitate networking.

21

Page 22: Control system for polarimeter
Page 23: Control system for polarimeter

Part II

R E V I S E D C O N T R O L S Y S T E M F O R P O L A R I M E T E R

Page 24: Control system for polarimeter
Page 25: Control system for polarimeter

2

H A R D WA R E A N D S O F T WA R E M O D I F I C AT I O N

2.1 I N T O D U C T I O N

As it is evident from earlier chapter that earlier used boards can be replaced bymuch advance PCB boards, which are capable of handling the functionalityof all the boards taken together. In upcomoing sections we will study therevisions which have been carried out in the system in terms of hardware andsoftware.

2.2 H A R D WA R E A LT E R AT I O N S

The stack of board being used earlier was replaced by MESA 4i22 board(counter/timer) mounted on ADVANTECH PCM 3362 Board (standalone CPU).Following sections aims to provide a breif description of these embedded cir-cuits and also discuss the way in which we have utilised them in our project.

2.2.1 PCM 3362 Board

2.2.1.1 General

The PCM-3362 is a fanless, low power, small size (96X90mm), performancePC/104-plus SBC (Single Board Computer) geared to satisfy the needs forvarious industrial computing equipment. PCM-3362 is ideal for communi-cation, environment monitoring, factory automation, military, and medicalapplications that require flat panel support using digital displays with LVDSinterfaces and single Ethernet ports.

25

Page 26: Control system for polarimeter

H A R D WA R E A N D S O F T WA R E M O D I F I C AT I O N

Figure 3: Stepper motor with new control system

26

Page 27: Control system for polarimeter

2.2 H A R D WA R E A LT E R AT I O N S

2.2.1.2 Specification

Its features Intel Atom 1.66 GHz Processor and DDR2 667 MHz SDRAM ex-tendable upto 2 GB. It follows PC-104 standard as described by PC -104 con-sortium and hence facilitates easy mounting on peripheral boards. Mountingis faciliated by the avaliability of both male and female connectors. Onboard2 GB flash memory has been provided for storing OS and auxillary software.This can be further extended using SATA port. For monitoring essential pa-rameter during operation SUSIAcess has been provided. It keeps track ofparameter like temperature, fan speed and alerts user in case of extreme con-ditions. It also provides liberality in choosing between OS, as both Windowsand Linux is supported by this board. In our case we have zeroed down toLinux OS as it matches our operating needs.

2.2.2 MESA 4i22 Board

2.2.2.1 General

ADVANTECH PCM 3362 board serves as CPU, but for interfacing a steppermotor with that, MESA 4i22 board is used. It is a 10 MHz, nine channeluniversal counter-timer card. An on card 10 MHZ crystal oscillator is pro-vided as a time base. The 82C54 counters on the 4I22 may be used for eventcounting, frequency counting, frequency generation, pulse width modulators,digital one shots, interrupt timers and many other timing and counting ap-plications. Eight of the nine counters on the 4I22 have external clock, gate,and output connections. The ninth counter is used as a optional 10 MHz timebase prescaler for the other eight counters. Gate and output polarity can bejumper selected as active high or low.

2.2.2.2 Jumpers in 4i22 for configuration

4i22 consists of a family of jumpers, various important parameters like selec-tion of port address, base address, gate and output polarity can be selectedmanully by these jumpers. Datasheet and users manual of 4i22, which isavaliable online were referred in this regard. We had selected 0200 as baseaddress and internal clocking for our project.

27

Page 28: Control system for polarimeter

H A R D WA R E A N D S O F T WA R E M O D I F I C AT I O N

2.3 S O F T WA R E U P G R A D AT I O N

After accomplishing hardware advancement, task of developing software fortailored running of motor remains the main concern. In our case, since wewere using Linux OS, so it was required to write hardware level code in Linuxkernel to make the devices run according to the tailored need of project. Atthis stage it is essential to mention that kernel programming is done for Linuxkernel 3.2.x. Following sections describe the same process of developing adriver.

2.3.1 Device Driver Programming

It is highly appercialbe that OS, once a dark and mysterious area whose codeswere restricted to a small number of programmers, can now be readily exam-ined, unerstood, and modified by anybody wiht the requisite skills. Linux hashelped to democratize operating system.Drivers in Linux make a particular piece of hardware resopnd to well definedinternal programming interface. So in our case both user space and kernelspace program was written and same was executed in Ubuntu 12.04LS OS.From understanding kernel architecture to write a compatible code and tomake the devices operate is a complex process comprising of various steps. Infollowing sections we will describe various steps involved in kernel program-ming:

2.3.1.1 Building Modules

Developing expertise in building modules is an essential for kernel program-ming. Modules should not be misunderstood with applications. Applicationsperform a single task from begenning to end, whereas module registers itselfin kernel so as to serve future request. Also modules run in kernel spaceand application run in user space. Every module invariably consists of initial-ization (init) and exit function, these functions are called when function isregistered and unregistered in module respectively.There are some prerequisits that we must keep in mind before builing kernelmodules. First is to ensure that latest/current version of compiler, moduleutilites and other necessary tools is being used. It should be also ensured that

28

Page 29: Control system for polarimeter

2.3 S O F T WA R E U P G R A D AT I O N

user has superuser priviliges to perform functions in kernel. In linux environ-ment functionalities of superuser can be accessed by:observer@nth106c: sudo bashModules were made by using Makefile. It comprises of set of commands whichtransform the C codes into kernel readable object/modules using Makefile. Inour case, file 8phase.c was buit into 8phase.ko. Following command was used.

root@nth106c: make -C /usr/src/kernel SUBDIRS=‘pwd‘ modules

2.3.1.2 Loading & Unloading modules

After module is built, next step is loading it into the kernel, insmod commandloads the module code and data into the kernel. Apart from loading modulesin the kernel insmod accepts a number of command line options like assigninga value to parameter listed in module before linking it to the current kernel.Kernel support for insmod is defined in kernel/module.cThe modprobe utility is worth mentioning here modprobe, like insmod, loadsa moudule into the kernel and also look at the module for symbols that arenot currently defined in the kernel. Syntax for inserting module is as follws:root@nth106c: insmod 8phase.ko

After loading the modules in the system /sys/modules can be used for know-ing the currently loaded moudles in the system. It generally returns modulename, amount of memory each module uses, and the usage count. For un-loading a previously loaded module rmmod command is used.

root@nth106c: rmmod 8phase.koLinux has its own way of classifying devices, it divides devices on the basisof its functionallity in three class character devices, block devices and networkdevices. Since we are operating motor as a filesystem by open, close, read andwrite system calls so it is cassified as charcter device.

Character devices are acessed by nodes of the filesystem tree. List of activedevices can be reterived by issuing following command:root@nth106c: ls -l /devAll the device name starting with c is character device and b is block device.Also, two numbers can be seen associated with each device listed before thedate of modification of file. These numbers are major and minor number.

Major number identifies the driver associated with the device, whereas mi-

29

Page 30: Control system for polarimeter

H A R D WA R E A N D S O F T WA R E M O D I F I C AT I O N

nor number is used by he kernel to determine exactly which device is beingreferred to.

2.3.1.3 Adding device to the kernel

After loading the modules, we have to manually make directory and nodesfor our device by mkdir & mknod commands, while issuing these commandsutter importance to mention the major & minor number. This is carried outas follows:

root@nth106c: mkdir /dev/4i22root@nth106c: mknod/dev/4i22/ctr0_clk c 60 0root@nth106c: mknod /dev/4i22/ctr1_step c 60 1root@nth106c: mknod/dev/4i22/ctr2 c 60 2

Above set of commands, add three devices, ctr0_clk, ctr_step & ctr2 withmajor number 60 and minor number 0,1 & 2 resepectively. In our code, wehave registered these devices and square wave is expected to be obtainedfrom this.

2.3.1.4 Interrupt Handling

Apart from rotating stepper motor Mesa 4i22 Board is responible for countingthe pulses from two PMT. These two tubes are enabled and disabled alterna-tively at 2 msec interval. While one tune is exposed to source and other isacquisiting the data in form of pulse. We have integrated the enabling anddisabling of these PMT via 4i22 Board using Interrupt. Interrupt is requested,registered & handled via software, functions such as enable_irq, disable_irq,request_irq & free_irq defined in linux<interrupt.h> header file are used.

30

Page 31: Control system for polarimeter

Part III

R E S U LT S

Page 32: Control system for polarimeter
Page 33: Control system for polarimeter

3

R E S U LT S

In this section we will disucuss the results obtained after executing the codein Linux Kernel 3.6.x machine. We have divided the result into two sections.One deals with the squarewaves essential for the rotation of motor, withouttaking into considereation the interrupts, while the other takes into accountthe Interrupt generation and its handling.

3.1 P U L S E E S S E N T I A L F O R M O T O R R O TAT I O N

Figure 4 relates to the waves essential for motor rotation. We have employed8 phase stepper motor. First wave in figure 4(orange) obtained from the PinNo-43 of 4i22 board, which related to out of counter A denotes the systemclock. It is characterized by 500.1 Hz frequency. Waveform 3 with frequency62.5 Hz is applied to one of the 8 phase of the motor. And consequently other7 phase are also applied to the same wave with a shift of 1st wave, this keepsmotor continusouly rotating.

3.2 I N T E R R U P T H A N D L I N G

In this section, we will discuss the generation and handling of interrupt byour program. As evident form figure 5, waveform 2 represents interrupt beinggenerated at every 2 msec interval, and waveform 3 reperents the interrupthandler being invoked.

33

Page 34: Control system for polarimeter

R E S U LT S

Figure 4: Waveforms obtained from CRO

Figure 5: Interrupt Generation & handling

34

Page 35: Control system for polarimeter

B I B L I O G R A P H Y

[1] Jaap Tinbergen ‘Astronomical Polarimetery‘ Cambridge: Cambridge Uni-versity Press (2005)

[2] Jonathan Corbet, Alessandro Rubini & Greg Kroah-Hartman ‘Linux De-vice Driver, Third Edition‘ 1005 Gravenstein Highway North, Sebastopol,CA 95472:OReilly Media Inc. (2005)

[3] D. J. King ‘Polarized Light in Astronomy‘St. Andews Scotland: The Uni-versity Observatory(1983)

[4] Shashikiran Ganesh, U. C. Joshi, K. S. Baliyan, S. N. Mathur, P. S. Patwal& R. R. Shah ‘Automation of PRLs optical Polarimeter with a GNU/Linuxbased distributed control system‘Physical Research Laboratory, Ahmed-abad , IN:Astronomy & Astrophysics Division (2008)

[5] http://www.linuxforu.com/author/anil-kumar-pugalia/

35