AdSense

Sunday, 14 December 2014

Arduino - Read out height sensor GY-65

(Deutsche Version) A common way to measure relative heights is the usage of a barometric height sensor. Such a sensor measures the pressure and by using the barometric formula (Wikipedia), one can calculate the height. The ambient pressure varies during the days therefore the sensor is calibrated at a well-known height and the other heights are calculated by using this reference pressure and height. The measured heights have a precision of up to 1 meter.

If  you look for the GY-65 at ebay, you can find the sensor for about 5 euro. The sensor has a usual I2C interface so only two wires are needed. Additionally, the I2Cdev library is needed which can be downloaded here. The source code is as simple as possible, at first the sensor is initialised, then measuring the pressure is set and afterwards the pressure is read out and calculated into the height. A basic program looks like this:


#include <I2Cdev.h>
#include "BMP085.h"
#include <Wire.h>

BMP085 barometer;

double pressure;
double altitude;


void setup() {
  Wire.begin();
  
  Serial.begin(9600);
  Serial.println("starting...");
    
  //initialize the barometer
  barometer.initialize();
}

void loop()
{
  // request pressure (3x oversampling mode, high detail, 23.5ms delay).
  // Let's just wait a bit more to be sure...
  barometer.setControl(BMP085_MODE_PRESSURE_3);
  delay(30);
  // read calibrated pressure value in Pascals (Pa)
  pressure = barometer.getPressure();
  // calculate absolute altitude in meters based on known pressure
  // (may pass a second "sea level pressure" parameter here,
  // otherwise uses the standard value of 101325 Pa)
  altitude = barometer.getAltitude(pressure); 
  
  // print back the calculated altitude
  Serial.println(altitude);
  // do this every second
  delay(1000);
}

I2C OLED display

(Deutsche Version) If you look for "Arduino OLED Display" on Ebay, you will find a display with a size of 1 inch and a resolution of 128x84 pixels which is controlled via I2C. It costs less than 4 Euros. Of course, 1 inch isn't much, but I was curious and so I ordered it. To show you how small it really is, I placed a coin next to it:


Connecting the display is very easy (thanks to I2C): you only need the voltage supply and two wire for I2C. But how can you control the display? After some searching on Google I found out that the display is a clonde of the Adafruit OLED display called SSD1306. Adafruit offers an Arduino library for this display which can be downloaded HERE. Additionally you need the Adafruit-GFX-Library. After installing the two libraries you will find the example "ssd1306_128x64_i2c" under "Adafruit_SSD1306" in the Arduino IDE. But if you transmit this example to the Arduino nothing will happen. The china-clone-display has a different I2C adress than the original Adafruit display. You will have to change something in the setup() function. Change
  display.begin(SSD1306_SWITCHCAPVCC, 0x3D);  // initialize with the I2C addr 0x3D (for the 128x64)
to
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x64).

After that you can transmit the example to your Arduino and you should see a small demonstration of the different functions of the GFX library on the display. Since there are a lot of functions and the example has a lot of code I will not explain it in detail. I think all of the functions in the example are self-explanatory. I you have problems understanding the code, just have a look in the header file of the GFX library. There you find further explanations like parameters for the functions. You can print text, draw squares, triangles, etc. Even inverting or scrolling the screen is possible.

You also have the possibility to print a user-defined bitmap. I'm going to explain this:

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

#define XPOS 50
#define YPOS 25
#define BITMAP_HEIGHT 16 
#define BITMAP_WIDTH  16 
static const unsigned char PROGMEM bitmap[] =
{ B00000001, B10000000,
  B00000010, B01000000,
  B00000100, B00100000,
  B00001000, B00010000,
  B00010000, B00001000,
  B00111111, B11111100,
  B00101000, B00010100,
  B00100100, B00100100,
  B00100010, B01000100,
  B00100001, B10000100,
  B00100010, B01000100,
  B00100100, B00100100,
  B00101000, B00010100,
  B00110000, B00001100,
  B00111111, B11111100,
  B00000000, B00000000 };

void setup()   {                

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x64)
  
  //clear display buffer
  display.clearDisplay();
  //draw a bitmap stored in variable bitmap with given size at XPOS, YPOS in color white
  display.drawBitmap(XPOS, YPOS, bitmap, BITMAP_WIDTH, BITMAP_HEIGHT, WHITE);
  display.display();
 
}


void loop() { 
}


In this example we are going to draw a bitmap with the size of 16x16 pixels. Of course you can choose another size. The bitmap has to be stored in a character array. It is very important to use the keyword "PROGMEM" when declaring the variable. This will make the Arduino store the variable in the flash memory. The library only accepts bitmaps stored in flash. In the example, two characters store the 16 bit data of a line of the bitmap. If a bit is set, a pixel is set when the bitmap is drawn. To increase readability, line breaks were inserted. On line in the code is on line of the bitmap. To draw the bitmap, you have to call the function drawBitmap(). Parameters are: x- and y-position of the bitmap, the variable in which the bitmap is stored, height und width of the bitmap and its color (BLACK or WHITE) of a set pixel.

The result:

Friday, 5 December 2014

Sharpen a brush

(Deutsche Version) A newly bought brush is usually sharp and also a bit hard so you can draw very fine lines. After a while, the hair of the brush starts to point into every direction so you cannot use the brush any more. To get the brush back into the state which it has been after buying, you can use a simple trick.
A used brush which you cannot use for fine details any more.
First you have to create a mixture of sugar and water. Simply mix the two ingredients and stir. Now you may put the brush in the liquid. The surface tension keeps the hair together.
Brush tip with the sugar water mixture applied. The hair is kept together (Surface tension).
To get the brush back into the perfect shape, you have to wipe off the brush off carefully, this gets it even sharper. If the brush dries, the tip gets even better, as good as for a newly bought brush. I use brushes of the size 00, you can get them in every toy's shop. If you take good care of the brush, you should be able to use it forever.
The sharpened brush.

Saturday, 15 November 2014

An introdurction to tabletops

(Deutsche Version) Since I have been playing tabletops for quite a while now, I want to post an introduction today because I think that tabletops are the best and most intresting kind of parlour games. Tabletops do exist in many different worlds, I will focus on the fantasy setting. Technologically, a fantasy setting is like in the Middle Ages when gunpowder was just developed. There are many different races like dwarves, elves, orcs, goblins, dragons and many more. Additionally, magic exists as for example a wizard being capable of shooting fire balls.

A tabletop consists of figures which are placed on a table or gaming plate. Well-known producers of tabletop miniatures are for example Kings of War von Mantic Games, Warhammer von Games Workshop, Dwarf Wars von West Wind Productions or Hail Caesar von Warlord Games. Personally, I use the miniatures from Mantic Games because they are quite cheap and have sime interesting units like archangels or brock riders which are not sold by other manufacturers.

The basic principle of a tabletop is two armies (or more) fight against each other, similar to the video games of the series Total War.

Painting and constructing
If you want to start with a tabletop, you have to have an army. Usually there are starter sets, i.e. from Mantic Games, consisting of one or two armies, dice and a rule book. This set then delivers single plastic pieces which have to be painted and constructed. This already offers one point of conflict: Construct first or paint first? Personally, I think that painting first is better, if the figures are already constructed, you cannot paint all places as good as prior to constructing. If you pain first, I would suggest to painting above all places with glue again after construction to have a better look. Another important argument for painting first is that otherwise you can already play with the constructed figures. Painting will be shifted to later and maybe never done, this is responsible for whole armies being unpainted what looks miserably. If you paint first, you can only play with the figures when everything is done, so you have the motivation to paint them.

For construction, I use the well known Revell Contacta glue, you can purchase this cheaply in nearly every toy store. I also use colours from Revell, at first I used the Email colours, they are really strong (except for white) but are rather thick and not easy to handle because they cannot be thinned with water. I later switched to the Revell Aqua colours, they are really easy to handle and can be thinned with water so you can also use different painting techniques like washing by thinning the paint with lots of water. Additionally, the Aqua colours should dry faster (4 hours vs. 1 hour).

If the army is constructed, you can start to play. Therefore you need another player with an army or you simply purchase two armies and let them fight against each other. You can use nearly everything as a gaming field, starting at the carpet or a table to a green felt mat or special gaming mats and even modular terrain as I already described it in this blog. For the beginning, a table is sufficient with some objects like a piece of paper as a swamp, a book as a hill, the only limitation here is your mind.

Rules
I now want to address the rules of these games, especially the rules for kings of war which you can download here on the bottom of the page. Basically, the game is round based, one player after the other. Every player has three parts during his turn.

Movement
At first, movements are executed, every unit has a movement value in inches which describes how far a unit may move. There are special rules for attacking enemies which are explained in the rule books.

Shooting phase
After the movement, ranged attacks are executed, all units which are not in melee may shoot. There are usual ranged infantry units but also artillery and magic attacks, all of them are handled in this round. Let's for example face dwarven crossbowmen (Ironwatch) from Kings of War. They have a ranged ability (Ra) of 5+ and 10 attacks. This means that you have to throw 10 dice and every result of 5 or higher counts as one hit. Next, the damage is calculated. Therefore, every die that hit the enemy is thrown again. If the dwarves for example shoot on orc warriors (Greatax) which have a defense value (De) of 4+, you have to throw now 4 or higher to inflict a point of damage. Afterwards a nerve test is performed, this will be explained below.

Melee phase
After the ranged phase, the melee phase starts. All melees are initiated in the movement phase by bringing your units in contact with the enemy. The melee phase is similar to the shooting phase, except for that the melee value instead of the ranged value is used. Here, also hits and then damage is calculated and afterwards a nerve test has to be performed.

Nerve test
After the shooting and melee phase, a nerve test has to be executed. The nerve test determines whether a unit can still fight or is damaged too heavily, the moral has broken down or the unit has been wiped out completely. Therefore, two dice are thrown and all the damage from the unit has to be added. Every unit has a nerve value, consisting of two numbers. If the sum out of dice and damage is as big as the first number, the unit has lost its moral, can only do some basic movements like going backwards or turn and cannot shoot in the next round. A round later, this effect is gone again. If the sum is as high as the second number, this means that the unit is wiped out. Either all soldiers are dead or they fled and will never return again - this unit will not fight again and has to be removed from the battlefield.

These are the main principles for playing a tabletop. Of course I just showed some simple aspects of tabletops, if you really want to play a tabletop, you should look into the rule book. The different games have different rule sets, personally, I prefer the rules from Kings of War because they are quite simple and still allow a lot of tactical depth, so the game does not only consist of checking special rules and reading in the rule book all the time.

There are other settings where you can find tabletops like e.g. science fiction tabletops which have quite similar rules, and also historical variants, completely without magic. There also exist tabletops in other scales like a space ship fight or a sea fight with ships. I really like Kings of War from Mantic Games best, the scale, 28 mm, is a good compromise between size of units and the size of the details. It also is the most common scale for tabletop miniatures. I hope that I was able to arouse interest for tabletops so more people can discover this amazingly interesting sort of parlour games.

Sunday, 2 November 2014

Tabletop terrain - water

(Deutsche Version) The basics of creating your own terrain are quite simple. Construct your model, paint it and add grass or some decorative stuff. Of course you can spend an infinite amount of time for doing this but the basic principle is easy. What I did not try until now was water. The easiest version of water is a simple blue area with a shiny surface. Usually, this does not look that good.

There are several commercial solutions to create nice water which I did not try at all. I used silicone instead, which you can get cheaply, for example at Obi (I used this one from an Obi in Germany). The result looks quite good:
When working with the silicone, you should keep in mind that it dries very fast and sticks to your fingers. Creating a wavy surface is easily achieved, if you want to have a flat surface, this is much harder. Additionally, you should keep in mind that the silicone is not perfectly transparent. Therefore, I would suggest to only use the silicone for a thin layer or the waves effect. If the terrain piece shall also consist of grass, I would highly recommend to applying this before the silicone due to the fact that the small grass pieces stick horribly to the silicone and nearly cannot be removed any more. If you want to create deep water, you can see a test object from me in the next two pictures:

The test object is 1 cm deep. The surface is much flatter but still not a perfect flat surface as you would want to have for a lake. For larger volumes, keep in mind that the silicone does not stick to itself after it has started to dry, this creates white areas which do not look good, as you can see in the pictures.
Compared to the price of other commercial products, the silicone is much cheaper and still looks quite nice.

Siege equipment part I: Siege ladder

(Deutsche Version) Since I explained how to create parts for a castle, I now have to focus on the attackers. As a first step, I want to start with the most easy part, namely the siege ladder.
To create a siege ladder, you need a piece of wood which has a cross-section area of 3x3 mm, I used balsa wood. For a ladder, you need 72 cm. The balsa wood is cut into two pieces of 18 cm length and 9 short pieces of 4 cm. Now, you have to mark the large pieces at the positions 1,3,5,... cm and glue the short parts on them. This completes the siege ladder, you can add some brown color (I would propose watercolour because you still can see the wood structure from below).

Tabletop terrain - hills

(Deutsche Version) In this post I want to introduce some new terrain plates: Hills. As like all my other terrain pieces, I build them from styrofoam. I also use the base plate made from wood on which I glue all the other things.

I defined the height of the hills as 5 cm, this fits to the 28 mm figures. Let's figure out the transition between two terrain pieces. This has to be the same for all hill pieces for being able to combine the terrain in any way. I build the hill from 5 plates of 1 cm thickness which are 8, 9, 10, 11 and 12 cm width. The scheme looks like this:
Now you can build the first basic shapes: Edges and corners. For a corner you need 5 pieces in the size of 12x12, 11x11, 10x10, 9x9, 8x8 cm. These are glued on top of each other fitting to one edge.
Now, this looks a bit like a hill. To improve it, you can easily tear off parts out of the styrofoam which looks a bit more like rocks than the 5 plates before.
Now you have to paint the hill. The two plains in brown and the rest in grey. All the grey parts are then drybrushed in white and then grass is put on the plains.
I would suggest to tear off more styrofoam than in this picture (this was my first try so it does not look that good). You can now build additional pieces like edges or inner corners.
The elevated plain is simply a 6 cm thick block of styrofoam glued on a wooden base plate.