Skip to content

PIC Based Logic Probe

DSC02335 (Medium)Frank shows us how to made a PIC based logic probe. He covers everything with step by step instructions and explains the how and why. This article is a great kick start for the PIC microcontroller, Frank really does cover the basics well. Including what software to get, how to set it up, how to write the program and even how to draw the schematic and build the probe. This is truly a great how-to article.

This article was submitted by Frank Zhao as part of the “Hobby parts for articles” program. Frank received a Bare Bones Arduino kit for this great article.

The purpose of this device is to test a wire to determine the logic state. Two LEDs show the logic state as either high, low, or high impedance (aka floating). Simply attach the ground probe to any ground connection of the circuit you want to test, then touch the test probe to the signal you want to test.

Parts List:

  • Prototyping board
  • 2 LEDs
  • 10k resistor
  • 100k resistor
  • 300R resistor X2
  • 8 DIP IC socket
  • PIC12F683 microcontroller
  • PIC programmer
  • 7805 voltage regulator
  • 9V battery and connector
  • Probe style of your choice (alligator clips, multimeter probes, etc)
  • Wires (Use clipped leads of resistors as jumpers, and 22 gauge stranded as the probe wires)
  • Sheet of plastic (any, I used 3mm acrylic)
  • Smarties box

Software Needed:

How it works:
First, this device determine if the wire is floating, this is done by applying a weak current into it with a pin on the microcontroller and see if the state changes, and draw a weak current from it using the pin and see if it changes. The current is weakened by the 10k resistor attached to the pin, commonly called a pull up or pull down resistor if used for this purpose (overriding the state of a floating wire). If the state changes, it means the wire is floating, and the device indicate that using a LED.

If it’s not floating, then the voltage on the wire should indicate a logic high or low, and the device indicate that using another LED.

Writing the Firmware:
First, install all the software you need in order.

Once that’s done, open MPLAB and use the project wizard to start a new project. Remember to select the PIC12F683 microcontroller, and select CC5X as the compiler. Put the project into a new folder. Go to the directory in which CC5X is installed and find the file “12F683.H” and copy that file to the new folder and add the file into the MPLAB project workspace. Start a new file, save it as “main.c” into the new folder and add the file into the MPLAB project workspace.

tool suit

add files

Now, to set the configuration bits of the microcontroller, type:

#pragma config |=

on the first line of the code.

Then go to the menu bar -> Configure -> Configuration Bits
And configure your project like so:

menu to config

config bits

  • Oscillator: Internal RC No Clock
  • Watchdog Timer: Off
  • Power Up Timer: Off
  • Master Clear Enable: External
  • Code Protect: Off
  • Data EE Read Protect: Off
  • Brown Out Detect: BOD and SBOREN disabled
  • Internal External Switch Over Mode: Disabled
  • Monitor Clock Fail-safe: Disabled

This will choose the minimum needed configuration and uses the internal 4MHz oscillator as the clock source for the PIC.

Remember the value of the configuration, it should be 30F4, so the first line of your code should be:

#pragma config |= 0x30F4M

Which will tell the compiler to configure the PIC as so.

Now every program is written within:

void main()
// Program Goes Here

So put that into the code.

First, declare all the variables we are going to need at the beginning of “main”

// Declare Variables
bit logic;
// 1 = High Impedance, 0 = Logical Signal
bit state; // On or Off, 1 or 0
char repcount; // Used for Flashing LED Only

We want something special to happen when the device is turned on, to indicate if the device has been reset or not, if the device resets by accident, it’s not a good thing and we want to know about it. So we are going to flash the LEDs 5 times.

// Flash LEDs
while (repcount != 5) // Only 5 Flashes
GPIO = 255; // LEDs On
delay(17777); // Pause
GPIO = 0; // LEDs Off
delay(17777); // Pause
repcount = repcount + 1; // Next Flash

After that, our program should run forever in a loop, so put it inside:

while (1) {
// In Here

The first thing to do is to set the probe pin as an input, and disable the pin that uses the pulling resistor (also by setting it as an input). Changing pins between input and output mode is done by modifying the TRISIO register. This device uses pin 5 to test the wire and pin 4 to pull pin 5 up or down.

TRISIO.5 = 1; // Input
TRISIO.4 = 1; // Disables Pulling

At the beginning of every loop, the variable called “logic” needs to be 0:

logic = 0; // Reset This Bit

Then take the first sample on pin 5, the test pin:

state = GPIO.5; // Take Sample

Then enable the pulling pin, and pull down the test wire, then compare the results, if it has changed, the pin is floating.

TRISIO.4 = 0; // Enable Pulling
GPIO.4 = 0; // Pull Down
TRISIO.5 = 1; // Input
// If the state of the pin has changed
// It will mean that the sample is floating
if (state != GPIO.5) // if original sample is not equal to the pin's current state
logic = 1;

Do this again but pull up:

// This needs to be done again
TRISIO.4 = 0;
GPIO.4 = 1; // This Time, Pull High
TRISIO.5 = 1;
if (state != GPIO.5) // if sample is not equal to the pin's current state
logic = 1;

Now the testing is done, now indicate the results with the LEDs, those pins must be output.

// Set LED Pins To Output
TRISIO.1 = 0;
GPIO.1 = logic; // Indicate
TRISIO.2 = 0;
GPIO.2 = state; // Indicate

And the main program is done, but we need a delay function inside the program.

// This Uses Count Down To Generate A Delay
void delay(unsigned long repeat)
while (repeat != 0)
repeat = repeat - 1;

And now the entire firmware is written, to compile it, press the build button in MPLAB.

If you have trouble doing this on your own you can get the source code here.

Connect the microcontroller to your programmer, run your programming software, load up the .hex file, and program your firmware into the microcontroller.

My kick ass PICkit 2 clone from eBay is shown below. DSC02337 (Medium)

[uCHobby comment] I got one of these PICKit clones from FCBElectronics eBay store.

DSC02336 (Medium)

Designing the Circuit:

Start with the microcontroller.



Add the power supply, which is a 7805 voltage regulator connected to a 9 volt battery.2

The reset pin of the microcontroller needs to be pulled up, so we use a 100k resistor for that.3

Now the test probe, and the 10k resistor used to pull the test probe up and down.4

Add the final LEDs. The 300R resistors are used to limit the current so the LEDs won’t burn out and the microcontroller isn’t over stressed.


And the grounds of the two circuit must be connected together, so a 2nd probe is added to the ground.even better

And clean up the diagram a bit.


Make the Circuit Board:

First, cut down the board to size using a hack saw, save the leftover for later use.DSC02326 (Medium)

Strip a lot of bare solid copper wire, these will be used as jumpers.

Put the jumpers in because they are the lowest components. Note, do not completely solder the two jumpers at the top, they are going to be underneath the chip socket and the socket’s pins needs to go in before you solder.first jumpers

Then add the resistors. The 10k resistor should stand up. You need to shift the 100k resistor a bit down so the Microchip socket can fit.


Add in the chip socket, now you can solder those pins I told you not to solder. Put on the two LEDs, make sure the flat side is towards the center of the board (the flat side is the negative side and is connected to the ground power rail). Add the voltage regulator, the ground should be connected to the ground rail, the output to the 5V+ rail, and the input should be on the side.


Now solder in the wires for the probes, and solder the probes (whatever you want to use, but use an alligator clip for the ground probe) onto the wire. Solder in the wires from your 9 volt battery connector, the black wire goes to the ground rail and the red wire goes to the voltage regulator’s input pin. Remember to loop the wires through a few holes, so that they won’t break when you flex it around, also hot glue them down.done

Plug in the PIC microcontroller into the socket, the notch facing up. Test your circuit, turn it on by plugging in the 9 volt battery into the clip. The LEDs should flash 5 times quickly. The top LED is lit when the test probe is floating, and it is off when there is a logic signal detected. The bottom LED indicates either high or low on the test probe, but only when there is a logic signal present.DSC02339 (Medium)

DSC02331 (Medium)

If it works, cut out a piece of thin plastic the same size as your circuit board, and hot glue it to the back of the circuit board. Now, take a small Smarties box, and cut it slightly shorter than a 9 volt battery, and glue it to the back of the plastic piece, and put the battery in the Smarties box.DSC02332 (Medium)

DSC02333 (Medium)

DSC02334 (Medium)


You are done!

DSC02335 (Medium)

There are things that can be improved, a 5.1 volt Zener diode should be added between the test probe and the ground, and another one to between the power rails, this will protect your microcontroller chip from any voltages higher than 5 volts, preventing damage. This extra protection isn’t needed if you plan on using this only on your own circuits. A signal diode on the test probe can prevent damage from negative voltage.

even better

You can also put a on/off switch somewhere, but I didn’t have one so I just clip and unclip my battery to turn it on and off.

Note: Placing the probe on any input of any device will cause unexpected operations.

Posted in Microcontroller, Projects, Workshop Tools.

5 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Steven Moughan says

    The 5v1 Zeners are to clamp the test voltage to ~5.1v to -0.5v on the off chance that its used to measure something say at, 12v which would normally be disastrous for the PIC…

  2. Steven Moughan says

    Whats the software you used to do the stripboard layout? Or was it just paint or something?

  3. Steve says

    Very cool!

    I wonder what the 5.1v Zeners are for. They’re in the schematic, but not in the built devbice. I notice they’re wired as pointed away from ground.

    Is this to limit the voltage to 5.1 volts if the circuit comes reversed-biased by the equipment under test?

  4. Alan Parekh says

    Nice documentation!

  5. pK says

    Weel done and very welll explained! Another great article here, keep on the hard work!