15,936,337 members
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
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)) :-)

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

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.

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

thanks