Code::Blocks with MSVC2013

This is a quick placeholder post on how to set up the C++ IDE Code::Blocks with the Microsoft Visual Studio 2013 tool chain. The main information is found in this PDF.

Quote from the PDF:

“This document aims to explain a way to configure Code::Blocks on Windows using different Visual
Studio C++ compilers and Windows SDKs. Where relevant it is discussed how to compile for x86
(32bit) and x64 (64bit) executables.

The general approach taken is to employ the Code::Blocks global variables for configuration of the
compiler and related tools, i.e. set the global variable values according to the needs of the compiler,
SDK and target processor architecture. Examples are provided for MSVC2010 and MSVC2013. By
extension, it should be feasible to reconfigure for other MSVC versions.”

If you have questions or comments to the method described, please comment below.

A pipe dream come true

The old sewage pipes have been a worry since we found out their condition recently. Fixing it seemed like a pipe dream. Today that dream came true, the plumber arrived and did a great job! The old cast iron pipes are out and modern plastic ones are in.  A last goodbye to the old rusted pipes:


The new plastic pipes have been installed, quite some difference compared to before:


A second pipe goes under the wall next to the fireplace. It continues under the chimney behind the wall and into a washing room.  A pipe from the kitchen also connects there. The big problem with the pipe under the chimney was that it was rusted and totally filled with old muck.  With a lot of effort and high water pressure, enough of it was cleaned to allow a slightly smaller plastic pipe to run inside it. We were saved!


Here is a detail of that connection.   The top one had to be cut a bit more after the image was taken as it was cracked. Luckily, the material further in was fine.


In the other end the pipes meet and go though the outside wall.


Tomorrow the new pipes will be covered by concrete, to prepare for pouring the new concrete floor on top.  A person from the company who will pour the floor showed up today so it seems to come together quite nicely now.


It has been a while since the last post, and it is for a reason. On September 2nd we experienced very heavy rainfall, I measured 143mm rain on my weather station that day. The result was that our basement was flooded, the water level was 7-8 cm above the floor. As the basement contained old furniture, library and a home office with desktop computers we found ourselves in crisis mode.

The first action was to limit the damage by moving everything away from the basement and start pumping water. That’s a long story in itself, but to cut it short we got assistance from the insurance company. The second realisation was that  the drainage system needed improvement, here is a small part of that effort:


My desktop computer found itself under water as well.  The water level was at least up to the bottom PCI slot in the image below. After cutting power and pouring water out of the cabinet, plus drying it for a couple of days, the machine actually rebooted. The only problem was that the motherboard sound card was fried and totally silent.  A cheap sound card was ordered and installed a few days later. It turned out the sound card (ASUS Xonar DG) had limited Linux support, but with a bit of effort it worked just fine, and the computer was back in business:


However, the basement was still a complete mess. The wooden floor with heating had been removed and under it we found rough concrete with sand used for levelling (the house is from 1969).  The sand was now all wet and very difficult to remove:


The solution was provided by these guys, who sucked out all the sand to allow the the floor to dry:


In theory, we could then start planning of the basement floor rebuilding. However, a “problem rarely arrives alone” as we say here.  As the house is from 1969 and the sewage pipes from that period are made from cast iron, it made sense to inspect them for damage.  That turned out to be a good idea…


The pipes are completely rusted and in urgent need of replacement. The needed repairs triggered by the flooding are just growing in magnitude and cost. They just have to be done. One might even argue that the good news is that due to the flooding we got a chance to inspect and replace the pipes.  The plumbers will arrive tomorrow…

This post could have been ten times longer, but the main idea is to explain the lack of recent blog posts.  Hopefully, we are now at the low point of this experience. Let the reconstruction begin!

Luk thung

I tend to enjoy a bit of variety, so therefore this post offers something out of the ordinary: a teaser on  popular rural Thai music.

‘Luk Thung’ (Thai: ลูกทุ่ง ) is short for ‘Phleng luk thung’  which means something like ‘song of a child of the fields’. It is a music style from the north-eastern provinces of Thailand, referred to as Isan, where rural life is dominated by the poor working in the fields under a blistering sun. Luk thung music is said to reflect the hardships in this kind of life. The tempo is slow and the style of singing is very different from  western popular music. Being different, it becomes interesting.

A westerner would perhaps assume this style of music is traditional folk music, but it really isn’t. It is a relative new creation not much older than western popular music, but with obvious influence from Thai culture and traditions.  Some of the luk thung artists are no less than superstars in Thailand, selling millions of records. Still, most people in the west have no idea of their existence.

There is an obvious language barrier, as the songs are performed exclusively in Thai, Lao and Isan dialects. However, when I was a kid I listened to English language music without understanding the words. Understanding the words is not always required in music, and I don’t pretend to understand the words of Luk thung music.

Below is an example of Luk Thung music, the artist is Tai Orathai .

Tai Orathai


For more information on Luk thung, see for example *Luk thung* (Thai country song) and the history of popular music in Thailand from the 1930s up to the present.


Back in the day – in 1969 – American space travel was inspiring. The mighty Saturn V rockets, 110m tall and 10m wide, launched Apollo 11 to the Moon and inspired everyone who saw it.

Saturn V Launch with Apollo 11


Recently, I discovered a model of the mighty rocket on Thingiverse so I thought it would be fun to print it.  the model was split according to the original rocket stages, i.e. 3 rocket stages and the parts which flew to the Moon.


The printed model is 30 cm tall, so essentially it is a 1/366 scale model of the original.  It was printed using 0.1 layer thickness, so each part took about 2-3 hours. It snapped together very nicely.


This model  will be allocated visible location in the living room!

Greece should be proud

I have been following the Greek story for a number of years and intensely the last months and weeks.

In short, the story began in earnest when Greece adopted the Euro 1 January 2002, only 13 years ago.  At that point, the country could no longer control its currency exchange rate, but suddenly it had almost unlimited access to low interest loans. For a country like Greece, this was an arrangement certain to fail. Greece was never qualified to adopt the Euro, but with the help of Goldman Sachs and its own corrupt elite, the books were cooked and Greece became an Euro member anyway. At that point the rules was well and truly bent, but the EU did not have any problem with broken rules in 2002.


Enter the money-lenders. Big, privately owned German, French and other banks offered huge loans for big projects like the Olympic Games in Athens 2004, plus a number of other large projects. As long as the economy was booming, no-one seemed to care about repayment.

In 2008, the financial crisis arrived, and Greece was hit like no other country in the EU as it entered into recession. The huge Euro debts it had acquired could not be paid back. If Greece had not already converted to the Euro, it could have devalued the Drachma and that way made imports more expensive and exports cheaper. That would have made Greek export more competitive, lowered domestic interest rates and they could have worked their way out of the problems, like many other countries had done before them. But since Greece no longer had the Drachma, it could no longer control its currency exchange rate and devaluation was not possible.

Greece was unable to pay its debts in 2010 and was bankrupt because of domestic and foreign mismanagement. A Greek default in 2010 would have caused major discomfort to the debtor banks. This did not happen, however, because the so called “Troika”, namely the EU, ECB (European central bank) and the IMF (International Monetary Fund), “helped” by giving Greece more loans, 110 billion Euros. Almost all of these new loans never entered Greece, it went straight into the bankrupt banks outside of Greece to cover the bankruptcy. It wasn’t Greece which was “bailed out”, it was the banks! Through this brilliant move, the debt was now suddenly on the tax payers of Europe. This is how you rob people, both in Greece and elsewhere in the EU.

The next stage was the stage of “reforms”. Now, in return for its “help”, the Troika demanded severe cuts in the Greek economy. This caused the Greek GDP to contract by 25-30% and caused mass unemployment, especially among young people. The ability to pay back the loans was steadily diminished because of this, and the problems naturally kept growing. Greece had no chance to limit its deficit to 3% as required by the EU, in 2009.

Greece is far from guilt free in this. Businesses didn’t pay enough taxes and the corrupt government enlisted banks like Goldman Sachs and JPMorgan Chase to cook the books once again, while the EU looked another way. The result is that in 2015, the Greek debt is about 180% of GDP, up from 100% in 2010, and 3 times the maximum allowed in the EU. As the the EU austerity policy forces the reduction in GDP, the debt/GDP ratio just grows. It is almost like someone wanted it to be that way.

Enter the January 2015 elections. The traditional corrupt Greek politicians (PASOK and New Democracy) were essentially swept aside and a new party, SYRIZA, comes out victorious. Their message is to end the damaging austerity policy and find an agreement with the EU so that the debt can be paid back. and the economy rebuilt.  For this to happen, the Greek economy must grow. As it stands, it is mathematically impossible to pay back the debt, it will just increase to infinity because of interests and the ever smaller size of the Greek GDP.

So what does the so called “EU leaders” propose to solve this conundrum? More austerity! It defies any logic, regardless of how you look at the former and current Greek politicians handling of the matter. The only logic that makes any sense is that the plan is to loot the country completely, both for the sake of the remaining Greek assets and as a “reminder” to other countries that may be on a similar path (make that Italy, Spain, Portugal, Ireland and maybe France).

After months of negotiations, where the Greek negotiators have bent over backwards to try to find a viable deal, i.e. one that allow them to pay their debts without killing the economy and the people, the only replies from the unelected EU bureaucrats have been more “reforms”, i.e. more of the same austerity policy that has transformed Greece from a problem area and into a disaster zone.

This behaviour from the EU is simply criminal, as it is well understood by the EU politicians and unelected EU bureaucrats. The former Greek finance minister Yanis Varoufakis said: “What they’re doing to Greece has a name: terrorism”.

In a surprise move on June 30th, the Greek prime minister Alexis Tsipras called a national referendum July 5, asking the Greeks if they would accept the conditions put forward by the EU and Troika. Instead of suggesting a referendum to the Troika, something which has led to “regime change” in Greece only a few years ago, Tsipras announced the referendum directly on TV. This was too short time for the media and EU machinery to manipulate the process, although they tried very hard to tell the Greeks to accept more austerity and that anything else would be catastrophic.

The result of the referendum was that about 61% voted OXI (“no”) to the EU conditions. This was a stunning lesson in democracy from the country where democracy was born, and the EU was totally naked. It was now much harder for the Troika to impose the policy that has been proven to not work (assuming their aim is to help Greece). Still they tried, disregarding mathematical laws.

This time, it seemed very important for the EU to “follow the rules”, rules they had themselves broken long ago. The reason for this irrational stance is that if the EU writes off enough of the Greek debt (it will never be repaid anyway), the tax payers of the Eurozone will be handed a huge bill. One suspects the bureaucrats think there could be “blood in the streets”. Secondly, many of these taxpayers live in France, Italy and Spain, countries with problems similar to Greece. The dominos will simply start to fall and the Euro and the EU will become history very quickly if countries like Spain have to pay the Greek debt.

So what is the best scenario for Greece and the EU?

The best scenario for Greece is to defaults on its debt, exit the Eurozone and adopt its traditional currency, the Drachma. Then devalue it to make export more competitive. This will be extremely hard on the Greek people, the times ahead will be very tough. However, through this move they regain their sovereignty and with time and hard work they will come back stronger than before, I am certain Greece will again be proud.

The EU will be able to show how deep the solidarity goes towards smaller countries. The EU will also be able to prove its assurances that the rest of the EU will be just fine after Greece exits the Eurozone and possibly even the EU. The fact of the matter is, however, that the EU has now been exposed, the peoples of Europa have seen who the unelected EU-bureaucrats and EU-politicians are, and who they represent. It is not the peoples in Europa.

Edit 11. July 2015: Yanis Varoufakis has written an article titled “Behind Germany’s refusal to grant Greece debt relief” in which he writes:

“Our government was elected on a mandate to end this doom loop; to demand debt restructuring and an end to crippling austerity. Negotiations have reached their much publicised impasse for a simple reason: our creditors continue to rule out any tangible debt restructuring while insisting that our unpayable debt be repaid “parametrically” by the weakest of Greeks, their children and their grandchildren.

In my first week as minister for finance I was visited by Jeroen Dijsselbloem, president of the Eurogroup (the eurozone finance ministers), who put a stark choice to me: accept the bailout’s “logic” and drop any demands for debt restructuring or your loan agreement will “crash” – the unsaid repercussion being that Greece’s banks would be boarded up.”


“Based on months of negotiation, my conviction is that the German finance minister wants Greece to be pushed out of the single currency to put the fear of God into the French and have them accept his model of a disciplinarian eurozone.”


In the Printrbot – Heated Bed post, I mentioned the covers to go over the wings of the heated bed.  I asked for comments to the blog posts, and today a request for the wings design files was posted in the comments of that post. I am therefore happy to say they are now available for download at

I have been using the printer with the wing covers quite extensively for about 3 weeks, and they work just as intended as far as I can tell.  Note that the photo shows a small rectangular hole on the left which is not in the uploaded model. The large rectangular hole is to allow access to the X belt tensioner. The smaller rectangular hole was not required and therefore removed in the model.

The covers are designed as solid parts, but printed with “hollow” infill and 0.8 mm skin. The parts should be hollow since air is a good heat insulator. With the insulation I can reach 60C bed temperature in 4-5 minutes and 100C in 19-20 minutes.

About comments

Almost every day I check for comments to the posts, but find that all I get is spam posts in the spam filter :-) Does that mean no-one reads this blog? Perhaps, but the visitor count is increasing …

If you happen to visit and find something of interest, you are now encouraged to make a comment, if you prefer you can do it anonymously. With comment feedback you may influence the contents of future posts, otherwise I get 100% of the votes and that’s not fair :-)

You can for example begin with a simple hello below this post!

A wheel centre cap

In the post about printing 3d gears, we saw that it was possible to print replacement gears for car parts. I have now received a report that the printed gear works after several weeks of in-car testing, so let us count that as a success. In fact, it was so successful that I got a request to print another part that was missing; a press-fit wheel centre cap, original as below.


The owner also wanted the logo on the replacement part. When you don’t pay, there is no limit to what you can ask for :-) Anyway, I thought we might give it a try.

First step was simply to place the original on the flatbed scanner and make an image of the logo. I could have found the logo on the web, but that is cheating. Instead the scanned image was imported into Photoshop and turned into a monochrome image and blurred/clipped and saved to a PNG file.


Then, OpenSCAD  was fired up, and the following script was edited


In the above code, the d1 to d4 parameters define measured diameters (using a caliper) on the original. d1 is the outermost diameter. Similarly h1 to h4 define the heights measured from the bottom when logo is pointing down.

The “logo()” module imports the scanned image and turns it into a 3d object. A slice of that is created by intersecting it with a “cube” (actually a cuboid). The intersection is then scaled, rotated and translated to fit the size and orientation of the printed object.

The “bottom()” module is simply a short cylinder minus the logo at bottom and a smaller cylinder on top, to create a “rim” on the bottom part.

The “teeth()” module describes the 2d profile of the teeth that grips the wheel and then performs a rotational extrude (360 degrees). This is then intersected with the result of the “cross()” module which simply defines a cross from 2 cuboids. The result is 4 teeth, separated by 90 degrees.

All in all, less than 60 lines of code. We then get this OpenSCAD model to export as an STL file.


There are many ways to process an STL file, but generally it needs to be run through a “slicer” program to generate the G-code that a printer can understand. There are many very good slicer programs, including slic3r and Cura, but recently I have been using KISSlicer, as it has many nice customization options.


After completing the slicing, we have the G-code to send to the printer. I am using OctoPrint running on a wireless Raspberry Pi to control the printer, so the G-code is sent to OctoPrint via the web browser on the PC. OctoPrint can also display the temperature of the hot end and the heated bed. All we have to do is check that the printer calibration is ok and commit the print:


When finished, we have something that closely resembles the OpenSCAD model.


When we turn the print around, we also see something that resembles the logo. It is not perfect, but it is there. One idea is to fill the void with some dark filler and sand the top surface a bit. Then it might pass :-)


A challenge with a part like this is that the printed part is relatively brittle compared to the original, so it is hoped that the teeth simply do not break off. This is why the printed teeth are made wider than in the original, where it is only the smaller teeth that grip the wheel.

Printrbot – heated bed

The break in posts on 3d printing does not indicate that nothing has happened in the time passed. On the contrary, I have been too busy exploring various smaller problems and ways to improve.   The most important improvement is the installation of the “heated bed” upgrade that has been waiting since I got the printer. I left it alone for a while because I wanted to get some experience with printing on the unheated standard bed. I think now it was a good idea, because I can see the benefits in better perspective after installing the upgrade.

So what exactly is the “heated bed”? It means that the print surface is heated by a heating element so that the plastic parts do not warp as easily (or at all). With the unheated bed there will be temperature gradients in the parts causing warping, especially when the print surface is relatively large, i.e. longer than just a couple of centimetres.  With the heated bed the temperature is more uniform through the part and you can then create more geometrically accurate parts. Since I am mostly interested in mechanical parts, it is important.


The upgrade kit contained a machined aluminium print surface (bottom right). Being machined, it also provides a flatter surface than the standard bed, which can be slightly non-flat. The other main parts are the 2 black aluminium “wings” that are needed for the X belt after removing the standard non-heated bed. At top left is the heater element with 12V wires and next to it is a sheet of heat resistant Kapton tape which will be fastened to the aluminium print surface. In the bag is a thermistor that will be used for monitoring and controlling the bed temperature. Both the thermistor and the heat element power wires connects to the board under the printer. The bag also contains delrin parts to help insulate the “wings” from the hot print surface.


On the underside of the machined print surface, there are grooves that must be electrically insulated using Kapton tape. The biggest groove will contain the soldering points on the heater element and the smaller groove is for the thermistor.  After placing the thermistor in its place, the heater element is put on top (i.e.  under it, since the print surface is upside down still). The black & white wires are for the thermistor.


Over (i.e. under) the heater plate comes a reflective sheet that is simply screwed into the corners. I added some Kapton tape pieces to secure it. I am not sure this is sheet very effective, heat is lost not only via radiation. It would make sense to let the sheet cover the whole plate also. But this is according to the kit.


What remains after this is to turn the heated bed around and connect the X-belt to the wings and then connect the wires to the board. But I also added an update of my own. Under the 4 corners of the heated bed I put a flat and a split washer so that it is possible to manually adjust the “bed level”, i.e. manually make the print surface as perpendicular as possible to the print Z-axis of the printer.  The goal is not to replace the Z probe which accounts for unlevelled beds automatically, but  to ensure the adjustments are very small.

Once installed, we have a new and shiny printer! Notice also the Raspberry Pi  Model B in the background, that is the other important upgrades that the recent weeks have seen.  Instead of connecting the printer to the main computer, the Raspberry PI is committed as a wireless printer server, running OctoPrint . OctoPrint provides a web interface, so you can access the printer via any browser, anywhere. This is now the standard mode for how I  operate the printer, it is very convenient.


Also in the background is the new power supply serving the printer. The standard laptop-style power supply that came with the printer cannot be used with the heated bed, you need a power supply with more “grunt” as the heated bed draws about 7A  at 12V.  The power supply I use is rated at 10A and seems to be working fine for the job.

Below is how OctoPrint reports the temperatures of the bed and the hotend. The bed can reach 100C in about 14-15 minutes from a starting point of ~20C which I find adequate.  100C is required for ABS, but for PLA 60C is sufficient, it achieved in about 5 minutes.


The temperature curves above are not really reflecting the standard heated bed upgrade shown above. It reflects an additional modification. I noticed that the black “wings” of the heated bed got quite warm, they acted as heat sinks and radiators, even with the delrin pieces in the kit that were supposed to insulate the “wings” from the machined print plate.  It probably has some effect, but a lot of heat is lost that way still.  The curve above shows the effect after installing the “blankets” described below.

It seems like a good idea to put a “blanket” over the wings to reduce the heat loss. I did that by designing hollow covers to go over the wings. They are designed as solid parts, but printed with “hollow” infill and 0.8 mm skin. Below is how it looked during early print, there are for parts since each of the two wing covers are split,  you cannot print a part covering the whole print surface on the same print surface…


After completion, you get this nice looking view, four parts complete with holes for screws and belt tensioners.


These parts simply “snap” onto the wings, the heat loss is now much reduced.


I am very happy with these changes. The power supply is working, the Raspberry PI with OctoPrint is the perfect way to operate the printer, it works flawlessly even with the older Raspberry PI model B. It also frees up the main computer during long prints.  The heated bed itself works fine, I can now print large parts without warping and I am also ready to consider printing ABS.