Building a quadrature generator with a PIC10F222

I need to start my new project with my digital RTJ gage and in order to do so I need to use the quadrature decoder chip LS7166. I could use the actual encoder I’m going to use for the project but it is large and unwieldy so I decided to build a generator for it.

The concept is simple, have a knob that produces no waveform in the middle of it’s stroke and as the pot deviates from the center, the speed of the signal increases also changing direction based on which side the knob id turned to. I couldn’t use a PIC10F200 much to my chagrin because it doesn’t have an ADC module built in, the PIC10F222 does however. It still works within my concept of low-end mcu’s doing valuable jobs since they’re still only 55 cents in quantity, from digikey of all places.

Overall, it’s a pretty simple design.

  • GP3 -> unconnected
  • GP2 -> Channel B out (Digital output)
  • GP1 -> Channel A out (Digital output)
  • GP0 -> 10k Potentiometer in (Analog in)

Dead simple. I did program a bit of a dead spot in the middle so that one can stop the quadrature from advancing quite easily. I put 2 LEDs on it to indicate that it is in fact working. Anyways, here’s the source (again it’s in Oshonsoft BASIC)

10f222 quadrature

I didn’t bother drawing up a circuit diagram since it’s such an easy circuit but here’s an additional image if you’re really curious. keep in mind that the board I’m using is Stripboard (aka Veroboard) so the traces run along one direction

Now for the fun challenge of making a simple serial interface MCU to the LS7166.


Comments (0)


Ugluino, the ugly Arduino powered robot

So, even though I’ve built a wide variety of crap over the last few years, all of them with varying utility, I’ve decided to build a quick robot. With oodles of free time and the feeling of having to go back to work on the horizon after what feels like an eternity of holiday (1 week) I quickly grabbed a bunch of stuff I had sitting around and put this guy together with all the grace of a kindergarten macaroni art sculpture.

Ugluino Being Built

Based off of an Arduino Nano, this guy works just fine. I don’t like using Arduinos for the following reasons.

  • Perceived lack of control of what’s going on inside
  • Feels like cheating since it’s so easy
  • Arduino UI is kind of shitty, especially for larger source files.
  • When dealing with AI routines, making it difficult to use multiple files is a minus

Anyways, i plugged ahead and quickly pounded this out with the following IO

  • Input – The only one, the Echo pin on the ultrasonic sensor
  • Output – Trigger on ultrasonic sensor
  • 4 Digital output – for controlling direction on SN754410 Quad half h-bridge driver. These go to two gear motors which are attached directly to wheels
  • 1 PWM out for duty on motors
  • 1 attached servo out of the servo to turn the sensor

The back end of the Ugluino

Most everything worked out swimmingly until I fucked around with some wiring and produced a short. I hooked the robot on to the USB supply on my computer, I noticed after a few second that the power to the unit wasn’t running… hmmm POOF! Well, as it turned out, there was a problem with the wiring to the ultrasonic dealy and it blew what I beleive was a zener diode

I wasn’t able to figure out exactly what it was, I suspect that it is a zener diode that selects between main power and USB since it is on the output of the VReg. I could be wrong. Since I didn’t have any more Arduino Nano’s I simply tried to fix it and soldered a wire across the offending gap. The device seems to work fine…? Anyways, if anyone know what that part was on the Arduino Nano v3.0, I’d like to know ’cause I couldn’t find the 3.0 Schematics and the design has moved those parts around.

Anyways, The robot moves around based on a very simple algorithm.

  1. Stop Moving
  2. Scan from 40Deg Right to 40 Deg Left in 10 deg increments
  3. return appropriate movement from a function that analyses it
  4. execute proper movement (Forward, Backward, Right, Left, Hard Right and Hard Left)
  5. rinse
  6. repeat

It seemed to work reasonably well. I’d like to build a more sturdy version for shits and giggles so that I can play with the algorithms. I’m probably gonna build one with a PIC18F2685 instead of an Arduino. Also, instead of a single sensor, I will use IR proximity sensors to detect low lying objects. Moving the sensor with the Servo make the robot seem more intelligent than it actually is like it’s ‘looking around’. I quite like that. 🙂

Anyways, it’s my first post of the year, considering it’s January 1st and 3:52 am as I write this. maybe I should go to bed. Here’s a video of it getting around.


Personal Projects

Comments (0)


The underrated PIC10F200 (and 202/204/206 as well)

Sitting around looking through my collection of parts during a brief stint of illness I came across my stash of 30 or so PIC10F200’s. These were my entry into the world of microcontrollers. Granted I wasn’t very good at electronics (and probably still not very good) and I found the lowest end microcontroller i could in order to understand them on a more fundamental basis. I found all of the peripherals on other microcontrollers to be a distraction and complicating factor from what I wanted to learn.

batch of 10f200's

My little batch if PIC10F200's, I got more in tubes

Nowadays, delving into 32bit architectures and whatnot, I’ve forgotten about the little MCU’s. Thinking about it they’re still incredibly useful in a myriad of circumstances. Only costing 59 cents or 30 cents at volume, and running at 4Mhz internally these have an amazing range of uses.

Consider the lowest end of the low end, the 10F200. Now it only has 256 words (12-bit wide instructions) and 16 bytes of RAM. It has 3 I/O and one input only pin. Now in a world of Arduinos and large pin count microcontrollers running at 40+Mhz , it may seem like this thing has no use but I beg to differ.

Today I was tinkering around with the little unit today and I was recalling some of the things I imagined I could do with the limited hardware. So today I wanted to see how well it could produce sound. Now this little thing is trivial for most MCU’s, simply output an appropriate square wave. My goal though was to produce a warble and program it in a C compiler. This was very easy and achievable.

The little sound circuit

The little sound circuit I was working on... using a LM2904 for amplification.

Now, granted, it’s not a very complicated circuit, but I found it to work admirably. The compiled code took up only 36% of the ROM and 38% of the RAM. That’s with 2 16 bit counters and an 8 bit function variable. it also used delay functions. Of interest to note though, I tried using floats, no go, the libraries filled up the ROM like boom!

Anyways, here are some used I dreamed up for the PIC10F200 over the years. They are mostly in support roles but I think they’re equally as useful as any other role within a project, especially given the MCU’s small footprint and low price. The applications I’ve thought up are as follows, keep in mind we only have 3 IO and one input.

  • A dice game: I actually created a prototype of this some time ago based on the idea that this would be my business card. It was simply a set of multiplexed LED’s (six in total) on a PCB that would show like the face of a dotted die. one input was used and the other three were for the IO. Bringing the IO to an input mode would turn off the leds.
  • Two button debouncing: Using a microcontroller for debouncing has been my favorite way to debounce inputs on a button. By using an internal count on the MCU you can simulate a charging/discharging capacitor and provide threshold values to simulate a ‘dead zone’
  • A little robot: Using the two output for motor control and the two inputs for sensing, you could potentially make a simply robot. the only problem with it may be the limited ROM for logic routines, but I suppose that’s the challenge.
  • Timer Lamp: The 10f200 has just enough IO for two buttons and two outputs (I = On/off, I=Timer function, O= LED out, O=Relay for lamp). my old project with a timer lamp was done with a PIC16F505 (a limited MCU in its own right) but the 10F200 would’ve done the job quite admirably.
  • Dimmers on AC lamps: This example is used by microchip extensively to promote the device, it is one of the many uses of this device.
  • Sound generation: Like I did today, it seems like a pretty worthwile use of the chip. Cheap and easy. small size also helps with the surface mount varieties.
  • One-wire wake up: You could use it as a separate node to watch a data line for signalling on the one-wire protocol. I have used this to fire up LED’s in a specified pattern and duration. With the SOP package tou can solder it directly to the LED and data line in a bizzaro single package.

Anyways, the uses are endless for such a limited but inexpensive device. I have no idea why such a limited device captivates my imagination but perhaps it’s the small size that makes it interesting and uncomplicated design and use.

So, for your troubles of reading a wall of text. Here’s a neat photo of an old diode for your perusal.

Neat picture of a diode

A bonus picture of an old school diode. Gotta love the little spring inside holding the junction together.


Comments (3)