Tutorials on USB, SPI, I2C, CAN, LIN, etc.

April 21, 2011

Thanks to the Arduino, and others including Maple, lots of new users, beyond traditional developers and engineers, are using microcontrollers. Microcontrollers are mind-boggling pieces of equipment, genuinely worthy of the moniker ‘only limited by your imagination’. Many users create amazing projects using the excellent libraries and existing electronics. Some need to go further. They want to understand how to make the hardware do even more and different things.

I have always been the type of person who likes to understand how things work. I like to read manuals. Even as a child I read the manuals for my brother’s HiFi so I knew how to do make it do pretty much anything possible. I like looking at low-level code, and digesting Microcontroller manufacturers manuals. I like reading technical stuff, especially over a balmy Holiday Weekend.

I sometimes work with folks with technical backgrounds in software not hardware or low-level embedded systems who want to do more. They have all the knowledge and skills to program the hardware, but the hardware manuals are too hard a place to start. It is surprisingly rare to find good introductory material for low-level technology which is both approachable and also detailed enough to enable non-specialists to go further.

I was pleased to stumble into a set of resources for embedded systems at “EE Herald”
http://www.eeherald.com/section/design-guide/index.html

It includes a section of “On line Courses” on common embedded communication interface ‘standards’. The tutorials include USB, I2C, SPI, CAN, LIN, Serial, and RS232. Those standards are used to communicate with individual chips such as accelerometer sensors, other microcontrollers, host PCs, SD memory, Wii controllers, controllers in manufacturing plant, and parts of cars. There are also section on ‘IEEE 802’ local area and wide area networking standards.

The sections I’ve skimmed seem to have good coverage and a decent level of details. The tutorials include some helpful diagrams, which helps folks like me a lot, and are written at useful level of technical detail without going down to the manufacturer specific hardware.

For example USB is covered in
http://www.eeherald.com/section/design-guide/esmod14.html

I have only skimmed it, but it reads as good coverage of USB 2.0 from history to physical hardware, electrical levels, signalling, end-points and protocol including packet formats. It isn’t as detailed as the USB specifications, but I don’t think many people would want to start their! I like to get a good overview of the way a system works before digging into the detail, and I like to have a broad technical understanding to stitch detail into.

The USB article at EE Herald isn’t perfect. It includes a very brief overview of USB On-The-Go (OTG), but not enough to feel I could properly understand the STM32F USB OTG hardware. USB On-The-Go includes the more complex host-side of USB, so it would be impressive if they had got that too. I feel that is a minor and common weakness.

It is a readable alternative to
USB in a NutShell at http://beyondlogic.org/usbnutshell/
USB made Simple at http://www.usbmadesimple.co.uk/

These won’t replace the manufacturers manuals (e.g. ST Micros STM32F RM0008), but they cover generic technical detail, and look pretty good. I’m hoping they may be enough overview for anyone who wants to read low-level code or hardware specific manuals like STM32F RM0008 or the Atmel ATmega 48/88/168/328 manual.

I briefly looked at some other articles in the EE Herald design guides, and they are not all good quality. I felt disappointed by the ‘MEMS based motion sensing design’. It had almost no useful detail; I thought it was weak even as marketing ‘puff’. I wouldn’t feel ready to tackle a manufacturers MEMS datasheet after reading that.

EE Herald have some links to other sites, including this useful looking article on 1-Wire Interfaces from Maxim which has a lovely list of 1-Wire Application Note links at the end. Ideal Holiday Weekend reading ūüôā

Advertisements

OROne – Cortex-M3 robot controller (STM32F103)

April 6, 2011

I was lucky enough to get some financial support to design and prototype a robot controller. I got outstanding help and advice from Dr Tony Wilcox, Chris Evans and Roger Thomas of Birmingham City University. Chris did a lot of the PCB routing, and much of the board construction. Tony generously shared his wide experience of developing robot controllers, and embedded and electronic products. Roger was a font of knowledge on PCB design and manufacture, and electronics. Thanks also to Pete Harrison for his always helpful comments and suggestions.

I learned a huge amount from them. This is the result.

OROne STM32F Robot Controller

OROne STM32F103 Robot Controller - without 0.1" headers

It is based around an ST Micro STM32F103CB Cortex-M3 microcontroller. This version has 128K Flash, 20K RAM, USB, CAN, 3xUSART (serial),15xPWM, 16xADC, 2xI2C, 2xSPI, and JTAG in a 64-pin package, all ticking along at 72MHz.

The board adds dual DC-motor drive, seven LEDs, two buttons, two servo sockets, as well as sockets for six analogue input, two quadrature encoders, and headers for JTAG and Serial. The two 30-pin 0.1″ headers (missing from the photo) gives access to all of the microcontroller signals and power on a veroboard friendly grid. The microcontroller can be powered over USB, or via an external power supply or batteries. The board also has independent on-board voltage regulation for the servo’s and motor drive chip.

Like an Arduino, it is ‘self-programming’ over USB once the bootloader has been installed. I installed the bootloader over the microcontrollers on-board serial interface using an ordinary FTDI USB to serial cable. So it doesn’t need JTAG or an in-circuit programmer, ever.

It is based on the Maple from LeafLabs. LeafLabs have built an IDE using the same Processing-derived IDE as Arduino. It sits on top of GNU GCC. They have also implemented most of the Arduino base-libraries, so Arduino programs may move across to Maple with minimal or sometimes no changes. To top it all, they have developed a bootloader which enables the STM32F103 to program itself over USB. The whole software environment, libraries and bootloader are Open Source, and runs on Windows, Linux and Mac OS X.

Maple is a magnificent piece of work. My board ‘came up’ in a couple of hours (after we found and fixed a couple of my PCB errors).

Chris did much of the construction; he has a very steady hand. We used the ‘Mini-oven SMD technique’. Paul Gardiner of Finham Park school in Coventry did a workshop a while ago, and this is the biggest board I’ve made using it.

I’ll describe some of our experiences, and where-to-next over my follow-up blogs.

Printing Wax onto PCB – Simple, Quick DIY PCB’s

January 11, 2011

I stumbled across this YouTube video at dorkbotpdx.org.

The video is presented by Jeffrey Gough of¬†¬†Warranty Void If Removed. He is working to make DIY Printed Circuit Boards (PCB’s) much quicker and easier. He is aiming to reduce the PCB manufacturing process to two steps: print, etch. His ink-jet-based printing mechanism will directly print wax onto the PCB material to resist chemical etching.

The video talks about many different methods of making DIY PCB’s (maybe the first 30 minutes). Most ‘normal’ methods use printed circuit board material which is fibreglass boards covered in copper. A circuit is formed by removing the unwanted copper using a chemical etching process. The mass-production methods use photographic technology to apply an image differentiating the circuit and unwanted copper ¬†using a technology which protects the required copper from the etching chemicals (it is actually many steps, as the industrial process is more complex than the one used by DIY PCB techniques). DIY PCB makers often use a photographic process which leaves a protective chemical ‘film’ over the required copper. This requires several steps before getting to a stage where the copper clad fibreglass can be etched into a PCB.

The approach proposed on the video is very different. Jeffrey Gough prints wax straight onto the board, and the wax resists the etching process. So there is no need to make intermediate ‘tools’ to create the photographic image, and no need for intermediate ‘manufacturing’ processes.

His approach is to modifying a low-cost (‚ā¨40) Epson¬†ink jet printer so that it can print wax straight onto blank PCB material. He did a lot of reverse engineering to build a piece of electronics which could take over driving Epson’s print head. It appears to be able to print tracks as fine as 0.1mm, which is better than most commercial PCB manufacturing process (that I can afford ūüôā

The print head is heavily modified to keep the wax liquid while being printed. When liquid wax is ‘fired’ from the print head nozzle, in the same way as ink is ejected, it solidifies (freezes) on contact with the PCB copper, forming a wax covering which protects the copper from the etching chemicals.

The development is far from complete, but it shows real promise. It might revolutionise PCB production for professional design engineers, and not just DIY makers. If it were robust enough, every school and colleague that does any electronics would use it. For me, making one-off, prototype PCB’s is the slowest, and often most costly part of exploring an idea. This would remove that obstacle. By using Surface Mount Technology and Devices (SMT/SMD), I could make a PCB in well under an hour using this process. I’d use surface mount technology to minimise the drudgery of drilling hoes in the PCB. I’d solder the whole board in my trusty mini-oven using solder paste.

One slightly frustrating part is Epson could probably bring this to a production prototype stage in a few months with a few people.  If anyone at Epson is reading this, there may be a real market for such a printer, and Epson are one of the few printer manufacturers who use piezoelectric print heads, so the market may have very little competition while the products are developed, sold and improved.

Making without Tools or Technology

September 6, 2010

I was listening to one of my favourite internet radio programs, All A Capella at wers.org.¬†I used to listen ‘live’ on the radio when I lived in MA.

It struck me how striped down some kinds of Making can be; talent, voices and collaboration.¬†It’s like ‘glitching’ every instrument and studio technique to a single ‘sound technology’; only the essence remains. The ultimate ‘Unplugged’.

I very much like ‘Kiss from a Rose’,¬†they can sing.

My digging around got started because I heard a superb rendition of Gangsta’s Paradise.

This is a¬†pretty cool piece of A Capella, with video, but I think ‘All A Capella’ played¬†a different version tonight, which sounded better to my ears. It was by University of Pennsylvania Off the Beat.

Many of the performances ‘All A Capella’ feature are college groups.¬†It is great to hear talent, enthusiasm, discipline, ingenuity and ‘cojones’, whatever the sex, are flourishing.

We don’t need computers, Arduinos, blinky-LEDs, reprap,¬†soldering irons, glue-guns, or even duct-tape to make amazing things.

Let’s Make a Difference!

Dev8D 2010 – Arduino Workshops

April 28, 2010

I had a wonderful time at Dev8D. It was a great event, and I feel privileged to have been able to contribute. Many thanks to Dave Flanders for the invitation, his enthusiasm, and encouragement, and Mahendra Mahey for making it work so well.

I ran three workshops introducing Arduino and basic electronics, and two intermediate, follow on Arduino workshops. To keep costs down, we had 12 complete kits, and asked folks to work in pairs. There were a mix of skills and expertise, and the folks supported each other so well that two of use were able to provide success to 24 people. I should add a special thanks to Dave Chalis*. He was incredibly helpful. Without him, day one one have been less smooth, and much less fun.

Folks gave lots of useful feedback and encouragement. So I hope to do even better in the future.

*Dave I apologise if I have misspelled this, please someone correct me.

Dev8D 2010

February 23, 2010

I am very excited to be running five Arduino Workshops at Dev8D 2010 in London this week.

I’ll be running three hands-on Beginner’s Workshops on Thursday, Friday and Saturday. The electronics will not require a lot of knowledge, it’ll assume that folks remember there are two connections on a battery, and they are different. I’ll be using my favoured, ultra low-cost, Maplin breadboards, so we won’t be soldering. We’ll provide Arduino’s (Feeduino’s), electronic components and tools.

I’ve run these before, and I believe we can do most of the core Arduino language, and build some electronics, in a few hours. We’ll write programs for digital input and output, analogue input and output (PWM), and use the Arduino millisecond and microsecond clock. The electronics will be LEDs, squeaky speaker, resistors, potentiometers, light sensors, and lots of wire :-).

I’ll be running a couple of ‘Advanced Arduino Workshops’ on Thursday and Friday afternoon. We’ll use a small driver chip to power a motor (or 100+¬†LEDs), use ‘time division multiplexing’ to drive many more LEDs than an Arduino has pins (without using any external electronics), and recognising Infra Red Remote Control signals.¬†These are all based on things people ask me about, so I hope they are useful. We’ll provide Arduino’s (Feeduino’s), electronic components and tools.

If you really want to drive motors in an even fancier way, get hold of an L293D, and we can experiment with that too. If you have something that responds to Infrared Remote Control, bring it and it’s control along, and we can drive it from the Arduino (if the data to generate the Infrared signal is on the web, we don’t need a control. For example, the specification for things like Nikon camera’s are available, and we can work the rest out ourselves).

I’ll be around all day Saturday, so if anyone wants some help, or wants to try any of the ‘Advanced’ projects, please come find me.

Arduino at RS

February 23, 2010

I’ve just noticed, RS Components are selling Arduino boards, shields and books.

I use RS because I live near a trade counter, and can get parts within two hours. So, for folks who want an Arduino now, maybe you can!

(I am not on commission, and have no business relationship with RS, other than giving them money for components :-)).

I still recommend buying Freeduino’s from Nuelectronics, they are significantly less money.

A lower-cost, ARM-based Arduino alternative?

December 15, 2009

I stumbled across this NXP press release for the¬†LPC134x which is based on the ARM Cortex-M3.¬†The press release says “The on-chip USB drivers support both the Mass Storage Class (MSC) and Human Interface Device (HID) class. Furthermore, these drivers are incorporated in ROM, saving customers approximately 5-6 K bytes of user code”

Looking at this¬†presentation, (slide 25), the chip shows up under Windows (and they say Linux) as a Flash drive to provide “Drag and Drop Flashing”. It has this capability built in at manufacture! No need for a bootloader, JTAG, or a second chip, like the FTDI USB to serial interface on an Arduino. Put an LPC134x on a board, connect USB, and it should ‘just work’ (TM :-))!

An entire USB-based micro-controller board only needs an LPC1342 or LPC1343, a crystal, voltage regulator, a few passives and PCB. The LPC1342 is available from Farnell for £2.20 and LPC1343 for £2.70 or £3.30. So a board could be smaller than an Arduino-Nano, and lower-cost.

I haven’t read the datasheet in detail, but overall these micro-controllers are more powerful than Arduino’s¬†comparable Atmel ATmega168 or ATmega328, with 16K or 32K of program memory, so this is the best I’ve found to achieve the goal of sub-$10 micro-controller (at one-off prices).

The NXP parts have plenty of advantages over the Atmel parts. The LPC134x runs at 72MHz vs the ATmega’s 16MHz, and both execute instructions in one or two cycles. The LPC134x is a genuine 32-bit processor, whereas the ATmega is an 8-bit processor, so this means some calculations will go much faster on the ARM. I don’t think this is a huge benefit, as my Arduino’s spend most of their time waiting around for something to happen, but it may mean some programs are smaller on the LPC134x.

The LPC134x looks like it has much faster (40x) Analogue to Digital Conversion (ADC), opening up a range of interesting sensors and experiments. The LPC134x has significantly more RAM; LPC1342 has 4KB vs the ATmega168’s 1KB, the LPC1343 had 8KB vs ATmega328’s 2KB.

Both families have a set of timers. Timers are used to implement analogWrite, millis, micros, delay and delayMicroseconds in the Arduino language, but they are also used to control servo motors, stepper motors, modulate Infrared LEDs, and time external events.

The LPC134x have 2 √ó¬†32 bit timers, and 2 √ó¬†16 bit timers vs the ATmega’s 1 √ó¬†16 bit timer, and 2 √ó¬†8 bit timers. The LPC134x timers look more flexible than the Atmega168/328. The LPC134x comes in a package with more pins, so there are more PWM pins, and more pins to time external events.

The on-board LPC134x USB is 12Mbit/second vs 0.115Mbit/second for the FTDI chip on an Arduino.

The rest of the comparison between LPC134x shows similar peripherals to the Arduino’s on chip. They both have I2C, SPI and USART. So overall the LPC134x looks as good or better than comparably priced ATmega’s (at one-off prices).

There is a free, Open Source, GNU toolchain for the ARM, which is based on the same compiler as the Arduino IDE uses. So it looks like there are no real obstacles to making a lower-cost, ARM-based Arduino alternative. Of course, there is a plenty of work in porting the Arduino language libraries, like analogRead and analogWrite, but the core functions, which we use the most, would probably be only a few weeks.

I’ve ordered a low-cost NXP development board, LPCXpresso, to do some investigation. This is a similar price to Arduino’s, at ¬£18.34 from Future, or ¬£17.86 from Farnell (plus VAT). This is an encouraging price because the LPCXpresso contains much more technology than an Arduino. The LPCXpresso has a JTAG debugger which supports much more sophisticated debugging than available on an Arduino, and it probably costs as much or more than the LPC1343 itself.

There is a free downloadable LPCXpresso development environment available, so it should be practical to get a better understanding, and discover the disadvantages that datasheets never show for very little further cost. I’ll try to make some time to investigate this in more detail after Christmas.

Please don’t misunderstand. I love my Arduino’s, but the ability to significantly reduce its price, and make better technology available to an even wider audience is compelling.

fizzPOP Howduino 25th November – Part 1

November 25, 2009

Thank you to everyone that came to the fizzPOP Howduino ‘Happening’ on Saturday. It was wonderful to meet so many energetic and talented people.

Extra thanks to the folks in my two Arduino/Freediuno workshops. I really appreciated working with you, and all your valuable feedback. Every comment helps me to try to improve the material.

The wonderful Todbot material is at Todbot’s Spooky Projects:

I’ll load my slides this week.

Thanks again for all of the effort and brain-power lavished on the workshops. It was a delight to help, and great to be a part of it.

James May’s Airfix kit

October 28, 2009

I’ve just watched James May’s Toy Stories. The first episode was about Airfix plastic model construction kits. He set out to interest a group of 13-year olds in making Airfix model kits.¬†I vividly¬†recall the acetone whiff of polystyrene cement, rekindling my memory of Airfix.¬†I was so buzzed by Jame’s introduction, that I thought it would be good. I was wrong. It was much better than merely good.

His tactics to tempt the teenagers into make Airfix kits were predictable yet surprising. I winced along with every misstep, and fell for every dummy. Beautifully assembled. The kids were amazingly co-operative.

The goal was a dream of every 13 year old Airfix-er of my generation, and better. It was to build a full size, 1:1 scale, Airfix Spitfire kit. Cooler than a Bose‚ÄďEinstein condensate. I was so pleased, my jaw still aches from an hour-long manic grin. I haven’t wanted TV, or a movie, to work out right so much since “The Shawshank Redemption”. The climax was inspired.

The 13-year olds were stars, and did a great job under the pernickety eye of a ‘benign, but obsessive codger’ (I hope James doesn’t mind this characterisation, but that’s his TV persona, and neither of us are at all bad :-). The prospective builders reactions were illuminating. I felt it a worthwhile watch for folks trying to develop projects with teenagers.

I beg every fan of Airfix kits to watch this. You may even be delighted at the use of your BBC TV license fee! May I be even more gushing and say ‘heart warming’? (Yes, I liked Airfix kits).