Friday, April 17, 2015

I SPI with my little eye...

If you're trying to work with SD cards on a microcontroller setup you designed yourself, there's a good chance you have to write the low-level SPI drivers.

This page: http://bikealive.nl/sd-v2-initialization.html

Was indispensable for me recently when trying to figure out why I could not read an SD card. It turned out that an on-board regulator for one of my parts was expecting 5 Volts, so when supplied with 3.3 Volts,  it was supplying ~2.3 Volts to the SD card, and it was not operating reliably. Once I told the SD card to operate on 2.7-3.3V, it would stop responding.

I placed a serial print statement in my low-level "spi-send-byte" function that printed the byte transmitted and the byte received, and it let me follow along the initialization sequence outlined in the above link and see where things went screwy.

--P

Saturday, April 11, 2015

Taxes

I feel like a kid who waited until the last minute to do that book report for school, and realized he should have actually read the book.

US Income tax filings are due on April 15th for the prior year. My income for Anibit sales is not organized in a way the makes it easy to come up with a net taxable income, so I have to manually pour over all sales for last year to come up with the proper figures. The worst part of it is that while I have the cost basis (ie, the part of gross sales that were not profit) data, I don't have an easy way to collate it, so I'm going to have to wear out the numpad on my computer with a bunch of spreadsheets. All of this will actually amount to a very small amount for Uncle Sam. Anibit's sales last year were nothing to write home about (more on that in a future post).  I just really need to avoid overpaying what I owe, which is what would happen if I don't comb through all the sales.

This could possible be avoided if my Anibit's software had a little more in the way of reporting tools, but I understand it's a very hard thing to do since you can't really make a blanket formula for how tax accounting should work.


Thursday, April 9, 2015

Prototyping with EMW3162 "IoT" devices.

I've picked up a bunch of EMW3162 devices recently. I don't yet have any up on Anibit, I'm trying to figure out how many I want to keep and and many I could part with.

EMW3162 Overview


They are really neat little devices:

The Good


  • Price: Runs in the neighborhood of $10 USD
  • Wifi b/g/n, reportedly up to 54MBps
    • On-board chip antenna, and UFL connector for an optional external antenna
  • Included STM32F205 ARM Cortex-M3 120MHz CPU with 128kb SRAM and 1Mb of Flash
  • About 20 available IO pins (+2 on board LEDs, and JTAG/SWD breakout)
  • Uses Broadcom Wifi chipset, compatible (after some finagling) with their WICED sdk
    • Broadcom has a lot of support for "IoT" in their SDK, with appliance samples, Access Point setup, and embedded web server support.
  • Mostly (but not all!) 5V tolerant I/O pins. (I love that, level shifters are such a pain)

The Bad

  • Documentation for the device itself, is almost non-existent. 
    • You must rely on the documentation for the constituent parts, and the work of some industrious hackers, see this
    • If you can read Chinese, you may have better luck.
  • It's not straightforward on how to use it as simply a Wifi adapter for an external Microcontroller. I believe there are firmwares for this, but it will require a lot of research.

The Ugly

  • 2.00 mm pitch headers on the breakout. Who does this, seriously! I think MxChip must have hired the person who came up with the XBee socket.
  • The various SDK and libraries are a slight licensing minefield. If you want to use this for a closed source or proprietary application, read through all the licenses of all the sub-parts carefully. There are some "free for closed source commercial" library license options, but not all of them are. 

Prototyping

I have thrown together a quick and dirty adapter PCB to let you mount the EMW3162 on a breadboard. I'm considering possibly doing a run of kits for the adapters to get the cost down, we'll see. 

You can get your own adapter from OSH Park here. [Updated link to new version here] Use at your own risk, I have not received my boards yet to verify that it works, but a paper printout looked like it matched up, and the actual circuit is so simple. You will also need:
  • 2 15-pin 2.54mm (0.1") pitch male headers for the breadboard part.
  • 2 15-pin 2.00mm pitch male headers for the EMW3162 module, unless you already have them mounted.
  • 2 15-pin 2.00 pitch female headers to receive the EMW3162 on the adapter.

Comparison to ESP8266


The main advantages of this over the popular with makers ESP8266 is that it has many more pins broken out, and they are 5V tolerant, making this device a better candidate for standing on it's own as an appliance vs acting as a peripheral for another Microcontroller. The CPU of the EMW is also faster (120 Mhz, vs 80Mhz), and has a lot more on board RAM and Flash space. Also, the WICED SDK from Broadcom is very sophisticated, with support for features such as OTA updates to the device. You can develop code to run directly on the ESP8266, but the support for that is more community built than officially supported. To be fair, WICED does not officially support the EMW3162, ether, but the board is close enough in design to other officially supported devices that it's not very hard to port.

Though the EMW3162 is about twice the price of the ESP8266, for some applications, it is worth it, especially if the extra capabilities allow you to remove external components form your design.

Resources to get you started

  • Several folks have started an analysis as a Hackaday project, and they're adapting their own flavor of the WICED sdk for use with the board.
  • The WICED SDK, which includes an Eclipse/CDT tailored to embedded devices using Broadcom chipsets.
  • The Github Repo for the WICED fork specific to this board.
  • Seeed studio sells a couple Development boards you can plug your 3162 into. This one has a JTAG port for an external JTAG, and this one has an on board JTAG built in.
  • My breadboard adapter you can order in multiples of 3 for $8 per set (you'll need to find the headers separately)

--P