Posts

voltage and current

voltage: force responsible for movement of electrons(electric current) through a electric circuit current:amount of electrons flowing at a point per second

Pull-up and Pull-down resistors

Image
Suppose in a microcontroller ,you have configured the GPIO functionality of a particular pin to input, and if you read the state of the pin when nothing is connected to it,will it be high(Vcc) or low(Gnd).This is difficult to tell and the state it is present is known as floating state(high impedance state).To prevent this unknown state or floating state,a pull-up or pull-down resistor will ensure that the pin is either in a high state or low state.            A pull-up resistor is connected to 3.3V or 5V (Vcc) and the pull-down resisitor is connected to ground(GND).       Pull-ups are often used with buttons and switches. When the pull-up resistor is connected,the input pin will read a high state when the button is not pressed,a small amount of current will be flowing between the input pin and the VCC thus the input pin is reading to close to VCC.When the button is pressed it connects the input pin directly to the ground,the curr...

What is the difference between phase and polarity

Image
Phase :  For phase to measure we require two signals, and it gives the time relationships of the signals. Polarity :  Can be measured on a single signal. It refers to positive and negative values of a signal.So a signal can have either positive polarity or negative polarity. Inverting the polarity means shifting the amplitude,so that positive components become negative and negative components become positive. Sine wave are the waves which alternates from positive to negative and back to positivie,place where the voltage is zero volts is taken to be zero degrees and place where the voltage starts becoming negative is taken to be 180 degrees,when it gets back to positive again it is 360 degrees which is 0 degrees. Phase Difference :  Difference between two sinusoidal signals of the same frequency in time or degrees and  they are referenced at the same point is known as phase difference. In-Phase:  Two sinusoidal signals having the same frequenc...

How to Setup an FTP Server in Ubuntu 12.04

In order to install an FTP Server in ubuntu 12.04, we have to install the corresponding package sudo apt-get  install vsftdp For setting the ftp server, we have to modify the following file /etc/vsftpd.conf To start the ftp server sudo /etc/init.d/vsftpd restart Then u can open the browser and  type : ftp://ipaddress of the interface t check whether it is successfully running or not. Copy the files to /srv/ftp to keep it on the ftp server

c in C

unsetenv is used to delete the  variable name from the environment Syntax : int unsetenv(const char *name); Arguments Passed: name of the variable which you want to remove Return  Value :  Returns zero on success else returns -1 Code: #include<stdio.h> #include<stdlib.h> int main() { int result=putenv("NAME=TEST"); if(result==0) { printf("\n environmental variable successfully written"); printf("\n value of the environmental variable written is %s",getenv("NAME")); }else{ printf("\n error in writing the environmental variable"); } unsetenv("NAME"); printf("\n value of the environmental variable written is %s",getenv("NAME")); return 0; }

putenv example in C

Use : To change the environmental variable value Syntax: int putenv(char *string) Arguments : Takes a string as NAME=VALUE, where NAME  is the name of the environmental variable and VALUE is the value of the environmental variable you want to set If NAME is present in the environment list then replace the value else it will add this to the environmental list Return Type: 0 on success                       -1  if any error Code: #include<stdio.h> #include<stdlib.h> int main() { int result=putenv("NAME=TEST"); if(result==0) { printf("\n environmental variable successfully written"); printf("\n value of the environmental variable written is %s",getenv("NAME")); }else{ printf("\n error in writing the environmental variable"); } return 0; }

getenv example in C

Syntax:  char* getenv(const char* name) Arguments Passed: Name of the environmental variable Return Value:  Value of the environmental variable if present else returns null Code: #include<stdio.h> #include<stdlib.h> int  main() { printf("HOME Path :%s\n",getenv("HOME")); printf("ROOT Path :%s\n",getenv("ROOT")); printf("USER :%s\n",getenv("USER")); printf("Present Working Directory: %s\n",getenv("PWD")); return 0; }