Split personality IO pin on 08M

nbw

Senior Member
I'm using a SMD 08M for a project and I"m a little short on IO. Not enough to use a bigger chip or an expander, but I'd like to do the following on 08M:

For pin3, which is either an ADC, IN, or OUTPUT - when I switch it to be an output, it powers the 5V pin of a 433 TX module. When I change it back to an INPUT, I want to read an ADC value from a 2.5V ref diode.

The two mini-circuits would of course be both wired up permanently. The picaxe code would only engage 1 at any given time, actually like a switch. My thoughts are around whether problems will occur.

For example - when the pin is an output, 5V will exit the pin and encounter 2 branches. The first goes to power the TX module. That's fine. The other branch will hit the anode of the reference diode, which will be sitting at 2.5V courtesy of a resistor attached to 5V. The resistor will be around 33K, as the ref diode only needs a fraction of a mA. Will problems occur with the 5V from the picaxe encountering the 2.5V from the reference diode? Will it stress the diode?

A similar situation will occur with another of the 08M's IO pins. Output - sending data to the TX module. On the input, reading the voltage from the 3.7V battery, again through a fairly substantial resistor. I'd expect the picaxe ADC should be comfortable with 0.5mA to make a reading, so assuming the voltage is around 3.7V, a 6K8 resistor or similar should be ok. In theory I could take the reading direct from the battery, but if this idea is going to work, a resistor in there would limit data signals getting pumped hard into to the 3.7V terminal .

It's late, so I'm a bit hazy at the moment. Any thoughts / suggestions / warnings before I blow up my little SMD 08M, much appreciated.

cheers all
 

Dippy

Moderator
Get out of bed and give us a drawing. Spend 10 minutes on a lovely sketch. Otherwise you'll get 50 replies (possibly based on ambiguous information) and you'll only read the last three.:)

Does this mean that, in effect, the RF Module is connected in parallel with a Vreference diode?
So, when you make the PICAXE pin an Output/High it also sends power directly through diode to ground?
 

techElder

Well-known member
No, that will not work, because the 2.5 reference will be powering the 433 transmitter all the time and trying to let all the smoke out of itself when you are trying to power up the 433 transmitter!
 

hippy

Technical Support
Staff member
Here's an off-the-cuff idea; replace the R with the transmitter module. When the pin is output low the module gets the full 5V through it and the reference diode effectively has both ends tied to 0V. When the pin is an input the reference works with the module as an R and returns 2V5. You can add R's in parallel with the module across its +V and 0V with no adverse effect except higher current draw when powered.

As it's a transmitter module, one presumes that as well as having power enable you also have a transmit data line; using the two lines you may be able to achieve other configurations which provide both options.
 

hippy

Technical Support
Staff member
And separate advice ... before blowing up your SMD 08M ... breadboard test it with a DIP 08M !
 

premelec

Senior Member
Not sure if this is of any help to your thinking however I recall I used an 08M pin to sense voltage from an LED + R and then switch that pin when it found a particular voltage level [LED being used as photovoltaic generative light detector]. Obviously both functions could not be simultaniously in operation...
 

John West

Senior Member
Yep - gotta see a dwg. of this stuff. I'm too old to picture trick circuits in my head and confidently trace their function. Gotta see it in black and white. Though I can get by with blue and white on occasion. ;)
 

premelec

Senior Member
@John W - it's more in the code... i.e. you READADC on the pin and then use the same pin to put out a high or low digital signal - to get the external functions working you may need a few resistors or diodes and pay attention to levels... however I don't know if this leads to a solution for this particular lead query... :) 'AXE on!
 

nbw

Senior Member
OK, out of bed now. Had a bad night's sleep. Dreamed I got yelled at to provide a drawing ;-)

Anyway - here is one. Specially for Dippy:

Hmm, reading the replies - not as simple as one would have liked. Pity I didn't have a SMD 14-pin axe around.
 

Attachments

nbw

Senior Member
@ Hippy: Hey, I love my chunky DIP picaxe kids just as much as the cute little SMD ones!! No picaxe deserves to be cooked :)
 

fernando_g

Senior Member
Your circuit as drawn could cause damage to the picaxe, diode or both.

No simple solution I can think right away...let me se if I can figure out something.
 

Dippy

Moderator
There you are.
Three minutes with a pen and paper has helped us enormously :)
I won't appear in your nightmares now.... well maybe not.

You haven't commented on hippy's suggestion.

Without extra components I can't see any other easy solution.
And if you have to add more components then you may as well get a bigger PICAXE.
 

MPep

Senior Member
The circuit as it is now, when you power the TX, you will be applying 5V directly to the reference diode!!!! Just remember that the 'magic smoke' is meant to stay inside components :eek::eek:!
 

techElder

Well-known member
Wonder where he heard that? ...

The circuit as it is now, when you power the TX, you will be applying 5V directly to the reference diode!!!! Just remember that the 'magic smoke' is meant to stay inside components :eek::eek:!
 

Dippy

Moderator
Happens all the time Tex.

Even the most prolific poster here sometimes echoes something said only a post or two previously ;)
 

nbw

Senior Member
Cheers all. @ Dippy: hey, it took four minutes to draw it, 10 secs to photograph it, etc...!

This is for a small wireless transmitter to go on a kid's arm, so space is fairly critical, and I only have an SMD 08M. I was quite keen on the 2.5 ref and to be able to sample the little 3.7V LI+ battery, as they can get b*tchy if they're under-discharged. On the face of it, I'll just probably end up making two reasonably accessible points to measure the voltage after we've finishing using the transmitter. A bit mongrel, but oh well.

I thought it might be worth seeing if I could get away with switching a pin from input to output mode, but there you go.

A thought however: if I had the 2.5V from the reference diode, then dropping across a 1n4001 or similar, that should block the 5V from hitting the ref diode when power is applied to the TX module. When the pin was in input mode, it would read 2.5V less say 0.6V for the forward drop, say 1.9V - and it should be quite steady as a reference.

Just a thought. I've still got another 12 hours before I go to sleep again, so I may have more :)
 

nbw

Senior Member
@ e: that went to an empty dialogue box...? Or maybe that was the point??!!

Yet another thought I have an SMD LM339 spare. I could do ye olde light an LED trick if the Li battery drops below say 3V. A bit of a waste of the other 3 comparators I guess. I toyed with the idea of using one of them to drive a transistor, but that would then slice 0.7V off my 5V supply voltage.

Then again, I could up the DC-DC from 5V to 5.7V, but it seems slightly wasteful to do this essentially just to check the source voltage.

And here I am again, having gone full circle! :)
 

nbw

Senior Member
Can you draw a quick sketch please Hippy? I like the gist of what you're suggesting.
 

nbw

Senior Member
As a mongrel, yet vaguely suitable indicator of battery status without blowing up the 08M - I have come up with the following:

Batt +ve terminal >>> 1n4148 diode >>> 1n4148 diode >>> 470 ohm resistor >>> red LED >>> ground

I did some tests, with 0.66V across each diode, plus 1.85V for the red LED, at voltages above 3V from the batt (approx) the LED is on. Below that it's so dim it's essentially off. Even at full Li+ batt voltage of 4.15V, it only draws 2.5mA, so not too bad in the context of the battery (470mAh). I'll tell my son to watch for the red LED - when it goes off, it's out of juice.
 

hippy

Technical Support
Staff member
Can you draw a quick sketch please Hippy? I like the gist of what you're suggesting.
You might need to ensure keeping the TX data out high / low or using a diode / resistor or something.
 

Attachments

nbw

Senior Member
this would indeed work Hippy. I see what you mean about using the TX as a resistance. The only catch is I wanted to also control the V+ to the TX module via the picaxe. As I understand it in your pic, the picaxe pin at the ref diode cathode would only really be used for measuring Vref, rather than be a dual-purpose pin. I am quite short of pins unfortunately. A 14M would be ideal, but that compartment in the toolbox is empty... :)
 

nbw

Senior Member
@ e - cheers for the pdf! There is some interesting stuff in there. I am using already TIP#5 - the using one input for multiple buttons by using resistors and reading an ADC. :)

thanks!
 

nbw

Senior Member
hey, some of us are bordering on 3rd world status here, coupled with the fact we live 20,000km away!!!!
 

hippy

Technical Support
Staff member
As I understand it in your pic, the picaxe pin at the ref diode cathode would only really be used for measuring Vref, rather than be a dual-purpose pin.
As well as an input for reading Vref, the pin can be output low to put a full 5V across the transmitter module.
 

nbw

Senior Member
Ah! Very good! Thinking about that pin, when I drive it high to 5V, wondering about a resistor between the picaxe pin and diode cathode - otherwise the diode will see 5V "unresisted" from the picaxe versus 5V from the TX-5V line, with some resistance. I know those diodes need only a few dozen uA to operate, that said though - they can handle up to 20mA which is about as much as picaxe can supply from memory, so it may be a moot point.
 

John West

Senior Member
In the right-hand thumbnail above:
You might add a blocking diode (cathode points down - Shottky type for low IR drop) to the ground side of the transmitter. Then add a pull-up to the top of the Zener.

It's only 5:30 A.M. here in Colorado so please double check this idea against reality as I'm still snoring.
 

techElder

Well-known member
Go back to sleep! :D That doesn't make much sense, John. Just complicates Hippy's brilliant solution! :)

The brilliant solution by Hippy also assumes that the transmitter will not do funny things with 2.5 volts across it. Hopefully, it is dormant when power is below a certain voltage.

In the right-hand thumbnail above:
You might add a blocking diode (cathode points down - Shottky type for low IR drop) to the ground side of the transmitter. Then add a pull-up to the top of the Zener.

It's only 5:30 A.M. here in Colorado so please double check this idea against reality as I'm still snoring.
 

hippy

Technical Support
Staff member
The brilliant solution by Hippy also assumes that the transmitter will not do funny things with 2.5 volts across it. Hopefully, it is dormant when power is below a certain voltage.
It probably would need prototyping and testing. One possibility would be to raise the Vref so there are less volts dropped across the module.
 

John West

Senior Member
It probably would need prototyping and testing. One possibility would be to raise the Vref so there are less volts dropped across the module.
Well thought. That's exactly what I just got back online to suggest. In fact if you can use a diode drop on the xmitter gnd leg with a suitably high Vref you might entirely isolate the module and give the ref Zener a more stable current source.

Now it's time for me to go to work on other people's equipment. Later.
 
Last edited:
Top