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
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 <stdio.h> // Standard I/O - required for printf() function
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