Bookmarks

I’m pleased to announce that Interactive Controller for Brushless Motors reached the “revision” phase. I finished implementing and verifying the core functionality and now have a handy tool to test and compare brushless DC motors. In addition to basic abilities to spin a BLDC and change A4960 parameters, demonstrated in this video, the controller now has the following:

Untethered operation. Basic functions like start, stop, brake, and motor speed change can now be performed via controls on the board – no terminal connection necessary.

Separate power bridge. Power MOSFETs have been moved to a second board; this allows me to use the controller to drive loads with different power requirements. Also, replacing burnt MOSFETs is easier this way.

A heartbeat LED indicator is added – when a code crashes I can see it right away :-).

The circuit is built on a single-sided homemade PCB. The copper on the other side is kept intact and it serves as a ground plane and a heatsink. The Eagle CAD files as well as QM model file and PIC24 code generated from it is hosted on github. PDF files for two boards are also in the tree, the files can be printed on a laser printer and used in toner transfer process.

The following pictures show details of the project. Please take a look – and stay tuned for the updates.

I finished laying out the first revision of the PCB for ICBM. In addition to what is shown in the video I decided to add rotary encoder as a second control to change PWM duty cycle. RUN/STOP and BREAK functions will have their dedicated hardware buttons as well. The MOSFETs are mounted on a separate daughter board, this way I can have drivers for different power requirements. The first one I routed accepts DPAK-packaged transistors. The Eagle files plus pdf schematics for both boards are on github. Enjoy!

Recently I was working on a test bench for brushless motors based on Allegro A4960 BLDC controller – a device capable of driving motors while giving interactive read-write access to A4960 configuration registers and allowing changing motor driving parameters (such as phase advance, BEMF window, startup ramp, etc.) when motor is running. The circuit and accompanying code finally reached alpha stage, meaning the electronic is more or less finalized and the code is more or less working. I shot a short video demonstrating the capabilities of the device, please take a look at the video above.

The controller was built free hand, no documentation is available at this time. I will start capturing schematic tomorrow and make it available on github together with source code as soon as it’s ready – stay tuned! [EDIT: github repo here ]

Today Kristian added support for STM32F4-based NUCLEO-F446RE board. The board is available from the manufacturer for little more than ten bucks which is pretty good for this type of MCU. The commit can be examined here.

Even though NUCLEO claims Arduino compatibility the 2×3 SPI connector is absent. It means that many modern Arduino shields, including full-size USB Host Shield, won’t work on this board. For his setup, Kristian used USB Host Mini wired as described in Teensy 3 wiring article. More information is available in the example repository on Github.

The alpha of the third revision of USB Host library has been posted on GitHub. The code has been extensively re-organized to make it modular and generic; as a result, it is now possible to run it on more Arduino compatibles and also use native USB Host hardware on some of them. At the time of this writing, USB Hub and Mass Storage classes are supported, the work on migrating the rest of device drivers is in progress.

The code is to be used with Arduino IDE 1.6.1 or newer, please upgrade before attempting to compile it. Also, please read the README file for more details. If you encounter any issues, post them in the issue tracker on GitHub.

Thomas Strausbaugh contacted me a while back with a project involving XKeys – a series of HID keyboards with extended functionality. Tom also offered to lend me XK-16 Stick; after receiving it I made a small addition to the USB Host Shield library and soon after Tom e-mailed me back asking to test his code. The picture on the left shows one of the example sketches, a “blinky” of sorts, where all backlights are sequentially turned on and off.

Xkeys can be controlled by sending proprietary (but well documented) output report which doesn’t follow standard HID report format. By sending this report it is possible to turn LED integrated into each key on or off, change light intensity, as well as switch the keyboard on the fly between mouse, joystick, and keyboard emulation modes. Larger keyboards have some additional features. In addition to that, products are very maker-friendly; for example, a manual for XK-16 Stick contains this:

Customization
The electronic design of the X-keys Stick is such that the stick may be cut off to any length after the second key. P.I. Engineering will perform this service in our lab for a fee including testing to maintain the warranty, or you may contact us for specific instructions if you wish to do it yourself.

The big disadvantage of Xkeys is price. However, if you want you project to look professional but don’t have much time to refine it, a good looking user interface can be produced very quickly with Xkeys.

Tom’s library implements programmer’s interface to extended keyboard features (sans cutting). Easy to use functions are provided enabling direct access to programmable features of each key or LED. Thank you very much, Tom!

Andrew Kroll and I were talking a lot about running USB Host Shield at higher SPI speeds. We were discussing one peculiar case of seemingly defective SPI master module and were needed full sized shield-compatible host board with fast SPI to check our theories when I realized that I have two Digilent ChipKIT Uno32 boards sitting in my ever expanding “to-do” pile of projects. I sent one to Andrew and soon he made a port which compiles under Digilent’s IDE and runs on chipKIT boards, although we only tested on Uno32 (rev.B).

It should be noted that another good candidate for the host board capable of high-speed SPI would be Arduino DUE. It is supported by the library and presumably runs at up to 24 MHz SPI speed with full-size shield. Incidentally, none of us have a DUE so we can’t test. Donations are gladly accepted.

The chipKIT support is currently in beta. At the moment, the only code example I have verified is Board QC routine – a program I’m using to test the shields before selling them to people. The port lives in xxxajk branch. Making other examples work should be a simple matter of (quoting Andrew) “including the right SPI.h”. Indeed, nothing in the library relies on SPI speed so increasing it would simply allow data to be sent faster.

In this article I will show how I modified a standard full size USB Host shield rev.2.0 to run on chipKIT Uno32 board at high SPI speed. I was able to run up to 20 MHz; unfortunately, the next available SPI rate on Uno32 is 40 MHz which is too high for the MAX3421E chip. The modded shield can be seen on a title picture (click on it to make it larger). Uno32 is 3.3V board; even though the inputs on PIC32 on-board MCU are 5V tolerant and it is likely possible to run the shield as-is I removed the level shifting ICs, which are unnecessary when interfacing the shield with 3.3V boards and could decrease error margin. Also, the RESET line on the ICSP connector on Uno32 has been replaced with CS by Uno32 designer, perhaps to make it look more like SPI, so I also needed to disconnect and reroute it. Here is the implementation, step-by-step.Continue reading Running USB Host code on Digilent chipKIT board

Real time microcontroller applications, such as digital power supplies, motor controllers, and others that utilize one or several real time digital control loops generally can’t be efficiently debugged using LEDs, single-stepping, setting breakpoints, and other traditional programming techniques. In the process of developing a real time system it is often necessary to change a variable on the fly while observing changes in some other variable, also in real time. Microchip MPLAB X and MPLAB IDE have a tool called DMCI (Data Monitor and Control Interface) allowing to do what the name suggests when used in combination with dsPIC and PIC24 micros. I am a big fan of new “enhanced mid range” PIC16 micros and I always wanted to have similar tool to use with these chips. Some time ago I started porting dsPIC RTDM (Real Time Data Monitor, used to communicate with DMCI) protocol implementation to PIC16 and this short article is the announcement of the first working implementation of the protocol.

The title video (expand it to full-screen and switch the resolution to 1080 to see numbers better) demonstrates PIC16F1509 MCU reading its internal fixed voltage reference (FVR). A plot on the right shows, in near real time, last 128 ADC conversions collected into a buffer. A slider on the left allows me to modify sampling delay of the ADC and you can see the difference in conversion when I change this delay from 50 to 20 microseconds. A FVR is high-impedance source and the effect of sampling too fast can be clearly seen. The output is free running, similar to free running oscilloscope timebase; with little extra effort, reads and writes can be synchronized, if desired – see Microchip code examples CE155, CE455 for details.

It should be noted that PIC16 is a very small micro and no amount of clever coding will change that. The RTDM overhead will likely constrain the use of RTDM to test cases rather than real projects. Still, ability to change and read MCU memory on the fly is very useful while testing implementation of digital filters or PID loops.

The C code used to produce the demo along with DMCI config file is available on GitHub. It will run on PIC16F1509 with external 16MHz crystal, other necessary connections being a decoupling capacitor on VCC and a serial connection to a PC running MPLAB X. All software versions are current at the time of writing.

The detailed documentation of RTDM implementation will be posted in several weeks (or so I hope). To increase speed and reduce code size I will be replacing chunks of C code with assembly so if you don’t like assembly, use github commits made earlier than the timestamp of this article. In the mean time, much can be learned from the code itself and developers already familiar with DMCI for dsPIC will have no difficulties using the code as-is.

Please try this code and let me know how it worked for you. Comments can be left in a my Google Plus community or in the “Issues” section of the GitHub repo. You can also use the comment section of the article or by contacting me using one of the e-mails from the “About” section of the site.

The comment system on this site leaves much to be desired. Formatting is non-existent, attachments are not supported, and most importantly, spam-reducing features are very basic leaving the bulk of spam processing to yours truly. At the same time, about 75% of human commenters have @gmail.com address and therefore already have access to Google Plus. Given all that, creating a Google Plus community seems to be the right way to go.

At present, the community have no structure and there are almost no rules. All G+ functionality is present, including links and attachments. Self-promotion is allowed but spam is not. Pictures of your own (in)complete projects are much welcome.

Even though the built-in comments will stay in place for some time I encourage everybody to migrate to G+. This will allow better support, discussion, as well as idea exchange. I’m also hoping the spam will go down giving me more time to develop and share useful stuff.

Several weeks ago, a friend e-mailed me asking for help building a bitcoin miner based on Bitmine A1 ASIC – a mighty chip capable of 40GH/sec and also very DIY friendly. Last Sunday my friend showed up in the morning carrying a box of parts and in the evening we had semi-functioning board and zero casualties. In this article I’m writing my notes hoping that other builders following the same path may find them useful. As soon as we get working board I’ll build another one and post the real build log.

Note 1: The board we were building is a reference design by Bitmine.ch, a company that designed A1 ASIC. The reference board documentation is inconsistent; the rev.1.0.A schematic is different from rev.1.0.B Gerbers. Several part designators won’t match the PCB silkscreen, and the 500 ohm R12 resistor, likely added to improve stability of 2-phase buck converter, was not present on the schematic and/or BOM; we finally managed to figure out what it is by studying the board’s Pick-and-Place job file.

Note 2: Gerber file of a paste layer (the one used to cut a stencil) has openings for the thermal pads and power rails that are too large, using them as-is caused too much paste to be dispensed. Ohararp, the stencil shop, suggested shrinking some of the openings in half. This has helped, especially for pads with many thermal vias but the amount of solder on A1’s power bars was still excessive – take a look at the title picture, left side of the A1. On the subsequent builds about 3/4 of the paste from the power bars would have to be removed manually.Continue reading Bitmine A1 reference board build notes.