Click here to Skip to main content
13,056,401 members (114,390 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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.

Posted 24-Nov-10 3:41am
Updated 30-Nov-10 3:54am
ManfredRBihy 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)) :-)
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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)

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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170728.5 | Last Updated 30 Nov 2010
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100