I know you can make a DAC by using pulse width modulation.
Can you do that in reverse? i.e. make an oscillator who's frequency depends on the input (resistance presumably), then each time the oscillation goes above a certain voltage it would trigger a digital 'on' signal (edge trigger I guess). Count how many of those you get per time, and you have an ADC.
Yes. The way this is done is to make the oscillator's frequency dependent on the parameter you want to measure (normally a voltage) and the A/D conversion is done by measuring the osc. frequency. There are temperature sensors and accelerometers that provide output as a varying frequency so they can be fed straight into a digital input.I've been playing with a Maxim temperature sensor that works this way and it works really well.
Alternately, there is an old technique that generates a PWM-like output that is added with the signal-under-test (the thing you want to measure :-) and the output of that addition is monitored by an input pin. Measure the on vs. off time (PWM) at the input pin and you have a fairly accurate ADC. Low resolution, but it works.
But honestly, with so many precise, accurate and cheap ADCs available these days, doing conversions like this in software is relegated to designs where pennies are significant and the manufacturing costs dwarf the development time.
You could also just feed a ramping pwm output to a lowpass filter and have it go into a comparator, with the other input to the comparator be the analog signal to be measured. You watch the pwm count and when the comparator fires, you have the digitized signal in the pwm count.
Right, and this sweet little chip already has the PWM output and the analog comparator, and you can get a wakeup interrupt from the comparator. And then there's the VFC/VCO approach someone else suggested. But I think you can get a higher sample rate with a dedicated ADC. How fast can you do the PWM/comparator trick on a device like this?
You can always get a higher rate with a dedicated chip, and they are pretty cheap these days. The max you can do the pwm trick is a function of the max clock rate, divide down pwm clock, and the number of bits you want for resolution. Take a look here:
Can you do that in reverse? i.e. make an oscillator who's frequency depends on the input (resistance presumably), then each time the oscillation goes above a certain voltage it would trigger a digital 'on' signal (edge trigger I guess). Count how many of those you get per time, and you have an ADC.
Would that work?