Most Basic Doubt Of Digital Electronics!!!

Status
Not open for further replies.
how do we give a digital 1 or 0 to a wire..(does giving a wire 5v makes it digitally 1 and giving 0v makes it digitally 0??)
suppose i have four input wires connected to a microcontroller giving following inputs:
1st wire : 5volt
2nd wire : 0 volt
3rd wire : 3 volt
4th wire : -3 volts
are these inputs analog or digital??
if they are analog then how do we give a digital input??
if they are digital inputs then which of them would be 1 and which would be zero??
please do not ignore my question thinking it to be too basic!!! i have searched from winki..to google to get my answer but couldnt get it...
thanks!!!
 
A voltage is always a analog value. For convience we choose to view/use it as a digital value/signal by saying a voltages between A and B are a ONE and between C and D are ZERO.

So if we put a voltage between A and B on a wire and hook it to a digitial input it will show up as a 1.

The voltage level for zero and 1 are defined by the logic family (chips) you are working with.

HTH
 
Last edited:
Thanks !!
If I Am Giving A Digital Input To A Microcontroller, How Do I Decide Whether I Have Do Give It 5v, 3v Or Any Other Voltage To Make The Input Digitally 1..(is It Decided By The Programming Code Given To That Microcontroller??)
Also Suppose 5volts Represents Digital 1, Then How Would The Microcontroller Respond To Any Other Voltage?? (i Mean Will The Voltage Like 3volt Would Be Any Analog Value For The Microcontroller??)
 
First please not not send me email asking me to respond to a post.


As I said
So if we put a voltage between A and B on a wire and hook it to a digitial input it will show up as a 1.

The voltage levels (A,B,C,D in above quote) for zero and one are defined by the logic family (chips) you are working with.

First you have to know what logic family you are working with. That tells you what the upper and lower limits (ABCD) are for 1 and 0.

The micro controller does not use code to determine the value of a digital input. It is done in hardware.

A digitial input expects voltages to fall in the 0 or 1 range. I do not recall what happens when it does not. I expect that it depends on the logic family.

Try googling for info to read on the subject.
 
sorry for the email!!
ur reply was very useful...can u clear my just one more doubt:
now if i have to make a line follower, can i do the following:
i will use a ir sensor which gives an output voltage of about 1.7v when ir rays falls on it... i will connect this output to an opamp which will convert 1.7v into a higher voltage lying between the limits of digital 1(say 3v...).....this output of 3v will be given to a digital input pin of a microcontroller which will read it as 1...(i am talking about just 1 of the sensors right now)
now i have two doubts after this:
1)can we use a comparator instead of using a opamp??
2)how does the microcontroller controls the motor driver using theseinputs?
also, please correct me wherever i am wrong with the working given above....
 
There are several ways you can read a sensor.

If you have a sensor that puts out 1.5V when active you can use an op-amp to amplify the voltage so that when the sensor is 1.5V the opamp will output 5V. That can be read by a micro controller digital input.

It is also possible to connect the sensor to a comparator. If you setup the comparator right the comparator will output a one when the sensor is at 1.5.


You could also hook the sensor to a micro controller analog input and read the voltage. When the voltage is at about 1.5V you know the sensor is active.

Motors are controlled using digital outputs. The micro controller outputs do not provide enough current to run a motor. So the outputs are used to switch transistors which actually drive the motor. If you want the motor to reverse you need to use a H-Bridge. If you want variable speed you use PWM (Pulse width modulation). Many times we use both to get variable speed and direction control.
PWM is often done inside the micro controller. The H-Bridge is a separate board or chip.

Again time to google.
 
Check the specifications for the micro controller you're using, it will list the voltage required to trigger a state change on it's I/O lines. Just as an example the tiny11 AVRs that I use will read any voltage bellow .3 volts as a digital 0 and any voltage above 3 volts as a 1.
 
Input pins on a digital IC have protection diodes. If you are running 0 and 5V logic, then the diodes start to kick in at 5.3V and -0.3V typically. They can only handle so much current, so if you give them too much current they blow and you've damaged that input pin.
 
this next question of mine may sound very stupid..but please help me with it..
in many of the replies i read u people talking about current given to the pins of the chips...but frm what i understand only a voltage is given to a pin..say 5v or 3v..so how does a current flows to the pin when there is no potential difference??
for example the following lines...

Input pins on a digital IC have protection diodes. If you are running 0 and 5V logic, then the diodes start to kick in at 5.3V and -0.3V typically. They can only handle so much current, so if you give them too much current they blow and you've damaged that input pin.
 

What speakerguy79 was referring to was providing to high (>5V) or too low (<-0.3V) a voltage to the inputs. By providing a higher (or lower) voltage, you thereby increase the current flow through the protection diodes, which could damage them if it's excessive. The negative swing of the input voltage is typically caused by over-shoot from the switching waveform. Transients can also cause this.
 
so how does a current flows to the pin when there is no potential difference??

For TTL logic, the Thevenin Equivalent circuit you would see if you looked into a logic input may be
a high value resistor in series with a voltage source,
this voltage being the threshold at which a 1 or 0 is decided.
Current will flow into or out of a logic pin depending on the voltage you put in.

Old books on TTL circuitry spent some pages modelling this equivalent input circuit.

You can find the value of the Thevenin equivalent voltage by measuring the voltage on a floating logic pin (except for CMOS; the equiv. circ. for this is a small current source).
 
thanks 4 replies..
k.. i am basically working on a line follower project ...i read that the microcontroller runs on very small current and and this much current cant run a dc motor...so we have to increase the value of current..how do we do that...(can l293d do this for me??)...andwhy do we worry about current in the first place?? shouldnt we just keep the voltage given to the pins in their desired range and the current will take care of itself??
please help me out..i m really confused...
 

First, you must determine what the load requirements are (i.e. the current that will be required). You must refer to the data sheet for your particular µC to determine what the output current for your I/O is. It can only deliver so much and does have a limit. Your I/O can drive other TTL/CMOS devices. Things of low current a so forth. For larger loads, such as a motor, will require extra drive capability. For instance, you would have to use MOSFET transistors capable of handling the current requirements of your load. The digital I/O would control the on/off function of the transistor (so a low current device controls a high(er) current device). Your µC uses transistors to drive the lines, however they are not as "big" and cannot handle as much current as a power transistor. Again, refer to the data sheet for your µC.
 
In a perfect world, we could maintain the voltage and the current would take care of itself. However, this isn't a perfect world. We can only build things that do this "within limits". For example a microcontroller pin will provide 5V at any current...as long as the current is 20mA or less. It's the same thing as how a 12V power supply rated for 20A is able to provide 12V at any current less than 20A.

So for a brushed motors (which commutates themselves so you just give them straight power and they run) you can use a power N-channel MOSFET transistor where the source-drain are in series with the gate being controlled by the MCU pin. THe NMOS is placed nearest to ground so that it connects and disconnects the motor from ground- this is the simplest arrangement because the voltage that controls the MOSFET is between it's gate and source pin, and since the MCU pin voltage is relative to ground then if you connect source to ground then the gate voltage and MCU pin voltage have the same reference. THis only provides unidirectional control though.

FOr bi-directional control you need more complicated transistor arrangements like an H-bridge and support circuitry to switch the power MOSFETs. THe support circuitry mainly does two things:
-In more complicated MOSFET arrangements, it is almost guaranteed that some MOSFETs will not have their source pin connected to ground. Because now the reference point for the voltage controlling the transistor isn't the same as the reference voltage that the MCU pin is using anymore, you need some circuitry to take the voltage between MCU pin and ground and "float it up" to become the voltage difference between the MOSFET's gate and source pin.

- to make the MOSFET turn on faster and spend less time in between on and off where it wastes the most energy and heats up the most. THis is important for high frequency switching for things like speed control where the MOSFET spends a lot of time moving between on/off and does so frequently.
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…