BikeBikePower//:doObj('build,'BikePower)//:doObj('remove,'BikePower)//:buildFolderLib('BikePower)//:saveApp('BikePower)//m.zielinski@gmx.de{_proto: protoApp, viewBounds: RelBounds(0,0,220,255), title:" Bike Power", helpBook: :helpBookTemplate(), helpView: NIL, MZNum: func(num,b,a) begin local xz := FormattedNumberStr(num,"%."&a&"f");// a = Nachkommastellen local t := b+1+a; // Gesamtlänge if a = 0 then t := b; while (t > StrLen(xz)) do xz := " " & xz; return xz; end,_package:{ version : 1, copyright : "©1998 by Michael Zielinski. All rights reserved.", devSignature: "MiZi", copyProtected : nil, compressed : true, dispatchOnly : nil, partData : nil,},}-----BikeBikePower.protoField{_proto: protoLabelInputLine, initialValue: "", getValue: func() begin local val := StringToNumber(entryline.text); if val then val else StringToNumber(initialValue); end, textsetup: func() Clone(initialValue),}-----BikeBikePower+aboutFloat{_proto: protoFloatNGo, // an empty floating view to contain about textviewBounds: RelBounds(0,20,180, 100),}-----BikeBikePower.aboutFloat+Text{_proto: protoAboutText,text:"Bike Power 1.0\nThis Program calculates the power needed for bicycling.\nMichael Zielinski\nM.Zielinski@gmx.de\nHamburg, Germany\nlong live the Newton",}-----BikeBikePower+CalcButton{_proto: protoTextButton, viewBounds:{ left: 150, top:210, right:210, bottom:230 }, text: "Calculate", buttonClickScript: func() begin local kg_per_Nt := 0.102; local mOs_per_kmOhr := (1000 / 3600); local wc := wcyclist:getValue() / kg_per_Nt ; local wm := wbike:getValue() / kg_per_Nt ; local w := wc + wm; //total weight in newton local r := friction:getValue();// coefficient of rolling friction local g := grade:getValue();//grade of hill local t := efficienc:getValue() / 100;//transmission efficienc local a2 := Position.a2; local h := wind:getValue() * mOs_per_kmOhr;//velocity of wind if crosswind.viewValue then h := h * 0.7; local bm_rate := 1.4;//basal metabolism rate local b := bm_rate * kg_per_Nt * wc;//total caloric rate local v := first:getValue() * mOs_per_kmOhr ;//first velocity local v_incr := increment:getValue() * mOs_per_kmOhr; local n_entry := entries:getValue(); //displayparameters local out := "grade of hill " & g & " % Headwind " & (h/mOs_per_kmOhr) & " km/h\n"; out := out & "weight: cyclist " &(kg_per_Nt *wc) & " + machine " & (kg_per_Nt *wm) & " = total " &(w*kg_per_Nt) & " kg\n"; out := out &"rolling friction coeff = " &r&"\n"; out := out &"air resistance coeff = " &a2&"\n"; out := out &"transmission efficiency = " & (100*t) &" %\n"; out := out &"BM (Watts) " &B&"\n\n"; out := out &"km/h Fkg Pa Pr Pg Pt P hp heat C Cal/hr\n"; local entry := 0; while (entry < n_entry) do begin local f_a := a2*(v+h)*(v+h); if((V+H) < 0)then f_a := f_a * -1; // Calculate the force or rolling restance local f_r := r * w; //* Calculate the force (+/-) of the grade */ local F_g := (g/100) * w; // Calculate the total force local F := F_a + F_r + F_g; // Calculate Power in Watts local P := V * F / T; // Calculate Calories and drivetrain loss if (P > 0)then begin // 0.249 = efficiency of human in cycling local C := P / 0.249 + B; local P_t := (1.0 - T) * P; end else begin local C := B; local P_t := 0.0; end; out := out & :MzNum(V/mOs_per_kmOhr,2,1); out := out & :MzNum(kg_per_Nt * F,3,1); out := out & :MzNum(V * F_a,4,0); out := out & :MzNum(V * F_r,4,0); out := out & :MzNum(V * F_g,4,0); out := out & :MzNum(P_t,4,0); out := out & :MzNum(P,4,0); out := out & :MzNum(P / 745.7,2,2); //745.7 =Watts/horsepower out := out & :MzNum(C - (B + P),4,0); out := out & :MzNum(C,4,0); out := out & :MzNum( C / 1.163,5,0) & "\n"; //1.163 Watts_per_CalOhr V := V + V_incr; entry := entry + 1; end;//while //Print(out); GetRoot().paperroll:open(); //GetRoot().paperroll:MakeTextNote(out,true); //Notiz erzeugen & anzeigen local notes := GetRoot().paperroll; theNote := notes:MakeTextNote(out,nil); theNote.data[0].viewFont := {face:0, family: 'Monaco, size: 9};// := 9218; notes:NewNote(theNote,true,nil);end,}-----BikeBikePower+crosswind{_proto: protoCheckbox, viewBounds:{left:150,top:105,right:210,bottom:120}, text: "Crosswind", viewValue: nil,}-----BikeBikePower+efficienc{_proto: protoField, viewBounds:{ left: 0, top:140, right:150, bottom:160 }, label: "Bike efficiency %", initialValue: "95",}-----BikeBikePower+entries{_proto: protoField, viewBounds:{ left: 0, top:210, right:100, bottom:230 }, label: "entries", initialValue : "10",}-----BikeBikePower+first{_proto: protoField, viewBounds:{ left: 0, top:170, right:150, bottom:190 }, label: "first velocity (km/h)", initialValue : "10",}-----BikeBikePower+friction{_proto: protoField, viewBounds:{ left: 0, top:120, right:150, bottom:140 }, label: "Rolling Friction", initialValue : "0,0051";}-----BikeBikePower+grade{_proto: protoField, viewBounds:{ left: 0, top:80, right:130, bottom:100 }, label: "Grade of hill %", initialValue : "0",}-----BikeBikePower.helpBook+page1.subject 1Input Parameters.storyefficency of the bicycle drivetraingrade of hill (vertical_rise/distance)velocity of the wind (+ for headwind, - for tail).weight bike = machine and clothing-----BikeBikePower.helpBook+page2.subject 1The Output Table.storykm/h = velocityFkg=resisting forward motionPa=air resistance [Watt]Pr=rolling friction [Watts].Pg=power to climb grade [Watts]Pt=power loss, drivetrain inefficiencyP=Pa+Pr+Pg total power output [Watts]hp=total power output [horsepower]heat=C-(P+BM) power wasted, human inefficiency [Watt]BM = basal metabolism [Watts].C = total power consumption [Watts].Cal/h = total power consumption,dietary Calories-----BikeBikePower.helpBook+page3.subject 1Biking Position, air resistance.storyquadratic coefficient of air resistance Typical values for Nt*s^2/m^20.356 standing 0.267 upright (hands on bar tops)0.233 crouch (hands on drops, elbows locked)0.167 racing crouch (hands on crops, elbows bent)0.145 full downhill tuck0.12 end of pack of 1 or more riders0.10 in the middle of a pack-----BikeBikePower.helpBook+page4.subject 1coefficient of rolling friction.story Force of rolling friction Fr = R * WR = k / wheel_diameterand suggested value of k is 0.0012.R = 0.0012 / (27 * 0.0254) = 0.00175 27"R = 0.0012 / (26 * 0.0254) = 0.00182 26"For 1.125 inch tires, the value is R = 0.0047For 26 x 1.375, value is R = 0.0066Other results for 27 x 1.25" tires are 0.0051-----BikeBikePower.helpBook+page5.subject 1power output [Watts].story For elite bicyclists, P > 1200W is sustainable for very very short periods, drops to about 570W for duration of 60 sec, then curves to about 430W for 300s, on down to 390W for 3000s, finally dropping off to 240W for 100000s. Eddy Merckx could sustain about 440W for about 3000s on an ergometer.-----BikeBikePower+increment{_proto: protoField, viewBounds:{ left: 0, top:190, right:100, bottom:210 }, label: "increment", initialValue : "2",}-----BikeBikePower+info{_proto: protoInfoButton, viewJustify: 134, /* vjCenterH + vjCenterV + vjParentBottomV */ viewBounds: RelBounds(25,-16,13,13), DoInfoAbout: func() begin if aboutfloat exists then aboutfloat:open(); end, DoInfoHelp: func() begin local ttim := GetRoot().tinyTim; if not helpView then helpView := BuildContext({ _proto: ttim._proto, bookRef: helpBook}); ttim:close(); helpView:openManual(helpBook); end,}-----BikeBikePower+MyDivider{_proto: protoDivider, viewBounds: RelBounds(0,160,0,180), title: "Output format",}-----BikeBikePower+Position{_proto: protoLabelPicker, viewBounds:{ left: 0, top:25, right:222, bottom:50 }, text: "Biking Position", a2: 0.267 , labelCommands: [" Upright", "Standing","Crouch","Racing Crouch","Downhill tuck","End of 1 Or more","Middle of a pack",], labelActionScript: func(index) begin local x := [0.267,0.356, 0.233, 0.167, 0.145, 0.12, 0.1]; a2 := x[index]; end,}-----BikeBikePower+wbike{_proto: protoField, viewBounds:{ left: 0, top:60, right:120, bottom:80 }, label: "Weight Bike", initialValue : "16",}-----BikeBikePower+wcyclist{_proto: protoField, viewFlags: 0x0000A201, viewBounds:{ left: 0, top:40, right:120, bottom:60 }, label: "Weight Cyclist", initialValue : "84",}-----BikeBikePower+wind{_proto: protoField, viewBounds:{ left: 0, top:100, right:150, bottom:120 }, label: "Wind speed (km/h)", initialValue : "0",}-----BYE!