Bread Board Encoders

Using a normal size panel mount encoder when breadboarding a new circuit can be somewhat inconvenient at best since the solder lugs are mostly too large and usually in the wrong location.

Bourns makes a series of encoders that are very useful for prototyping circuits on the plastic breadboard strips that are in common use. The 16mm rotary encoders that Bourns manufacturers are low in cost and available from many different distributors in 12 or 24 pulses per revolution, with or without a momentary switch.

These encoders have just the right height and solder lug spacing to allow a simple straight inline 0.1 inch pin header to be soldered to the front of the solder lugs. Since the lugs are spaced on 5mm (0.2 inch) centers, I used a header with five pins, removing two of the unneeded pins.

On the encoder with the momentary switch, a 0.1 in pin header can be soldered to the opposite side of the input pins where the switch connections are located.

On the encoder without the switch, a piece of bare 22 awg wire was soldered to the mounting lugs on each side and the wire was then formed to provide support on the opposite side of the input pins.

Finally, a simple and inexpensive knob can be created for these encoders from a 0.5 inch piece of 3/16 inch silicone tubing.

 

 

ENCODER CONNECTIONS TO A MSP430 LAUNCHPAD

 

 

End Post

Simple Square Wave Generator

This astable timer circuit is a simple square wave generator based on a CMOS version of the 555 timer that can maintain a nearly constant 50% duty cycle (+/- 1.0%) over a wide frequency range. This requires a transistor and a diode in addition to the other timing resistors and capacitor normally used.

HOW IT WORKS:

When the timer’s output is high, transistor (Q1) is forced into saturation (transistor on) by resistor (R2, 5.1k). This results in current passing through (Q1) and also (R1 + 3.3k resistor) to charge timing capacitor (C1).

When the output goes low, the discharge transistor, (open collector, internal to the 555 at pin 7) cuts off the base of Q1 (transistor off) and allows the timing capacitor to discharge through (R1 + 3.3k resistor) and diode (D1).

Since the resistance path is equal (or nearly so) in both the charging and discharging paths, the timing periods of both the high and low outputs are also equal.

COMPONENTS USED:

Although a regular bi-polar 555 timer can be used with good results at lower frequencies, I have found that using a CMOS 555 gives much better results over a wider and higher frequency range.

Transistor (Q1) can be any general purpose NPN transistor such as a 2N3904. Diode (D1) can be a 1N4148 or 1N914.

Resistor (R2) should be a value between 1.5k and 10k. The exact value of (R2) can be selected to give the best duty cycle symmetry with the timer running at maximum frequency. Maximum frequency is about 650 KHz (dependent on value of timing capacitor) .

The timing capacitor should be a quality Mica, Mylar or Tantalum type. Minimum timing capacitor value is about 100 pF.

 

SQUARE WAVE GENERATOR SCHEMATIC

 

OUTPUT AT 25 KHz

 

OUTPUT AT 250 KHz

 

 

 

END POST

 

 

 

 

 

Bread Board Potentiometers

Using a potentiometer (other than a trim pot) with a 0.1 inch grid bread board can be difficult or inconvenient since in many cases the connecting lugs on the potentiometer usually do not match the 0.1 inch spacing on the bread board.

I have found one solution. The CTS 296 series single turn rotary potentiometers are reasonably priced, small in size and can be easily adapted to use on a bread board. These carbon composition potentiometers are 12mm in size and have a power rating of 0.15 watts.

They are available in 11 different resistance values from 500 ohms to 1meg ohm. The most commonly available have a linear output and a tolerance rating of +/- 20% . The vertical mount type are the ones I used. Matching knobs are also available for use with the knurled plastic shaft.

In order to adapt them to bread board use, I used four pins obtained from a 0.1 inch breakaway header. The pins were then soldered to the pins on the potentiometer. The potentiometer can now be easily plugged into the breadboard.

They seem to work quite well without further modification.

However, for additional support, a loop of 22 awg uninsulated wire can be soldered to the metal tab that is opposite the solder lugs. This loop of wire can then be cut to the correct length and inserted into the bread board along with the header pins.

 

 

 

end post

 

The Art of Electronics

The study of electronics is a very interesting and rewarding occupation for either the hobbyist or aspiring engineer.

Even the most casual hobbyist has easy access to thousands of low cost components, allowing anyone to take up the pursuit of electronics and advance it to any level of sophistication that he or she might desire – including as a rewarding career.

Back in the 70’s and 80’s, it would typically cost thousands of dollars to get started in the development of products that used a microprocessor – meaning that only large businesses could afford to do it. The use of a microprocessor also usually required the use of a number of support IC’s such as timers, port expanders, memory, and communication IC’s. The end result tended to be complicated and difficult to breadboard for testing purposes.

Today, just the opposite is true. Hundreds of low cost microcontrollers are available from a number of different manufacturers. For about ten dollars or so, one can purchase a complete development board that has an on board programmer and debugger and along with a free complete development environment (IDE) that can be downloaded to any laptop. (Some are code limited, but usually a generous limit.)

Sure, you would need to learn to program in assembly or C and also need a basic understanding of digital logic. However, the easy availability of the internet, for most people, allows the access to all kinds of electronics information, including electronic forums where you can ask others for help and even find complete programming examples to help you get started. Also, complete datasheets on practically any component you can imagine is usually just a few clicks away.

That said, it is always a good idea to have on hand a few reference books that pertain to your area of study.

In my opinion, one of the best must have books available for general electronics is:

The Art of Electronics (Third Edition) by Paul Horowitz and Winfield Hill.

This book, of about 1200 pages, contains an extensive amount of information on the basics of voltage, current, and resistance. Also, the theory behind and the use of components such as resistors, capacitors, inductors, diodes, bipolar and mosfet transistors, op-amps, voltage regulators, logic devices and much, much more.

The book also has numerous pictures and circuit examples that can be considered building blocks for your own projects. Most examples are simple and use components that are inexpensive and easily obtained. This allows one to breadboard and test the examples, providing an excellent way to learn and experiment with circuit theory.

All in all this is an excellent book for both the beginner and expert alike.

One Final Thought:

There seems to be a number of counterfeit and poorly produced copies of this book being sold, mostly online and at suspiciously low prices.

Please respect the enormous amount of effort over many years that the authors have put into creating this series of books starting with the first edition in the early 1980’s by purchasing only authorized and official versions.

 

 

end post

MSP430 Encoder Adjustable PWM

PULSE WIDTH MODULATION

Pulse Width Modulation (PWM) is an easy and efficent way of controlling the speed of a DC motor or control the brightness of a lamp or LED. In conjunction with a low pass filter, PWM can also be used as an accurate way to create a digital to analog converter, which in turn can be used to create sine waves or other analog waveforms.

A basic PWM output consists of a digital waveform that is fixed in frequency and varies in duty cycle, usually from 0% (FULL OFF) to 100% (FULL ON). When used to control an inductive load such as a motor, PWM, operating at a high enough frequency, provides an average value of current flow to the motor which is directly related to the duty cycle of the PWM.

While it is possible to create PWM in software, many low cost microcontrollers, including the Texas Instruments MSP430 series, contain hardware timer modules which allow the creation of PWM waveforms to be easily implemented.

The program shown below creates a single PWM output using a MSP430G2553 microcontroller along with the MSP_EXP430G2 Launchpad.

The PWM control program has the following attributes:

1.) PWM output frequency of 10 kHz. (Easily Changed)
2.) PWM output duty cycle is adjustable using an inexpensive quadrature encoder
3.) PWM output is adjustable from 0% (Full Off) to 100% (Full On) in 1% increments.
4.) Visual indication of PWM duty cycle percentage using a red – green LED.
5.) Visual indication (Blue LED) when PWM is at exactly 50%.
6.) Encoder pushbutton switch sets PWM output to 0% (Off).
7.) Precise PWM frequency and duty cycle using a 4.0Mhz crystal oscillator.
8.) LaunchPad LED1 and LED2 flash with increment and decrement pulses from encoder.

OUTPUT DRIVER

Most applications will require an output driver to control a motor or a lamp. A reasonably priced driver is the SN754410 quadruple half H-bridge driver that has a 1 amp output capability per driver at a voltage of 4.5 VDC to 36VDC in positive supply applications.

COMMENTS

The start-up PWM value is set at 5%. This can be easily changed in the main function below. The maximum PWM is set to full on (100%), this can be changed to another value in the encoder interrupt.

I have done extensive testing and the encoder interface works very well, in fact quite bullet proof – no skipped or extra encoder pulses even when the encoder is rotated as fast as possible. The combination of RC network and interrupt polling makes it happen.

Note: The program below utilizes an external 4.0 MHz crystal oscillator connected to pin 19 (xin) of the MSP430 Launchpad. This oscillator is not shown on the schematic! The program can be modified to utilize the microcontrollers internal oscillator.

 MSP430 ENCODER PWM MAIN FUNCTION

MSP430 ENCODER PWM INTERRUPTS

MSP430 ENCODER PWM OUTPUT WAVEFORMS

PWM OUTPUT AT 1%

 

PWM OUTPUT AT 50%

 

PWM OUTPUT AT 99%

 

MSP430 ENCODER PWM SCHEMATIC

MSP430 ENCODER PWM SCHEMATIC

 

ENCODER PWM PROTOTYPE

ENCODER PWM PROTOTYPE

 

 

 

 

 

 

 

End Post