Saturday 26 October 2013

Arduino LCD Logger

The post "Arduino Tinker Library"  introduces the technique by which an LCD logger with no effort can be created with a different concrete implementation of the AbstractLog class.

My set up consist of an LCD display which is contained in the Arduino Starter Kit. You can easily program it with the LiquidCrystal Library.

Connecting LCD Display

The hardware set up is really simple


And here's the result



LiquidCrystalLog

Now we are ready to use the LCD display as a logger. In the LiquidCrystalLog.h file you can find a concrete implementation of the class AbstractLog.
You can also find a new example, called vect3d_LiquidCrystalLog. As you can see, the original source code has not beeing modified, except for the log variable: it's now a LiquidCrystalLog type variable.
Here's a video of the new logger



You can write every type of logger, SD Card logger, Bluethoot logger, RF logger and so on.

Friday 25 October 2013

Arduino Tinker Library



I've just started working on my Arduino C++ library. You can find it on GitHub: feel free to download it and use it for your projects.

I'll try to build a modern C++ library with advanced techniques and many examples. I'll suggest you a couple of books by which I am inspired:

Log Interface

AbstractLog.h contains an abstract class that you can use in your algorithm class to log every operation.
In SerialLog.h you will find a concrete implementation of AbstractLog which write your algorithm log on the Arduino serial port
In the future I'll show you how to log on a LCD display instead!

Vect3d

Vect3d.h contains a class that represent a 3-dimensional vector. You can use it to do some calculation on a generic 3D space (euclidean space, RGB color space ...)


If you install the Arduino Tinker Library you will find into Arduino IDE an example on how to use Vect3d in your code (File -> Examples -> ArduinoTinkerLibrary -> vect3d)

If you open the Arduino Serial Monitor (Tools -> Serial Monitor or Ctrl+Shift+M) you should see the following output

Vect3d Example
Constructor
V[0;0;0]
V[128;128;128]
V[64;64;64]
V[0.00;0.00;0.00]
V[1.00;1.00;1.00]
V[1.00;1.00;1.00]
V[123.00;456.00;789.00]
Copy
V[64.00;64.00;64.00]
V[1.00;1.00;1.00]
Test
f1 == b2
f3 != b2
Sum
V[124.00;457.00;790.00]
V[124.00;458.00;792.00]
V[129;129;129]
V[130;131;132]
Sub
V[122.00;455.00;788.00]
V[122.00;454.00;786.00]
V[129;130;131]
V[127;127;127]
Scalar Mul
V[307.50;1140.00;1972.50]
V[3.00;3.00;3.00]
Scalar Div
V[49.20;182.40;315.60]
V[1.00;1.00;1.00]
External functions
NormL1(V[1.00;1.00;1.00] - V[64.00;64.00;64.00]): 189.00
NormL2(V[1.00;1.00;1.00] - V[64.00;64.00;64.00]): 13.86
dot(V[1.00;1.00;1.00] - V[64.00;64.00;64.00]): 192.00
cross(V[123.00;456.00;789.00] - V[64.00;64.00;64.00]): V[-21312.00;42624.00;-21312.00]


Tuesday 22 October 2013

KD-Tree art

Lately I've worked on a KD-Tree implementation.
I've programmed a 2D log system using OpenCV which allows the visualization of the data structures.

After some test, a nice idea came up to my mind! Why shouldn't I post my data structures as a piece of mathematical art to launch my blog?! ;)

Here is the result: some points which lay on two circle and a sinc, inserted into a KD-Tree.


PS: As you can see the point x=0 of the sinc is not in the correct position! I have left it, so that it would remaind me that a PC doesn't know the concept of limit