Monday, April 21, 2014

Book Announcement: Getting Started with Trinket

Now you may officially know why I have not posted much in the last few months.  From September through December, I was writing tutorials on http://learn.adafruit.com as previously discussed.  I was contacted by Maker Media who asked for a book on the Adafruit Trinket microcontroller.  How could I refuse?  So I have been writing and writing some more.  Today Adafruit listed it in their store for interest and Amazon now has it for preorder:

Getting Started with Trinket


The price will probably be a bit less than those listed as it will probably be edited down a bit more.

Hopefully it will be out for Maker Faire New York, September 20 & 21st.

More information and it develops.  Thank you to my viewers for your support of my projects.  Mike

Sunday, December 22, 2013

Intel Arduino Galileo

It's here.  The Intel based Arduino Galileo is finally hitting retailers.  I am fortunate enough to have a Microcenter nearby and they have them at the special price of $69.99 in-store limit 1.  They are currently also at Newegg.com and Mouser Electronics with availability announced by Adafruit.  The box:


The box is not that big, It is a bit longer but shorter than the full Arduino Uno box.  It is a bit deeper as it includes a AC to DC adapter and plug adapters for several countries (Europe, UK, Australia, US):


Looking at the board, it is smaller than the publicity photos make it out to be (always happens I would say):



I am told that retailers do not put rulers in their pictures because buyers ask where their ruler is when they get it - putting a quarter coin in there is even a stretch.

Here are the specs:

Galileo is designed to support shields that operate at either 3.3V or 5V. The core operating voltage of Galileo is 3.3V. However, a jumper on the board enables voltage translation to 5V at the I/O pins. This provides support for 5V Uno shields and is the default behavior. By switching the jumper position, the voltage translation can be disabled to provide 3.3V operation at the I/O pins.
Galileo is also software compatible with the Arduino Software Development Environment (IDE), which makes usability and introduction a snap. In addition to Arduino hardware and software compatibility, the Galileo board has several PC industry standard I/O ports and features to expand native usage and capabilities beyond the Arduino shield ecosystem. A full sized mini-PCI Express slot, 100Mb Ethernet port, Micro-SD slot, RS-232 serial port, USB Host port, USB Client port, and 8MByte NOR flash come standard on the board.
Detail of Intel Architecture Supported Features
The genuine Intel processor and surrounding native I/O capabilities of the Clanton SoC provide for a fully featured offering for both the maker community and students alike. It will also be useful to professional developers who are looking for a simple and cost effective development environment to the more complex Intel® Atom processor and Intel® Core processor-based designs.
  • 400MHz 32-bit Intel® Pentium instruction set architecture (ISA)-compatible processor
  • 16 KBytes on-die L1 cache
  • 512 KBytes of on-die embedded SRAM
  • Simple to program: Single thread, single core, constant speed
  • ACPI compatible CPU sleep states supported
  • An integrated Real Time Clock (RTC), with an optional 3V “coin cell” battery for operation between turn on cycles
  • 10/100 Ethernet connector
  • Full PCI Express mini-card slot, with PCIe 2.0 compliant features
  • Works with half mini-PCIe cards with optional converter plate
  • Provides USB 2.0 Host Port at mini-PCIe connector
  • USB 2.0 Host connector
  • Support up to 128 USB end point devices
  • USB Device connector, used for programming
  • Beyond just a programming port - a fully compliant USB 2.0 Device controller
  • 10-pin Standard JTAG header for debugging
  • Reboot button to reboot the processor
  • Reset button to reset the sketch and any attached shields
  • Storage options:
  • 8 MByte Legacy SPI Flash whose main purpose is to store the firmware (or bootloader) and the latest sketch. Between 256KByte and 512KByte is dedicated for sketch storage. The upload happens automatically from the development PC, so no action is required unless there is an upgrade that is being added to the firmware.
  • Default 512 KByte embedded SRAM, enabled by the firmware by default. No action required to use this feature.
  • Default 256 MByte DRAM, enabled by the firmware by default.
  • Optional micro SD card offers up to 32GByte of storage
  • USB storage works with any USB 2.0 compatible drive
  • 11 KByte EEPROM can be programmed via the EEPROM library.

You can see the PCI-E mini slot on the back.  I am looking to re-purpose a wifi radio from a laptop to test that out.

Comparison with other Boards:


The Galileo is upper left, going clockwise the Adafruit Wave Shield, the Adafrit Motor Shield version 2, and the Arduino Uno R3.  There is not much on shield compatibility, that will have to be part of upcoming experimentation.

What You Will Not Get in the Box


What is not in the box: USB cable (A to micro B), software, any parts or shields, no micro SD card.  There is only an Ikea-like diagram in the lid of the box and a hint to go to make.intel.com.

Information You Need to Know


The available resources for getting going with your Galileo as of this post:
I will be posting information on using this board, stay tuned.

Sunday, November 3, 2013

Sensing Switches on an Analog Input, Including Multiple Key Presses

Many microcontroller projects quickly run out of pins when adding functionality.  The methodology used to continue to add functionality is to use expansion chips or share pins.  Many methods implement an approach that will register individual switches.  This article shows a method detecting single or multiple key presses.

One method recently written about at http://tronixstuff.com/2011/01/11/tutorial-using-analog-input-for-multiple-buttons/ uses a well known method of using one analog pin to register different values for different key presses.

This method is also used on various "LCD Shields" used to add buttons to an LCD display on Arduinos.

While these methods work well, they will not correctly register two buttons pressed at the same time.  For the first picture, if the far right button is pressed, the line is grounded and no further buttons will register.  Same for the second picture with the "RIGTH" button.  The reason is the button shorts out parts of the resistor "ladder".  Again, these work, but only give the lowest value to the analog pin.

For my next project, an alarm, I need to be able to differentiate between pins including multiple "buttons" at the same time.  The following is a schematic of what I will use to differentiate between 3 inputs:

The R4 pullup resistor can be the same as the internal pull-up on microcontrollers like the Arduino, enabled via 
pinMode(analogpin, INPUT_PULLUP); 
or 
pinMode(analogpin, INPUT); 
digitalWrite(analogpin, HIGH);  // set pullup on analog pin while the pin is an input.

On Arduinos like Uno, analogpin can be A0 to A5.  For ATTiny based boards like Adafruit Trinket and Gemma, you must use numbers 1 to 3 for the analog pin (GPIO #2 is A1, GPIO #3 is A3, GPIO #4 is A2).  Note the pullup does change the range of the AnalogRead.  See http://arduino.cc/en/Tutorial/AnalogInputPins for more information.

My application uses an Adafruit 5 volt Trinket.  In the schematic, Pin GPIO #3 (Analog 3), already has a 1.5 K ohm pullup to use USB, so no additional resistor is required.

For mapping values, you can read the analog measurement as various switch states are changed (your values may differ depending on resistor changes, pull-up values, etc.  You should take measurements on your own setup):

Switches   Value
Nothing    647
1 closed   397
2 closed   537
3 closed   576
1 and 2    320
1 and 3    342
2 and 3    457
All closed 283 

This works by using changing resistors in parallel along with R4 in series.  So if Switches 1 and 2 are closed, the resistance is (R1*R2)/(R1+R2) + R4.  See Wikipedia for a detailed explanation of resistor combinations.  This is also why the resistor values on the switches must be different - you are looking for unique resistances for each combination.  If you use the same values on the switches, the same analog reading will register for each key press.

The values do not have to be the same as the ones I used.  Avoid too small values to limit current to the analog pin.  Avoid values in the Megohm range as being too close to an open.  Values should not bee to close or too far from each other.  I suggest you wire the circuit up and measure the values - you want probably 10 or more between each registered combination.  The jitter (variability in reads) for me was about 2, so when you compare values you want to check like this:

int jitter = 3;
int readvalue;
int switchone = 397; // from table above for my circuit

readvalue=analogRead(analogpin);  // use your pin number

if(readvalue >= (switchone-jitter) && readvalue <= (seitchone+jitter) ) {
    Serial.println("Switch one is closed");
}

So for a project where you may have multiple key presses, you can sense them on one analog input by placing switches in parallel with differing resistors.


Sunday, September 22, 2013

Kicad: Making Your Own Circuit Boards

Last weekend, I took a class on using KiCad, the free, open source circuit board design program.  I hadn't made a board since high school using a Radio Shack etch-it-yourself kit.  To be honest, college was mostly wire wrap in those times.

The class was sponsored by WyoLum, held at the Nova Labs makerspace, and taught by Anool Mahidharia who had flown over from Mumbai with his bride to attend the Open Hardware Summit.

In the course of the weekend, we learned how to use KiCad, building a power supply, then building our own creation.

My design is at OSH Park now and should be delivered this week.  I will not spoil the surprise as there is a healthy chance there will need to be another set of revisions to get it where it should be.

I would guess I qualify now for the KiCad Skills Badge :)

ABC Arduino Basic Connections the Book!

I have gushed over the circuit diagrams published by Alberto "Pighixxx" Piganti over the past few months.  He decided to collect them into a laminated bound book!

The campaign is on Indiegogo here.

Beautiful diagrams on every page


The campaign has already met it's goal and will make the book larger if they meet higher targets.  If you like building circuits but Making Things, this will help immensely.

Summer Lull and Where New Projects Are Being Posted

Summer has been rather busy around here.  With warm weather comes home improvement and three fair sized projects (deck, plumbing, foundation leak).

But I've still had time for electronic projects.  I received my Adafruit Trinket ATTiny85 based board and I was off connecting circuits.  This was a challenge, as many Arduino libraries do not work out of the box as the Tiny has fewer onboard hardware resources and limited memory.   So I started some posts on my progress, not here on the blog but on Google+.   It was faster.

Then I got "the e-mail".  Adafruit sent me a message stating they liked the work I had done on Trinket and asked if I wanted to write some tutorials.  Of course!  After formally asking work to ensure I had the ethics issues taken care of, I've started some articles, two of which have been posted.  My articles will appear in a group on this page.



Exciting, definitely.  So for fans of my open source posts, for now I suggest looking on the Adafruit Learning System for guides, mine will be there.

Sunday, June 30, 2013

Home Server Backup Build

I have not posted in a bit as my project took a bit of time.  I have been planning a new home server for several months.  The list of requirements:

  1. Be able to accommodate many drives for storage
  2. Use Windows Home Server 2011 
  3. Have as many CPU cores as economical
  4. Motherboard should be economical
  5. Re-utilize parts from my previous PC
  6. Maximum capability at a low cost. 
Numbers 1 and 5 came in via my previous case - a Thermaltake Armor case from about 6 years ago.  I ordered it a bit hastily having bolted on a TigerDirect deal on the Q6600 which was bad-ass back then.  The Armor is a beast of a case and accommodates a ton and a half of drive slots.  Great for a server but it was overkill for an enthusiast PC (and those wing doors and other things drove me crazy).

The previous Q6600 motherboard has some fault so it was not reused.  I got a deal on an AMD Phenom II 1055 6 core CPU and Asus M5A78L-M LX Motherboard from Microcenter in a bundle deal for around $100 about 6 months ago.  With such bundles, you are at the mercy of the bundle for the features of the motherboard.  But this one has a very good selection for a basic unit:
  • Integrated video (saving money and power on a video card).  VGA for switching.
  • 6 SATA ports
  • A legacy PCI card slot
  • Fair number of USB 2 ports.
  • mATX form factor - although the case can handle huge boards, if you don't need it, the space is welcome.
For a server, you want to minimize the amount of extras you add to save power and cost.   What I did end up adding, for features and because I had parts on hand:
  • 4 port USB 3.0 PCI-Ex1 card
  • 4 port SATA II PCI Card
  • 2 sticks of 4GB AMD PC3 memory that was on a deal from Slickdeals for $9.95/stick during the last low in prices.
I could have gotten a more modern motherboard with more capabilities but again I had "the bundle" deal and these cards were from previous server/PC upgrades so they were bought and paid for.  The PCI card will be a big bottleneck for server use but I only have a DVD drive and the server OS backup drive on it at present, freeing up motherboard SATA ports for real use.  The USB 3.0 ports are handy for external drives.  The card was a noname brand from the far east.  No driver disk found and WHS didn't recognize it.  A search on Google was sparse but led me to the VIA website where there were qualified drivers meant for manufacturers but they worked fine.

For drives, I wanted to get a few big ones and be done with it but I did not want to blow the budget if I did not have to.  The capacity needs were met after some scrounging - I had some 1 and 2 TB drives from an older HP Server and other uses.  I repurposed two 1 TB drives and two 2 TB drives for storage, putting them in a 4 bay caddy that was splurge #2 from Microcenter as it made placing drives easier than screwing them into the Armor case.  An older 750 GB drive serves to back up the boot drive.

So what did I use for the boot drive?  I had a 320 GB drive from the old PC that would have done fine as well as a 300 GB 10,000 RPM drive (but I wanted to keep that OS image).  Splurge #1 was getting a refurb 180 GB Corsair SSD on clearance at Microcenter.  WHS 2011 wants at least a 160 GB boot drive (although a hack will get that to 60 GB).  WHS can be pretty pokey when it comes to access especially the boot and console access.  That has always bothered me to an SSD was the way to go.  And it works, console startup is an order of magnitude faster.

I took my time on the hardware build, removing the old PC parts, getting all the dust out, getting the new motherboard ready with the CPU and stock cooler and RAM sticks.  The harder part was the drive caddy mounting and manufacturing an SSD mount from an old 2.5" bay insert as I was saving money from buying a commercial kit and the old 2.5 to 3.5 fat rails don't work with the SSD.

The cabling is as clean as one can generally make it if the motherboard mount does not have cutouts.  If this build was in my desktop Corsair case, the wires would be 98% hidden but this vintage case did not have those and I was not going to drill out large holes and ensure the sharp edges were taken care of.  That's ok - this is a server and not for show.  The airflow is not impeded by the wiring so all is good.  The case has a fan up front and back and a large side fan so for a server it's well ventilated (unlike my production server.  It's case was pre-active cooling so I rigged an intake fan in a nonstandard bay and out the back, it will be retired in the next couple years.

My choice of Windows Home Server 2011 is my own.  I have used WHS since it first came out, having used Windows XP for a server before that.  My home does not have any Macs and Linux is only on the electronics.  The WHS backup feature has saved the bacon a number of times and the file sharing works well enough for family use.

Time spent copying files off the HP Server not on the main server then all the server file shares to the new server.  I suggest Microsoft RichCopy (free and a bit newer than Robocopy but still 4+ years old).

I moved an external 3 TB drive off the main server used for backup of important files and placed it on the new server as the old server's USB3 drops the drives off every now and then.

So now we have our data on a WHS 2011 primary box with the new server as a server clone and the external drive as a last chance backup.  I am still weighing off-site backup alternatives, we have many files secure but it does not work in a dynamic environment.  With several hundred thousand pictures, cloud storage could get pricey.

So that's my setup for now.  Working on all of these issues was my main hobby for many years and I enjoy doing it but I have been away from the embedded electronics for too long and I have some cool items from YourDuino.com and Adafruit to get assembled.