CycleBanter.com

CycleBanter.com (http://www.cyclebanter.com/index.php)
-   Techniques (http://www.cyclebanter.com/forumdisplay.php?f=8)
-   -   program to compute gears, with table (http://www.cyclebanter.com/showthread.php?t=254683)

Emanuel Berg[_2_] September 8th 17 06:33 AM

program to compute gears, with table
 
Hey guys, does this look right to you?

;; (print-gears '(34 50) '(12 13 15 17 19 21 23 25) 622)
;;
;; =
;;
;; 622 wheel
;;
;; chainring sprocket gear
;;
;; 34 25 2657.5360544880004
;; 34 23 2888.626146182609
;; 34 21 3163.7333982000005
;; 34 19 3496.7579664315795
;; 50 25 3908.1412566000004
;; 34 17 3908.1412566000004
;; 50 23 4247.97962673913
;; 34 15 4429.226757480001
;; 50 21 4652.549115000001
;; 34 13 5110.64625863077
;; 50 19 5142.291127105264
;; 34 12 5536.5334468500005
;; 50 17 5747.266553823531
;; 50 15 6513.568761
;; 50 13 7515.656262692309
;; 50 12 8141.960951250001

(require 'cl-lib)

(defun compute-gear (chainring sprocket wheel)
(let*((pi 3.14159265)
(radius (/ wheel 2.0))
(circum (* 2 radius pi))
(gear (* (/ chainring sprocket 1.0) circum)))
(list chainring sprocket gear)))

(defun gear (chainrings sprockets wheel)
(let*((gears
(cl-loop for c in chainrings
append (cl-loop for s in sprockets
collect (compute-gear c s wheel) )
)))
(cl-sort gears #'= :key #'cl-caddr)))

(defun print-gears (chainrings sprockets wheel)
(let ((out-buffer (get-buffer-create "*Gears*")))
(with-current-buffer out-buffer
(erase-buffer)
(insert (format "%s wheel\n\n" wheel))
(insert "chainring sprocket gear\n\n")
(let ((gears (gear chainrings sprockets wheel)))
(cl-loop for g in gears
do (let ((c ( car g))
(s ( cadr g))
(d (cl-caddr g)))
(insert (format " %s %s %s\n" c s d)) ))))
(pop-to-buffer out-buffer) ))

--
underground experts united
http://user.it.uu.se/~embe8573

Graham September 8th 17 09:46 AM

program to compute gears, with table
 

"Emanuel Berg" wrote in message ...
Hey guys, does this look right to you?

;; (print-gears '(34 50) '(12 13 15 17 19 21 23 25) 622)
;;
;; =
;;
;; 622 wheel
;;
;; chainring sprocket gear
;;
;; 34 25 2657.5360544880004
;; 34 23 2888.626146182609
;; 34 21 3163.7333982000005
;; 34 19 3496.7579664315795
;; 50 25 3908.1412566000004
;; 34 17 3908.1412566000004
;; 50 23 4247.97962673913
;; 34 15 4429.226757480001
;; 50 21 4652.549115000001
;; 34 13 5110.64625863077
;; 50 19 5142.291127105264
;; 34 12 5536.5334468500005
;; 50 17 5747.266553823531
;; 50 15 6513.568761
;; 50 13 7515.656262692309
;; 50 12 8141.960951250001

(require 'cl-lib)

(defun compute-gear (chainring sprocket wheel)
(let*((pi 3.14159265)
(radius (/ wheel 2.0))
(circum (* 2 radius pi))
(gear (* (/ chainring sprocket 1.0) circum)))
(list chainring sprocket gear)))

(defun gear (chainrings sprockets wheel)
(let*((gears
(cl-loop for c in chainrings
append (cl-loop for s in sprockets
collect (compute-gear c s wheel) )
)))
(cl-sort gears #'= :key #'cl-caddr)))

(defun print-gears (chainrings sprockets wheel)
(let ((out-buffer (get-buffer-create "*Gears*")))
(with-current-buffer out-buffer
(erase-buffer)
(insert (format "%s wheel\n\n" wheel))
(insert "chainring sprocket gear\n\n")
(let ((gears (gear chainrings sprockets wheel)))
(cl-loop for g in gears
do (let ((c ( car g))
(s ( cadr g))
(d (cl-caddr g)))
(insert (format " %s %s %s\n" c s d)) ))))
(pop-to-buffer out-buffer) ))

--
underground experts united
http://user.it.uu.se/~embe8573


Not sure about your code as I do not speak that language but a quick check gives:

622*3.142*50/25=3908.648mm

So if your definition of gear is roll out in mm then it looks close. Do not forget to include the tyre. See:

https://www.cateye.com/data/resource..._chart_ENG.pdf

for approximate circumferences. Taking a 23mm tyre the above example would be:
2096*50/25=4192mm

Graham.

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


Frank Krygowski[_4_] September 8th 17 04:50 PM

program to compute gears, with table
 
On 9/8/2017 4:46 AM, Graham wrote:

"Emanuel Berg" wrote in message ...
Hey guys, does this look right to you?

;; (print-gears '(34 50) '(12 13 15 17 19 21 23 25) 622)
;;
;; =
;;
;; 622 wheel
;;
;; chainring sprocket gear
;;
;; 34 25 2657.5360544880004
;; 34 23 2888.626146182609
;; 34 21 3163.7333982000005
;; 34 19 3496.7579664315795
;; 50 25 3908.1412566000004
;; 34 17 3908.1412566000004
;; 50 23 4247.97962673913
;; 34 15 4429.226757480001
;; 50 21 4652.549115000001
;; 34 13 5110.64625863077
;; 50 19 5142.291127105264
;; 34 12 5536.5334468500005
;; 50 17 5747.266553823531
;; 50 15 6513.568761
;; 50 13 7515.656262692309
;; 50 12 8141.960951250001

(require 'cl-lib)

(defun compute-gear (chainring sprocket wheel)
(let*((pi 3.14159265)
(radius (/ wheel 2.0))
(circum (* 2 radius pi))
(gear (* (/ chainring sprocket 1.0) circum)))
(list chainring sprocket gear)))

(defun gear (chainrings sprockets wheel)
(let*((gears
(cl-loop for c in chainrings
append (cl-loop for s in sprockets
collect (compute-gear c s wheel) )
)))
(cl-sort gears #'= :key #'cl-caddr)))

(defun print-gears (chainrings sprockets wheel)
(let ((out-buffer (get-buffer-create "*Gears*")))
(with-current-buffer out-buffer
(erase-buffer)
(insert (format "%s wheel\n\n" wheel))
(insert "chainring sprocket gear\n\n")
(let ((gears (gear chainrings sprockets wheel)))
(cl-loop for g in gears
do (let ((c ( car g))
(s ( cadr g))
(d (cl-caddr g)))
(insert (format " %s %s %s\n" c s d)) ))))
(pop-to-buffer out-buffer) ))

--
underground experts united
http://user.it.uu.se/~embe8573


Not sure about your code as I do not speak that language but a quick check gives:

622*3.142*50/25=3908.648mm

So if your definition of gear is roll out in mm then it looks close. Do not forget to include the tyre. See:

https://www.cateye.com/data/resource..._chart_ENG.pdf

for approximate circumferences. Taking a 23mm tyre the above example would be:
2096*50/25=4192mm

Graham.


Right, don't forget to include the tire. 622 is bead seat diameter, but
you want (effective) outside diameter instead.

I first did such a thing in the 1970s, using Fortran. But I formatted it
as a compact table in rows and columns. You could have one row for each
chainring, one column for each rear cog. A matrix, 2x8.

Another useful trick is to plot the gear development on a logarithmic
scale, so the change from one gear to the next is scaled as the
percentage change. Plotting using a separate row or a separate symbol
for each chainring makes clear which gear is "next" in your gear
progression.

These days, it's probably easiest to do all the above using a
spreadsheet, such as LibreOffice Calc. Or Micros**t Excel.

BTW, back when there were only five rear cogs and a person wanted a wide
range with uniform or other logical spacing, plotting gear development
(or "gear inches," in "inch" countries) was a useful tool for the art of
bike design. These days, with up to 11 cogs in back, the entire exercise
isn't as valuable as it once was.

--
- Frank Krygowski

David Scheidt September 8th 17 06:09 PM

program to compute gears, with table
 
In rec.bicycles.tech Emanuel Berg wrote:
:Hey guys, does this look right to you?

As noted, you need to consider the diameter of the wheel including its tire.

The style is awful. In straight common lisp:

(defun compute-gear (chainring sprocket wheel)
(list chainring sprocket (* (/ chainring sprocket) (* 3.14 wheel))))

(defun gear (chainring sprocket w)
(let ((g))
(dolist (c chainring)
(dolist (s sprocket)
(push (compute-gear c s w) g)))
(sort g #' :key #'third)))

(defun print-gears (chainring sprocket wheel)
(format nil "~:{ ~d ~d ~f ~%~}" (gear chainring sprocket wheel)))





--
sig 46

Emanuel Berg[_2_] September 8th 17 06:44 PM

program to compute gears, with table
 
Graham wrote:

So if your definition of gear is roll out in
mm then it looks close. Do not forget to
include the tyre.


Right, perhaps I should change "gear" into
"roll out" if that's the agreed-upon term.
Perhaps I should even make it print the
formulae first thing.

And I'll include the tyre. Excellent :)

--
underground experts united
http://user.it.uu.se/~embe8573

Emanuel Berg[_2_] September 8th 17 06:52 PM

program to compute gears, with table
 
Skip Montanaro wrote:

* Why the 1.0 divisor when computing gear?


As explained, otherwise it'll be integer
division. But I think that qualifies as a hack
(not an ugly hack tho) so there is no shame in
spotting it an "error" :)

* You can skip the radius and use wheel
(diameter) directly in computing
the circumference.


Right!

* It never occurred to me to do this in Lisp.
I always just use an online calculator, like:

http://www.gear-calculator.com/?GR=D...&SL=2.6&UN=KMH


Let's agree there is no need to do it in Lisp.
Only a desire :)

--
underground experts united
http://user.it.uu.se/~embe8573

Joerg[_2_] September 8th 17 08:56 PM

program to compute gears, with table
 
On 2017-09-08 10:52, Emanuel Berg wrote:
Skip Montanaro wrote:

* Why the 1.0 divisor when computing gear?


As explained, otherwise it'll be integer
division. But I think that qualifies as a hack
(not an ugly hack tho) so there is no shame in
spotting it an "error" :)

* You can skip the radius and use wheel
(diameter) directly in computing
the circumference.


Right!

* It never occurred to me to do this in Lisp.
I always just use an online calculator, like:

http://www.gear-calculator.com/?GR=D...&SL=2.6&UN=KMH


Let's agree there is no need to do it in Lisp.
Only a desire :)


Why make things complicated? I do such stuff with spreadsheets. That's
what they were invented for. Part of every office software including
free ones.

--
Regards, Joerg

http://www.analogconsultants.com/

David Scheidt September 8th 17 08:59 PM

program to compute gears, with table
 
In rec.bicycles.tech Joerg wrote:
:On 2017-09-08 10:52, Emanuel Berg wrote:
: Skip Montanaro wrote:
:
: * Why the 1.0 divisor when computing gear?
:
: As explained, otherwise it'll be integer
: division. But I think that qualifies as a hack
: (not an ugly hack tho) so there is no shame in
: spotting it an "error" :)
:
: * You can skip the radius and use wheel
: (diameter) directly in computing
: the circumference.
:
: Right!
:
: * It never occurred to me to do this in Lisp.
: I always just use an online calculator, like:
:
: http://www.gear-calculator.com/?GR=D...&SL=2.6&UN=KMH
:
: Let's agree there is no need to do it in Lisp.
: Only a desire :)
:

:Why make things complicated? I do such stuff with spreadsheets. That's
:what they were invented for. Part of every office software including
:free ones.

I rewrote his code in common lisp in less time than it takes excel to
start.


--
sig 106

Doug Landau September 8th 17 09:21 PM

program to compute gears, with table
 
On Friday, September 8, 2017 at 12:59:18 PM UTC-7, David Scheidt wrote:
In rec.bicycles.tech Joerg wrote:
:On 2017-09-08 10:52, Emanuel Berg wrote:
: Skip Montanaro wrote:
:
: * Why the 1.0 divisor when computing gear?
:
: As explained, otherwise it'll be integer
: division. But I think that qualifies as a hack
: (not an ugly hack tho) so there is no shame in
: spotting it an "error" :)
:
: * You can skip the radius and use wheel
: (diameter) directly in computing
: the circumference.
:
: Right!
:
: * It never occurred to me to do this in Lisp.
: I always just use an online calculator, like:
:
: http://www.gear-calculator.com/?GR=D...&SL=2.6&UN=KMH
:
: Let's agree there is no need to do it in Lisp.
: Only a desire :)
:

:Why make things complicated? I do such stuff with spreadsheets. That's
:what they were invented for. Part of every office software including
:free ones.

I rewrote his code in common lisp in less time than it takes excel to
start.


A+

[email protected] September 8th 17 10:17 PM

program to compute gears, with table
 
On Friday, September 8, 2017 at 8:50:36 AM UTC-7, Frank Krygowski wrote:
On 9/8/2017 4:46 AM, Graham wrote:

"Emanuel Berg" wrote in message ...
Hey guys, does this look right to you?

;; (print-gears '(34 50) '(12 13 15 17 19 21 23 25) 622)
;;
;; =
;;
;; 622 wheel
;;
;; chainring sprocket gear
;;
;; 34 25 2657.5360544880004
;; 34 23 2888.626146182609
;; 34 21 3163.7333982000005
;; 34 19 3496.7579664315795
;; 50 25 3908.1412566000004
;; 34 17 3908.1412566000004
;; 50 23 4247.97962673913
;; 34 15 4429.226757480001
;; 50 21 4652.549115000001
;; 34 13 5110.64625863077
;; 50 19 5142.291127105264
;; 34 12 5536.5334468500005
;; 50 17 5747.266553823531
;; 50 15 6513.568761
;; 50 13 7515.656262692309
;; 50 12 8141.960951250001

(require 'cl-lib)

(defun compute-gear (chainring sprocket wheel)
(let*((pi 3.14159265)
(radius (/ wheel 2.0))
(circum (* 2 radius pi))
(gear (* (/ chainring sprocket 1.0) circum)))
(list chainring sprocket gear)))

(defun gear (chainrings sprockets wheel)
(let*((gears
(cl-loop for c in chainrings
append (cl-loop for s in sprockets
collect (compute-gear c s wheel) )
)))
(cl-sort gears #'= :key #'cl-caddr)))

(defun print-gears (chainrings sprockets wheel)
(let ((out-buffer (get-buffer-create "*Gears*")))
(with-current-buffer out-buffer
(erase-buffer)
(insert (format "%s wheel\n\n" wheel))
(insert "chainring sprocket gear\n\n")
(let ((gears (gear chainrings sprockets wheel)))
(cl-loop for g in gears
do (let ((c ( car g))
(s ( cadr g))
(d (cl-caddr g)))
(insert (format " %s %s %s\n" c s d)) ))))
(pop-to-buffer out-buffer) ))

--
underground experts united
http://user.it.uu.se/~embe8573


Not sure about your code as I do not speak that language but a quick check gives:

622*3.142*50/25=3908.648mm

So if your definition of gear is roll out in mm then it looks close. Do not forget to include the tyre. See:

https://www.cateye.com/data/resource..._chart_ENG.pdf

for approximate circumferences. Taking a 23mm tyre the above example would be:
2096*50/25=4192mm

Graham.


Right, don't forget to include the tire. 622 is bead seat diameter, but
you want (effective) outside diameter instead.

I first did such a thing in the 1970s, using Fortran. But I formatted it
as a compact table in rows and columns. You could have one row for each
chainring, one column for each rear cog. A matrix, 2x8.

Another useful trick is to plot the gear development on a logarithmic
scale, so the change from one gear to the next is scaled as the
percentage change. Plotting using a separate row or a separate symbol
for each chainring makes clear which gear is "next" in your gear
progression.

These days, it's probably easiest to do all the above using a
spreadsheet, such as LibreOffice Calc. Or Micros**t Excel.

BTW, back when there were only five rear cogs and a person wanted a wide
range with uniform or other logical spacing, plotting gear development
(or "gear inches," in "inch" countries) was a useful tool for the art of
bike design. These days, with up to 11 cogs in back, the entire exercise
isn't as valuable as it once was.


Almost the entire automobile industry is being programmed with languages like Python. Like Fortran these higher level languages are easy and fast to correct errors but everything is on the net now - Tesla updates all of their software off of the Internet.

Higher level languages have millions of holes in them for hackers to gain control of your system. How would you like all of the traffic lights in your area to turn red at once and stay that way? How would you like pressing the accelerator on your car to act as a brake or visa versa? Being interviewed by electric car manufacturers for development jobs I can't seem to get it through their heads that they are placing their company's in grave danger by using languages that are not certifiable.

Even the people that write in Assembly language don't do it as I do. They write utility groups and then simply make calls to these utilities. This is so clumsy that I write smaller, more compact and faster code in C. Though in general these assembly code groups are relatively safe compared to the higher level languages.


All times are GMT +1. The time now is 07:17 PM.
Home - Home - Home - Home - Home

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
CycleBanter.com