Freesteel Blog » University

Saturday, October 21st, 2006 at 6:13 pm - - University

Friday was a day at the psychology department. I battled with wxwidgets to get a full screen frame without any window decorations on Mac OS X, not with the desired outcome. The best I can get is a screen filling frame, but with a title bar and a ‘close window’ button at the top. Acceptable. Shame that it works as desired under windows. The other thing I looked at was using py2app to wrap up a python application that uses Python Imaging Library and wxwidgets to run on another mac. After some unsuccessful attempts I decided to upgrade python and site packages to newer versions. I upgraded python from version 2.3 to 2.4 and downloaded wxwidgets latest available version. The new site-packages installation meant I had to reinstall py2app. Success, with the latest versions py2app created mac a working application. A lot of these different packages come with their own installation tools. Ever heard of ez_install.py (say eazee(!))? Well, that is used for setuptools and py2app. Or python eggs? Don’t quite know what they are good for, but some got laid in my working directory.

And I had a chat with another scientist at the department about programming some experiments for her.

Thursday, October 19th, 2006 at 8:07 am - - University

On Tuesday afternoon I went to the engineering department and together with Carl rejigged the python script he uses to control their machine. We now use two python threads, one controls all moves of the motors, updates the user interface edit boxes with the current position and speed data, and also controls buttons that are pressed or unpressed automatically when the machine is rotating. We have a separation of user interface and motor control so that the user interface is always responsive. The UI passes requests for movements through a queue to the motor thread.

In the past we could use just one thread because we always ever had to handle one request for the motors to move. The calls to the DLL for the controller card always return immediately, the controller maintains it’s own motion queue. But we had to implement sequences of movements of different speeds and pauses. The queueing system we have now in place in the python thread allows that now easiy.

Thursday, October 12th, 2006 at 7:01 pm - - University

I did some work in the engineering department of Liverpool University today. Some time ago Carl did a write up of something we had programmed to print undistorted images with one or more rotating print heads, assembled in a row. The inkjet print heads they use are meant for normal printing with paper moving rectangular to the print width. But in their machine the medium to print rotates underneath the print head, with one side of the head closer to the centre of rotation than the other. So, a rectangular bitmap would be distorted to a pie wedge. We wrote a little algorithm that transforms a bitmap into a new bitmap that, when printed on this setup, prints undistorted.
I had read it on the train last night and had a few comments and suggestions to make it clearer what this does.

Then looked into extending the controller of the machine that performs these rotations. In order to shine a light on the same area on the print medium for a specified time they want to be able to stop the rotation, then start it again, and so on. We use a python thread that monitors the machine position and when it has reached the target of the rotation joins the main thread that in turn can sleep for the specified time, then start the motion again.

I had hoped we could use some sort of callback mechanism in the DLL that controls the digital controller card: When a motor has reached it’s target position we get a user specifiable callback. We had found something in the documentation for the DLL and started coding. But we got stuck and had to call the support phone line for the card manufacturer. The friendly support person told us we were following a red herring: The documentation we had used was for a different card, using a different (probably real-time) operating system.

Last week I also spend a day there:
We had looked into rewriting the user interface of the motion controller: The old user interface got out of hand, partly because a master student had used unsuitable GUI code generators on it (python glade). We had decided to shelve this code and write a much simpler new interface. Now that this motion controller has been in use for more than a year we could also reduce the functionality to what was really needed.

Another half day last week was spent in the department of psychology. I am working on a framework to programme visual perception experiments using python, wxwidgets and python image library (PIL) on a mac os x system. More about that some other time.