picaxe08M - using pin 5 for ADC input AND speaker output. problems.
February 4, 2010
The problem, as always is situated between the chair and the keyboard.
Telefox mentioned that a pizo is actually capacitor-like, not resistor like as I had assumed. The diode therefore, prevents the pizo from discharging. A proposed solution was to buffer the pizo with a transistor and pulldown resistor, or a double transistor (i.e an inverted inverter), with a pull up.
I'll try these, and see how it all works out.
Like most people, I was drunk when I took my electronics classes (everyone else was drunk too right?). I have a hazy recollection of trying to recall ohms law in the middle of the final exam.
But enough of my bacchinalian lifestyle - onto the problem:
I'm putting together a machine that does very little other than wander around and avoid walls, using the IR sensor circuits that Oddbot wrote up. I suppose it's a bit like the start here robot in it's functionality.
(Just as an aside, the sensor circuits work very well- mine picks out a surface from about 20 cm away, and as close as 5 cm - which is as good as the SHARP sensors.)
This creation is using a picaxe 08, because I want it to be small and compact, and I want to be efficient in using pins - the problem is I'm trying TOO hard to be efficient.
The outputs are:
1, left motor
2, right motor
3, sensor-rotate servo
4. IR lamp high/low
the inputs are:
1. bumper switch
2. ADC input from IR sensor
since the 08 only has 5 in/out pins (three are both adc AND in and digital out, one is digital in, one is digital out) pins, I have to multitask on some pins. i.e. I use the same pin for the IR lamp and servo, however I ALSO want to use pin 5 to output to speaker AND read the ADC input from the IR sensor. And this is where the difficulty lies.
Here's the circuit I'm using, Since I was largly incoherent for my basic electronics labs, I've just used diodes to try to separate out the input and output signals, as seen by pin 5. The pizo also sees the output from the transistor - but that's no problem because it's zero for most of the time.
Now, when I connect this up, and read from the ADC, I get a lot of jitter on the ADC output. I thought it might be some problems to do with impedance mismatching, and the pulses from the transistor circuit might be reflecting off the the diodes, so I goofed around with some resistors to try to get the resistance of the pizo circuit to match that of the transistor circuit - as seen by pin 5 - but I rapidly descended into alcholic fog with complex numbers embedded in it and I had to go get a drink. Realising that I am now clueless about what is going on, I'm posting the situation and hoping that people who were NOT drunk during their electronics classes might be able so share a few pearls of wisdom or other thoughts. Pearls of ignorance are also acceptable.