Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Angle Measurement design

Status
Not open for further replies.

vincentspm

Newbie level 6
Joined
Jun 14, 2007
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,364
anyone who know how to design a circuit and program code for angle measurement using PIC16F877A and output to LCD display.

the similar product pic as i attach.
 

Use a high quality linear pot as the hinge, connect as a voltage divider. The voltage in the middle of the divider vill vary linearly with angle. Use the pic to measure the voltage, convert to an angle and then send to a 7 segment display or similar.
 

Put a rotary encoder on axle.
And read it (quadrature encoder).
It's very simple and very high resolution is done ...

PS : Excuse my poor english, but i'm frenchy ...
 

Old Nick said:
Use a high quality linear pot as the hinge, connect as a voltage divider. The voltage in the middle of the divider vill vary linearly with angle. Use the pic to measure the voltage, convert to an angle and then send to a 7 segment display or similar.

I use code as below to detect the voltage first on convert to angle, can make correction for me, why cannot get the voltage value display on LCD? did my calculation convert to voltage wrong?


#define LCDPORT PORTD
#define LCDTRIS TRISD

unsigned temp;
unsigned voltage;

void main(){
ADCON1=0x80; //Configure analog input and Vref
TRISA=0xFF; //PORTA is input

#ifdef LCDPORT
// init LCD
Lcd_Init(&LCDPORT) ;
Lcd_Cmd(Lcd_CLEAR) ; // clear display
Lcd_Cmd(Lcd_CURSOR_OFF) ; // cursor off

Lcd_Out(1, 1, "Voltage =") ;
#endif

do{
temp=Adc_Read(2); //Get results of AD conversion
voltage=((temp*5)/1024);

#ifdef LCDPORT
Lcd_Out(2, 1, voltage);
#endif

}while(1);
}
 

As i can see you have defined the Data bits port for your LCD in the top of your program. But i can't see where are the definitions fro the control pins (E, RS, RW) of your LCD. If your compiler doesn't configure them somewhere, then you must set up the correct ones...
 

for Angular measurment Synchro is used for all military and industrial application
 

Anyone can give some example code for convert the ADC to angle and display on LCD?
 

anyone can help?while read value from ADC, the code as below then how to convert to angle base on different voltage input to different angle.

do{
temp=Adc_Read(2); //Get results of AD conversion

}while(1);
 

You are using mikroC and they have an ADC output example in the compiler. An LCD can accept ASCII values from 0 to 255. If you have a number it must be converted to a string of characters. A BYTE can be 3 characters, and a WORD can be 5 characters.

mikroC has 2 functions that will do the conversion:

Code:
ByteToStr(number, bytestring)
WordToStr(number, wordstring)

LCD_OUT(1,1,bytestring)

Check the Library Reference in the compiler under Conversions. Also, check the examples folder.
 

#define LCDPORT PORTD
#define LCDTRIS TRISD

unsigned bit;
unsigned angle;
unsigned char wordstring[6] ;
void main(){

ADCON1=0x80; //Configure analog input and Vref
TRISA=0xFF; //PORTA is input

#ifdef LCDPORT
// init LCD
Lcd_Init(&LCDPORT) ;
Lcd_Cmd(Lcd_CLEAR) ; // clear display
Lcd_Cmd(Lcd_CURSOR_OFF) ; // cursor off
Lcd_Out(1, 1, "Angle = ") ;
Lcd_Out(1,15, "'");
#endif

do{
bit=Adc_Read(2); //Get results of AD conversion
angle=((bit*90)/1024);
WordToStr(angle,wordstring);
Lcd_Out(1,9,wordstring);
}while(1);
}

i want supplying 0-5v and display 0-90degree, why 0-3.4v the degree output is correct but after 3.5v above all value wrong.
there are the degree display from 1-63 then 0-25, why not 0-90 ??
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top