12,065,204 members (47,554 online)
Rate this:
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.

thanks,
Posted 24-Nov-10 4:41am
Edited 30-Nov-10 4:54am
v5
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:

## 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.
Rate this:

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

Top Experts
Last 24hrsThis month
 OriginalGriff 160 RDBurmon 100 ppolymorphe 50 CPallini 50 nv3 40
 Dave Kreskowiak 1,857 Richard MacCutchan 1,250 d@nish 980 OriginalGriff 974 CPallini 790