Archive for April, 2015


Solar Panel USB Charger

One of the panels

One of the panels

During the mayhem of last weeks storm and aftermath I had one problem that I hadn’t prepared for. Charging my phone and Android tablet. Whilst I was out and about I visited my not-so-local Jaycar to see if I could get something that would help. They had a 5W solar panel made by Powertech that provides both USB charging and charging for 12V batteries. It was expensive compared to other solutions at about $70 AUD, but I wasn’t sure when I’d get my power back on and I wouldn’t have to wait to get it from an Ebay seller. Some people were without power for almost a week, I wanted to be prepared so I bought it.

At first I wasn’t terribly impressed, but there are some nice features to this unit. For a start the charge regulator is separate to the panels, and the wire from the panels is sturdy with a solid connector on the end. This means you can use the panels elsewhere if the regulator were to fail. A similar connector is used for the 12V output which terminates with a cigarette lighter socket. This is hardly useful for me, so I might have to wire up something else so I could trickle charge a SLA battery.

Charge Regulator

Charge Regulator

The regulator has a port for connecting other panels/regulators of the same type. It comes with a cable that allows you to connect three panels together for a total of 15W. There are better ways to get that much power, so I don’t recommend using these panels for this feature.

The unit doesn’t include a Lithium-ion battery bank, which in my view is a positive thing. Although you may disagree, I’d rather not have my panels tied to a battery that will eventually fail. Also I’ve noted that power banks with solar panels generally speaking will not charge very quickly from the sun. This is because they have panels that are too small to produce any meaningful amount of power. With this unit you can always attach an external battery bank for charging if you want, but aren’t stuck with the battery when it wears out.

So, how well does it charge a phone/tablet? There isn’t really a simple answer because it depends on many things. When I first tried it to charge my phone I wasn’t impressed because it didn’t seem to charge it much, but there were a few things I did wrong. I found it best to turn off the phone or at least all wireless and bluetooth to save power. During times the solar panels are not outputting much power, the phone will still think it’s connected to a charger and turn on extra features such as these, sometimes using more power than the panel provides and actually discharging your device instead. So you can get some charge on a cloudy day, but you absolutely must turn off your device or charge something passive like a battery bank.

On a day with much better sun it charges quite well and is more than capable of fully charging my phone from about 50%. I have a fairly small phone which charges very quickly (a Samsung Galaxy Y) but with full sun it will even put some charge into my tablet which consumes quite a bit more energy. Like any other solar panels you get peak charging rates in the middle of the day whilst the sun is at it’s peak, and properly pointing your panels increases the amount of energy they collect.

In my window

In my window

I hung my panels in my window using some suction cups I got from Woolworths, so the positioning of the panels wasn’t really ideal. That window gets the best sun, but gets shade in the late afternoon. This is where I did most of my testing, so you may get better performance by positioning your panels in a brighter locale at the correct angle.

I think for practical use you probably want to also have a power bank or 12V battery to charge. Most people would be carrying their phones about with them during the day, and a battery bank will likely continue to charge under worse light conditions, so may gather more charge. I haven’t tried charging a 12V battery with it yet, but I suspect it will work fine provided the battery isn’t too large.

Now that I’ve had more time to try it out in better conditions and with different devices and circumstances, I’m much happier with this Solar charging kit. It’s capable enough that given an situation without mains power, I’ll be able to charge a device like my phone given enough time and sun.


The big storm

This week here in Newcastle we’ve had a rather nasty storm, so bad in fact it has taken out power to about 200,000 homes initially, blown down many many trees and caused severe flooding. Fortunately I haven’t had any damage to anything, and myself and my family are in good health, although I did have to endure quite a long black-out.

I grew up in rural north-western NSW on a farm, so I have experienced many black-outs before as they were common during storms. As kids me and my brothers actually thought they were kinda fun, we’d play hide and seek around the house and play with our torches and other battery powered toys. The darkness made everything new and fun. As we got older it became a good time to study for school and catch up on books we were reading.

Consequently I was reasonably prepared for when the power went out initially, I just got out my candles, filled up some containers with water (just in case) and sat down with my collection of Footrot Flats comics to have a read and a chuckle. It was kinda nice to have a technology free evening.

My entire suburb lost power, it’s amazing how silent the place became, it felt like being back at home on the farm. I spent most of a day listening to the sounds of the wind and rain as they lashed the house, and silence in between.

During a lull in the storm I went shopping for some basics, pretty much just bread and matches. I noted many people rushing around trying to get some kind of lighting, unfortunately many places were simply sold out of candles and even battery powered lights because of the demand. I took the opportunity to get myself a good feed of take-away whilst out.

But the black-out continued, I got worried food in my fridge was going to get warm, so I went and got a bag of ice to pack in to keep the inside of the fridge cool. Normally you could expect food in your fridge to stay cold for about 12-24 hours as the ice melts, so usually you don’t need to worry, just don’t access the fridge much and it will stay cold.

Yesterday I went about getting a gas camping stove so I could cook, and a solar phone charger in case the power stayed off for longer, luckily, it came back on late yesterday afternoon for me, but the whole experience has made me think about what I should have in case just such a thing should happen again.

You should have:

  • Some means of storing fresh water, or fresh water should your supply fail.
  • Candles and torches so you can find your way around in the dark.
  • A means to Cook food that you have, a BBQ or camp stove would suffice.
  • A small emergency supply of food, usually canned or dehydrated stuff is good to have. I often have canned stuff in my house simply because it is easier to store and lasts longer. Just make sure that it’s in date.
  • A radio and batteries to hear emergency broadcasts.

Luckily I already kept most of this stuff on hand, I just didn’t have a gas stove before this time.

I’d imagine stuff like a generator would be handy to have, but I don’t have the storage space. I’m thinking of getting a few SLA batteries and setting up some electronics to charge them and make use of them for charging phones and lighting. I did buy a basic solar charger for phones, but it doesn’t have a battery, and it doesn’t seem to do a good job of charging even a small phone. I may review it when I get some better sunlight and maybe some measuring equipment for USB power.


Xsokoban on NetBSD

Having been busy and stressed out lately I haven’t had much time for tinkering or gaming. This is where smaller games that you can play as a quick distraction can help, as they are easy to squeeze in between other jobs, and todays game is one such game.

Xsokoban is obviously a clone of the old classic game sokoban. The original was made for the PC-8801 way back in 1982 by Thinking Rabbit. It has since been implemented and ported to pretty much every system, Xsokoban is one such port for Unix systems running X windows.

There isn’t anything really remarkable about this particular port. The quality of the graphics is quite reasonable, and it works well on pretty much any system I’ve tried it on including my older machines such as the Sparcstation 20. I’ve even played it over SSH via my comparatively slow ADSL2 connection, and it worked really quite well.

Interestingly the game has been studied in the field of computer science, it turns out it’s quite a difficult problem computationally, being PSPACE-complete. Lots of different researchers have worked on different algorithms for solving and producing optimal solutions. The complexity certainly makes me feel better about getting temporarily stuck on level 6!

As far as enjoyment goes, it’s really enjoyable for the puzzle solver in me, even when I’m stuck. It doesn’t take a huge commitment to play for a short while, and is quite challenging! This particular port isn’t any better or worse than any other, so don’t go out of your way, but NetBSD and FreeBSD users will find it easy to get running.

This slideshow requires JavaScript.


Motherboard: Gigabyte GA-6VM7-4E

Today’s main-board is from my person desktop PC from around 2000-2001. I bought it after my Pentium II machine started acting up. I didn’t have much money at the time being a student, so I bought a relatively cheap system from a friend who happened to work in the industry.

It’s a Gigabyte GA-6VM7-4E coupled with a Celeron 800Mhz (coppermine with FSB @100Mhz) which unfortunately since being in storage seems to no longer work. This is an unusual case where I suspect the CPU over the main-board that I’ll go into later. It could take up to a Pentium III at about 1.1Ghz with an 133Mhz FSB.

This board has a similar chip-set to the board I looked at last time, it has a Via Apollo Pro according to the manual and spec sheets. The south-bridge chip has almost exactly the same markings as those on the Asus board, the main difference being the date code. There is about 17 weeks between them in terms of manufacture date. Of course it makes sense that the south-bridge is likely an identical part, it’s the north-bridge under the heatsink that will be different.

Whilst it is certainly a lower end board, it has some features I didn’t expect such as the ability to use ECC SDRAM. Also interesting is the choice of a Creative CT5880 for on-board sound, these were usually (and often still are) Realtek chips instead.  Luckily it doesn’t stick you with on-board video, opting for an AGP 4x slot instead.

It seems this board has the facility for overclocking, allowing an FSB up to 150Mhz, which would have been good if your cards and RAM could accommodate the speed increase. The Coppermine Celeron I had was meant to be one good for overclocking although I never tried.

In service this board turned out to be quite reliable and performed reasonably well considering the lacklustre CPU I had in it. It worked for about 5 years as my desktop and a further 2 as a file server before being retired and stored. The silk-screen on the board isn’t as informative as I’d like, so the manual is a good thing to have when configuring the board. They probably didn’t have enough room because of the mATX form factor.

Here’s the reason I suspect the CPU is the reason this system doesn’t work anymore. It may be hard to see, but the CPU appears to have some damage around its edges. It was working before it was put into storage, so I’d say that the damage has probably occurred during a house move. This is rather unfortunate as this system was quite power efficient in service, but I have a few other coppermine processors that may get this board working again.

This would have to be the first CPU I’ve seen like this, I hope it’s the last! Most of them have been stored separate to the boards in padding, so they should be ok.



Creating a benchmark: Part 4

Last time I used the  in-line assembler to improve the speed of the sprite blitting functions with lots of success. Other functions such as line drawing however still suffered speed issues on systems with out a built-in FPU such as the 386sx.

The reason for the slow line drawing was simple, I had used a simple slope based algorithm that used floating point. On a system with a FPU this was quite fast, about as fast as anything else, but obviously it wasn’t going to cut the mustard when it came to the old processors I’m targeting. So I decided to give fixed point arithmetic a go.

Fixed point numbers are a variation on basic integers, using some of the bits to represent the fractional part. You can then use integer instructions to do some basic math that involves fractions. This is much faster for processors lacking hardware floating point support. Check out more details of fixed point here or at Wikipedia. It’s a very common technique for embedded systems, but was also used in games such as Doom for speed.

I however ran into a problem. Because the integer in turbo pascal is 16bits I didn’t have enough bits for addressing all the pixels and have enough precision to for the fractional part of the slope. For the integer part I needed to have a range of 0-319, requiring 9 bits unsigned. The fractional part was thus left with 7 bits, with the smallest representable fraction being 1/128th. The smallest conceivable slope in 320×200 is 1/320 which obviously is much smaller. I could have switched to using longints or storing the fractional part separately but this would have added extra overhead that would make line drawing slower.

I set the line drawing problem aside for the moment to look for a quick circle drawing algorithm. Something I hadn’t implemented yet. The SWAG archive came up with suitable options, but also had some algorithms for line drawing. In particular the Bresenham line drawing algorithm.

Not having coded my own low level line drawing routines before I hadn’t heard of it, but it uses all integer math in a clever way to produce the correct slope. I modified the algorithm I found to reduce the amount of calculations for the screen address when plotting points in the line. The resulting code was slightly faster than previous line drawing code, but not overwhelmingly so.

Returning to implementing circle drawing, the algorithms I found unfortunately used floating point math. They all use the basic formula for a circle, x^2 + y^2 = r^2, thus requiring the use of a square root function to calculate the co-ordinates. Unfortunately it is one of the more expensive floating point operations.

One algorithm I looked at used the square root function, but rounded it to an integer immediately. This got me thinking, if I could implement an approximation of square root using integer arithmetic I could draw circles quickly. So after a bit of research I wrote exactly that. Code follows.

function intSqrt(num: word):word;
     {we're using Newtons method for approximating the sqrt}
     if (num=0) then
     xo := 0;
     xn := num;
     if xn=0 then xn:=1;
     while (abs(xo-xn) > 1) do
          xo := xn;
          xn := (xo + (num div xo)) shr 1;
     intSqrt := xn;

As stated in the comment, I’ve used Newton’s method for calculating the root, mostly because it’s a simple method I know. I did a little testing, and it turns out this returns pretty much the same result as rounding the built-in sqrt function that uses floating point, only quicker. Once I finished the circle drawing code it drew around 36% more circles in the same time as the BGI code. That’s not bad, but I think there may be more room for optimisation here.

Next time I hope to have optimised the circle routine, and I’ll test the code on some hardware to see how all the different libraries compare to each other on different platforms.

Enter your email address to follow this blog and receive notifications of new posts by email.

Mister G Kids

A daily comic about real stuff little kids say in school. By Matt Gajdoš

Random Battles: my life long level grind

completing every RPG, ever.

Gough's Tech Zone

Reversing the mindless enslavement of humans by technology.

Retrocosm's Vintage Computing, Tech & Scale RC Blog

Random mutterings on retro computing, old technology, some new, plus radio controlled scale modelling.


retro computing and gaming plus a little more

Retrocomputing with 90's SPARC

21st-Century computing, the hard way