Everything for Electronics

Tech Forum

PIC16F876A Answered June 2010

What is the least expensive system to use to program a PIC16F876A? I got one as a sample from Microchip; now I don't know what to use to talk to it.

Joseph Walker
Newville, AL


Download the free Microchip IDE from: www.microchip.com/mplabx-ide-windows-installer which is a free, full feature download of the Interactive Development Environment. More info about the IDE and its features at: www.microchip.com/pagehandler/en-us/family/mplabx/ where there are also C language downloads - though I don't know if all the C downloads are free.

Purchase a programmer board such as one of the following from  www.ramseyelectronics.com/ 
www.ramseyelectronics.com/cgi-bin/commerce.exe?preadd=action&key=CK1301 for $34.95 - with this one you will have to program your PIC chip with the ICSP (In Circuit Serial Programming)  connector.

www.ramseyelectronics.com/cgi-bin/commerce.exe?preadd=action&key=K8076 "Note: This product requires a standard RS232 serial connection and is NOT compatible with USB to RS232 serial adapters or converters." for $47.95   It also has an ICSP (In Circuit Serial Programming) connector for programming PIC chips that are soldered to a PCB. This can be a way to program PIC chips that are other than a DIP (Dual In-line Package).

www.ramseyelectronics.com/cgi-bin/commerce.exe?preadd=action&key=UK1300 for $69.95 This one connects to your PC with a USB cable.
The datasheet for the PIC16F876 is at:  ww1.microchip.com/downloads/en/devicedoc/30292c.pdf

Mark Peterson
Plymouth, MN

Connecting an Old Printer to a Current PC Answered August 2012

I have an IMP-24 printer with a Centronics interface. I would like to print to it from a Windows 7 or XP computer using some form of Basic. I have VB and Visual Studio 2010 Ultimate. However, there seems to be no drivers for this old printer. Is there a way to address LPT1 from Visual Basic or Visual C so I can send the data to the printer directly without going through the operating system?

Lake Forest, CA


Here is one method that I think will work for you, but I don't know how it will handle control characters. It's fairly quick to set up, though.

On XP:

- click Start
- point to Settings, then click on Printers and Faxes
- double-click on Add Printer
- click on Next
- click on Local Printer
- select Local Printer Attached to this Computer
- click on Next
- let it search, it will come up with "The Wizard was unable ..."
- click on Next
- select the LPT port you want to use
- click on Next
- from the left column, select Generic
- then from the right column, select Generic / Text Only
- click on Next
- if you desire, change the printer name
- select whether or not you want this to be the default printer
- click on Next
- select whether or not you want to share this printer on your network
- select No for printing a test page

It will now show you your selections.
If it looks ok, select finish.

It will show that it's copying some files and then the window will disappear indicating that it is complete.

To cause Windows to NOT spool the printer output:
- Right click on the printer you just created
- click on the advanced tab
- select Print directly to printer
- click Apply, click OK
(The following code is from a VB6 app that I wrote that was using an HP printer with an HP driver.)

In VB there is a Printer object.
'It needs some setup code:

'Printer defaults
   With Printer
        ColorMode = vbPRCMMonochrome
       .Copies = 1
       .Orientation = vbPRORPortrait
       .Zoom = 100
       .ScaleMode = vbTwips
       .FontBold = False
       .FontItalic = False
       .FontStrikethru = False
       .FontTransparent = True
       .FontUnderline = False
       .FontName = "Courier New"  'not proportional letters
       .Orientation = vbPRORPortrait
       .ScaleMode = vbInches
       .FontItalic = False
       .FontBold = False

'You may not need the following:
.FontSize =  

If .PaperSize <> 1 And .PaperSize <> 9 Then
.PaperSize = 1
End If

'sets top, left of page
Printer.CurrentY = 0
Printer.CurrentX = 0

'end of May Not Need

' Here's where you actually print the text"
Printer.Print strStringOfText

' note: If you want to print more on the same line,
' add a trailing semicolon for all but the last print

Printer.Print strStringOfText;

Printer.NewPage    'ie: formfeed

'If your printer is spooling, the following will cause the document to print.
'It will also signal End of Document so you can start the next document

Mark Peterson
Plymouth, MN

Audio Sound Spectrum Answered August 2012

Is it possible to take the sound heard in the frequency range of 0 to 40 kHz and space it evenly into the 10 Hz to 20 kHz range? I want to hear what a dog hears but in the human range. I know this will make people’s voices sound funny, but how would this be done and is there such a device? Is there even a mic for that upper range of up to 40 kHz?

Robert Spencer
Phoenix, AZ


He might refer to the June 2011 issue of Nuts & Volts and the article on the "Bat Detector" by Jonathan Berber.  Using this concept, a hetrodyne circuit, utilizing a piezo transducer (microphone), should result in an audible, to human ears, signal.

Rod Hogg
Scott City, KS

One easy approach is the digital divide circuits used in Bat detectors. For example: http://pw1.netcom.com/~t-rex/BatDetector.html

Basically it just divides the input frequency by some power of two (2,4,8,19, ...). In this case divide 0 to 40KHz by 4 and get 0 to 10KHz. The digital divide circuit is pretty simple but you will lose all amplitude information. Given how simple the circuit is that might be acceptable.

A suitable microphone will be a bit of a problem. Many mics will give a signal at frequency up into the 40KHz range but the sensitivity will drop off a fair amount. Piezo transducers are often used for Bat calls and they'll give some signal up to, perhaps as high as, 100KHz. But piezo have resonant frequencies and they'll be super sensitive near that frequency. A typical 1" diameter thin piezo resonates at about 3KHz.

There are ultrasonic transducers designed for 40KHz that work well as a mic at that frequency, but their sensitivity at lower frequencies drops off.

Jim Sluka
Greenwood, IN

Cell Phone Amplifier Answered August 2012

I need a parts list and schematic to build a cell phone amplifier to connect to standard headphones.

James Moore
via email


I would try using either one or two LM386s in low gain low noise configuration, depending on if you're using mono or stereo headphones. Look at the Data Sheets at: www.nari.ee.ethz.ch/wireless/education/PPS/PPS02/doc/LM386.pdf and page down to page 5. The very first schematic is for the amp used without the 10µf cap between pins 8 & 1 which limit the gain to 20 & the noise is greatly reduced as well.

Also, I noticed that Russell Kincaid had a similar question in the same issue, page 24 and his answer was given in Figure 7, which seems to be missing from my paper magazine, perhaps he'd be kind enough to send it to you directly? (Ed: Figure 7 can be downloaded from the link on this page {filedir_8}index.php?/magazine/article/august2012)

I also found a link to a solution (with a problem of high hissing noise) for the same application on-line at: www.edaboard.com/thread232457.html  He ended up saying "Now I am able to reduce the hiss type noise at the output by just removing the 10mf cap between pins 1 and 8. There is still a little bit of hiss noise at the output but for me that is ok." Which is then the configuration I mentioned above in the Data Sheets.

Philip Karras KE3FL
AEC Carroll County

A LM386 based circuit would be simple and will run from a 9V battery. See http://web.mit.edu/6.s28/www/schematics/lm386.htm

You can also buy a small kit such as at www.electronics123.com/kits-and-modules/audio-amplifier-1W-LM386-kit.html

If the output sounds to harsh, drop the gain by removing the feedback cap (C1 in the diagram at the first link).

Jim Sluka
Greenwood, IN

Powering a Hydrogen Generator Answered August 2012

I’m building a HHO generator and am trying to figure out the best way to power it, keeping the power usage low. A high voltage, low amp method like using a Tesla coil might do the trick. Any ideas to help me figure it out?

via email


First of all, try to avoid the term "HHO" it makes you look like a crackpot. Electrolysis of water produces a mixture of molecular hydrogen (H2) and molecular Oxygen (O2) in a 2:1 ratio, there is no such thing as "HHO".

Second thing to know, is that no matter what you do, the energy into the system is more than the energy you get back out of the system. If you put in one Joule of energy to break the water into H2 and O2 you will get back less than one Joule when the H2 and O2 is recombined. That's the laws of thermodynamics and you can't break those laws.

Now, what are you really trying to do? You mention a Tesla coil but that is a high voltage low current system. Electrolysis cells are intrinsically low voltage high current devices. To electrolyze water you only need about 2 volts per cell. Using higher voltages doesn't accomplish anything useful, indeed higher voltages just mean that you will get electrolysis reactions you don't want as well as significant energy loss due to ohmic heating. So it would be really silly to take an energy source and use that to run a Tesla coil then use that output to run the electrolysis rig. If you are thinking of using the Tesla coil to pull power out of say… atmospheric RF (basically using the coil as an RF antenna), then you have to go back to my earlier point about energy in > energy out.  How much "free" energy can the coil actually capture from the atmosphere? RF waves are extremely low energy; even with a big antenna you are not going to be able to capture enough energy to light even a single LED.  So, running an electrolysis cell might be possible but it isn't going to generate enough fuel to make it worthwhile.

One last thing, H2 + O2 is explosive. The Hindenburg didn't explode, it combusted. A mixture of H2 + O2 WILL explode, and that explosion will be much more energetic than what occurred with the Hindenburg. Add in the worry that any electrolysis cell produces gases that can be compressed along with heat and you have two pathways to an explosion: combustion and over pressurization of the H2 + O2 storage tank.

Jim Sluka
Greenwood, IN

Schematics and Components Answered July 2012

I don’t know that much about reading circuit diagrams, but in theory, if I bought all the components in a given diagram, could I simply connect each component to the others as shown in the schematic? I have seen reference to using a breadboard but from what little I’ve read, they are configured in various ways and I wouldn’t know what configuration a given project might require.


I understand that soldering component leads together with no substructure or framework might look like a piece of modern art, but could I do that and expect it to do what it is supposed to — whatever that is?

M. D. Calvert
Oak Ridge, TN


Yes, you can wire parts together in free air following the schematic and in most cases it will work just fine. Indeed I have done just this on a few occasions, either to lash up a very simple circuit to test or for artistic reasons. In general though I would recommend other techniques for day to day use. Do some searching online for electronic prototyping and building techniques, there are countless methods that have been developed over the years and you are sure to find something suitable.

Perfboard is a good simple one that I've used many times. I would also recommend becoming proficient at reading schematics and identifying components prior to jumping in. It will save you much time and headaches in the long run.

James Sweet
via email

There are plenty of examples of building circuits without a PC board available on the net. http://blog.makezine.com/tag/freeform/ is an excellent example of this type of freeform circuit building. It is sometimes a little more complicated than using a printed circuit board pattern, but for some circuits, it's more practical. As long as no leads touch were they shouldn't, and as long as stray capacitance isn't an issue, the circuits will function just fine.

Derek Tombrello
via email

Whether you can simply connect components as shown in the schematic without regard to parts layout and lead dress depends entirely on the project.


For "DC" projects, such as a demonstration of an AND gate with two switches, an LED, perhaps an IC, a few resistors, and maybe a bypass capacitor, parts layout isn't critical so long as the bypass capacitor (from Vcc to ground) is physically close to the IC. It would even be OK to solder component leads together with no substructure or framework.


On the other hand, for radio frequency work (FM receivers, AM receivers, garage door openers, etc.), and for any project with a microprocessor, parts layout is critical, and you should follow the perfboard layout or printed circuit layout published with the schematic. If you don't, stray inductance and capacitance can wreak havoc with the circuit, and unwanted oscillation may even occur.


In between are audio frequency projects. For high-impedance projects, generally those with a low-level signal input, layout is critical.


However, for low-impedance projects, such as a circuit to drive a speaker from the output of an MP3 player, layout isn't critical.

John Herro
Cincinnati, OH

RF Chip for Fuel Tank Answered July 2012

Has anyone heard of a RF chip which attaches to the fuel tank of a vehicle and supposedly provides high frequency output which increases fuel mileage?

via email


While I haven't heard of the "RF Chip" you refer to, I have seen a great many miracle gadgets over the years claiming to increase your fuel economy. All of them of course come with grand claims and glowing testimonials, but invariably the only thing they do well is extract money from your wallet. There is only so much energy in a gallon of fuel and modern engines do very well at burning fuel efficiently and extracting as much of that energy as possible. The inherent inefficiency in an internal combustion engine comes mostly from the process of turning heat into mechanical motion, not inefficient creation of heat from fuel. You can't argue with the laws of physics.

James Sweet
via email

Garage Door Sensor Answered July 2012

What’s the best way to hack the garage door sensor so that when the garage door is open, anything breaking the light beam will trip a relay?

Kenneth Lysek
Henderson, CO


When you look across either sensor you will see negative going pulses. When the beam is broken it changes to supply voltage, no pulses. If you would like a schematic to "hack" this information send me a request. It is essentially a missing pulse detector.

Art Askey
State College, PA

All openers are not the same, but most are similar. You want to see when the beam is obstructed when the door is open, but you really only need to know when the beam is broken because if the door is closed, nothing can enter to break the beam. You can install an end of door travel switch in series with the relay if you like. With the beam intact, a scope shows pulses going toward ground but not to ground. A broken beam stops pulses and voltage remains at maximum.

When you look across either sensor you will see negative going pulses. When the beam is broken it changes to supply voltage, no pulses.

I used a LM555 because it contains differential amps to monitor voltage levels and will source or sink to 200ma. If your pulses go down to 1/3 of supply.. circuit with diode input will work ... if not, use transistor input. Any general xsistor, such as a 2N2222, will work. I'll stop here, but feel free to ask questions!

Art Askey
State College, PA

This will vary from one garage door opener to another, but most that I've seen have an LED either on the photo beam receiver or on the opener itself that illuminates when the beam is intact. If I wanted a relay to trigger, I would tap into this LED. If you want to interface to it without modifying anything, a phototransistor or CdS cell could be mounted over it to detect light from the LED. Anything else will require some reverse engineering on your particular opener.

James Sweet
via email

CCD/CMOS Camera Back Answered July 2012

One of my deepest desires has been to "resurrect" my film cameras as digital. Is it at all feasible to construct some sort of relatively compact and usable CMOS or CCD device which can be attached to an existing camera that would yield high resolution images to be stored on a standard memory card? If so, could a diagram and list of materials be provided? I would prefer a full format sensor for use on a full format 35 mm camera, but a smaller format sensor would be acceptable for attachment to microscopes or telescopes.

Greg Bargis
Baltimore, MD


The biggest issue with what you would like to do is that typical CCD sensors are a fraction the size of a 35mm film frame. In order for the existing optics to focus properly onto the sensor, it has to be located in the same plane the film would be. If you install a 1/3 inch CCD in a 35mm film camera, you will only be capturing a small portion of the field of view. Anything is possible with enough effort, but given the low price of some very good digital cameras these days, you are better off buying one than trying to convert something and ending up with inferior results.

James Sweet
via email

Timer Needed Answered July 2012

I need a 2-3 second timer to operate a 24 volt relay, to open and close a garage door using a Desa Int'l wireless doorbell.

James Moore
via email


The two solutions above are good but I think they are both overly complex. I assume that the reason for the time delay is that the wireless system produces a pulse whose duration is too short to properly trigger (and latch) the garage door relay. I know that my garage door will stop if the button push is of too short a duration. So we need to stretch the signal from the wireless system and we probably need to make the voltage of the wireless system compatible with the 24V relay in the garage door opener.

Looking back a couple months in Nuts & Volts there is an article about a circuit that turns on a laser to help park a car at the proper place in a garage. The circuit uses the sound of the garage door opener's operation to turn on the lasers for a minute or so. The article is Nuts and Volts - May 2012 - Page 40 - "Build a sound-activated laser parking system." I think the second op-amp stage from that circuit might be all that you need.

The op-amp is setup as a comparator with the reference voltage level set by Potentiometer P1. The other input is from an amplifier stage but I think you could just directly couple the wireless device to that op-amp input (perhaps via a largish value resistor to give some isolation). You would set P1 so that the reference voltage is a bit less than whatever the wireless system puts out.

When the wireless signal is high the comparator swings to the voltage rail charging cap C2. When the wireless signal goes away the op-amp goes off but C2 is kept from discharging back through the op-amp by diode D1. The voltage on the cap turns on the mosfet T1 which you can use to control the current to the relay's coil (replace the laser diodes with the relay's coil in the circuit). The combination of R5 and C2 controls how long the mosfet is turned on.

In the publication the author was going for a couple minutes. If you only want a couple seconds then R5 and C2 can both be made smaller to decrease the on time. As a rough estimate the on time is about 2/(R5*C2) seconds. So R5=1M and C5=1uF should give an on time of about 2 seconds.

Jim Sluka

I assume that the need is to have a delay before opening or closing the garage door. The circuit diagram below will do this.

The circuit shown here, uses a 1Hz oscillator (ICL555) which clocks a 4015 shift register as a sequencer. When the output of pin 2 goes high, the 4N35 optocoupler conducts. The output shorts across a garage door pushbutton.

The "Desa Int’l wireless doorbell" will need to close the switch shown as "Enable PB." This can be done with either another optocoupler or suitable transistor logic to simulate the switch closure. In operation, the Enable signal (pin 15) must be active high long enough to be captured on the next clock edge. When the yellow LED goes on, the input has been captured. For the circuit shown, the delay is about four seconds. Increase the clock frequency by decreasing the 560K and/or 330K resistors in the clock section.

Note the series wiring of the RLED resistor, optocoupler (LED), and red LED. The 47 ohm resistor must be changed if the circuit is to operate on higher voltages, up to the 15 volt limit of CMOS. Use Ohm's Law to get 20 mA of current through the optocoupler / RLED combo. For the RLED value shown (47 ohm), a six volt supply is required. In practice, I took the circuit board from a cell phone car adapter and "floated" it with a diode to get the six volt regulated output. From a 24 volt source, I use a 12 volt series zener to drop the voltage to 12 volts to the cell phone car adapter. A one watt zener is sufficient.

Originally, I tried using a CD4060 for this, but found the circuit to be more predictable. The approximate component placement is shown below the circuit. Actual wiring may vary! The circuit has been in operation for over six months now and works great. If an actual pushbutton is used, the circuit may have potential electrostatic discharge susceptibility through the pushbutton to the D input. While I have not had issues with this, I have a small grounded loop near the pushbutton to reduce static discharge through it. Using a pushbutton with a grounded static shield is recommended.

Most parts (including the solderable breadboard) are from AllElectonics.com, though the 4015 is from Digi-Key.


Jim Lacenski
via email

This sounds like a classic application for the ubiquitous 555 timer IC.

The datasheet for the 555 includes many examples of using it, including the one-shot circuit that I think will meet your needs nicely. You can use a common transistor like the 2N2222 to drive the relay coil. Don't forget to put a reversed diode across the relay coil to protect the transistor.

James Sweet
via email

Page 29 of 33 pages ‹ First  < 27 28 29 30 31 >  Last ›