Wednesday, May 31, 2017

Getting Started with Orange PI Zero

Orange PI Zero is a small SBC (single board computer) with 256/512MB memory, its similar to Raspberry PI Zero with some minor differences:

Raspberry PI Zero
Orange PI Zero

BCM2835 1GHz, Single-core CPU
H2+ Quad-core Cortex-A7 1.2GHz
Ethernet 10/100 (PoE) + WiFi
Mini-HDMI port
Micro-USB OTG port
1 micro-USB and 1 USB 2.0
Micro-USB power

HAT-compatible 40-pin header
26 Pins Header, compatible with Raspberry Pi B+
13 Pins Header, with 2x USB, IR pin, AUDIO(MIC, AV)
Composite video and reset headers
Via 13 pins header
Optional CSI camera connector (v1.3 only) (w $20/ wo $5)
Realistic Price: ~$30 
Limited to 1 per order but not on AliExpress
Realistic Price ~$15 (256/512)

First you’ll need to get an image to flash on your SD card, I’ve used Ubuntu server from armbian.

Then I've used 7zip to decompress the image and write it on SD card with Win32DiskImager.

- Configure Ethernet NIC as static IP
- You can use DualServer to start up a DHCP server on the Ethernet port, you can either install the server from sourceforce or download just the executable from here, you can start a temporary instance by running RunStandAlone.bat.

- Insert the SD Card, connect the Orange PI Zero to power and connect the network and wait for about a minute, you'll see the DHCP request in the console:
DHCPREQUEST for ee:77:55:88:44:dd (orangepizero) from interface received
Host ee:77:55:88:44:dd (orangepizero) allotted for 36000 seconds

Alternatively if you power up the Orange PI Zero with a PC you get a COM port, fire up putty, and set to 9600 and you're ready to go!

use root and 1234 as default login credentials and follow up the instructions to change the password and create a default account.

when that is done, you can configure the wifi with nmcli:

- list wifi networks:
nmcli dev wifi list
- create a new connection:
nmcli con add con-name SSIDName ifname wlan0 type wifi ssid SSIDName
- set password:
nmcli con modify SSIDName wifi-sec.key-mgmt wpa-psk
nmcli con modify SSIDName wifi-sec.psk PASSWORD

- set up avahi to get mDNS, its easier than going into the DHCP/Router each time:
sudo apt-get install avahi-daemon
sudo apt-get install avahi-utils

sudo nano /etc/avahi/avahi-daemon.conf

- to set up hostname resolution - install nss mdns resolution, another unexplored option is to use libnss-resolve, purge/install):
sudo apt-get install libnss-mdns

- edit nsswitch.conf file:
sudo nano /etc/nsswitch.conf

- modify hosts to:
hosts:          files dns myhostname mdns4_minimal mdns4

you should be able to ping the mdns record name now:
ping <hostname>.local

To enable mdns on windows, you can download Bonjour from Apple.

And last but not least, mDNS uses Multicast, which needs router support but its usually disabled, You should find a way to enable it, I can't really guide you on your particular router, in my Netgear it was something else, unchecking "Disable IGMP Proxying" fixed it.

You can monitor your device temperature with:
sudo armbianmonitor -m

Luc Small did a more thorough beginners guide.

Friday, May 26, 2017

Node js C++ Addon Overload Resolution - v1.2.0

Major feature implemented for namespace and class wrapping, no more SetMethod/SetPrototypeMethod and target tracking, all is done automatically. 

Since its inefficient to write so much code, while making sure SetMethod and SetPrototypeMethod is called on each overload and track the namespaces used to store the callbacks manually, an experimental namespace_wrap and class_wrap were introduced, these two classes wrap the needed calls as well as track the targets (v8::Object).
The wrappers do add overhead to function execution time but it didn't even register when I did performance analysis.
to use the wrappers you'll need to initialize an overload_resolution instance normally but also start tracking a root target:
void init(v8::Handle<v8::Object> target) {
 auto overload = std::make_shared<overload_resolution>();
 auto base_overload = overload->register_module(target);
NODE_MODULE(tester, init);
once you have the base_overload you can start attaching methods:
base_overload->add_overload("standalone_function_construct", {}, standalone_function_construct);
nest methods:
auto nested = base_overload->add_namespace("namespace_construct");
nested->add_overload("nc_standalone_function_construct", {}, nc_standalone_function_construct_nc);
add classes:
auto class_def = base_overload->add_class("class_constructs");
class_def->add_overload_constructor({}, New);
class_def->add_static_overload("test_static", {}, test_static);
class_def->add_overload("test_member", {}, test_member);

note: you must call done<T>() when you're done defining the class methods, otherwise the class won't register in both the overload_resolution and V8.
for now classes can be nested inside namespaces but not the other way around, though it should be theoretically possible.

Minor build and bug fixes:
- integration with node-addon-tracer npm package so build is simpler.
- expose node-overload-resolution as an npm module, so require("node-overload-resolution") works in parent module gyp files.
- remove support for node 0.11
- fix travis ci builds

Sunday, May 14, 2017

50V 15A Power Supply - $140

I've recently found myself in need of a more powerful power supply than my loyal 50V 3A  Circuit Specialists (CSI5003X) I had for many years.

So when I did a bit of research, I've found out that even now prices are not very low for a more powerful power supply I've decided to try and DIY it without doing any electronic work.

A while back I've seen the DPS5015, which is a 50v 15A programmable power supply which has other versions, 30v/50v, 2A/3A/5A/12A and 15A, add on top of it the possibility to DIY your own programming and it looks like a winner to me (~$37). 

You can even get an enclosure with a fan for it (~$24).

But that is just the controller, it needs a power source of some sort, I've looked around and found a 48v 16.7A switching power supply (~$73).

Throw in a couple of banana screw terminals ($1-2) - don't get the cheap ones, they fall apart.

and add a 3 Terminal Power Socket with Fuse Holder and you have a working power supply (don't forget the fuse! I've used 5A)

A few wires and a cover for the power supply and you're done.

For now, the only drawback I've seen is that this specific PSU doesn't monitor the temperature and power the fan accordingly, so the fan is always on, making a lot of noise.

I've thought about adding something like this to fix that, but I'm not sure yet, need to do a bit more reading about it and see if the power supply needs an always on cooling or not.

In the end, the time and effort to find the parts, read, design a back cover, print it and build it took a long time and I'm not really sure its efficient use of one's time, but I've had fun doing it!