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.

how to display tangent value in lcd using mikro c and pic18f442

Status
Not open for further replies.

madhushan90

Newbie level 6
Joined
Jul 26, 2012
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,362
Hi, I'm new to microcontroller programming and i want to display a tangent value of an angle in a lcd. I tried by using tan function in mikro c, code was compiled but didn't work in proteus. can any one help me to find out any method to do this. thanks
 

madhushan its no problem
just see help by searching floattostr in seach manu if problem then i will send u code
 

zia, this is the code I used, but when it simulate in proteus it gives this error massage "Write 0x00 (0) to unimplemented memory address 0x0B5C does nothing" repeatedly.what i should do for solve this
Code:
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
char txt[];
float x;
void main(){
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
x = tan(45);
FloatToStr(x,txt);
Lcd_Out(1,1,txt);
}
 

Change char txt[];

to

char txt[16];

:)

Download this it's working perfectly..

View attachment LCD.zip

Working.PNG
 
Another solution:-
If you do not want to include the math library use the following table and simple if- else statement or switch statement.


degrees radians tan(x)
-90º -π/2 not defined
-60º -π/3 -1.732050808
-45º -π/4 -1.000000000
-30º -π/6 -0.577350269
0º 0 0
30º π/6 0.577350269
45º π/4 1.000000000
60º π/3 1.732050808
90º π/2 not defined
 

tan(45) in radians = 1.6197751905438615499827965173949

tan(45) in degrees = 1


------------update---------------

Check this

Code:
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections

char txt[23];
double x;

void main(){
       Lcd_Init();
       Lcd_Cmd(_LCD_CLEAR);
       Lcd_Cmd(_LCD_CURSOR_OFF);
       x = tan(45 * 3.1416 / 180);
       FloatToStr(x,txt);
       LCd_Out(1,1,"tan(45) = ");
       Lcd_Out(1,12,txt);
}

tan(radian_value) or tan( degree_value * pi / 180)... pi = 3.1416

Regards

Jayanth D
 

Attachments

  • ss5.jpg
    ss5.jpg
    141.7 KB · Views: 116
  • TANGENT.rar
    18.3 KB · Views: 106
Last edited:
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top