On 3/12/2013 5:02 PM, peter green wrote: > Neil wrote: >> Hi all, >> >> Looking for a way to measure a voltage of 200VDC or a bit more with a >> PIC circuit. I don't need the full range all the way to zero -- only >> about 100V to 200V. The PIC circuit already has its own power supply, >> so I only need the circuit to drop the 200V to something under 5V, or >> some varying resistance perhaps. And it needs to be cost-effective >> (under say $5 in 100-pc quantities). >> >> A resistor divider is not doable because the sections are isolated. I >> did find some special opto-isolators for analog signals, but they're >> very pricey. But I understand that some common (ie: typically used for >> on/off signals) opto-isolators can work for linear signals. Anyone here >> know if this is true, or have another way to do this > One possibility may be to use a SPI ADC on the "hot side" and then > opto-isolate > the digital signals between the ADC and PIC. You can send the data over the opto using something other than RS232. I=20 use a method which can be recovered under very noisy conditions. I send a 12-bit=20 result across the opto. I carefully measure the interval between bits, then I measure the=20 data, which is a positive-going pulse that begins when the bit begins. It then ends=20 either within the first 1/4 bit length, or within the last 1/4 bit length. This method is easier=20 than dirt, and is bulletproof at data rates of 1000 baud or less, because the data can be recovered=20 even when the bit length varies all over the place. This works even on the wobbly internal=20 RC clocks of the PIC16Cxxxx and PIC12Cxxxx devices. Be warned that the latest PIC eeprom devices inside almost all=20 PICF12,-16,-18 and probably the -24 and -33 series as well, work poorly. What happened was that the=20 cell size of the eeprom array was shrunk so small that the cells now bleed charge between each=20 other. The solution is to write several copies of the data, so whenever the value is needed, all 5=20 copies are read, and if a cell or two fails to read properly, the array is rewritten (all 5 values). So=20 I compare all 5 to each other, using a "best 3 of 5" algorithm to see what cells have correct data. If you=20 only have a few bytes to save, "best 2 of 3" works pretty good, too. BTW, sorry but the code is very=20 long-winded for the "best of" methods. In Tucson I was getting at least one bit lost in an 8-byte EEPROM string=20 array after 1 year. Using "best 3-of-5," I have not detected a single error in 4 years. Microchip=20 knows this, -but sadly- has decided NOT to fix it. If your code really needs to work long-term,=20 you'll have to fix this. NOTE: while you'd think that the code array would have this problem, too, I've not=20 seen this at all. --Bob A --=20 The only place success comes before work is in the dictionary. VINCE LOMBARDI --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .