Programming in C Using the A D converter module

This blog post describes the ADC part of PIC16F877 microcontroller and addresses the least CCS C inbuild function required to activate the ADC, to read the analog signal and display the converted digital signal on a LCD. This tutorial uses Proteus, MPLAB and CCS C compiler.

A PIC microcontroller has Analog to Digital converter or ADC module build inside in it. The function of this part is to convert the external circuitry analog signal into n=8, 10.. bits digital signal. For example PIC16F877 is a 10 bit converter while PIC16F73 is an 8 bit converter. The number of levels of quantization is n to the power of 2. For n=8 the level is 2^8=256 levels and for n=10 its 2^10=1024 levels. The voltage resolution is then Vref/L, where Vref is voltage reference and L is the level. If Vref=5V and L=256 then voltage resolution is 5V/256=0.0195V.

The functioning of ADC module inside the PIC16F877 microcontroller is shown below-

Setting up ADC and reading values using C-language

The process of reading analog and using the ADC module to convert to 8bit digital value requires to set up the ADC device properly. Few of the things that must be specified are the clock source for the ADC, port settings and which port will be used to read the analog signal. The C functions to do these are pointed out below-
  • Specify the ADC clock for sampling( setup_adc(ADC_CLOCK_INTERNAL)
  • Set up the ports type(setup_adc_ports(ALL_ANALOG)
  • Specify which port is used(setup_adc_channel(0))
 Once the A/D port is configured properly the analog signals can be read. The command to read the value is read_adc( ). This value can be strored as an integer as follows-
  • x = read_adc( )
Then the value x(digital value) can be manipulated and displayed onto the screen.

This value x is stored in the ADRESH and ADRESL registers which are 8 bit registers. The value x can be arranged into these two register from left and right. This selection is controlled by the bits value in the ADFM register.

The following code illustrates reading reading analog signal and displaying it on a LCD.

#include "16F877.h"
#device ADC=8
#use delay(clock=4M)
#use rs232(baud=9600, xmit=PIN_D0, rcv=PIN_D1)

void main()                      
    {
        int x;
        setup_adc(ADC_CLOCK_INTERNAL);
        setup_adc_ports(ALL_ANALOG);
        set_adc_channel(0);

        for(;;)
    {
            delay_ms(500);
            x = read_adc();
            x = (x/32)+0x30;

            putc(254);
            putc(1);
            delay_ms(10);
            printf("Level=");
            putc(x);
    }

}

The Proteus Simulation circuit is below-


 Scroll down and up the variable resistor and the corresponding level is displayed in the LCD display.

See How to write C-program to display character on LCD interactively tutorial and other microcontroller tutorials with proteus.

Read More..

Play TITAN Escape The Tower v2 APK with Full Version For Android Free Download



TITAN Escape The Tower v2 APK is one of the most popular Game this week downloaded by the Android users.this android game is one of the most favorite game for android users.Playing game is always a fun thing to do, even more for the game lovers. If you think you are a lover of game, then you need to try this TITAN Escape The Tower v2 of android games apk.Will you escape from the Tower? this game can be downloaded from Google Play store.here we will provide you the paid version.




TITAN Escape The Tower v2 

The great block breaker* developed by Titus Interactive in 1988 is back with a brand-new HD version featuring superb 3D environments.
when Titan was released in 1988, it was awarded the Oscar for Innovation at the CES in Chicago.






Locked up in an 80-level tower by a mad scientist, use your brainpower to help you to escape.

Armed with your pod (a cubic robot) and a metal ball, avoid the numerous traps and try to find the way out.

Titan is an innovative block breaker in which you control a cube at the center of the screen that allows you to move a ball in all directions and destroy the bricks.

In this game, it is not reflexes that count because you are inside an enclosed arena and the ball cannot get out.

It is brainpower and strategy that will carry the day. In each arena, different surprises and riddles await you… you will have to try to understand how to get out and, above all, how to avoid the traps. Some bricks can be destroyed by the ball, others by your pod. Teleporters allow you to navigate from one zone to another, the ice makes you slide, while mortal robot-pods try to hunt you down and traps try to destroy you…






  • 80 diabolical levels from the original game
  • A captivating futuristic universe
  • Superb 3D environments
  • An original gameplay offering varied situations (clear a passage for the ball by breaking the blocks with the racket, use teleporters, and much more…)
  • 8 different universes offering their own specific traps and gameplay subtleties (Prison, Techno, Forest, Ice, Water, Air, Fire, Alien)
  • With two difficulty levels, normal and original, this version offers the same conditions as the original game (speed, number of lives), with the added advantage of being able to save your progress.
  • 2 camera positions (close-up and distant)
  • 2 camera angles (overhead view, the same as for the original TITAN, and perspective view)
Required Android O/S : 2.2+
Size :120Mb APK+OBB 

These are the features of this wonderful Android Game App by the Android Programmers.For you who have Android device,TITAN Escape The Tower v2 is unquestionably a great game with greater future. You will know your free time will always be fun with this game. Download directly the TITAN Escape The Tower v2 here from your device or from your computer. Install and enjoy! 

Password= www.shakzone.com

Download Now !

  OR

 

  Mirror-1 | Mirror-2 | Mirror-3

 
Read More..

Ice Age 2 The Meltdown Pc Game Free Download Full Version






Ice Age 2 The Meltdown Pc Game Free Download Full Version !

System Requirements!
Cpu: 1.4 Ghz
Ram: 256 Mb
Hard: 1.4 Gb
Video Memory: 64 Mb 3d Support
Windows Xp,Vista,7,8

Password=fullypcgames.blogspot.com

.. :: Part 1 :: ..

.. :: Part 2 :: ..

Read More..

The Sims 3 No CD DVD crack mod Nuclearcoffee Edition Working

Very simple install the sims from your disc, go into the bin folder. Copy the contents form this download and overwrite in the bin. then double click the tse.exe boom good to go!
Read More..

Blog Archive

Powered by Blogger.