Help on PIC18F1320

Discussion in 'Hardware' started by dapsonlee, Feb 20, 2011.

  1. dapsonlee

    dapsonlee

    Joined:
    Feb 20, 2011
    Messages:
    1
    I am hoping i can get some help from this forum as the reviews on this site has been tremendous.

    i have been given an assignment which includes the programming of a micro controller. the assignment is explained below,

    I am to measure the voltage output from an accelerometer which is a DE-ACCM3D, a 3D accelerometer. So far so good i have measured all 3 axis Xout = 1.62V, Yout = 1.62V and Zout = 1.97V, Having a source voltage of 4.83V. Using PIC18F1320 being an analog to digital converter, i need to convert those voltages from the X, Y, Z to display digital values.

    What i have done so far;

    i have created the delay h. and also written a little c program using a c18 compiler built it and it compiled successfully and after that i got stuck. I there any chance anybody could help because i was told that it should have to look like this

    "main
    while (not finished)
    {
    x_value = getADC(PA0);
    y_value = getADC(PA1);
    z_value = getADC(PA2);

    printf("Accel Data is %d, %d, %d ", x_value, y_value, z_value);

    }"

    using port 2, 6 and 7 respectively as analog inputs the code wriiten so far is described below


    /*
    * Clock frequency value.
    * This value is used to calculate other values
    * NOTE:- This value should be the crystal freq or crystal x PLL multiplier
    */
    #define CLOCK_FREQ (( unsigned long ) 8000000 ) // 8MHz
    #define INSTR_FREQ (CLOCK_FREQ/4) // one instruction take 4 clock cycles

    /*
    * Set Device config bit settings
    */
    #pragma config WDT = OFF
    #pragma config OSC = INTIO2 // Internal Osc, OSC1 as RA7, OSC2 as RA6
    #pragma config LVP = OFF
    #pragma config MCLRE = ON

    #include <p18f1320.h>
    #include <stdio.h> // Standard I/O - required for printf() function
    #include "Delay.h"

    void main(void)
    {
    OSCCON = 0x70; // set Internal Oscillator Frequency for 8MHz
    PORTB = 0x04;
    TRISA = 0x01; // RA0 as input
    TRISB = 0; // all outputs
    ADCON1 = 0x7f; // Ports as digital I/O

    } // end of main

    Can anyone please help how to define the voltage to convert them to digital outputs by completing the program.

    Thank you to whoever can save a life :D
    dapsonlee, Feb 20, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jacqueline

    help help help

    jacqueline, Jun 29, 2003, in forum: Computer Support
    Replies:
    16
    Views:
    851
    Slumpy
    Jun 30, 2003
  2. Cam

    HELP HELP HELP

    Cam, Aug 7, 2003, in forum: Computer Support
    Replies:
    3
    Views:
    418
    Brian H¹©
    Aug 7, 2003
  3. Tony Bowring
    Replies:
    8
    Views:
    522
    Patrick
    Nov 10, 2003
  4. Tony Bowring
    Replies:
    0
    Views:
    421
    Tony Bowring
    Nov 10, 2003
  5. The Martian

    Help Help Help Pentax S5i Help needed (Please)

    The Martian, Jun 4, 2008, in forum: Digital Photography
    Replies:
    14
    Views:
    1,493
    ASAAR
    Jun 20, 2008
Loading...

Share This Page