Friday, 22 December 2017

How to use Inverting Operational Amplifier. Step by step, quick and easy way to learn this article.

Inverting Operational Amplifier


The Inverting Operational Amplifier

We saw in the last tutorial that the Open Loop Gain, ( Avo ) of an operational amplifier can be very high, as much as 1,000,000 (120dB) or more. However, this very high gain is of no real use to us as it makes the amplifier both unstable and hard to control as the smallest of input signals, just a few micro-volts, (μV) would be enough to cause the output voltage to saturate and swing towards one or the other of the voltage supply rails losing complete control of the output.
As the open loop, DC gain of an Operational Amplifiers is extremely high we can, therefore, afford to lose some of this high gain by connecting a suitable resistor across the amplifier from the output terminal back to the inverting input terminal to both reduce and control the overall gain of the amplifier. This then produces an effect known commonly as Negative Feedback, and thus produces a very stable Operational Amplifier based system.
Negative Feedback is the process of “feeding back” a fraction of the output signal back to the input, but to make the feedback negative, we must feed it back to the negative or “inverting input” terminal of the op-amp using an external Feedback Resistor called . This feedback connection between the output and the inverting input terminal forces the differential input voltage towards zero.
This effect produces a closed loop circuit to the amplifier resulting in the gain of the amplifier now being called its Closed-loop Gain. Then a closed-loop inverting amplifier uses negative feedback to accurately control the overall gain of the amplifier, but at a cost in the reduction of the amplifier's gain.
This negative feedback results in the inverting input terminal having a different signal on it than the actual input voltage as it will be the sum of the input voltage plus the negative feedback voltage giving it the label or term of a Summing Point. We must, therefore, separate the real input signal from the inverting input by using an Input ResistorRin.
As we are not using the positive non-inverting input this is connected to a common ground or zero voltage terminal as shown below, but the effect of this closed loop feedback circuit results in the voltage potential at the inverting input being equal to that at the non-inverting input producing a virtual Earth summing point because it will be at the same potential as the grounded reference input. In other words, the op-amp becomes a “differential amplifier”.



Inverting Operational Amplifier Configuration

inverting operational amplifier


In this Inverting Amplifier circuit, the operational amplifier is connected with feedback to produce a closed loop operation. When dealing with operational amplifiers there are two very important rules to remember about inverting amplifiers, these are: “No current flows into the input terminal” and that “V1 always equals V2”. However, in real-world op-amp circuits, both of these rules are slightly broken.
This is because the junction of the input and feedback signal ( X ) is at the same potential as the positive ( + ) input which is at zero volts or ground then, the junction is a “Virtual Earth”. Because of this virtual earth node, the input resistance of the amplifier is equal to the value of the input resistor, Rin and the closed loop gain of the inverting amplifier can be set by the ratio of the two external resistors.
We said above that there are two very important rules to remember about Inverting Amplifiers or any operational amplifier for that matter and these are.
  • 1.  No Current Flows into the Input Terminals
  • 2.  The Differential Input Voltage is Zero as V1 = V2 = 0 (Virtual Earth)
Then by using these two rules, we can derive the equation for calculating the closed-loop gain of an inverting amplifier, using first principles.
Current ( i ) flows through the resistor network as shown.



resistor feedback circuit

inverting op-amp gain formula

Then, the Closed-Loop Voltage Gain of an Inverting Amplifier is given as.

inverting operational amplifier gain equation

and this can be transposed to give Vout as:

inverting operational amplifier gain

The negative sign in the equation indicates an inversion of the output signal with respect to the input as it is 180o out of phase. This is due to the feedback being negative in value.
The equation for the output voltage Vout also shows that the circuit is linear in nature for a fixed amplifier gain as Vout = Vin x Gain. This property can be very useful for converting a smaller sensor signal to a much larger voltage.
Another useful application of an inverting amplifier is that of a “transresistance amplifier” circuit. ATransresistance Amplifier also known as a “transimpedance amplifier”, is basically a current-to-voltage converter (Current “in” and Voltage “out”). They can be used in low-power applications to convert a very small current generated by a photo-diode or photo-detecting device etc, into a usable output voltage which is proportional to the input current as shown.
op-amp linear output

Transresistance Amplifier Circuit


trans-resistance operational amplifier

The simple light-activated circuit above, converts a current generated by the photo-diode into a voltage. The feedback resistor  sets the operating voltage point at the inverting input and controls the amount of output. The output voltage is given as Vout = Is x Rƒ. Therefore, the output voltage is proportional to the amount of input current generated by the photo-diode.

Inverting Op-amp Example No1


Find the closed loop gain of the following inverting amplifier circuit.

inverting op-amp circuit

Using the previously found formula for the gain of the circuit

inverting op-amp gain
we can now substitute the values of the resistors in the circuit as follows,
Rin = 10kΩ  and  Rƒ = 100kΩ.
and the gain of the circuit is calculated as    -Rƒ/Rin = 100k/10k = -10.
therefore, the closed loop gain of the inverting amplifier circuit above is given -10 or 20dB(20log(10)).


Inverting Op-amp Example No2

The gain of the original circuit is to be increased to 40 (32dB), find the new values of the resistors required.
Assume that the input resistor is to remain at the same value of 10KΩ, then by re-arranging the closed loop voltage gain formula we can find the new value required for the feedback resistor .
   Gain = -Rƒ/Rin
therefore,   Rƒ = Gain x Rin
  Rƒ = 40 x 10,000
  Rƒ = 400,000 or 400KΩ
The new values of resistors required for the circuit to have a gain of 40 would be,
 Rin = 10KΩ  and  Rƒ = 400KΩ.
The formula could also be rearranged to give a new value of Rin, keeping the same value of .
One final point to note about the Inverting Amplifier configuration for an operational amplifier, if the two resistors are of equal value, Rin = Rƒ  then the gain of the amplifier will be -1 producing a complementary form of the input voltage at its output as Vout = -Vin. This type of inverting amplifier configuration is generally called a Unity Gain Inverter of simply an Inverting Buffer.
In the next tutorial about Operational Amplifiers, we will analyse the complement of the Inverting Amplifier operational amplifier circuit called the Non-inverting Amplifier that produces an output signal which is “in-phase” with the input.

Saturday, 16 December 2017

How Does Image Upload Controller Is Used JSP Java Programming...

Learning Java Programming Made Easy

Below is the program which uploads the image to the webpage in jsp java program. This program is stored in a jsp controller file and called in form control tag inside view page(html/jsp).





<%--
    Document   : ImageUploadController
    Created on : Oct 4, 2017, 6:40:15 PM
    Author     : HP
--%>

<%@page import="org.w3c.dom.Document"%>
<%@page import="java.io.*,java.util.*, javax.servlet.*" %>
<%@page import="javax.servlet.http.*" %>
<%@page import="org.apache.commons.fileupload.*" %>
<%@page import="org.apache.commons.fileupload.disk.*" %>
<%@page import="org.apache.commons.fileupload.servlet.*" %>
<%@page import="org.apache.commons.io.output.*" %>

<%
   File file ;
   int maxFileSize = 5000 * 1024;
   int maxMemSize = 5000 * 1024;
   String filePath = "C:/Users/HP/Documents/NetBeansProjects/HIbernateWEB/web/ImageStorage/";

   String contentType = request.getContentType();
   
   if ((contentType.indexOf("multipart/form-data") >= 0)) {

      DiskFileItemFactory factory = new DiskFileItemFactory();
      factory.setSizeThreshold(maxMemSize);
      factory.setRepository(new File("c:\\temp"));
      ServletFileUpload upload = new ServletFileUpload(factory);
      upload.setSizeMax( maxFileSize );
      try{ 
         List fileItems = upload.parseRequest(request);
         Iterator i = fileItems.iterator();
         out.println("<html>");
         out.println("<body>");
         
         while ( i.hasNext () ) 
         {
            FileItem fi = (FileItem)i.next();
            if ( !fi.isFormField () )  {
                String fieldName = fi.getFieldName();
                String fileName = fi.getName();
                boolean isInMemory = fi.isInMemory();
                long sizeInBytes = fi.getSize();
                file = new File( filePath + fileName) ;
                fi.write( file ) ;
                
                
    
                out.println("Uploaded Filename: " + filePath + fileName + "<br>");
            }
         }
        
    
         
         out.println("</body>");
         out.println("</html>");
      }catch(Exception ex) {
         System.out.println(ex);
      }
   }else{
      out.println("<html>");
      out.println("<body>");
      out.println("<p>No file uploaded</p>"); 
      out.println("</body>");
      out.println("</html>");
   }
%>



Wednesday, 13 December 2017

Know About Close-ended Mutual Funds | Mutual Funds | Mutual Fund Investment | Mutual Fund SIP | NAV


Know About Close-ended Mutual Funds


Why To Avoid Close-ended Mutual Funds...

Mutual Funds love launching close-ended schemes for a variety of reasons.

Unfortunately, the reasons may not always be in your best interest.

It is common to see fund houses come out with New Fund Offers (NFOs) when the market is hot. This is the time investors are attracted by the supernormal returns generated by equity mutual funds. Asset managers strike when the iron is hot and launch new schemes with similar objectives, in order to garner more funds and increase their asset base.

For example, in the balanced fund category, a few fund houses have launched multiple schemes. The mutual fund regulator, the Securities and Exchange Board of India (SEBI), has often chided mutual fund houses for launching open-ended schemes with similar investment objectives. This has led to scheme mergers and reduced frequency of open-ended NFOs. 

But, money managers found a way out. They soon began to launch close-ended funds. Here there is no restriction on overlapping investment objectives and the money is locked-in for 3-5 years, depending on the maturity period of the scheme. Being new funds with a small asset base, the expense ratio too is higher than most established open-ended funds.

Has this strategy helped mutual fund houses? Absolutely!

Over the past one year, fund houses launched as many as 36 close-ended funds garnering an asset size of nearly Rs 11,000 crore. In comparison, only 13 open-ended schemes were launched, picking up about Rs 6,000 crore.
With the regulator introducing a categorisation for open-ended schemes, keeping a limit of one scheme per category, the number of close-ended NFOs may shoot up in the coming months. 

Distributors aggressively push close-ended schemes as the trail-commission, which is a monthly commission to the distributor, is paid up front as a one-time payment. This is in addition to the upfront commission paid, which is limited to 1%.
While fund houses benefit with a strong inflow of assets and higher fees, there are several reasons why you should avoid NFOs of close-ended funds.
It highlights five reasons why you should avoid close-ended schemes:
  1. The costs outweigh the benefits

    Fund houses and distributors advocate NFOs of close-ended schemes because it makes better business sense.

    For example, if the fund can charge an expense ratio of up to 3% and if the duration of the fund is for five years, then the fund house receives guaranteed revenue of 15% of the assets, as investors cannot redeem their units. The bulk of commissions paid by the fund houses to distributors is up front.

    So, if your mutual fund advisor is insisting you to invest in a close-ended fund; it might be only keeping in mind the commissions. The fund may not be suitable to you at all.
     
  2. Timing of launch

    Most close-ended NFOs are launched during times when the market is doing well, which leads to much better collections and a larger scheme corpus. It is important to note that most close-ended NFOs launched in 2007, just before the financial crisis of 2008, have not created wealth for investors. During such times, construction of portfolio could be a challenging task as valuations are stretched at a broader level.

    Under such market conditions, the margin of safety is often low. The rush of close-ended schemes, even in the current bull phase, exposes the tendency of fund houses to launch NFOs with an aim of growing AUM ignoring market valuations.
     
  3. No assessable track record

    It is never wise to invest in a fund during its NFO period. Past performance is the most important indicator you have of how good a fund is and there is no past performance for new funds. Unfortunately, close-ended funds by design are open for investments only during the NFO period. There is no track-record. That leaves the investor in the uncomfortable position of having to invest based entirely on the track record of the fund house on similar funds.

    This is workable, but far from an ideal way to choose a fund. This is mainly because the underlying portfolios may differ drastically depending on the investment strategy and fund manager style.
     
  4. Lock–in of capital

    The only mode to sell close-ended fund units, before maturity, is on the stock exchange, provided you bought the units in demat form. On the exchange, you will have to find another investor who is interested in buying units of the fund.

    Based on experience, there is hardly a market for close-ended funds. And even if there are buyers, units will generally be sellable at some discount to the NAV.

    There are also some other potential problems with a lock-in period for close-ended funds. Take this example, you found that the scheme is performing miserably or you had a financial emergency. You may be unable to exit that fund before maturity for lack of liquidity. This might work against you in some cases.
     
  5. No option for regular investments

    Under close-ended NFOs, there is no option to invest regularly through a Systematic Investment Plan (SIP), which is the ideal way to invest in equities. Even if you do invest in a close-ended mutual fund schemes when the market is high, there will be no way to average out your cost if the market heads lower. Therefore, before investing, take a long-term view on the direction of the market. It will be difficult to fit in close-ended funds with your long-term financial goals that require a regular contribution.
Structurally, given their limited corpus size, closed-ended funds take concentrated portfolio bets with only about 25-30 stocks in the portfolio. As there is no inflows and outflows from the scheme, portfolio churn too, is limited. That can be an advantage, as it can give you better returns. But, stock picking skills and costs, too, have an important role to play.

Past data shows that open-ended schemes have performed at par, or even better at times, than closed-ended NFOs.

Therefore it is believed that investors would be better-off avoid investing in close-ended funds. You should instead prefer investing in existing open-ended diversified equity mutual funds having a consistent and dependable performance track record. The best way to invest in such funds is to do so gradually, by investing through a SIP.


Thanks,


How Does Java.Util Pagackage is used in Java?

Learning Java Programming Made Easy




Java.util Package in Java


Java.util Package

It contains the collections framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes (a string tokenizer, a random-number generator, and a bit array).
Following are the Important Classes in Java.util package :
  1. AbstractCollection: This class provides a skeletal implementation of the Collection interface, to minimize the effort required to implement this interface.
  2. AbstractList: This class provides a skeletal implementation of the List interface to minimize the effort required to implement this interface backed by a “random access” data store (such as an array).
  3. AbstractMap<K,V>: This class provides a skeletal implementation of the Map interface, to minimize the effort required to implement this interface.
  4. AbstractMap.SimpleEntry<K,V>: An Entry maintaining a key and a value.
  5. AbstractMap.SimpleImmutableEntry<K,V>: An Entry maintaining an immutable key and value.
  6. AbstractQueue: This class provides skeletal implementations of some Queue operations.
  7. AbstractSequentialList: This class provides a skeletal implementation of the List interface to minimize the effort required to implement this interface backed by a “sequential access” data store (such as a linked list).
  8. AbstractSet: This class provides a skeletal implementation of the Set interface to minimize the effort required to implement this interface.
  9. ArrayDeque: Resizable-array implementation of the Deque interface.
  10. ArrayList: Resizable-array implementation of the List interface.
  11. Arrays: This class contains various methods for manipulating arrays (such as sorting and searching).
  12. BitSet: This class implements a vector of bits that grows as needed.
  13. Calendar: The Calendar class is an abstract class that provides methods for converting between a specific instant in time and a set of calendar fields such as YEAR, MONTH, DAY_OF_MONTH, HOUR, and so on, and for manipulating the calendar fields, such as getting the date of the next week.
  14. Collections: This class consists exclusively of static methods that operate on or return collections.
  15. Currency: Represents a currency.
  16. Date: The class Date represents a specific instant in time, with millisecond precision.
  17. Dictionary<K,V>: The Dictionary class is the abstract parent of any class, such as Hashtable, which maps keys to values.
  18. EnumMap,V>: A specialized Map implementation for use with enum type keys.
  19. EnumSet: A specialized Set implementation for use with enum types.
  20. EventListenerProxy: An abstract wrapper class for an EventListener class which associates a set of additional parameters with the listener.
  21. EventObject: The root class from which all event state objects shall be derived.
  22. FormattableFlags: FomattableFlags are passed to the Formattable.formatTo() method and modify the output format for Formattables.
  23. Formatter: An interpreter for printf-style format strings.
  24. GregorianCalendar: GregorianCalendar is a concrete subclass of Calendar and provides the standard calendar system used by most of the world.
  25. HashMap<K,V>: Hash table based implementation of the Map interface.
  26. HashSet: This class implements the Set interface, backed by a hash table (actually a HashMap instance).
  27. Hashtable<K,V>: This class implements a hash table, which maps keys to values.
  28. IdentityHashMap<K,V>: This class implements the Map interface with a hash table, using reference-equality in place of object-equality when comparing keys (and values).
  29. LinkedHashMap<K,V>: Hash table and linked list implementation of the Map interface, with predictable iteration order.
  30. LinkedHashSet: Hash table and linked list implementation of the Set interface, with predictable iteration order.
  31. LinkedList: Doubly-linked list implementation of the List and Deque interfaces.
  32. ListResourceBundle: ListResourceBundle is an abstract subclass of ResourceBundle that manages resources for a locale in a convenient and easy to use list.
  33. Locale – Set 1Set 2: A Locale object represents a specific geographical, political, or cultural region.
  34. Locale.Builder: Builder is used to build instances of Locale from values configured by the setters.
  35. Objects: This class consists of static utility methods for operating on objects.
  36. Observable: This class represents an observable object, or “data” in the model-view paradigm.
  37. PriorityQueue: An unbounded priority queue based on a priority heap.
  38. Properties: The Properties class represents a persistent set of properties.
  39. PropertyPermission: This class is for property permissions.
  40. PropertyResourceBundle: PropertyResourceBundle is a concrete subclass of ResourceBundle that manages resources for a locale using a set of static strings from a property file.
  41. Random: An instance of this class is used to generate a stream of pseudorandom numbers.
  42. ResourceBundle: Resource bundles contain locale-specific objects.
  43. ResourceBundle.Control: ResourceBundle.Control defines a set of callback methods that are invoked by the ResourceBundle.getBundle factory methods during the bundle loading process.
  44. Scanner: A simple text scanner which can parse primitive types and strings using regular expressions.
  45. ServiceLoader: A simple service-provider loading facility.
  46. SimpleTimeZone: SimpleTimeZone is a concrete subclass of TimeZone that represents a time zone for use with a Gregorian calendar.
  47. Stack: The Stack class represents a last-in-first-out (LIFO) stack of objects.
  48. StringTokenizer: The string tokenizer class allows an application to break a string into tokens.
  49. Timer: A facility for threads to schedule tasks for future execution in a background thread.
  50. TimerTask: A task that can be scheduled for one-time or repeated execution by a Timer.
  51. TimeZone: TimeZone represents a time zone offset, and also figures out daylight savings.
  52. TreeMap<K,V>: A Red-Black tree based NavigableMap implementation.
  53. TreeSet: A NavigableSet implementation based on a TreeMap.
  54. UUID: A class that represents an immutable universally unique identifier (UUID).
  55. Vector: The Vector class implements a growable array of objects.
  56. WeakHashMap<K,V>: Hash table based implementation of the Map interface, with weak keys.

How Does java.lang package is used in java?

Learning Java Programming Made Easy



Java.lang package in Java


Java.lang package in Java

Provides classes that are fundamental to the design of the Java programming language. The most important classes are Object, which is the root of the class hierarchy, and Class, instances of which represent classes at run time.
Following are the Important Classes in Java.lang package :
  1. Boolean: The Boolean class wraps a value of the primitive type boolean in an object.
  2. Byte: The Byte class wraps a value of primitive type byte in an object.
  3. Character – Set 1, Set 2: The Character class wraps a value of the primitive type char in an object.
  4. Character.Subset: Instances of this class represent particular subsets of the Unicode character set.
  5. Character.UnicodeBlock: A family of character subsets representing the character blocks in the Unicode specification.
  6. Class – Set 1Set 2 : Instances of the class Class represent classes and interfaces in a running Java application.
  7. ClassLoader: A class loader is an object that is responsible for loading classes.
  8. ClassValue: Lazily associate a computed value with (potentially) every type.
  9. Compiler: The Compiler class is provided to support Java-to-native-code compilers and related services.
  10. Double: The Double class wraps a value of the primitive type double in an object.
  11. Enum: This is the common base class of all Java language enumeration types.
  12. Float: The Float class wraps a value of primitive type float in an object.
  13. InheritableThreadLocal: This class extends ThreadLocal to provide inheritance of values from parent thread to child thread: when a child thread is created, the child receives initial values for all inheritable thread-local variables for which the parent has values.
  14. Integer :The Integer class wraps a value of the primitive type int in an object.
  15. Long: The Long class wraps a value of the primitive type long in an object.
  16. Math – Set 1, Set 2: The class Math contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions.
  17. Number: The abstract class Number is the superclass of classes BigDecimal, BigInteger, Byte, Double, Float, Integer, Long, and Short.
  18. Object: Class Object is the root of the class hierarchy.
  19. Package: Package objects contain version information about the implementation and specification of a Java package.
  20. Process: The ProcessBuilder.start() and Runtime.exec methods create a native process and return an instance of a subclass of Process that can be used to control the process and obtain information about it.
  21. ProcessBuilder: This class is used to create operating system processes.
  22. ProcessBuilder.Redirect: Represents a source of subprocess input or a destination of subprocess output.
  23. Runtime: Every Java application has a single instance of class Runtime that allows the application to interface with the environment in which the application is running.
  24. RuntimePermission: This class is for runtime permissions.
  25. SecurityManager: The security manager is a class that allows applications to implement a security policy.
  26. Short: The Short class wraps a value of primitive type short in an object.
  27. StackTraceElement: An element in a stack trace, as returned by Throwable.getStackTrace().
  28. StrictMath: The class StrictMath contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions.
  29. String: The String class represents character strings.
  30. StringBuffer: A thread-safe, mutable sequence of characters.
  31. StringBuilder: A mutable sequence of characters.
  32. System: The System class contains several useful class fields and methods.
  33. Thread: A thread is a thread of execution in a program.
  34. ThreadGroup: A thread group represents a set of threads.
  35. ThreadLocal: This class provides thread-local variables.
  36. Throwable: The Throwable class is the superclass of all errors and exceptions in the Java language.
  37. Void: The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the Java keyword void.

How Does java.io pacakage in Java Programming ?

Learning Java Programming Made Easy



Java.io Package in Java


Java.io Package in Java


This package provides for system input and output through data streams, serialization and the file system. Unless otherwise noted, passing a null argument to a constructor or method in any class or interface in this package will cause a NullPointerException to be thrown.
Following are the important classes in Java.io package:
  • BufferedInputStream
  • BufferedOutputStream
  • BufferedReader
  • BufferedWriter
  • ByteArrayInputStream
  • ByteArrayOutputStream
  • CharArrayReader
  • CharArrayWriter – Set1 Set2
  • Console
  • DataInputStream – Set1 Set2
  • DataOutputStream
  • File
  • FileDescriptor
  • FileInputStream
  • FileOutputStream
  • FilePermission
  • FileReader and FileWriter
  • FilterInputStream
  • FilterOutputStream
  • FilterReader
  • FilterWriter
  • InputStream
  • InputStreamReader
  • LineNumberInputStream
  • LineNumberReader
  • ObjectInputStream
  • ObjectInputStream.GetField
  • ObjectOutputStream – Set 1 Set2
  • ObjectOutputStream.PutField
  • ObjectStreamClass
  • ObjectStreamField
  • OutputStream
  • OutputStreamWriter
  • PipedInputStream
  • PipedOutputStream
  • PipedReader
  • PipedWriter
  • PrintStream – Set1   Set2
  • PrintWriter – Set1  Set2
  • PushbackInputStream
  • PushbackReader
  • RandomAccessFile
  • Reader
  • SequenceInputStream
  • SerializablePermission
  • StreamTokenizer – Set1 Set2
  • StringBufferInputStream
  • StringReader
  • StringWriter
  • Writer
  • ZipInputStream class in Java
  • ZipEntry class in Java
  • JarEntry class in Java
  • ZipOutputStream class in Java
  • Zip.InflaterInputStream class in Java
  • Zip.DeflaterInputStream class in Java
  • Zip.DeflaterOutputStream class in Java

Sunday, 10 December 2017

How to write Java program to get a list of all file/directory names from the given

Learning Java Programming Made Easy


Here is an example program to get the list of all file/directory names from the given link...

Please try this by your self and learn..



import java.io.File; import java.util.Date; public class Exercise1 { public static void main(String a[]) { File file = new File("/home/students/"); String[] fileList = file.list(); for(String name:fileList){ System.out.println(name); } } }

Charactor_At_Position

public class Char_At_Position { public static void main(String[] args) { String str = "Wankhede"; String rev=""...