Anti-Proton Decelerator quick tour


IMG_5399I recently wrote a project page about re-purposing a flip-dot bus display for the Anti-proton Decelerator control-room. It maybe interesting to show you with pictures how this synchrotron looks like.

The Anti-proton Decelerator (AD) is a 182 meter long synchrotron. Its aim is to lower the energy of anti-protons. In contrary of the majority of the existing synchrotrons, the AD is used as a decelerator, producing low energy anti-proton and send them to different experiments. For the details, have a look on the official web page.

The AD stands inside a concrete tunnel build inside a large hall:


Before accessing the synchrotron ring, we can make a quick stop by the AD control-room (ACR):


The hall with the concrete shielding is conveniently visible from the ACR:


Down in the hall, we can find the access system for the machine tunnel:


This special door will control your personal dosimeter and your identity with an iris scanner:


Once in the ring tunnel, you’ll meet the AD itself. Here we are facing two of the main dipole magnets (in blue):


And right after we can see the vacuum pipe going through quadrupole magnets (focusing elements, in red):


On the next picture you will see on the right where the anti-protons come from. Behind the wall is the target and horn area. On the left starts the injection region where we can see the vacuum pipe literally going through the blue dipole yoke:


In the next strait section we will meet the electron cooler, one of the rare device able to reduce the size of a charged particles beam:


Right after, these two big silver colored blocks are radio-frequency (RF) cavities. In general RF cavities are used in synchrotron to change (increase or decrease) the particle beam energy. These two ones are used in the AD to change the shape of the beam:


Continuing along the ring you’ll meet a lot of magnets to steer and focus the beam:


The stochastic cooling system is another remarquable element of the AD, it is a beam size reduction system:


Without entering into the details it consists of beam sensors and fast kicker elements (electro-static). The sensors signal is amplified and transmitted to the kicker elements that are installed at the opposite side of the ring. The transmission is faster than the particles take to make half a turn of the synchrotron.

If we exit the ring tunnel, we can pass by the stochastic cooling amplifiers:


And the powering system for the injection element, able to deliver a controlled pulse of hundreds of kilo-volts. Most noticeably are the cable coils (Pulse Forming Network):


I hope you enjoy this little tour, and thank you for reading.




Another Candle

candleV1 v22

Christmas lightnings around houses are not my favorite, however I like the atmosphere of warm little candles put on the bottom borders of the windows . That’s the starting point of a long and lazy digression.

Instead of burning continuously paraffin wax, could we make a reusable electronic one ? Of course, there is tons of cheap products available. But they are somehow not really convincing me. And I’m not the first one to look on that subject.

I’ll try here to summarize what I’ve found and what I’ve enjoyed to do. Sources and drawings can be found in this github repository.

Over internet:

You can spend a lot of time completely lost on internet as I did, by just googling ‘led candle’ or ‘flickering led’ or ‘micro controller candle’ etc…

I’ve found a nice Tim’s blog post about the reverse engineering of a flickering led. It is really worth a read, he details everything from measurements to analysis, and reproduce the algorithm. This is followed by another post which really interested me. How a real candle flame behave.

The real flame:

To summarize, and as probably everyone knows, the candle flame brightness has two types of behavior. Usually it is rather constant, and it happens some time that the brightness starts to oscillate for one or two seconds. One thing I can add to that is the flame is gently moving, from one side to another one.

Another property of the flame is its light spectrum. And here as well, a lot of people studied this. It is a very warm light with plenty of red / infra-red. We can find some measurements from 1000 to 2000K of color temperature.

Start the Project:

We roughly know what to mimic, so let’s choose some components according these constraints.

For the LED, I looked for the warmest white on the range of 10-20 mA. My ‘local’ provider is Farnell, so after some sorting and filtering I end up with a Wurth warm white led, €0.18.

medium-pic10f320-sot-23-6To add a bit of challenge I choose a very small micro-controller, but still accessible with my tools and knowledge. The PIC10F320 has only 6 pins, 64 bytes of RAM and 256 bytes of program memory. But it has 2 PWM output and an ADC, all for €0.42

To power everything from an AA battery I choose to use a step up converter. The €0.38 MCP1624 is able to output 50mA at 3.3V from a single AA battery, and is working down to 0.35V.

From this point we can control and power two led and read an analogue value such as the ambiant luminosity (using a photo-resistor for example). It is possible to mimic the flame swing by balancing the brightness of the two LED, plus the random oscillations with the total brightness. We can switch off the LEDs when the day is too bright as well.

Code contraints and Prototyping:

After some soldering I manage to put the components on a small development boards and start coding.


I used the Microchip IDE and their XC8 C compiler. The challenge here is that the compiler is in ‘free’ mode, so the compiled code is rather large. I didn’t want to use assembly mainly because I’m not quite confident to prototype with it. But I admit it is the preferable way to do something with only 256 bytes of program available. It’s perfectly legit to argue that an ATtiny10 would at least do the job better. I should invest time to the AVR side one day !candle_XC8

After many iteration to reduce the program size, I end up with only 4 free bytes. Wow. Some C operations give more compact program for the same function (for example initialisation to 0 or an arbitrary value).

The code uses the famous Linear feedback shift register as random generator. The flame position, the speed to go from one to the other position, the oscillations occurrence and their period number are random. The two LEDs are dimmed with the build in PWM, and the speed of change with the Timer0.

It is still open to more complex code as I can use the PIC10F322 with 512 bytes of program space (or even ATtiny10 which seems to be almost pin compatible).

I acquired the two LEDs PWM signal with my recently acquired DSLogic :


And plot them with a quick and dirty Java program:


You can notice the oscillation mode on the chart after 4th second, and the flame swing mode surrounding it. For the oscillations, the total brightness is changing while otherwise it stays constant at 50% (the sum of the two led brightness).

Getting serious with a PCB:

Let’s startup Kicad, do the schematics and play a bit with the PCB drawing. I have in mind a design for a 3D printed case, we’ll see that later.


Several times now I ordered PCB from OSHPark, and never been disappointed. I could use their manufacturing precision to down size the board area up to 17x17mm, giving $2.45 for 3. I let an option for a push button, we never know…


Less serious with the 3D shape:

It is time to think how to hold everything together. I applied for the free student Fusion360 licence. I have to say the program is very nice to handle and to learn.

candleV1 v20

The idea is to hold the battery on the PCB with the three part threads. Just screw them together and it should light-up. The only compromise is the ground wire that goes from the PCB to the bottom part along the battery body.

I also made a join part to be able to have some versions with two AA battery stacked, making it taller and with a longer battery life.


Then I removed the dust of my M3D micro printer, far from the best printer nowadays, but the cheapest when it went out.


Soldering and programming:

And the boards crossed the Atlantic ocean and arrived in the mailbox! It’s always a pleasure to solder components on these high quality boards (even 0805 with a soldering iron).


To program the PIC, I forgot to order some 1.27mm spacing pin headers. However, there is a solution with two 2.54mm ones:



I don’t own yet a nice multimeter, so the current measurement I did with my actual (too) cheap one is rather approximate. I got around 12mA with the LEDs on, and around 4mA in sleep mode, drawn from the battery. Maybe the current of the sleep mode is still high due to the step-up circuit, which runs all the time…

However it stays on at least 3 consecutive days on a single AA Ni-MH rechargeable battery. I logged the battery voltage of one candle with my raspberry-pi logging station. It start with a fully charge single AA Ni-MH battery and I remove the sleeping mode:



Final result:



It is rather hard to catch the effect on a video, as the aim was to create a LED candle as quiet as a real candle could be.


Thanks for reading !

(and my apologies for the approximate language)


8659491486300188651 The PolaPi camera flew to new adventures quite a long ago. I hope it still works and the new owner is using it time to time. I missed it a bit so it is time to rebuild one. In the meantime other parts got out on the market. Such as a smaller thermal printer and the smaller Raspberry pi Zero.

Here we have a good opportunity to try to slightly simplify the project and add features missing on the previous one.

By simplifying I mean avoid the thermal printer hack of the previous PolaPi, and use Python instead of Java. And by features I mean the possibility of review and re-print pictures. More details can be or will be on this page.

Is all about monochrome.

The Adafruit nano printer is only capable of printing black dots. So it is for the Sharp Memory LCD. Except the printer’s resolution is slightly higher than the screen, I like the coherence between_mg_5911 what you see and what you get.

Vít Hašek made it’s own PolaPi and push the concept for his thesis. He called it the white box, in opposition of today’s black box devices.

It is mainly the reason why I made the new one white as well.

Under the hood.

The electronic hardware is similar of the previous one, except the screen.shematics01

However I used 3D printed part for the case.

A button is for taking picture and change to ‘live view’ mode. Another to print the picture file or change to ‘review’ mode. Two others to navigate through the image files. And finally a last one to initiate the raspberry pi shutdown


The Python code and the way to get the LCD library compiled is still a bit messy at the time of writing, but I’ve put everything on github. Moreover, you can get the SDcard image on this dropbox.


Wireless remote display



07_rack_frontFor a while now the Pilogger needs a small remote display. The logging station is neither particularly compact nor elegant, therefore I made some tests about a battery powered status display. I tried solutions which I never used mainly by curiosity but also in order to continue to learn something. Especially the Wifi chip ESP8266 and a Sharp memory LCD. For tests logbook, see the page


esp-12e-frontThe wave of the famous ESP8266 wifi chip from espressif reached me few time ago, but I never experimented it. As a complete image has to be transmitted, the wifi sounds a good solution and the ESP8266 is very capable (beside being very cheap). There is plenty of solution to program it, among the official SDK, microPython or arduino, I chose to test the nodeMCU one. From building the firmware to the integrated development environment ESPlorer, everything is clearly explained on nodeMCU documentation website.

Memory LCD.

LCDA now common solution for very low consumption display is e-ink or e-paper, but another solution from Sharp is interesting as well. There is significant differences between the two, for example the memory LCDs don’t keep the image while out of power. However the current needed to maintain an image is very low, the refresh rate is fast, and the surrounding electronics are very simple. I choose the Sharp LS044Q7DH01, a monochrome 320×240 pixel, 4.4″ display.


For the firsts tests I begun by my usual ugly wiring on a proto-board. I made a schematics with some option regarding the LCD driving. The LCD needs 5V and TI have a convenient boost converter: REG710NA-5. For the ESP12E wiring, Adafruit made a very nice job with their Huzzah board.


After some divergeant ideas and solutions, I used sockets to transfert the image from the Raspberry pi to the ESP8266. In fact, the raspberry java code generate directly the data that should be transmitted to the LCD. The ESP Lua code is then just a bridge between socket and the SPI LCD connection. The Lua and Java code is on github (init.lua, socketLCD.lua and

The ESP is in deep sleep as much as possible. When waking-up, it connects and takes an IP from the house Wifi access point, connects to the raspberry pi socket, receives the image data and sends it in the same time to the LCD, and finally goes back to deep sleep.


We cannot stay with a prototype, and for the first time I tried the OSHpark services. What an amazingly good experience! I used Kicad for schematics and board design as the file format is directly compatible. I’ve uploaded one file, and 20 days later the 3 boards were in the mail box. The quality is very impressive, and the pricing for small size is unbeatable. The board can be find here.



As a frame, for the moment I’m staying with a simple aluminium plate. Few copper plates to fix the board do the job.



With a 2 minutes refresh rate, the batteries survive around one week. There is then still some improvements to do, such as lower refresh rate during night. Another point I should keep an eye on is the LCD driving. The Sharp datasheet recommend to invert a signal either by a serial command or a physical pin (EXTMODE and EXTCOMIN), thus at a minimum frequency of 1Hz. To lower the consumption, this inversion only appends when refreshing to avoid waking up the ESP8266. After few weeks I didn’t notice any artifact on the LCD. Sharp mention a risk of image retention as well, so an inverted image during night time might be a good idea.


Internet Of Mailbox



This post summaries the test I made to produce a mail presence sensor. It is aimed to be wireless, connected to the Pilogger logging station. It is interesting to use a load cell in order to know the weight of the object in the mailbox. But we will discuss the difficulties to implement a reliable solution.

The sensor.


Figure 1 – NTC inserted in the load cell

It could be found very cheap load cell on Ebay, with a small board featuring a 24-bits ADC. The ones I used for this test is a 10Kg cell with a HX711 board.

As the principle of sensing is based on the physical deformation of the metallic rod, the system is affected by temperature change. So I decide to use a thermistor (NTC), placed directly within the metallic rod, by placing it in a small drilled hole. (Figure 1, on the left)

The electronic

The HX711 is an interesting chip for its price range. It is design to measure very tiny resistance change using a Winston bridge. It have two channels, one with two gains (64 and 128) and another with a fixe 32 gain. While the first channel is connected to the load cell, the second one is perfectly usable for measuring the thermistor. To do so we have to do another Winston bridge including this thermistor. (Figure 2, on the right)


Figure 2 – Wireless mailbox probe schematics

I chose to use the same micro-controller and RF link as the previous wireless temperature probe. In other words, a PIC16F1825 and a nRF24l01+. The difference is the HX711 module and a voltage regulator. The HX711 needs a stable 3.3V, and then I use an analog input of the PIC to have a battery voltage information.


The micro-controller code is rather simple as well, it sleeps for around 8 seconds, then sequentially get 8 values of HX711 channel ‘A’ and average them, the same for channel ‘B’, then get the ADC value of the battery, and finally send the data with the nRF24l01.

The XC8 C compiler file for the PIC16F1825 is here in Github.


I fixed one end of the load cell directly to the mailbox bottom, and the other end to an aluminium plate of approximately the surface of the box. For the tests, I just fixed the proto board on a side with tape, and the battery below.

Tests and data.

The system is surprisingly sensible, a letter is clearly visible on the weight data.

But sensitivity is not precision. And things start to be more complex when I try to figure out how to calibrate the system. There is a link between temperature and weight data, but not only. The entire mechanical system plays a role.


Figue 8 – One month of data

Figure 8 shows a complete month of temperature and weight data, with arbitrary units (ADC output). While points marked with ‘1’ are the time where a letter was on the plate, the others are interesting. Point ‘3’ shows that a heavy parcel was kindly placed in the box by the postman. But after that, the weight base line did not recover to the same value. Apparently a mechanical bias appeared, it could be a permanent distortion of the load cell.

I could not fully understood the events marked as ‘2’. These drops should reflect a resistance change, so I imagine it could be linked with humidity and water condensation. It seems it disappeared once I cover the HX711 pins and copper tracks with varnish.

I tried to establish a correlation between the temperature values and the weight values in order to compensate the changes. As the event ‘3’ put an offset I have two data groups. I agree the data looks funny, and it is hard to see a true correlation. (Figure 9&10) We could barely see a kind of exponential curve such as Weight = a + b. Temp², but not enough to compensate correctly.



Figure 11 – Battery discharge in volts

To summarize, the concept is clearly working. I first though the battery would not last so long, but event not fully charged, the 4000mAh li-ion is still alive after a month. (Figure 11).

The HX711 used strait out of the box without shielding gives quite good results. On the 24bit resolution, around 19 to 20 are out of noise, which is remarkable for such a draft system.

As it is, I have at least an idea if there is something present (and roughly how big) in the mailbox, and this everywhere I could have an internet access. To be continued !


Image dithering


I had to convert images to black or white points. This post is a summary of my tests and learning. My main source is the nice ‘Dither’ Wikipedia page. The major issue I had to face is when converting an image with an undefined length coming from a scanning process.



To print pictures on thermal paper with reasonably good rendering, they should be converted according the printer limitations. It’s quite simple, it can be printed only black pixels (and whites as the paper is usually white).

The first step consists to get a gray-scale image. There is plenty well known method, from the simplest averaging of the Red/Green/Blue channels to advanced ones where the pixel intensity is scaled to a color wavelength to simulate a particular response (such as black & white films).

michelangelo27s_david_-_bayermichelangelo27s_david_-_floyd-steinbergThe second step could be achieved by several algorithms. To convert gray-scale pixels to only black or white, a rather easy method is the Ordered Dithering. But it there is noticeable patterns on the resulting image. Another common method is the error diffusion, and in particular the Floyd-Steinberg dithering algorithm. It is this last one that I choose to study as I found the resulting image interesting.


The codes we can find over Internet usually rely on a buffer to store and propagate the errors of each converted pixel. This buffer have the same size of the image and is completed during the iteration over all the image lines.

As receipt thermal printer use paper roll, there is virtually no image length limit. If we want to convert on the fly the image and strait print it, we cannot rely on a fixe full image sized buffer. That’s why I experimenting conversion algorithm based on Floyd-Steinberg, but with only a small rotating buffer. The size of this ‘line’ buffer could be as small as a line size plus one.

Other than the code itself, I try to explain the principle with this Gif :


And the Java code use to generate it :

Very good readings about dithering :


Icebreaker Game


12026610_10207455771046540_1864584773_nAfter experimenting with the small receipt thermal printers and manage to make a portable camera, my brother came up with a very clever idea. He is organizer of a juggling convention, and he looked for a kind of funny game around beer selling and their receipt. The aim was to entertain and offer a beer every lets say 50 sold. He said we can do more than print pseudo randomly a winning ticket based on certain ratio.

The idea.

beerWe imagined a machine standing on a bar, with on the client side a camera pointing at you, a screen showing the camera output and few instructions. On the back side, a single button allowing the barman to launch the lottery for one ticket. What the machine do once you press the front big button (I really love these Adafruit massive buttons!), is taking a picture of you. And then there is two possibilities. If you loose, a souvenir receipt is printed with the picture of your face and a random funny quote. If you win, a winning receipt with the face of someone else is printed, and instructions telling you that if you find the random guy on the printed picture, you both won a free beer.

The printer.

2321The printer choice should consider reliability, speed and print
quality. Even if the last one is relative to what we can expect for black or white thermal printing. I moved from the affordable and small serial Adafruit 58mm printer to a more professional one. After some non conclusive test with a cheap 80mm Chinese printer, I finally get an Epson point of sale printer. The TM-T20 is USB and commands are very well documented on their website. If not set to the maximum print speed, they could make surprisingly good prints for bitmap pictures. It depends a bit of the paper quality as well. I get very nice results with BPA-free recycled paper roll.

The system.

Raspi_Colour_ROnce again, the raspberry pi is a nice card and of course perfectly capable of doing such a process. There is the official camera module, even if a basic webcam would make it as well, USB ports for the printer, HDMI for a screen, GPIO for buttons and leds. But most importantly, I can reuse a lot of code form the Polapi.

The software is written in Java and uses two external libraries. One for GPIO – Pi4J and an other one for USB – usb4JavaIn addition, the native raspbian program raspividyuv is used to get the camera frames. The camera output is on top of everything and always visible on the screen. The all Java software part is hosted on github. The runnable Jar file must be launch on the Raspbian LXDE environment and could be easily auto-launched. There is some logs here, but I must complete them a bit.

The case.

In the view to avoid yet another device taking dust in the garage, I made the case looks like an arcade. I just have to exchange the front panel to have a raspberry pi Mame machine ! (That will instead probably take the dust of the attic, but with style, surrounded by retro consoles)

Wood sawing 

Case filling

Resulting device


It was quite a success on the Juggling convention, it brought fun and few free beers ! It ran smoothly without any reboot despite I expected some bugs.

After being used on a week-end for around 500 prints, it will be used on a Hackathon in Geneva with a slightly different mode.