'pressing' a button with picaxe

dsvilko

Senior Member
Hi! I'm new to both this forum and picaxe.
I am trying to interface a 08M with a few push-buttons used as input of some other (unknown) microcontroler. I have measured the voltage over the button contacts to be 3.15V. I am guessing that I could always use a transistor connected to one of the picaxe outputs to close the switch but as I am fresh out of transistors could I use a resistor and a diode to connect the microcontroller (normally high) side of the switch directly to the picaxe output:

picaxe ---|<----|10k|----- mC

and then set the output low to trigger a button press? Am I right in assuming that the diode should protect the mC while the picaxe output is high (5V power supply)?
I do apologize for asking such a trivial question.
 

tjetson

Senior Member
You could probably run the 08M at 3 volts to begin with. Then there's no need to muck about with voltage levels etc.
 

dsvilko

Senior Member
You could probably run the 08M at 3 volts to begin with. Then there's no need to muck about with voltage levels etc.
Thanks for the reply but it's much more convenient for me to power the picaxe directly from the 4xAA.
Can someone confirm that connecting the picaxe directly to the button's positive terminal (mC side) through resistor and diode is completely safe? I am guessing that connecting it through 10k resistor and a transistor (mC on the collector) is safe? Both mC and picaxe have a common ground.
 

westaust55

Moderator
Are the 4 AA cell powering the "other (unknown) microcontroller" ?

If so then how does it get to 3.15V on the contacts?

You could just tap off at 2 AA cels for the 08M ? = ~3.0V with "fresh" batteries

A LP2950ACZ-3.0 from say www.futurlec.com.au or www.futurlec.com or other sources would power the 08M from the 4 AA directly.

Others in the past have suggested a 10 kOhm resistor is sufficient for downward voltage level changing but not something I have found to be satisfactory in the past - had the "receiving" chip voltage forced up to 5V when a PICAXE was connected via 6.8 kOhm to a 74HC245 (without 5V tolerant inputs). Nothiong was damaged but changed to a 74LVC245A quickly.
 

dsvilko

Senior Member
Unfortunately I can't connect to just 2AA batteries. The PCB that I am trying to interface to is quite complicated for my level of knowledge (maybe a 50-100 components) so I would rather not try to find where is the 5V-3V converter. I would be much happier connecting directly to the batteries.
Wouldn't a circuit like this work even with picaxe at 5V?

All I need is to be able to occasionally pull the mC input to 0V.
 

dsvilko

Senior Member
The circuit you have shown is your best bet but without the resistor between emitter and 0v.
Ok, thanks! Are you sure I don't need a resistor to limit the current? The original circuit with the button shown on the left could have a resistor somewhere (can't really tell from looking at the PCB).

So, this wouldn't work?
 

dsvilko

Senior Member
6 volts?
Isn't that close to the max limit
for the
12F683?
e
It's actually 4xNiMH so closer to 5V and a suggested method of powering the 08M according the the manual. The power supply is fine. The 'button-pressing' part is what I wanted (still want) to check.
 

westaust55

Moderator
Ok, thanks! Are you sure I don't need a resistor to limit the current? The original circuit with the button shown on the left could have a resistor somewhere (can't really tell from looking at the PCB).

So, this wouldn't work?
By the datasheet, the 08M PICAXE output (Voh) may be as high as 0.6V but more likely around 0.2V when low.

Add to that say 0.6V as diode forward voltdrop and a bit more for the resistor volt drop and the result could be around 0.9V when the PICAXE output is low.
Is that sufficient to operate the 3V input of the unknown microcontroller.

The transistor circuit driven into saturation and without the emitter to ground resistor would give 0.2V Vce, so a better proposition.

Suggest around 820 ohms PICAXE to (BC548 ?) transistor base to drive the transistor into saturation.
 

dsvilko

Senior Member
Suggest around 820 ohms PICAXE to (BC548 ?) transistor base to drive the transistor into saturation.
I have just tried with the 10k base resistor and 2N2222 transistor (the only one I had) and it works. I have connected the emitter to the 'ground' side of the button as I am still not sure that there is definitely nothing current-limiting between the button and the ground. Can I safely connect the emitter to the picaxe ground?
The worst thing is that I only have one transistor and I need three so can't test the whole circuit today :)
 

westaust55

Moderator
Your PICAXE circuit and the board you are control should have the ground lines connected.
Then yes you can connect the transistor emitter to ground at either the PICAXE or controlled board.

If as your earlier sketch shows, the board pushbuttons are connected directly to ground then there is no need for any current limiting resistor- after all they are inputs and not outputs.

The gain of the 2N2222 transistor is quite low (datasheet indicates min of 35)
Obviously working, but personnaly, I would consider a lower value of base resistor
 
Last edited:

hippy

Ex-Staff (retired)
You could also leave the diode out, though it would be recommended to fit one.

The button 'live side' could connect direct to a PICAXE pin. When that pin is an input it will have no affect on the button, when output low it will act as if the button is pushed. The danger is should the pin become output high. That's an output short to 0V with the button pushed and you are injecting +5V into the other micro.

It may be false economy to not fit the diode, but if prepared to take the risk, consider the PICAXE and what it's controlling expendable should the worst happen, hold only yourself accountable for that decision and consequences, it's an option.
 

dsvilko

Senior Member
Thank you all for your replies! I'll buy a few more transistors tomorrow as the test with a transistor was successful. Good idea with the direct connection to the picaxe, Hippy but a bit too dangerous for me :)

One more clarification.... as I have already stated, I don't know what is between the button and the ground. All I can tell is that one side of the button is at 0V and the other at +3.15V. I also don't know if the positive end of the button is directly connected to the mC.
 
Last edited:

eclectic

Moderator
Thank you all for your replies! I'll buy a few more transistors tomorrow as the test with a transistor was successful. Good idea with the direct connection to the picaxe, Hippy but a bit too dangerous for me :)

One more clarification.... as I have already stated, I don't know what is between the button and the ground. All I can tell is that one side of the button is at 0V and the other at +3.15V. I also don't know if the positive end of the button is directly connected to the mC.
Can you supply
a scan or high quality photographs
of the board?

e
 

dsvilko

Senior Member
Thank you all for your help. In the end I opted for the simplicity of bc639 transistors. It works fine. I have just posted a finished project post in 'communication' (my first picaxe project!). :)
 
Top