MCU Series, 2: Sometimes MCU choice doesn’t matter

This article was originally posted on Microcontroller Central, which is no longer on the air. Much of the content is as it was when I originally posted it, with updates when necessary to correct errors in the original articles or reflect more current information. The following first appeared February 22, 2012.

In an earlier post, I discussed taking a 555 timer-based oscillator out of a high-voltage supply and replacing it with a PWM signal from a microcontroller. The design, an open-source Geiger counter, already has an Atmel ATTINY2313 MCU, but I had read someplace that it couldn’t handle both PWM and the other processing required for the circuit. That didn’t and doesn’t make any sense to me, but because it came from the Internet, it has to be true. Right? Relying on my Internet information source, I was going to use a PIC MCU to provide the PWM signal in my design. However, rather than leaving the Atmel stone unturned, I decided to try out its PWM first and see for myself if the chip could handle the whole task. The Geiger counter firmware already uses two timers: Timer0 for PWM chirp tone generation and Timer1 for actual timing duties. I’ll need a third PWM to feed the LC part of the HV supply.

The Atmel chip has four PWM channels, but the clock setup is a little different from the PIC chips I normally use. My first interpretation of the ATTINY data sheet revealed only two timers on the chip: an eight-bit and a 16-bit. That didn’t seem to be enough to drive the four PWMs that the chip offers. Fortunately, a little more research uncovered that the chip has two eight bit timers, and that each half of the 16-bit timer drives a PWM independently. All four channels are covered, after all.

That question being answered, the next step is to generate a PWM signal and mod-wire it in to replace the 555-based oscillator. Pin 9 of the ATTINY2313, OC0B/T1/PD5, is unused in the open-source design, so I’ll use that pin for the feed to the HV supply. I need 4-5KHz for the power supply’s LC circuit.

Deciding to try the Atmel part instead of a PIC MCU gave me an opportunity to explore the differences between the two parts by comparing the code needed to configure the PWMs. First, here’s the PWM setup for my PIC16F1825:

  • // Set HV power supply CCP2 to 4.9KHz, ~20% duty cycle
  • CCPTMRS = 0b00010000; // Select timers for PWM. CCP2 = Timer 2, CCP3 = Timer 4
  • PR2 = 0x65; // PWM period 4.9KHz (With 8MHz system clock)
  • T2CON = 0b00000101; // Timer 2 on, Prescaler = 4
  • CCP2CON = 0b00001100; // Turn CCP2 (RA5) on
  • CCPR2L = 0x33; // Set to 20% duty cycle
  • TRISA5 = 0; // Clear pin direction to enable

Now the comparable code in the ATTINY2313:

  • // Set HV power supply OC0B to 4KHz, ~20% duty cycle
  • DDRD = _BV(PD6) | _BV(PD5); // Set PD5 as output for PWM
  • TCCR0B = (0<(0<OCR0B = 0x33; // Set to 20% duty cycle

The ATTINY version seems simpler to program, though it’s entirely possible that I’m missing something, or that other parts of the initialization are done someplace else in the open-source code I’m starting with. As far as function is concerned, though, the two devices are effectively the same.

The more familiar I get with Atmel chips, the fewer functional differences I see between them and their Microchip counterparts. Microchip seems to have more varieties, but each Atmel variety covers a broader feature set.

In the end, they’re pretty much the same in my book. Before I started using Atmel chips, I really didn’t see what the big argument between the two MCU camps was all about. Now I see it even less. The differences just don’t matter.

NOTE: Since this was originally published, Microchip purchased Atmel, so it may soon matter even less.

The World’s Geekiest MP3 Player

Launchpad and capacitive touch booster pack

I’m helping put together  the Wireless Mesh Networked “Hello There!” badges for the upcoming 2016 Boston ESC (Embedded Systems Conference). My biggest contribution is that I got my company, Screaming Circuits, to assemble all of the badges for free, and I got Sunstone Circuits to fab the boards for free. Beyond that, I’m just trying to customize mine, so it will be just a little different than everyone else’s. [Read more about the badge here]

David Ewing, of Synapse-Wirelsss designed it to use their SNAP wireless engine, and display things on an 8×8 LED matrix. It’s also Arduino hardware compatible, which brings me to the world’s geekiest MP3 player.

I’ve got a 7-band equalizer Arduino-shield that I designed a while back with Max, who wrote the linked article above. I’m going to put that on my badge, with a microphone and turn my badge into a 1950’s style robot voice display.

Lauch pad and equalizer shieldAs a music source, while writing the software, I pulled out a Ti MSP430 Launch Pad development board with an “Audio Capacitive Touch” booster back, as shown on the right.

I acquired the Launchpad and booster pack back in 201, when I was writing for the website Microcontroller Central. I haven’t used it since then, but after bringing it back out, I might end up inspired to build it into some new project. More on the badge later.

 

Robots good. Neurotic thermonuclear devices bad.

Sipping a Late Night Xpresso

When I started in the MCU world, evaluation boards were pretty expensive so I designed and built my own, but that was a decade ago and things have happily changed. A number of MCU manufacturers seem to have decided that development boards should be really low-priced, making it very easy to try out their products. Case in point: the MSP430 Launchpad from TI. I just bought one for $4.35. For that price, they might as well be giving it away. I also ordered the NXP LPCXpresso when I bought the Launchpad; even at $26.95, the LPCXpresso is very inexpensive, in my book.

Speaking of giving it away, I recently picked up a Renesas development board for free at a tradeshow. Well, it wasn't totally free, but it was close enough. I had to listen to a presentation for five or ten minutes.

Anyway, I've been acquiring these boards because I'm in search of an MCU family that is a step or two up in capabilities from my usual PIC processors. I have a little experience with ARM processors from using the mbed and the Beagleboard, but I need something lower-end and less of a complete system, yet more powerful than an 8-bit.

Read More

MCU Series, 1: Those Pesky Fuse Bits

The content on Fuse Bits was originally posted on Microcontroller Central, which is no longer on the air. . Much of the content is as it was when I originally posted it, with updates when necessary to correct errors in the original articles or reflect more current information. The following first appeared February 3, 2012.

Hello all, and welcome to Fuse Bits. Come here to share in my travails with microcontroller project design, programming, and PCB design. I work primarily with eight-bit chips from Microchip and Atmel, but I have dabbled with a few ARM devices.

A while back, I put some effort into re-laying out an open-source Geiger counter design toconvert from thru-hole to surface-mount parts. Naturally, it didn't go quite as well as I expected. Geiger tubes require a multihundred-volt power supply, and the original design used a 555 timer to drive an RL discharge into the charge pump to generate this voltage. In theory, the design should create between 400 and 600 volts with microamps of current. Yet my layout produced only about 10 percent of that target. As a result, all of those radioactive particles just passed merrily through the tube without making so much as a tiny pip.

Read More