• CES
  • AMARTS
  • Electronic Kid
  • Useful-news
  • Forum
  • Fellowship
  • E-Library
  • All
gravatar

Voltage programmable simple logic device and square wave signal generator

Here's another daft yet interesting PIC12F675 idea I came up with. When I wanted to show someone how logic gates worked I could only find a NAND gate which wasn't very handy for demonstrating AND's OR's, NOR's and ExOR's.  I also wanted to have a play with the A/D converter on the 12F675 so I came up with the idea of a PIC that could function as a single 2-input logic element.  
The logic function is determined by an analogue voltage applied to the GPIO4 pin when the device is first reset, it isn't sampled again after this so logic can't be changed on the fly.  The 3 MSBs of the A/D conversion give eight distinct voltage levels that map to specific logic functions.  Six functions have been implemented;  these are 2 input AND, OR and EXOR gates and their negated equivalents. 
Just to prove the concept, here is a 'D' type flip flop (PIC Flop:-) I built out of five 12F675 Logic Elements operating as NAND gates.  The sixth device is configured to operate in square wave mode to provide a clock input to the flip-flop for testing.  The small pushbutton provides the 'data' input.
Code and schematics
This code is written to work on a 12F675 device. The HEX file below is assembled for and has been tested with the 12F675. It should work on a 12F683 too but I haven't tried it. This code won't work with a 12F629 because it doesn't have the ADC feature. 
Source From: http://picprojects.org.uk/projects/logic/logicelement.htm