Blog Sturntech

Archive for December, 2010

IMSA Intersession 2011 – Microcontroller Projects

without comments

For this year’s Intersession we will design and implement a Persistence of Vision (wikipedia) project.

This posting is my prototype design for the course. The full course documentation can be found at

POV RevA Build

Build of POV RevA

This project will be based on a PIC18F46k20 microcontroller (link). The firmware for the microcontroller will be written in C and compiled with the MPLAB C18 compiler (link). The functionality of the microcontroller will be used to turn LEDs ON and OFF. Timer modules will be used to sequence timed changing of the LEDs. An EEPROM module will be used to store LED patterns to draw POV designs. Initial POV testing of the design will be battery powered and will be waved by hand. Further testing of the design will involve mounting the design to a motor rotating at 360RPM.


The idea of this project is to use a microcontroller to create a device that can draw designs in the “air” by illuminating LEDs in sequence as the device moves through a repetitive motion. For this project, our initial repetitive motion will be generated by hand-waving the board through the air.

The example board pictured above has 8 LEDs. Each of these LEDs is independently controllable. The trick is to light the LEDs in a way that a pattern is drawn with the board’s motion.

Linear Motion: Zig Zag

For our first design we will draw a zig-zag pattern using 6 LEDs while waving the board through a linear motion. The algorithm is simple: one LED will be lit at a time, starting at one side of the 6 LEDs and moving toward the other, then the direction will reverse and the pattern will repeat. While this algorithm is running, the student will wave the board through the air. A certain amount of tuning will be required to synchronize the lighting of the LEDs with the movement of the board. This tuning can occur by changing the speed of waving or by modifying the timer interval between LED changes.

POV Linear Zig-Zag

Here is an example program to generate the above pattern. This program assumes the LEDs are all connected such that they ground into PORTB[5:0]. See the Hardware Schematic further down this page for hardware implementation details.
//linear-POV-zigzag.c for IMSAInterssion 2011

#pragma config FOSC = INTIO67
#pragma config WDTEN = OFF, LVP = OFF
#include "p18f46K20.h"

void main (void) {
// We will be shifting 0's in from a side to move the 1 (lit LED)
char pattern = 0b00000001;
char shiftDir = 0; //1 RSHIFT, 0 LSHIFT

// Set TRISB to configure PORTB as OUTPUTS
TRISB = 0;

// Configure the LATB register to set all PORTB outputs HIGH
// Remember: We are grounding the LEDs into the PORT pins.
// The LED will turn on when the pin LATB OUPUT is LOW
LATB = 0xFF;
while (1) {
// Delay some cycles between each LED change

// We are at one end of the LED string, switch directions
if(pattern == 0b1000000){
// Change shift direction
shiftDir = 1;
// We are at the other end, switch directions
else if(pattern == 0b00000001){
//Change shift direction
shiftDir = 0;

if(shiftDir == 0){
//Left shift in a 1
pattern = pattern << 1;}

//This blog´s software currently replaces certain characters with ascii command-codes.
// The above should be two left-arrow caret symbols; serving as the LeftShift operator.

else{ //if (shiftDir == 1){
//Right shift in a 1
pattern = pattern >> 1;

//This blog´s software currently replaces certain characters with  ascii command-codes.
// The above should be two right-arrow caret symbols; serving as the RightShift operator.


// Set the IO pin Latches
// We need to invert the pattern bit string since
// the LEDs are wired to light when LATB is LOW
LATB = ~pattern;

Hardware Schematic

The hardware schematic for the example design at the top of this page can be found below. The schematic has the full number of LEDs installed (the example only has the first 8 installed. 6 on PORTB and 2 on PORTD). The microcontroller is configured to use an internal 16MHz oscillator. Connecting the VCC pin from the ICSP connector to the circuit’s VCC bus allows the circuit to be powered from an external programming device (such as a PICKit2) during development. A 2xAA battery compartment is used to power the circuit during operation. Alternatively, this circuit will function from any 3.3V supply.

Schematic for POV RevA Device

Rotational Motion: Zig Zag

For the rotational motion we will mount the board to a motor. I chose to use a salvaged floppy disk motor. The motor control circuitry is configured to provide a 360RPM rotation rate.

Build of the POV RevA.1 design

Here is the zig-zag POV rotational pattern.

This is the zig-zag pattern shown on a POV RevA.1

The only change to the above code was modifying the delay count in the main while loop.

The modified lines should look like:
while (1) {
// Delay some cycles between each LED change

Written by sturnfie

December 26th, 2010 at 5:11 pm

ReverseEngineering: FD1231H Floppy Disk Spindle Motor Controller

with 7 comments

This weekend I took apart a NEC FD1231H 3.5″ Floppy Disk Drive (link) with the goal of re-purposing the floppy disk motor. The primary controller board IC is marked TRN9510A and thus far I haven’t been able to find a datasheet. The disk motor assembly is on its own board, connected via a backplane ribbon cable (6 pins).

Picture of the FD1231H Floppy Disk drive internals

The disk motor assembly board has a drive controller IC marked SS300 / 86CR. The motor is permanently mounted to the disk motor assembly and is marked “Y08 8428A”. The disk motor assembly board has PCB silk markings of “Sankyo KS-46 TM95C”.

Picture of the Sankyo KS-46 Motor Drive Assembly from a FD1231H

The above picture shows the motor that I wanted to drive; conveniently mounted to a board with a pre-existing controller IC, The only interconnection to the main controller board is via the 6 pin ribbon cable. My first assumption is that all power and control signals must pass through this connection. Since I haven’t found datasheets detailing the operation of any IC in this design, I started by scraping together every scrap of information I deemed relevant.

Close-up picture of the off-board ribbon connector on the Sankyo KS-46 Floppy Disk Motor assembly

First and foremost, a connectivity test on the Primary controller board’s pins indicates that one of the ribbon pins connects to GND, another connects to +12V, and the other four each connect to pin on the primary controller IC. From the silk-screened text on the Motor Drive assembly, I found useful names describing the functions of each pin on the backplane ribbon cable.

Pin 1 – Vcc (+12V)
Pin 2 – G (GND
Pin 3 – I
Pin 4 – CLK
Pin 5 – SPD
Pin 6 –  S/S

Additional interesting silk-screen text markings include “Hv+”, “Hv-“, “Hw+”, “Hw-“, “Hu+”, and “Hu-“. This indicated to me that the motor controller IC is meant to drive a stepper motor with 3 primary coils. These markings indicate the existence of sensor amplifiers used in determining the position of the motor’s rotor.

Powering the Motor Drive assembly board with +12V on Vcc and measuring the voltage on each pin indicates that the S/S and SPD signals have weak pull-ups to Vcc (32k and 47.2k respectively), whereas CLK and I signals are provided by an external circuit.

A couple hours of googling turned up several motor controller ICs for similar applications that use similar naming conventions. Most useful were the M56787FP Spindle Motor Driver  (link) and the ZMBM1015 Brushless DC Motor Controller (link).

I was able to deduce that CLK is an external clock signal. I assumed that it would be 50% duty cycle since the destination IC is a probably a Motor Controller IC (and any PWM function would be implemented by such a controller). The S/S signal is a Start/Stop logic signal. The SPD signal seems to be a voltage variable control on the motor rotation speed. I couldn’t find any direct reference to “I”, but since the only typical control line yet missing is a motor spin direction control, I assumed that this is probably what the “I” line was for.  See the comments for a more logical purpose of pin “I”. It is commonly used as an RPM output from a sensor that monitors the rotation rate of the motor.

Simulation of the 555 timer circuit used in the FD1231H Floppy Disk Controller project

For the first test run, I decided to leave SPD untouched (pulled to Vcc) and signal “I” pulled to GND. The S/S signal I pulled to GND. The CLK signal I arbitrarily decided to generate a 300kHz 50% duty cycle square wave (since this frequency was used by one of the reference Motor Control ICs I found earlier). For the CLK signal, I used a 555 timer circuit. When interfacing the 555 output to the CLK signal line, I used a BC547 NPN transistor.

The motor spins! The S/S signal was confirmed as a Start/Stop signal (GND/Float). The SPD signal is 100% Float, decreasing with voltage dividing down from the Vcc pull-up. The “I” signal does not seem to handle spin direction control CW/CCW as thought. See the comments for the information that pin “I” is commonly used as an RPM output (presumably from the position sensor that used to be mounted on the board, opps!).

A CLK of 300kHz resulted in a pretty jerky spin motion. Reducing the frequency worsened the performance. Increasing the frequency helped a lot, with a smooth continuous rotation discovered around 1MHz. Further increases in frequency heated the motor driver IC up quite a bit, without any noticeable gain in spin performance.

Using a 1MHz CLK signal, I was able to get this motor to spin at near 360RPM (measured with light strobe).

Build of the FD1231H Motor Drive Controller Project

Written by sturnfie

December 4th, 2010 at 11:23 pm