PDA

View Full Version : What's the voltage on output pin when it's HIGH?



TonyA
- 22nd April 2008, 21:20
Hi,

I was wondering what voltage is produced on an output pin when it is toggled "HIGH"?

I always assumed it was 5V, but when measuring it was only 1V, I wondered if my meter is off.

I am looking for a way to produce a TTL level output pulse; 5V (and 0V) (Similar to the output of a Schmitt Trigger Pulse Oscillator or a 555 timer IC)

Would I need a transistor for this, or can I just use the Pic by itself?

Thanks for any advice.

T

mister_e
- 22nd April 2008, 21:40
when you set a pin to HIGH it should close to Vdd, if not, you probably forgot few things

disable the Comparator
disable the ADCs
this pin is a open-collector type.
This pin is a INPUT only.. can't be an OUTPUT
etc etc etc

http://www.picbasic.co.uk/forum/showthread.php?t=561

since we don't know the PIC and I/O you're using...

TonyA
- 22nd April 2008, 23:11
I am using 18F452, and reading portb.7.

It lights an LED the way it should, but I only read 1-2V.

Thanks,
T

mackrackit
- 22nd April 2008, 23:15
I am using 18F452, and reading portb.7.

It lights an LED the way it should, but I only read 1-2V.

With or with out the LED attached?

keithdoxey
- 22nd April 2008, 23:17
With or with out the LED attached?

And if WITH the LED attached, did you also include a current limiting resistor in series with the LED ?

TonyA
- 22nd April 2008, 23:20
And if WITH the LED attached, did you also include a current limiting resistor in series with the LED ?


I don't remember... I'll test again and re-post.

Thanks again,
T

TonyA
- 22nd April 2008, 23:47
Yes, with the resistor and LED disconnected, I still read 2V out of the portb.7



'DEFINITIONS'
DEFINE OSC 20
DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 15

'PORT SETUP'
TRISA = %11111111 'set up all pins on portA as input pins
ADCON1 = %10000010 'Set PORTA analog conversion and right justify result

timeVar var word
pauseTime var byte



main:

adcin 0, timeVar

pauseTime = timeVar / 12

high portb.7

pause pauseTime

low portb.7

pause pauseTime

goto main


I'm using the pic like this to provide a TTL pulse, (replacing a Schmitt trigger osc.). I had it hooked up in place of the Schmitt trigger and it works the way I expected, however I don't know why I only read 2V from my multi meter.

The Schmitt trigger's pulse read close to 5V.

Ramonetnet
- 23rd April 2008, 00:01
I see no code saying "port b shall be used for output" .... do you ?
Ramon.

TonyA
- 23rd April 2008, 00:12
I see no code saying "port b shall be used for output" .... do you ?
Ramon.

I was wondering about that too, but when you say "portb.7 HIGH", doesn't that automatically take care of that?

OR do you still have to define port b as output before the code?

Thanks,
T

Ramonetnet
- 23rd April 2008, 00:17
a) instead of trying to imagine the possible combinations,
I would go and program it !

b) if you "select" Port A mode, why don't you specify the Port B mode of operation ?
It is NOT so large and difficult ...

c) if you say "HIGH PORTB.7" it means you write some data into the port,
not that you somehow are telling the compiler to configure it for you.

Let's do it and let's talk again. Ramon.

TonyA
- 23rd April 2008, 00:31
I added "TRISB = 0" and still read approximately 2.5V at portb.7

Thanks,
T

Ramonetnet
- 23rd April 2008, 00:33
Then either :

a) your Vdd is 2,5 volts

b) your PIC is gone nuts

c) any other I dont know right now - time to sleep here

Cheers.

TonyA
- 23rd April 2008, 00:56
I'm sure that I'm getting 5V to power my PIC.

T

keithdoxey
- 23rd April 2008, 08:37
How long is "pausetime"

You are toggling the pin between high and low and your meter will probably not see the voltage stable for long enough to get a true reading.

Currently the pin is operating on a 50% duty cycle and 2.5 volts just happens to be 50% or 5V !!!!

Comment out the "low port b.7" statement which means once the LED comes on it will stay on but you will then have a stable condition on the pin to be able to measure.

My guess is that it will then read 5V :)

sayzer
- 23rd April 2008, 08:42
I'm sure that I'm getting 5V to power my PIC.

T

Depends on where you are measuring your Voltage at.

A - B, A - C , B - C ?


<img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2534&d=1208936533">

keithdoxey
- 23rd April 2008, 08:43
also cant see what the code is meant to achieve because irrespective of whatever value you have for pausetime the led will alsways be at 50% brightness as the on and off times are the same.

If you are trying to get a variable brightness then with pausetime being 0-255 you should have something like



main:

adcin 0, timeVar

pauseTime = timeVar / 12

high portb.7

pause pauseTime

low portb.7

pause (255-pauseTime)

goto main


which will give a total time of 255 but the on will vary from 0-255 whilst off will also change from 255-0

TonyA
- 23rd April 2008, 15:06
Yes, you're right. The on-off time is too fast for the meter to register.

I am just trying to achieve a TTL pulsing; 5V, 0V, on/off at different rates. The LED was put in there just for a visual reference, it's not part of my finished circuit.

The purpose of this pulsing of the pic pin is to replace a Schmitt Trigger Pulse Oscillator.

It is working the way I expected "in circuit", but I was just wondering why I couldn't read discreet 5V and 0V on my meter, (taking reading on the bare pin, not resistor or LED).

If I had an Oscilloscope I guess I would see the TTL (I would see the square wave pulse).

I'm starting to see the benefits of an Oscilloscope...

Thanks for all the help, I appreciate it very much.

T