Fighting with computers

Computers are not always friendly.

Sunday, July 30, 2017

Spanish Stick Font for your project

I have a project where I need to draw some text on a plotter and while I could just use a vectorized Truetype font, that usually comes with the undesired effect of doubling the printing time plus leaving a white background, as the font strokes are made of two different lines.


A stick font consists of a single line. Just googling around I found this program. That happens to include a set of font files that were easy to parse (as they were text files).  This is the font I selected for my purposes:

Originally it did not include the full set of Spanish characters but that was easy to fix, as you can already see them on the picture above. Plus I realized some of the existing characters could be optimized so drawing time could be reduced. 

Maybe there is a better way as I have a very limited knowledge about font standards. But this approach makes sense to me. Now I just need to create a simple script to go from text to SVG or G-CODE. 

Update: I just put my code where my mouth was.

Saturday, July 08, 2017

Measuring weight with Arduino

While there are different solutions to achieve weight measuring, it seems the cheapest and neatest way is to use the HX711 amplifier and A/D converter.


Of course, a test weight is needed for you to be able to set the scale right. In my case that is going to be done by that idler that totals 11.30 grams. My sample load cell is a 100 grams unit so it is not that bad, but for a larger end scale, you want to have a test weight at least 10% of end of scale value.

What HX711 does is two things, on one hand, it is a precision low-noise amplifier for the load cell signal and on the other hand, it performs a 24-bit analog to digital conversion (much higher resolution than the 10-bit resolution of the Arduino built-in analog inputs).
Once data is converted to digital format, Arduino can read it from the HX711 using a two-wire serial interface. It basically streams the 24-bit value on one pin while the other provides the clock signal for the transfer. There are several Arduino libraries for that.
You want to wire the HX711 board (I used one I bought off eBay) to be close to the load cell. Example code is very simple and just provide you a numerical value that represents the digital number provided by the HX711 representing the current measurement.

My load cell is measuring around 106088 units (after I have divided by 100 the measured value to filter out most of the noise). And once I place the test weight on the load cell I get the measurement of 104635 units. That means the difference, that is 1.453 units, represents the weight of my test weight. Given that I know its real weight is 11.30 grams, that means there are 128.58 units per gram.

So, to measure in grams any other weight what I do is
grams = ( 106088 - measurement )/ 128.58;

Given my setup, each weight I measure is giving me a smaller number than the one I get when the scale is empty. If yours is the opposite, just invert the two terms (the zero-value and the measurement) or just consider the magnitude and not the sign of the value. 



Please note that even though I have divided the measured values by one hundred, there is still some jitter on the measured value. For better accuracy, you may want to average several measurements together.