ADC displays 512. Why?
lardom
Posts: 1,659
I want to display the signal magnitude from an electret microphone on the parallax serial terminal. The terminal only displays "512" which is the bit resolution. I constructed a circuit that worked properly with a 6v battery when I listened through an earphone. I connected the circuit to a prop and ran the ADC object. Once I saw I could only get "512" I measured the voltage across the feedback resistor which responded when I adjusted the potentiometer. I don't know enough about PASM to modify the code which seems to be the next place to check.
CON _clkmode = xtal1 + pll8x _xinfreq = 10_000_000 INP_PIN = 8 'Counter input pin for sigma-delta. FB_PIN = 9 'Counter feedback pin for sigma-delta. ADC_INTERVAL = 512 'Time interval over which to accumulate counts. ''=======[ External Object Reference ]============================================ {{ FullDuplexSerial is used to communicate with the user's PC. }} OBJ sio : "FullDuplexSerial" ''=======[ Hub Variables ]======================================================== VAR long value 'ADC result variable. ''=======[ Public Methods... ]===================================================== PUB Start {{ Initialize the serial I/O object and sigma-delta cog. Then repeatedly output the current ADC reading. }} dira[1]~~ sio.start(31, 30, 0, 9600) 'Start the serial I/O object. cognew(@adc_cog, @value) 'Start the sigma-delta cog. repeat 'Repeat forever... sio.dec(value) 'Send the current ADC value, sio.tx(13) ' followed by a carriage return if value > 293 outa[1]~~ waitcnt(clkfreq + cnt) outa[1]~ ''=======[ Assembly Code ]======================================================== DAT {{ This code initializes, then continuously monitors the sigma-delta converter and writes the values acquired back to the hub. }} org 0 adc_cog mov frqa,#1 'Initialize frqa to count up by one. movi ctra,#%0_01001_000 'Set ctra mode to positive w/feedback. movd ctra,#FB_PIN 'Write fback pin number to dst field. movs ctra,#INP_PIN 'Write input pin number to src field. mov dira,fb_mask 'Make the feedback pin an output. mov result_addr,par 'Save @value into result_addr. main_loop call #adc 'Get a new acquisition. wrlong acc,result_addr 'Write result to hub. jmp #main_loop 'Back for another. adc mov time,cnt 'Get the current counter value. add time,#16 'Add a little to get ahead. waitcnt time,interval 'Sync to clock; add interval to time. neg acc,phsa 'Negate phsa into result. waitcnt time,#0 'Wait for interval to pass. add acc,phsa 'Add phsa into result. adc_ret ret fb_mask long 1 << FB_PIN 'Mask for feedback pin. result_addr long 0-0 'Result address gets plugged in here. interval long ADC_INTERVAL 'Acquisition time. acc res 1 'General-purpose accumulator. time res 1 'Time variable use for waitcnt.
Comments
Without C3 to block that DC voltage the Propeller input pins will see the DC offset.
If you are running it with a 6 volts supply, the -386 output probably shows about 3 volts with no input signal....
I'm not interested in the quality of the amplifier output so much as I just want to see the output value change.
If you've tried the circuit as drawn, your Propeller chip may already have been damaged. As noted above, it's better just to use the microphone circuit from the Demo Board, without the amplifier.
-Phil
I used an amplifier so I could add sensitivity to the mic. I regard it as part of my education.
Really, though, you don't need the LM386 at all. The prop can detect some pretty fine inputs if you wire it up right.
It's been a while since I did much electronic design.
I had to go look up how to bias a transistor switch the other day (blush).
But I just noticed Phil's reply and realized you were running INTO the Prop pin, not out.
I'm afraid there is a good chance that what he said is correct.
Your circuit would likely put 5 volts into the pin, and that's not good.
Try reading that pin without anything hooked up and see if it still responds correctly.
If it doesn't work, there are 31 others...
@Phil, I bought another Quickstart board. I am now aware of the 40ma source/sink limit on the Prop pins.
@cavelamb, 5v probably destroyed both pins. I'm new at amplifiers but 'lesson learned'.
The things I destroy most often are transistors, diodes and leds. I make sure I'm stocked up. I also have enough Props to keep me busy while I re order.
I'm not disappointed. Even though I failed to get the range of values I wanted I the amplifier itself worked.
Tomorrow I'll start working on the circuit again. I think I have enough new information to succeed this time. When I do I'll smile and be grateful to the people who helped me.