For some reason, I kept thinking about this problem today. Now, some of you are going to cringe, but a 555C timer would be ideal for this. Well, not really, but read on. Here's a reference schematic with the timing formulas: http://www.geocities.com/SiliconValley/Haven/9004/555c.pdf Both duty cycle and frequency are programmable by selection of the timing components (C, RA, and RB). It should be possible for the PIC to determine frequency and duty cycle. The trick is to accommodate component tolerances. For resistors, this is easily done using 1% parts. Capacitors with tight tolerances are expensive, but this can be overcome by efficient design. Choose eight possible values for C such that worse case tolerances (+-20%) could never overlap. For instance: 0.0047 0.01uF 0.047uF 1uF 4.7uF 10uF 47uF 100uF Now choose a single value for the sum (RA + 2RB), 10K is a nice value. So now th e PIC has to be able to distinguish only 8 approximate frequencies: 30kHz 14kHz 3kHz 1.4kHz 300Hz 144Hz 30Hz 14 Hz No problem here, even if the cap has +-20% tolerance. The maximum duty cycle is 50% when RA=0. It is possible to use 1% resistors to program duty cycle in 5% increments, and discern different duty cycles with well written PIC code. Just keep the sum (RA + 2RB) constant. A trimmer would not wor k because of this limitation. Fortunately, capacitor tolerance and drift has no effect on duty cycle. So there it is - 1:8 select using frequency and 1:10 select using duty cycle. Combined, this makes a 1-of-80 ID select circuit. I have absolutely no idea how to make this manufacturable. Supply a bag of resistors and capacitors with each boa rd shipped? Heh! And definitely grind off the part markings from the 555 chip. Not to discourage reverse engineering, but to save face. Dave Sorlien David Sorlien (hey, that's me!) wrote: > When I read Mike's suggestion about a simple 8-bit shift register, I thought u p > a way to use a simgle pin to control a '165. Not being good at drawing ascii > schematics, I whipped up a quick schematic and converted to Acrobat format > (about 11k): > http://www.geocities.com/SiliconValley/Haven/9004/one_pin.PDF > > To load the shift register, drive the PIC pin low for a couple seconds, which > causes the cap to discharge through the 1 meg resistor. The '165 will not shif t > data while the /LD pin is low, so drive the PIC pin high for a couple seconds > to charge up the 1UF cap. I don't think rise time would be a problem, as the > DIP switch states remain constant. > > To shift data from a '165, you need a low-to-high transition on the CLK pin(s) . > Drive the PIC pin low, wait a couple instruction cycles, then drive the PIC pi n > high again. After a couple NOP's, make the PIC pin an input, and read the stat e > of the pin. Repeat eight times to shift all switch states. Note that a closed > switch will be read as logic high because of the transistor invertor. > > The 1N4148 diode provides a discharge path for the cap when power is removed. > All resistor values probably need tweaking to optimize the circuit. > > I have not tried this. Seems like it should work, though. Anyone care to > comment? > > Dave Sorlien > > Rigby-Jones, Michael [PAI01:4837:EXCH] wrote: > > > I've only just joined the list so this has probably been suggested, > > but if external components are ok, then why not use a simple 8-bit shift > > register and an 8 way DIL switch with ascociated pull ups? On the PIC this > > would need one output for clock,one input for data and most likely 1 output > > to reset the shift register. Admittedly you don't actually require 256 > > values, but 8 way switches and shift registers are the most common. > > > > Mike Rigby-Jones > > > > >I've got a few 12C508 around right now but I dont have any 16x84's > > which is > > > >why I was just trying to use the 12C508 chip. If anyone has any ideas on > > > >implementing a way to assign the 12C508 chip an ID (1 ~ 80) through > > > >external circuitry which the chip can pick up during its program > > > >initialization stage, I would like to hear it. > > > > > > > >Thanks! > > > > > > > >Shahid > > > > > > > > > > >