Picaxe 8M as a NPN transistor?

kardzzz

New Member
Guys, A NPN transistor could be thought of as a gate controller for a collector and emitter. Can I make a 8M chip function like a NPN transistor? I want to drive a signal high that takes an input from pin 4 and amplifies that output to pin 1. I therefor need pin 4-1 to act like a gate.

Please could i see some example code if this is acheivable.
*My aim is to minimise the number of components for circuit building

Thx
 

jglenn

Senior Member
Is the input digital or analog? Using a computer chip for a gate is not cost effective. It is common practice to try to eliminate hardware by implementing solutions in software. The limit is I/O, you need what is rqrd. If the input is digital, you should just use a transistor, cost five cents. Digital elements do not do analog amplification. :cool:
 
Do you want a ON/OFF output or will you be using PWM?

Program for ON/OFF:

Code:
'------------Settings--------------

symbol ADC_Pin		= 1			'ADC input pin
symbol ADC_Threshold 	= 20 			'A value 0-1023. which specifies at which ADC level the output switches on.
symbol Out_Pin		= 2 

'--------Configure Pins------------

input 	ADC_Pin				'Set pin as input
output 	Out_Pin				'Set pin as Output

'--------Assign Variables----------

symbol ADC_In = w0				'ADC value is stored in this variable

'-----------Program Body-----------

main:			

Readadc10 ADC_Pin,ADC_In			'Read ADC value on selected pin into "ADC_In" variable

If ADC_in >= ADC_Threshold Then	'Switch output on?
	
	high Out_Pin				'Make output high (5V)
		
else						'otherwise		
	
	low Out_Pin					'Make output low (0V)
	
endif				


goto main					'loop forever
A program that uses PWM will be more complicated.
 

Ralpht

New Member
Guys, A NPN transistor could be thought of as a gate controller for a collector and emitter.
Sort of- the base current controls the C - E current. A transistor is a current amplifier - that is why they are used to drive high current devices ie:relays, that a microcontroller of any flavour cannot handle.

The transistor will only act as a switch when it is saturated. Any thing else and the tranny is in it's linear mode where it is basically an amplifier of ac signals - think audio amplifier.

A 08 cannot do what a transistor is designed to do and that is current amplification and no - PWM is not even close. If you are talking about a digital switch to turn something on/off then that is what a micro does anyway, as long as it is about 20ma and 5V. The tranny is only used to amplify the micro's weak output.

If you want the amplification that is the transistors reason for existance then no, an 08 or any other micro will not be able to do it.

Why would you want to use a $2-3 microcontroller to act like a 0.25c transistor?
 
Last edited:

BeanieBots

Moderator
Guys, A NPN transistor could be thought of as a gate controller for a collector and emitter. Can I make a 8M chip function like a NPN transistor? I want to drive a signal high that takes an input from pin 4 and amplifies that output to pin 1. I therefor need pin 4-1 to act like a gate.

Please could i see some example code if this is acheivable.
*My aim is to minimise the number of components for circuit building

Thx
Without a FULL specification of what you REALLY require, impossible to say.
Taking you litterally, an NPN transistor can only conduct in one direction.
1. Do you need that feature? If yes, then you'll a didoe on the output.
2. A transistor has gain. What gain do you need.
3. A transistor can work with small signal inputs. How small is your input?
4. A transistor has a working frequency, what signal frequency do you require.
5. A transistor has a current limit, whay current do you require?
6. A transistor is an analogue device with no descrete steps. What resolution do you require?

Give precise answers to those questions and then we can start to home in on if you can do it or not.
Your question is bit like saying "I have a substance, could I use a car to transport it from place A to place B". In many cases the answer would be yes, but if the "substance" was a liquid, then no. If the "substance" is too big to fit in a car, then no. If place B is across the water then no. If it needs to be there faster than a car can travel, then no. If it's a cup of coffee you want to move from downstairs to upstairs, then a car would not be the ideal transport system.

Do you get the idea, we need SO MUCH MORE from you to answer that.
In addition, a transistor is about 10 times smaller and 10 times cheaper, so WHY would you not want to use a transistor?

Also, don't get the function of "gain" and "gates" confused.
 

kardzzz

New Member
Thank you all for your answers.
Jglen, my signal will be anolog. I guess the NPN is most cost effective.
xnetherland, I will test that code with a circuit.

Regards
 
Top