2007/07/30

Non Crystalline Diffraction

What kind of experiments can we do in a synchrotron? As far as I know, the beam lines receive the synchrotron light as an X-ray photons. The energy of this light normally is lower that the one used in the common medicine x-ray 'to see yous bones'.

In a basic way, there are two types of beam lines in a synchrotron, doing this differentiation with the energy of the used x-rays. If the used x-rays are from the order of electronVolts (eV), this is a low energy beam line, but with the order of KiloelectronVolts (keV). Remember that, the light (photons), and the matter in general, can be described as punctual particles, like also can be described as an electromagnetic wave. What does it mean the x-ray energy? It means, at more energy, more wave frequency, and smaller things you have the possibility to see. But not for the all experimentation is interesting to have the highest energy.

Why I write this post? Because until now I only work in the synchrotron machine control, and now I have assigned one beam line to construct on it all the control software. Until now, my developments had sense in the machine electron beam section, the accelerator itself. But now, upper that this I will work with x-rays. 'My' beam line will be this 'Non Crystalline Diffraction', a 6.5keV to 13keV beam line.

An alternative differentiation between beam lines is how the experiment use the x-rays. That is like ask where are the experiment observer. In this beam line, that I dare to calling mine, take photographs of the diffracted light from the illuminated source. I will learn more about this type of beam lines, then I will write with a collection of knowledge (that I will have acquired).

2007/07/20

OpenMoko in Qemu

The last February, in fosdem, I discover the OpenMoko project. In my humble opinion, it is a great idea: a completely free mobile; an 'Open Mobile Komunications' free software. The hardware in the terms of the firmware, is also free; but I don't know if you can download the hardware specifications to allow you fabricate the hardware also. By the way, I have not knowledge of how to do that.

As far as I can do, following a WikiHowto, I am able to run the phone over qemu!


2007/07/18

Ni-Visa Spectrum acquisition

After everything, it works. I have been able to show the signal that one oscilloscope have in the channel 1, in the distributed system tango-ds. In the last post, I try to implement an observer design pattern, but this is not the feature that already works now. In one hand there will be situations when the user will likes to see the signal as if him or her be there in front, I my objective likes to minimize the network traffic.

But, if the user refresh period is lower than the period with the instrument refresh the signal, this produce more traffic than the necessary one! I will need both possibilities: subscribe and on demand.

Giving back to the bridge design, the Instrumentation class have a new method under the name
Instrumentation::getCapture(int channel,double **buffer). This will ask the oscilloscope for the current curve (the double's parameter) that it have. This have no subscrition, this will not do any thing else. If you want another one, ask again.

And what is the goal on this? Now, my tango device server is able to ask to a Tektronix oscilloscope (and only a Tektronix) about the signal that it have in one channel. You can see what the instrument measures, via the distributed system:


Actualization:
The last image was on ATKPanel (written in Java), but also we are working with PyTauico (provisional name):



2007/07/12

Ni-Visa Observer pattern

Some days a go, I wrote something about the bridge pattern, and about where I want to apply it on my control software development. Now I am witting the VISA class from the diagram that I propose, that is a subclass of the ControlEnvironment class, this is an implementation in the bridge pattern.

In the way to reduce the number of data transmisions, the ni-visa protocol allows to subscribe your proces to a handler, this is a new thread, who will do the read() operation only when something new is able to be transmitted. Further than this, I want to have shared memory segments in side the agent to minimize also the internals memmove().

But it does not work! The ni-visa library sends me an error when I am trying to do this subscription. Without copy the error handlering my procedure is:

VISA::VISA(char *instrName,int timeout){
    sprintf(_rsrcName,"TCPIP0::%s::INSTR\0",instrName);
    _timeout = timeout;
    _status = viOpenDefaultRM(&_defaultRM);
}


int VISA::Open(){
    _status = viOpen(_defaultRM, _rsrcName, VI_NULL, VI_NULL, &_instr);
    _status = viSetAttribute(_instr, VI_ATTR_TMO_VALUE, _timeout);
    viClear(_instr);
    return _status;
}


int VISA::Open(const unsigned int ch){
    if (shmMalloc(ch) != VI_SUCCESS) return -1;
    if (Handlering(ch)!= VI_SUCCESS) return -1;
    return 0;
}


ViStatus VISA::Handlering(unsigned int ch){
    ViEventType event=VI_EVENT_SERVICE_REQ;
    _status = viInstallHandler(_instr, event, callback, _bufferHandler[ch]);
    _status = viEnableEvent(_instr, event, VI_HNDLR, VI_NULL);
    _status = openAChannel(ch);
    return _status;
}


ViStatus VISA::openAChannel(const unsigned int ch){
    char cmd[MAX_CNT];
    memset(cmd,0,sizeof(cmd));
    sprintf(cmd,"READ:WAVFM:CH%d",ch);
    _status = viWrite(_instr, (ViByte*)cmd, strlen(cmd), &_retCount);
    return _status;
}


I Really don't know what I am doing wrong.

Actualization:
I am trying to communicate with the instrument asynchronous but without the handler. Only asking for the spectrum, and waiting for it to be served. The Open() method change and a new one appears under the name EnqueueRead().



int VISA::Open(const unsigned int ch){
    if (shmMalloc(ch) != VI_SUCCESS) return -1;
    if (EnqueueRead(ch)!= VI_SUCCESS) return -1;
    return 0;
}


ViStatus VISA::EnqueueRead(unsigned int ch){
    ViEventType event=VI_EVENT_IO_COMPLETION;
    _status = viEnableEvent(_instr,event,VI_QUEUE,VI_NULL);
    _status = openAChannel(ch);
    _status = viWaitOnEvent (_instr, event, _timeout, VI_NULL, VI_NULL);
    _status = viReadSTB(_instr,&stb);
    _status = viReadAsync(_instr,(ViBuf)_bufferHandler[ch],MAX_CNT,&jobID);
    _status = viDisableEvent(_instr,event,VI_QUEUE);
    return _status;
}


ViStatus VISA::openAChannel(const unsigned int ch){
    char cmd[MAX_CNT];
    memset(cmd,0,sizeof(cmd));
    sprintf(cmd,"READ:WAVFM:CH%d",ch);
    _status = viWrite(_instr, (ViByte*)cmd, strlen(cmd), &_retCount);
    return _status;
}


Actualization:
The question (problem, issue,...) has been send to Tektronix, and they redirect it to National Instruments...

2007/07/06

I had it at home and I didn't know it

In the cells web site, there are a section called About, and it has a subsection called What is a synchrotron ?, and this is really interesting because it is my plain explanation about what is this machine and what is it good for.

I wrote about the different sections this machine has, but with this image nothing more needs to be explained:

Yes, there are the four segments and the last one (the beam lines) are showed divided also with their subsegments.

In ALBA machine the Linac will works generating electrons this 100 MeV of energy. This electrons will provide the booster where the electron beam is accelerated close to the light speed, and then this beam is injected to the storage ring that is the real place where the synchrotron light is generated and this will goes to the beam line front end.


The main characteristic of the ALBA synchrotron is that the booster and the storage shares the tunnel. In the last image the booster are considerable smaller that the storage using a different tunnel. This is common in this machines, but the own one will reduce a maintenance cost using the same circular room for both.

2007/07/05

Language processors

After many years studying computer science, another step is close to be finished. This is incredible, I need like 7 years to study my bachelor degree to be a technical engineer, using the Spanish naming. An 2 years a go, I began the Master degree and I am only at one subject to finish it. Next September I want to pass it, and then I will work on the research project, indispensable step to obtain the title.

One subject to the end: Language processors, or in other words compilers. Lexical analyzers, the abstract syntax tree, and the semantics. As far as I know, it is close to the subject that I already study when I was on Erasmus in the Vrije Universiteït.

During this summer that I will do the practicum works of this subject, I will profit to explain something.

Bridge pattern

Giving a change to what I have written until now, I think I can go deep in my daily work. In the synchrotron I have some projects in control software development. One of this projects is one Tango device server development to do a remote control of Oscilloscopes. I said something a couple of days a go, here, but only superficially now is a moment to explain a little bit deeper.

The problem:
In the instrumentation remote control there are much protocols to do this control. This protocols will do the same but in different ways, and some of them have different layer levels of abstraction. For example, GPIB or VXI-11 are in the lowest layer level and some times you will depends to the current instrument. Upper layer I like to use a library with the VISA specifications, but this could be not easy.

There are one general specification, but the manufacturers creates control implementations close to it, but not exactly compliant with in it. That is to say, the basic functions should be work in the same way between manufacturers (this is the reason for being of this specs), but some instruments can implement some special functions (or not implement, some others). Then some manufacturers have theirs special libraries.

One possible pattern solution:
To solve my problem about the control of an instrument connected to the Tango control system by an agent of this distributed system, one possibility is separate the abstraction to the several possible implementations. The bridge pattern should be my solution. The agent knows about the problem abstraction with a class that have the need methods, and have a reference to the real environment that knows how to talk with the real instrument.

In the construction on the instrument abstraction, also is created an object of control.

This idea allows the agent to call the abstraction class methods where implemented functions are. In the contruction time the concrete control environment will be decided, but this is not mandatory. By now the abstraction works forever of its existence with the same ControlEnvirinment object, but anything forbids to do the open with VISA and after some methods moves it to one specific manufacturer VISA library.


Right now, there is implemented (and it works) the identification with the VXI-11 protocol and also with VISA. But the capture presents some challenges... After a non productive try to capture with vxi-11, I dedicate my efforts to the ni-VISA library. It presents some advantages, specially a callback subscription executed when new data are available. Any suggestion to 'move' this data from the VISA object to the Tek_DPO7254 without movement?

This is alive

I have been some days very busy and this blog has come of a little forgotten. By the way I didn't publish this blog to many people, then I must not have many readers.

Long time a go, one friend insist, again and again, that it could be interesting that I wrote a blog. I never take seriously this idea, but a student opportunity to go to Svalbard moves me to change the opinion and it becomes the begin of this project.

I am preparing to write something more interesting.