Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

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.
 

Old Nick

Advanced Member level 1
Joined
Sep 14, 2007
Messages
480
Helped
68
Reputation
136
Reaction score
18
Trophy points
1,298
Activity points
4,243
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.
 

bigeye

Newbie level 2
Joined
Nov 13, 2004
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
9
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 ...
 

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
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);
}
 

kmougiakos

Newbie level 4
Joined
May 10, 2006
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,322
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...
 

ashad

Full Member level 6
Joined
Mar 28, 2006
Messages
394
Helped
40
Reputation
80
Reaction score
27
Trophy points
1,308
Location
Trento, Italy
Activity points
3,298
for Angular measurment Synchro is used for all military and industrial application
 

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 can give some example code for convert the ADC to angle and display on LCD?
 

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 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);
 

xorcise

Full Member level 2
Joined
Sep 27, 2007
Messages
124
Helped
20
Reputation
40
Reaction score
1
Trophy points
1,298
Location
NYC
Activity points
2,169
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.
 

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
#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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top