Running out of ports on 08M2

mikepanchaud

New Member
hi,

I'd like to use port 1 (pin 6) on a Picaxe 08M2 as an ADCinput using a thermister and resistor potential divider, BUT also use this pin to beep a piezo sounder.
All the other ports 0, 2 and 3 are tied up with driving a seven segment display. Port 2 and 4 to reset and clock a CD4026 driver and port 2 dimming the dissplay with pwm.

I've tried this and it works on a bread board, but I'd like to ask is this good / bad practice? Does using the same port to beep the piezo then immediatley use it to read an analogue value cause accuracy problems?

I'm going to build it any way and see what happens and will report back if anyone is interested. The project btw is to measure the temp of a cup of tea and beep when correct temperature to drink!


mike.
 

MPep

Senior Member
Maybe referring to physical pin3, not C.3!
But then, the first statement indicates that the difference is already known.:confused:

Welcome to the Forum.
Would you please post a circuit diagram?
 

hippy

Ex-Staff (retired)
I'd like to use port 1 (pin 6) on a Picaxe 08M2 as an ADCinput using a thermister and resistor potential divider, BUT also use this pin to beep a piezo sounder.
The common PICAXE terminology for the 08M2 would be "leg 6", "pin 1" / "pin C.1".

I've tried this and it works on a bread board, but I'd like to ask is this good / bad practice? Does using the same port to beep the piezo then immediatley use it to read an analogue value cause accuracy problems?
It should work because the piezo is a high resistance paralleled with your divider circuit. It may slightly affect the linearity of the AD reading but that can be corrected for in software or simply ignored if not a problem in practice.

The main issues in doing this would be the current which which flows through the thermistor when the pin is an output which could potentially cause damage to the thermistor or the PICAXE. That would depend on the rating and specification of the thermistor.
 

techElder

Well-known member
Welcome, Mike!

The solution to your problem is a little more obvious than you make it seem ... add more legs/pins!
 

inglewoodpete

Senior Member
Two comments.

I have successfully used a pin as an output to a piezo element and as an ADC input in a past project. For the record, the input was being used to measure current and had a very low impedance to ground (~1.5 ohms).

It is usually easier to use a 14M2 in this situation. I have done this too, by hanging the 6 additional 14M2 pins over the end of the 08M2's socket and hard wiring then to components on the PCB. Technically, a better solution would have been to redesign the whole project around the 14M2.
 

mikepanchaud

New Member
Circuit - Tea Alarm.JPG

Hi,

Thanks for all your replies!

Sorry I meant pin C.4 (leg 3), in my original post, I'm not using C.3 in, probably needs a pull down resistor?
I've inserted a circuit diagram.
I agree using the bigger 14M2 is the way to go, I was just trying to push it as far as possible and only have 08M2s to hand at the moment.

Thanks again.
Mike.
 

AllyCat

Senior Member
Hi Mike,

I'm not using C.3 in, probably needs a pull down resistor?
It's not really necessary; since it's "input only", it could be tied directly to ground, or enable the internal "Weak Pullup" resistor.

But, if you do connect a pulldown resistor of about 47k (or higher) on Leg 4 (Pin C.3) you can use it as an output. It looks as if it would drive the Reset line (of the CD4026) rather easily. Drive it high with a PULLUP 8 and Low with a PULLUP 0. Then you could use Leg 3 (Pin C.4) for either the Thermistor or the Sounder. ;)

Cheers, Alan.
 

Technical

Technical Support
Staff member
But, if you do connect a pulldown resistor of about 47k (or higher) on Leg 4 (Pin C.3) you can use it as an output.
We prefer not to call it an output in this situation, as the pin can't drive (sink/source) any current, and calling it an output sometimes confuses people.
This trick uses the pin as a potential divider, which can provide a high/low voltage signal under software control.
 

mikepanchaud

New Member
But, if you do connect a pulldown resistor of about 47k (or higher) on Leg 4 (Pin C.3) you can use it as an output. It looks as if it would drive the Reset line (of the CD4026) rather easily. Drive it high with a PULLUP 8 and Low with a PULLUP 0. Then you could use Leg 3 (Pin C.4) for either the Thermistor or the Sounder. ;)
Cheers, Alan.
Thanks AllyCat!

I've tried this on a breadboard and it works well - re setting the CD4026, as this is obviously a very high impedence input. I used 100k pulldown. And am using the freed up C.4 for the sounder.

Circuit - Tea Alarm 2.JPG

I've attached a revised circuit.
:)
Cheers,
Mike.
 
Top