The analog to digital converter (ADC) is a commonly required in most of the projects. Analog voltage measurement can be done using the ADC hardware built in together in a PIC. The picture below show a simple setup for measuring the voltage through the adjustment of the potentiometer. PIC used in this example come with a 10 bit ADC. In the picture the hex value shown is the ADC value acquired from the hardware. After a simple conversion the voltage can be obtain from this value.
Click here to download the full size of the above Circuit.
The next step would be to configure the register on the PIC for the ADC to operate. ADCON0 sets the refrence voltage to Vdd and Vss and select AN0 as the input for the ADC. ADCON1 configure the PIN as analog input. Only PIN AN0 is selected as analog input in this example. ADCON2 sets the required time for acquisition. The value for TAD is choose based on the calculation in the datasheet (pic18f2455, page 298-299). ADC module is turn on for it to function. To display the floating point number conversion to string must be done. The function sprintf is use to format the output so that it can be showed on the LCD. The sprintf function provided by C18 can't be used directly on a floating point number, so the number must 1st be breakup in to the digits left and right of the decimal point. The sprintf is used to join up the 2 parts and the floating point number is display out on the 2x16 lcd. A routine for reading of ADC value is created. The acquisition is started by setting the GO bit in ADCON0. Conversion is done when the done bits turn 0. The high and low byte of the ADC results are joined in to a 16 bit data and pass back from the function. A simple formula can be use to calculate the voltage from the ADC result. The result is multiply by the max value of reference voltage and divided by 1024. Doing this will obtain the voltage on the pin AN0.
This project fits more for custom made battery casing that can have more space to hide things inside. This switch with few alterations can be used for any other project as well but is designed based on e-bike needs! This project use a clever functionality of....
The circuit described here uses ultrasonic oscillations and operates based on the propagation velocity of these oscillations in the air. Thus, we can easily determine the distance of two points if the time within which the wave travels this distance is....
Sometimes the precious metals are hidden too deep and are not detected except with complicated devices. In many cases, however, small pieces of precious metal buried near the surface can be detected by relatively simple means. Everyone is very attractive to....
Many times for various reasons we forget or can not water the plants that we have in our homes. And many humidity sensors units just notify us with a beeping sound or with a flashing light, that the pot needs watering. But what if we are away from home? This....
The principle behind a metal detector is really very simple. Proof of this is the circuit that follows, in which it proves that the construction of a metal detector can be done in the minute, with few components that we find very easily everywhere. With the....
The sub-harmonic bass generator is a sound producing unit for guitars. The sound it produces looks very much like that of the bass guitar. The octave generator is sometimes quite unusual since it does not produce any of the usual ways of coloring the sound,....
In the past the sounding (sea bottom measurement) was done with the "bullet", that is, with a heavy lead object that the seamen plucked into the sea hung from a calibrated rope. As soon as the "bullet" reached the bottom, the depth appeared directly from the....
This Amplifier was designed to have the following specifications: Distortion less than 0.1% at full power of 100W even at 20KHz. Power has to be attributed to an extended bandwidth. The output transistors must be protected against short circuits. The power....
A series of LEDs serve to alert the gardener when plants need water. Using two conventional digital integrated LEDs and a series of LEDs, we make a very useful device for gardening. The device detects the amount of water in the pot and alerts the grower.....
characters left: