Thursday, July 30, 2015

Happy Birthday, Leona and Foxy!

Today my cats become two years old!
Happy Birthday!

It has been wonderful two years - they have brought me lots of laughter and lots of comfort.
There is nothing more relaxing than the cat purr - it washes away all anger, all troubling thoughts, all bad mood.

Yes, there is cat hair everywhere. Yes, it is hard to sleep when they decide to play chase or wrestle at 6am or when a 7kg monster walks on top of me and gives me a massage. Yes, there is some minor damage to the furniture and the curtains. Yes, I can't leave any small objects (like screws, cables, electronic components, lego parts, etc.) on the table unattended. But it is totally worth it.

They have changed quite a lot for these two years - they are much bigger now, less playful, way more lazy. But they are just as cuddly and kind as always. And they have changed from extremely cute little (ok, maybe not little) kittens into enormous but gorgeous cats.

Here is a little present I made for them:

It is not final - it needs some tweaking and proper packaging, but it works.

And, here are some pictures taken over the years (in more or less random order):

Tuesday, July 14, 2015

Cats and math

Two days ago I cut my foot by stepping on a piece of broken glass - obviously Billy did a lousy job cleaning that.
It wasn't anything serious, but enough to leave blood drops on the floor.

Then I looked at Leona:

And I did some quick math:
- The table dimensions are 80cm x 80cm
- She is probably about 1 meter long with her legs extended
- I've seen her jump easily over 1 meter high from standing still
- She is incredibly strong
- She might look fat, but she is still quite agile
- She weights more than 7.5kg

This is Foxy:
She doesn't look that fat, but still she weights over 7kg and is faster than Leona and almost the same size.

And, their claws are very very sharp.

They both are incredibly kind and cuddly, they would never hurt anyone on purpose. 

But ... if they taste blood? The blood I am spilling on the floor?
Home might become a very dangerous place to live.
They could reach my balls without even lifting from the ground and they could easily go for my throat if they jump. Before I can even react.

Boy, was I quick to wipe it from the floor!


Sunday, July 12, 2015

Meet F.A.R.T.

I am proud to present the first prototype of my Fully Autonomous Roaming Tank (F.A.R.T.):

It is a "robot" tank that roams the house by itself without crashing into things (too much).
What is most special about it is that it is built from Lego parts (chassis an motors), but driven by Arduino!
All I had to do was to cut one of the Lego's wires, do some easy soldering and voila - I can drive Lego motors from Arduino!
The possibilities this opens are huge, FART is just the first example.
Both the code and the mechanics are just quick prototypes - about 2 hours to build the chassis from Lego and maybe an hour coding ... no wonder it doesn't behave too well.

Just as a reference, more than an year and a half ago, I built something similar, but made entirely of Lego (using the Lego brick as a brain, not an Arduino):

Here is the parts list:
1x Arduino Nano - $3.20 (less if you buy more at once)
2x US100 Ultrasonic Sensors - $7 (for both)
2x Transparent Breadboards - $5.24 (for both)

Did you spot the biggest problem already? :)
Lego is fucking expensive!
Since I already have it anyway, it is not that much of a problem.
But, the price (along other problems) makes it useful only for prototyping.
I can't build something and keep it like this, because the price of that thing would be insane.
So, the plan is to replace it with this $10 kit when it arrives.
Still, the option to quickly prototype something with Lego is priceless!

On the other hand, if I wanted to buy an ultrasonic sensor for the Lego, I would need to spend a fortune ($60+), instead of $3.50 from China.

Plans for future improvements are:
- Improve the code for better obstacle avoidance, stuck detection and unstuck procedure.
- Make it internet-enabled, so it can be controlled from any web browser, including from the phone.
- Add some more sensors (maybe 1-2 infrared distance sensors).
- Add some servos, so I can rotate the sensors, like in the pure Lego roamer.
- Add FPV (a camera streaming video of what the robot sees). Ideally, over the internet.
- Replace the breadboards with PCBs
- Replace the Lego with the final chassis

If all goes well (and I don't just abandon the project), at the end I will have a tank, which I can control over the internet and see what it sees. How cool would that be? Well, at least until the batteries die.  

Overall, it was fairly easy to do it, but still I stumbled into few problems:

Problem 1: Ultrasonic sensors take a while to get a distance measurement. And they also need some time between measurements (so they don't pick some echoes). Having 2 of these, I have to measure one first, wait for some time (20ms), measure the second one, wait some more. As a result, I am getting measurements every ~60ms, and the second is about 30ms later than the first. These times might sound small, but actually are big enough to cause problems.

Problem 2: Speed controlling the motors using PWM from the Arduino turned out to be problematic. At low speeds the motors don't turn at all, jut make some noise. I am not sure exactly why, but I suspect the PWM frequency is too high. I could be wrong, but at least I can test that later and if needed fix it (either by reprogramming the Arduino timers or by manually setting the signal low-high from code). For now, I just put a lower limit at the speed control, so if the logic says it wants the motor rotating at 30% speed it actually rotates at 75%. Far from ideal, but enough for the early prototype. It might also help if I use a 9V step up regulator to provide 9V to the motors (currently the batteries provide 7-8). Testing with 9V wall power supply showed it is better, but does not eliminate the problem. I will have the 9V voltage regulator in a few days.

Problem 3: I am running out of digital pins. Motors take 2 pins each. Sensors also take 2 pins each. Adding and ESP8266 for internet connectivity would eat 2 more pins. If I want to read the motor encoders (so I can detect when a motor is stuck or balance the speed of the two motors) it would take 1-2 pins per motor (the encoders output through 2 pins, but I could only use one if I only want to detect if the motor is stuck). Adding extras, like servos, more sensors, speakers, LCD display, LEDs might turn out impossible (without adding second arduino or a GPIO extender).

Problem 4: I somehow burned an Arduino. Fartie was roaming around just fine, then got stuck under a chair and out of a sudden it stopped. It surprised me, because the logic it uses never stops. Then I saw the light I have programmed to blink when the batteries get low was actually blinking. This explained the stop, except the batteries were freshly charged. I measured them just in case - they were indeed fine. But since I unplugged the batteries, the Arduino won't boot from batteries anymore. It boots from USB, but not from batteries. And when hooked up to batteries its 5V output produces something like 1.5V. So, I am guessing its internal 5V regulator is gone. Maybe, because Fartie was stuck, the motors tried to draw too much current (I measured 1.5A, even 2A stall current before). The motor driver chip does have over current protection, but still, something might have happened to the battery power supply, which went through the Vin on the Arduino and fried its voltage regulator. This is only a theory though, I don't know for sure. What is worse, I have no guarantees that it won't happen again and kill the next Arduino.

Problem 5
Cat hair! Lots of it!
There is no solution to this problem (getting rid of the cats is not an option at all).
Billy (my robotic vacuum cleaner) suffers from the same problem.

Tuesday, July 7, 2015

You can stop bracing yourselves now, the money has come.

"Better late than never" they say.
I agree :)

Today I was greeted with this e-mail:

In other words, the first money finally came.
They were supposed to come on June 30st, but "due to internal issues" (according to Samsung themselves) they were delayed 1 week.

Not really a big deal for me, given the fact that my app started selling on April 19th and by the end of April it made $211 (according to their sales statistics). So, whether it is 2 months later or 2 months and one week later - it doesn't make much difference.

Anyway, the drinks are on me tonight :)

On a side note, their Sales Summary seem to be broken since July 1st.
They keep showing just one sale (in Korea) since then.
In the meantime their download statistics show "normal" rate of downloads.

Did you have any trouble understanding the above 3 sentences?
Because Samsung's support obviously did.
I wrote to them yesterday, to notify them of the problem and today they responded, asking for screenshots?!?
Why the fuck do they need screenshots?!? To understand the problem better? Well, I believe it was clearly described in 2-3 short sentences. For proof?  As if I have no better stuff to do, but mess around with them?
I think the answer is different - it is just laziness. The monkey in their support center is trained to ask for screenshots every time an issue is reported and no screenshots are attached. It is so much easier - ask for screenshots, bam! case closed, my job here is done ... next please.

Anyway, I resisted the urge to respond in a ... not so friendly manner ... and very politely sent them these 2 screenshots:

If I didn't already know what their answer will be, I would be really curious :)
As a matter of fact, this is the first time (in my experience) when their accounting data fucks up.
Until now, the statistics were breaking every couple of weeks, but the accounting data looked ok.
But, after so many problems, one more does not surprise me at all.

Ok, enough blogging for today, I have $472 to spend, starting immediately.
Let the shopping spree begin!