Logic 0 on port input

Post here to discuss thoughts on DAC's.

Moderators: Chuckt, Garth, bitfogav

Post Reply
User avatar
sdudley
Moderator
Moderator
Posts: 337
Joined: Sun Mar 28, 2010 1:33 pm
Location: Florida, U.S.A.

Logic 0 on port input

Post by sdudley » Tue Jun 15, 2010 1:16 pm

Brad,

I was reading through the ADC with digital ports project and started thinking, at what voltage level does the port pin read a logic 0?

As the CAP discharges and the port eventually reads the logic 0, I am sure that point is not 0 volts.

The only thing I could find in the PIC16F648A data sheet that gives an indication is in the DC Characteristics (section 17.4) on page 140.

My guess is that it is either the Input Low Voltage (VIL), or the Input High Voltage (VIH).

Any clues? :?


The reason I ask this is, I think by calculating the correct R/C time constant to reach the "logic 0" with the pot at full resistance "and" knowing the voltage threshold for the port pin to trigger a HIGH/LOW state, then there would be no need for calibrating.

For instance, by calculating the R/C time constant so at full resistance it will take 200mS to reach the trigger level and read logic 0, the count variable can be set up accordingly then divided by 8 such as you did. Then every 25mS will increase the LED to the next level.

I have not yet tried this but does it sound logical to you?

I am thinking the only way to make it work is to know the level at which it reaches logic 0 so you can calculate the correct time but that may not be necessary.

Stacy
Any time you deviate from sequential consistency, you increase the complexity of the problem by orders of magnitude.

User avatar
brad
Site Admin
Site Admin
Posts: 2576
Joined: Fri Mar 26, 2010 10:30 pm

Post by brad » Tue Jun 15, 2010 6:13 pm

Ah very good question indeed!

Vih is the minimum voltage at the input to be recognised as a logic 1

Vil is the maximum voltage at the input to be recognised as a logic 0

So for this task, Vil is the value you would want to be working with :)

And you are right, if you did do all the calculations and selected the correct components - there would be no need for the calibration routine.

Having said that, I would include a trimmer resistor in series to work as a fine adjustment (due to tolerances)

User avatar
sdudley
Moderator
Moderator
Posts: 337
Joined: Sun Mar 28, 2010 1:33 pm
Location: Florida, U.S.A.

Post by sdudley » Tue Jun 15, 2010 11:13 pm

brad wrote:Ah very good question indeed!

...Vil is the maximum voltage at the input to be recognised as a logic 0

So for this task, Vil is the value you would want to be working with :) ...

... I would include a trimmer resistor in series to work as a fine adjustment (due to tolerances)
Ah thank you. I don't know why that was so confusing to me. :?

I assume then that care needs to be taken as to which port pin you are connecting to (i.e. TTL or Schmitt Trigger input).

Hopefully I will find some time soon to experiment with this a little because I think this could be a good use for demonstrating how to change the PWM in the tutorial I did.

Stacy
Any time you deviate from sequential consistency, you increase the complexity of the problem by orders of magnitude.

User avatar
brad
Site Admin
Site Admin
Posts: 2576
Joined: Fri Mar 26, 2010 10:30 pm

Post by brad » Wed Jun 16, 2010 6:04 am

I saw a project on youtube where the guy has a 2x16 LCD, a push button and a potentiometer. He uses the potentiometer to cycle through different menu settings on the display and then presses the push button to select.

When there are alot of menu settings, the potentiometer makes it so much easier than just using up / down push buttons!
Last edited by brad on Wed Jun 16, 2010 6:29 am, edited 1 time in total.

User avatar
sdudley
Moderator
Moderator
Posts: 337
Joined: Sun Mar 28, 2010 1:33 pm
Location: Florida, U.S.A.

Post by sdudley » Wed Jun 16, 2010 6:14 am

I saw a project on youtube where the guy has a 2x16 LCD, a push button and a potentiometer. He uses the potentiometer to cycle through different menu setting on the display and then the push button to select.
Now there's a great idea.


George Carlin quote:
"If you nail two boards together that have never been nailed together before... some schmuck will buy it from you"! :)
Last edited by sdudley on Wed Jun 16, 2010 10:37 am, edited 1 time in total.
Any time you deviate from sequential consistency, you increase the complexity of the problem by orders of magnitude.

User avatar
brad
Site Admin
Site Admin
Posts: 2576
Joined: Fri Mar 26, 2010 10:30 pm

Post by brad » Wed Jun 16, 2010 6:29 am

sdudley wrote:

George Carlin quote:
"If you nail two boards together that have never been nailed together before... some schmuck will buy it from you"! :)
You're not wrong about that!

User avatar
bitfogav
Moderator
Moderator
Posts: 908
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Post by bitfogav » Wed Jun 16, 2010 7:06 am

I have used ADC with a potentiometer on one pin, and then setup different functions at different voltage inputs.

example:
if you use a potentiometer of say 10k when the potentiometer is fully one way you have 0volts and fully the other way you have 5volts or about (4.8v) I was using a 5 volt regulator LM7805, and in my program code I just tested what voltage was on the PIN and then used a goto command to carry out a certain function, I tested every 0.5volts so that gave me quite a few options for setting up different functions :)

This could be used to make a LED flash from slow to really fast!

User avatar
sdudley
Moderator
Moderator
Posts: 337
Joined: Sun Mar 28, 2010 1:33 pm
Location: Florida, U.S.A.

Post by sdudley » Wed Jun 16, 2010 10:51 am

bitfogav wrote:...I tested every 0.5volts so that gave me quite a few options for setting up different functions...
How did you do this using a digital port? If you are connected to the ADC port of the PIC (or the analog comparator input) I can understand, but configured as digital ports it doesn't make sense to me.

Please explain as I have been interested in finding different ways of handling analog to digital and vise-versa.

Thanks,

Stacy
Any time you deviate from sequential consistency, you increase the complexity of the problem by orders of magnitude.

User avatar
bitfogav
Moderator
Moderator
Posts: 908
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Post by bitfogav » Wed Jun 16, 2010 9:25 pm

I have just used an analog input and used the analog to digit converter, as your will find on the 12F675 microchip.

User avatar
sdudley
Moderator
Moderator
Posts: 337
Joined: Sun Mar 28, 2010 1:33 pm
Location: Florida, U.S.A.

Post by sdudley » Wed Jun 16, 2010 9:47 pm

bitfogav wrote:I have just used an analog input and used the analog to digit converter, as your will find on the 12F675 microchip.
Ah, that makes sense now!

I have been using the PIC12F617 for some of my most recent projects and I plan to post several tutorials using that chip. It also has an ADC and several options available that are not on the 16F648A.

I think one really cool feature is that it has a built in 5 volt regulator and you can run it off any unregulated supply up to 9 volts. I use a lot of 9 volt batteries so I LOVE that one!

Anyway, I want to continue a few more experiments and hopefully add several more tutorials using the PIC16F648A since much of Brad's projects and tutorials are done using that PIC.

That is why I used the 16F648A for the PWM tutorial. I figure Brad's "ADC with digital ports" project would be a perfect match to incorporate user input to vary the pulse width since the 16F648A doesn't have an ADC.

Stacy
Any time you deviate from sequential consistency, you increase the complexity of the problem by orders of magnitude.

User avatar
bitfogav
Moderator
Moderator
Posts: 908
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Post by bitfogav » Thu Jun 17, 2010 3:59 am

I had a 12F629 connected up today and thought just out of interest at what voltage would a microchip read a pin as a logic zero, so I was applying variable voltages to a digital pin using a 10k potentiometer, the microchip pin was configured as a digit input pin so when the microchip read the pin as a logic Zero it would turn on a LED, the Voltage results I got when the microchip turned on the led was between 1.2v to 1.15v approx.

So I would say that any voltage below 1.2volts would class as a logic Zero :)

I hope this gives you some ideas :)

User avatar
brad
Site Admin
Site Admin
Posts: 2576
Joined: Fri Mar 26, 2010 10:30 pm

Post by brad » Thu Jun 17, 2010 6:01 am

bitfogav wrote:I had a 12F629 connected up today and thought just out of interest at what voltage would a microchip read a pin as a logic zero, so I was applying variable voltages to a digital pin using a 10k potentiometer, the microchip pin was configured as a digit input pin so when the microchip read the pin as a logic Zero it would turn on a LED, the Voltage results I got when the microchip turned on the led was between 1.2v to 1.15v approx.

So I would say that any voltage below 1.2volts would class as a logic Zero :)

I hope this gives you some ideas :)
That's probably a better way of doing it rather than looking at the data sheet. Find out the exact voltage for your particular circuit.

I didn't even think of trying that! :)

Garth
I practically live here!
I practically live here!
Posts: 218
Joined: Wed Jan 16, 2013 1:17 pm
Contact:

Re: Logic 0 on port input

Post by Garth » Fri Jan 18, 2013 8:42 pm

I think the only safe thing, if you really want to do it that way, is to use a comparator or op amp. The input voltage will cross the threshold set at the other input, then the output which is either high or low (not in between) goes to the microcontroller input pin. A digital input's threshold voltage is not guaranteed, let alone to be consistent from one part to another, and across temperature.

When the company I work for now bought out the one I had been working for, my first task was to re-design a smart battery-box circuit for an active-noise-cancelling headset where the original designer depended on things like transistor threshold voltages. It was supposed to monitor battery voltage and turn off the power to the headset when the battery got too low for good operation, or if it had been a certain amount of time since the last perceivable usage (based on fluxuations in the load current), to determine if the user walked away and forgot to turn it off, without turning off if the user just sat still but was still using it. It worked fine in the office, so they went to production; but out in the field, it was failing on customers right and left when the temperature was significantly different. I looked at the design and could see what he was trying to do, but could also see why there was so much trouble. I took an entirely different approach, partly using two ADC channels of a PIC, and now after many thousands sold, they have not had a single failure.

Edit: I just realized this is an A/D converter question on a D/A converter section of the forum. Did I miss something?
http://WilsonMinesCo.com/ lots of 6502 resources

User avatar
brad
Site Admin
Site Admin
Posts: 2576
Joined: Fri Mar 26, 2010 10:30 pm

Re: Logic 0 on port input

Post by brad » Sat Jan 19, 2013 7:44 am

That's some great input Garth. You are spot on about transistors, we have a whole section in one of the analog fundamental subjects dedicated to dealing with transistor bias changes due to temperature variations. We show why the bias can change and then how we can modify the circuit to compensate for these changes.

Then in an entirely different subject, we get into op-amps and find out why they are so good to use, especially in applications such as these!

As for the A/D in the D/A section, I think this post was made before I had the A/D section of the forum :)

Garth
I practically live here!
I practically live here!
Posts: 218
Joined: Wed Jan 16, 2013 1:17 pm
Contact:

Re: Logic 0 on port input

Post by Garth » Sat Jan 19, 2013 8:11 am

I just remembered that although the bias voltages I was talking about were for bipolars, I also had a situation 25 years ago where I used the pinch-off voltage of a JFET to regulate the low voltage at miniscule current to keep a SRAM alive when the rest of the circuit was powered down, and that when I put it in the freezer (since this was also for something to sell and I had to know it's not going to fail), it changed a lot. I've never tried it with MOSFETs although I worked in applications engineering at a UHF/VHF power transistor manufacturer in the mid 1980's, mostly in MOSFETs. In those the effort was usually to get rid of the heat when they were running much hotter than any environment humans could survive in-- although it was nice that they didn't have the thermal runaway problem that the bipolars did, and part of our production test was to give them a 30:1 SWR, all phase, something that would always blow up the bipolars.
http://WilsonMinesCo.com/ lots of 6502 resources

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest