Click here to Skip to main content
15,891,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
MIDL
Test_time = Test_time/10;
jump_height = ((98*(Test_time*Test_time))/ 80);
    LCD0 = jump_height/1000;
    LCD1 = (jump_height/100)%10;
    LCD2 = (jump_height/10)%10;
    LCD3 = jump_height%10;


I don't really want to divide test_time by 10 as this affects the resolution. The problem is the jump equation as jump_height is an unsigned int and the calculation doesn't fit into it.

this is for an embedded C application not PC.

thanks,
Posted
Updated 30-Nov-10 3:54am
v5
Comments
Manfred Rudolf Bihy 24-Nov-10 9:45am    
Small re-edit adjusted end value to 50 giving 500ms. (The other way round would have meant to much work for me (I mean if I had adjusted the elapsed time to 50000ms)) :-)

I'm not sure I agree with your first sentence; if the integer increments once every 10ms then the value of 5000 should mean 50,000ms.

Breaking your equation down:
timesquared = time ^ 2 (assuming you mean time squared?)
interimtime = timesquared * 9.8
h = interimtime / 8

so if time = 500
timesquared = 250,000
interimtime = 2,450,000
h = 306,250

Is h now the height in micrometers (i.e. 0.3 metres)?

Assuming that is correct then just divide by 1000000 and put to the display.
 
Share this answer
 
your right about the fist sentence. a count of 50 would equal 500ms

the problem is that the height is an unsigned int and not sure the calculated values fit into the data type.

the display takes 4 arguements namely LCD0, 1 2 and 3.

so to display you must Display_LCD(LCD0, LCD1, LCD2, LCD3)

I have thought about calculating 2 heights h_m and h_cm and then displaying but no luck as yet.

LCD0 = m (tens)
LCD1 = m (units)
LCD2 = cm (tens)
LCD3 = cm (units)

thanks
 
Share this answer
 
Comments
Richard MacCutchan 24-Nov-10 12:46pm    
Assuming that you get your height value in centimetres, then calculating the values for LCD0/1/2/3 should not be too difficult; a small loop taking the "modulo 10" value each time.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900