Wednesday, November 25, 2015

Dedicated Energy monitoring with the ADE7763

After building the NodeMCU based energy monitor with an external 16 bit delta-sigma ADC i.e. the ADS1115 I started looking into solutions which were more accurate and cheaper.

I came across some work by Skye Sweeney with the ADE7763. He had built a prototype on breadboard and wanted to monitor lots of channels so the cost of sensors became prohibitive and he set the project on hold. I am attempting to measure only a single phase and disaggregate the data later by post processing, so a single ADE7763 should serve my purpose.

I set about building a breakout board for the sensor using the reference design in the datasheets and ordered it from Oshpark. This is where I made an error in my rush. I did not check the footprint the element14 library provided against the real chip. So I ended up with a board with TSSOP footprint for a SSOP chip. Should have printed the PCB 1:1 and checked with a real chip. At least the error was found while prototyping and not in production. I bent the package pins a tiny bit to squeeze it in and proceeded to assemble the breakout.

I could not quite get the SPI bus to work on the ESP8266 NodeMCU, it kept resetting the Watch dog timer. With the ESP it is often a power issue. So for a quick test I hooked up the breakout to a Teensy 3.1 and loaded Skye's code without the multi-sensor bus stuff. It worked on the first go and started dumping RMS voltage and current registers. The only thing to be careful about is the rather limited 1v peak-to-peak input range. Otherwise this chip is great with dual 16bit d/s ADC's and all the code for RMS and registers for offset removal. At about 1/2 to 1/3 the price of the ADS1115. I have uploaded some standalone  breakout testing code to github - Arduino ADE7763.

For accurate measurements this sensor can be connected to AC line using Shunt resistors for current measurement instead of a CT sensor and a direct volatge divider ladder to measure the voltage waveform instead of an isolation transformer. This makes the chip MCU unfriendly and subject to mains voltages. The SPI bus should be isolated with optocouplers when using this mode.

Meanwhile I have tested the sensor using my basic load bulb and CT clamp and voltage and current waveforms are picked up just great. At some point I will build up the courage to create a high voltage / phase accurate measurement rig.

Tuesday, November 3, 2015

The SeeedStudio ESP8266 Contest and resulting product on Tindie

A few weeks back I participated in the SeeedStudio ESP8266 project design contest with my NodeMCU based Energy Monitor. As in all popularity contests I had to ask my friends to help me out and vote for me as often as possible. I had the most views, but not the most votes. Still I ended up in the second place which I am quite happy with.
Fully assembled NodeMCU Energy Monitor - Sensors plug in at the bottom
With such encouragement I decided to get a PCB fabricated for my Energy Monitor project and put it up for sale on Tindie. This is my first electronics project for sale and apart from some local interest, I have made an export sale to the UK. Deciding how to put the project together for sale is quite new to me. I have a certain skill-set but other electronics enthusiasts may not share them. Should I just offer blank PCB's, which other's might as well get from OSHPark or DirtyPCB ? Should I offer a through-hole kit along with the PCB and take the interested party through the soldering order ? Should I put everything together as SMD in my oven and offer the kaboodle including NodeMCU and the rather expensive ADS1115 ? What about the current and voltage sensors ?
NodeMCU Energy Monitor "mostly" Through-hole Kit

There are also component and PCB sourcing issues as outlined in a previous post. Tindie offers some flexibility in this regard letting me set-up various tiers and options. My single product listing becomes effectively a stratified listing catering for buyers with multiple electronics proficiency levels. I might start offering the 100A clamp of current sensor and 12V transformers from YHDC as part of my kit, to make gathering of all the components easier. With bulk manufacture in SMD, cheap mass produced NodeMCU modules and knock-off ADS1115's I might be able to get the total cost down to USD20 unshipped. Which will put the design at par with these non-web connected versions of the same. The design will also be far cheaper than the custom web-connected offerings from Efergy and Wattcost, mainly because these consumer grade products also provide a data hosting service complete with apps and websites. The NodeMCU Energy Monitor leaves the user in charge of their own data and requires certain knowledge of IoT platforms to take full advantage of it. The number of players (AWS, Thingspeak, Bluemix etc.) in the IoT data hosting arena is increasing daily and I am sure people automating and sensorising their homes will appreciate the choice, rather than be locked in with the server hosted by the hardware vendor.

The remaining hurdle is of course shipping, it cost me about USD14 to ship 2 units to UK from Australia as small parcels. Where as China post shipping costs are minimal. Logistics - another hurdle holding back small scale production in Australia. The only long term sensible thing to do will be to manufacture in China and exploit the logistics there. All said and done I am pretty happy with my $50 sale, at least it has paid for the electrician who installed the energy monitor.
Fully installed NodeMCU Energy Monitor - Black YHDC transformer, current sensor inside the enclosure

Monday, November 2, 2015

Making MBed and Arduino compatible Xadow Modules (in Reflow Oven)

I have designed a long chain of Xadow modules by now, including right angled side chains. These include:
  1. Xadow SD (CD4050) - Which allows using upto 32GB Micro SD Card and good read/write speeds due to the driver IC.
  2. Xadow Serial (SC16IS750) - Which adds 1 UART and 8 GPIO ports, with jumpers to allow upto 4 modules in chain.
  3. Xadow MultiSerial (SC16IS752) - Which adds 2 UART's (theres is not enough space for the GPIO's)
  4. Xadow IO (PCA0539) - Which adds upto 16 GPIO ports using I2C
I have tried various suppliers to gather all the components, various PCB manufacturers as well as solder stencils from OSHStencils. Here is the breakdown of my experience so far in prototyping some very small single boards using SMD only components.
Chain of Xadow modules - GPS, Oled, 9-DOF IMU, Barometer, Dual-I2C Uart (Bluetooth), Xadow-M0, Xadow-SD (Left to Right)

PCB Manufacture:

DirtyPCB - They use SeeedStudio for manufacture and fulfilment, but get bulk discounts and I love the Gerber preview option, no extra charge black PCB's and option to get extra PCB's in a batch. I have got gold finished PCB's from them as well these look rather good.

SeeedStudio - My first test PCB's were made here.They also provide an assembly service and a library of commonly used parts. In most cases I have managed to get 80% of the PCB assembled in China with 20% hand soldered at home, mainly crystals and main IC's.

OSHPark - This is the made in the USA solution to Hobbyist PCB's. They produce PCB's in a signature purple colour, which I guess is a soldermask colour no serious industrial PCB maker wants. The ENIG finish PCB's look rather good. The preview function is also handy. However the DRU for checking PCB's is a bit strict in terms of clearance at the board edges, vias are not automatically tented and signals require greater separation leading to a low density PCB overall.

I am yet to try PCBPool and local Australian and New Zealand options, but they are beyond the budget of hobbyists. Once I start manufacturing my designs I shall surely give them a go. Local hackerspace recommended #hackvana and I had a great chat with them as well.

Component Sourcing:

AliExpress - Components are a bit hit and miss, had the wrong ones sent at one point. All the ones tested work.

EBay - Probably same sellers as AliExpress. Similar performance, no bad shipments so far.

Element14 - Next day delivery is amazing for quick prototyping. The part search system has improved a lot and they even have an Eagle library for most of the common parts.

Samples from TI, Maxim and ON Semi - Nothing is as good as free stuff delivered express. All parts are detailed with CAD models (albeit in .bxl).


OSHStencil - The holes are a bit too big, probably because I did not shrink the solder mask enough. Great otherwise.
Homecut - Cut on a Trotec laser Speedy 100 from Mylar and Kapton. The laser has a bi
t too much power, so pads need to be shrunk even more.

Overall it has been a great learning experience and I have probably spent more on research than I would have spent buying a hotshoe IMU like the solmeta off the shelf. However in the end the product does exactly what I would like it to do. Next step - find a suitable 3D printer on 3D Hubs and get an enclosure built, also complete the MBed code to make it all work.

Wednesday, September 9, 2015

Experimenting with Energy Monitors

After a spate of high electricity bills and trying to save energy by turning things off randomly I decided to do it the proper and scientific way by experimenting and collecting plenty of data.

In the days of bitcoin mining high energy bills were the norm. Now they miners have all moved to better homes and I am left with myriads of run of the mill appliances. Identifying the energy hungry beasts is not trivial.
Initial attempt at current measurement with DSO-Nano
The Open Energy monitor site has a plethora of ideas and some quite good Arduino and Raspberry Pi based designs for energy monitoring. SeeedStudio also has a couple of designs intended for energy monitoring use with an option to use an LCD or Oled screen, which I quite like. The downside of both these options however is the wireless component. The EmonTx option uses the RFM12/69 as the wireless transciever and the SeeedStudio option uses the nRF24L01+, both options require custom and expensive receiver hardware attached to an always on data-logging system.

Seeedstudio Energy monitor with nRF24
So after a bit of research I decided to roll my own on a breadboard using the ESP8266-12E based NodeMCU module. I started with a basic version is for apparent power only. To keep component count low and the circuit as simple as possible I used an ADS1115 breakout in differential mode eliminating the need for bias resistors. The hard part is getting a licensed electrician to wire up the clamp on current sensor to the main wire coming into the premises. Since we have only 1 channel we are going to monitor overall power rather than power per circuit.
Apparent power energy monitor with ESP8266
After the fact I made a Fritzing diagram showing how-to wire up the prototype on a breadboard. Powering the NodeMCU near the switchboard might be an issue as well, so I installed a DIN rail power socket, this will come in handy for real power measurement later on.
Fritzing diagram of apparent power energy monitor
One of the downsides of the ESP8266 approach however is the high current consumption (300mA or so) of the module and the fact that small block transformers used for voltage sensing will experience power factor shift under this load. This makes powering the system and measuring real power using the same transformer difficult, it can however be done with proper calibration.
NodeMCU Energy Monitor including power supply and voltage sensing
 The next bit is getting proper code to run on the NodeMCU. I chose to use the module in Arduino mode with the excellent work done here. For code inspiration I used Emonlib from the OpenEnergyMonitor project. I made some changes to read the current via the ADS1115 instead of directly via the inbuilt ADC, increased the integration period and patched in a square-root approximation method. The resulting code can be seen below.

The data from the monitor gets uploaded every 20seconds or so to Thingspeak. This makes it easy to plot graphs and analyse the data for appliance specific spikes, at the expense of losing control over it and some privacy. If you want to keep it all in house it is better to use something like EmonCMS.
Multi-day energy use graph(uncalibrated)

Thursday, December 25, 2014

Reflow oven controller with Multimeter and Arduino

After a few boards I got sick of soldering 0603 components using a soldering iron and started looking into using solder paste and hot air. I bought a hot air rework station from Rhinotools. It looks nice, but is rather noisy to use, and I find myself going for the iron always instead of the hot air gun.
The next step in the soldering tools exploration was a classic toaster over reflow. The boards I usually solder are rather small and not panelized, so I do not need a large oven. The smallest decently built oven cheap oven I could find was a K-Mart Homemaker 14L model with 1300W heating power. I also backed an Arduino Leonardo based reflow controller on Kickstarter - ControLeo2. While waiting for the controller to arrive from the US, I got itchy fingers and started hacking together a controller from bits I had lying around.

The ControLeo2 is impressive in being a 4 output reflow controller, to fully utilise this I ordered 4 cheap Fotek relays. They are rated at 25A, and the elements in the toaster consume about 3A each, so there is plenty left over. I would have liked to get a Crydom relay, but they are rather expensive. There is plenty of space in the controller compartment to fit all the 4 relays in, what I will control with them is another matter. Only 2 are needed to control this particular oven as it stands, 1 for the top and 1 for the bottom. The other 2 are planned for the booster element and a cooler of some sort.

Mounting the relays in the case requires some angle brackets, I found these at Bunnings which exactly fit the holes in the SSR with pre-drilled holes. They are galvanised steel however, not the best for heatsinking relays, but they are a good start. I am going to make some proper brackets with bent aluminium bars, but that can wait.
The initial controller was built using the BeagleBone GPIO's. There is the popular Adafruit GPIO library, but I used the less widely used PyBBIO since it has an included reflow oven controller code. My fork is modified to read temperature from a Digitek 4000ZC multimeter over the serial port using the FS9721 python library. A lot of multimeters, including some of the UNI-T models use this controller, so the adaptation should be useful for anyone with this multimeter at hand and not necessarily a MAX31855 breakout board. The SSR's are wired to the BeagleBone GPIO's via a ULN2003 relay/solenoid driver I picked up at Jaycar.
The BeagleBone arrangement though quite nice lacked a few features in the existing code, particularly support for curve editing and proper PID control. So I looked into another Python based toasterReflow controller - picoReflow. This one has even snazzier GUI and lots of options to create new curves and calculate cost in cents per reflow. I decided to try something different this time and replaced PyBBIO using my Arduino's GPIO capability, since a lot more people probably have Arduinos compared to BeagleBones and Raspberry Pi's. So my EeePC replace the beaglebone as the main controller, taking in the readings from the DMM over 1 USB port and feeding out the SSR control signals to the Arduino over another USB port. This closed loop looks something like this:

Oven -> Thermocouple -> Digitek 4000ZC -> EeePC -> Arduino -> ULN2003 -> Fotek Relays -> Oven

Overall this works quite well for me and I hope it is useful for someone else attempting to build an oven without a fancy controller with just the bits at hand, yet achieve a nice controlled profile.

Wednesday, December 3, 2014

Making a Great Helm and other pieces of armor

Sometimes I get carried away while making a costume, but not far enough to be considered a cosplayer. I started by making a Great Helm, in Australia this is commonly mistaken for a Ned Kelly Helmet. Then I got carried away and made most of the upper body armor in the crusader style. This post has some build photos and final result.

I wore the full suit on top of a traditional indian kurta, the best approximation I could come up with on a short notice of a crusader tunic.

Top on Great Helm
Completed Great Helm, with Breast Plate (template attached)
Top/Bottom parts of Great Helm
Had to take a photo of the pauldrons with the make magazine and the brushed aluminium of the Mac.

The gauntlets were some simple spray pained gardening gloves, the metallic paint costs more than the gloves. Next time I shall try to make an articulated stiched on number.
The final pieces were made of moulded Worbla, nothing fancy. Mostly because I ran out of aluminium sheet and wanted to experiment a bit with this new material. It has great potential, but is a bit thin when used by itself, next pieces will have some craft foam embedded in them.
The day at the medieval fair turned out to be quite a success, my Morning Star built out of coke cans and a foam ball got a lot of attention. Currently the armor sits on a mannequin in my living room. Looking forward to making some more pieces for next year.
Mixing up themes a bit

Saturday, September 13, 2014

Designing the Xadow - SD module

I am always looking for Arduino modules with small form factors, the first Arduino I ever got was not the classic chunky board , it was a Mini Arduino Pro. I proceeded to attach that to a quadcopter with some success in the era before pre-built ardupilots.

Lately I have been playing with the Seeed Xadow form factor modules. They are designed for a smart watch projects. My aim is to build a camera hot-shoe capable of injecting GPS into the exif as well as logging the orientation of the camera in Omega-Phi-Kappa co-ordinates. Something similar to the Solmeta unit or the much more affordable Navspark SUP800F, but with accelerometer-gyro-magnetometer combined to work better on more dynamic platforms i.e. a Helicopter circling a point and experiencing centrifugal force which can throw the accelerometer based gravity calculations off.

Xadow module chain including Xadow SD
The Xadow system has pre-built modules for most things including a 9-DoF IMU with the MPU-9150 on-board, low power OLED module for display and a GPS. These components can be used to build a complete AHRS + GPS system with one thing missing - large data storage. The pre-existing Xadow - Storage module offer only 64K of storage in EEPROM, an opportunity to make something new.

SD card shields are easily available in the standard arduino ecosystem, but none exists for the FFC cable based Xadow form factor. So I took an SD shield design and shrunk it down to the Xadow size. It is now available on the Seeed Wiki as Xadow - SD component. The next revision has bread-boardable breakout pins on the side for use as an SD card reader with any other system. So the Xadow watch can now have 32GB of storage. With the Cortex-M0 based Xadow main board and colour display anyone can now make a poor-mans version of the iWatch.

If you are interested in the Xadow system, grab the SD card module design here and give it a try. I also have some blank PCB's I can give away to anyone who wants to practice some SMD soldering.