Working Models Ratchet Making Code

A Bessler, gravity, free-energy free-for-all. Registered users can upload files, conduct polls, and more...

Moderator: scott

User avatar
jim_mich
Addict
Addict
Posts: 7467
Joined: Sun Dec 07, 2003 12:02 am
Location: Michigan
Contact:

Working Models Ratchet Making Code

Post by jim_mich »

Working Models Ratchet Making

First make a polygon with three (or more) sides and set its X and Y cordinates at zero.
Click 'Script' then 'Editor'
Copy this code into the editor.
Adjust the first five parameters to what you would like.
Press 'F5' to run the code.

Code: Select all

Sub Main()
 Ro = 1.000 	'outside Radius
 Td = 0.05  	'Tooth depth
 Ar = 0.250 	'Angle relief
 Nt = 60    	'Number of teeth
 CW = 1     	'CW = 1 else = 0 for CCW

 Rr = Ro - Td   'Root radius
 T$ = ""
 For a = 0 to 359 step 360 / Nt
  If CW then 'Teeth point CW
   T$ = T$ + Format$(Rr, "0.000") + Chr$(9)
   T$ = T$ + Format$(a + Ar, "0.000")
   T$ = T$ + Chr$(13) + Chr$(10)
   
   T$ = T$ + Format$(Ro, "0.000") + Chr$(9)
   T$ = T$ + Format$(a, "0.000")
   T$ = T$ + Chr$(13) + Chr$(10)  
  Else      'Teeth point CCW
   T$ = T$ + Format$(Ro, "0.000") + Chr$(9)
   T$ = T$ + Format$(a, "0.000")
   T$ = T$ + Chr$(13) + Chr$(10)  

   T$ = T$ + Format$(Rr, "0.000") + Chr$(9)
   T$ = T$ + Format$(a + Ar, "0.000")
   T$ = T$ + Chr$(13) + Chr$(10)
  End If
 Next
 Clipboard.SetText T$
 
 T$ = "Data is in clipboard, ready to paste."
 T$ = T$ + Chr$(13) + Chr$(10) + "Set Geometry "	
 T$ = T$ + "to 'Curved Body' and 'Shape coordinates'"
 T$ = T$ + Chr$(13) + Chr$(10)
 T$ = T$ + "then click 'Paste' and unclick 'Curved Body'."
 Msgbox T$

End Sub
To make the pawl first make a rectangle. Position one end at the center of the ratchet. (If/when pinned at its end you can adjust its length without causing problems.) Make a triangle polygon with one corner to fit into a tooth space. Make a 'Keyed Slot Joint' pinned at the corner of the triangle that contacts the ratchet wheel. Attach a spring and adjust its length to half the ratchet OD and its force as light as will work. Set the properties of the pawl and ratchet to 'Ice'

Pin the rectangle and the rachet together or to other objects that rotate. If you need a number of objects that ratchet around a single point then you only need one ratchet wheel with numerous pawls.

Enjoy!

Image
Attachments
Ratchet Example
Ratchet Example
Ratchet.gif (3.14 KiB) Viewed 10596 times
User avatar
ken_behrendt
Addict
Addict
Posts: 3487
Joined: Wed Mar 02, 2005 7:45 am
Location: new jersey, usa
Contact:

re: Working Models Ratchet Making Code

Post by ken_behrendt »

Jim...

I gave it a try and your code worked perfectly! Below is my first "coded" ratchet...it was a LOT easier make and more precise than trying to assemble one from individual pieces.

ken

P.S. Of course, I am still not convinced that Bessler's wheels actually used ratchets. However, if I change my mind in the future, it's nice to know how to make them...
Attachments
Your Script code makes ratchets easy...
Your Script code makes ratchets easy...
On 7/6/06, I found, in any overbalanced gravity wheel with rotation rate, ω, axle to CG distance d, and CG dip angle φ, the average vertical velocity of its drive weights is downward and given by:

Vaver = -2(√2)πdωcosφ
User avatar
ME
Addict
Addict
Posts: 3512
Joined: Wed Jun 08, 2005 6:37 pm
Location: Netherlands

re: Working Models Ratchet Making Code

Post by ME »

We, Dutch-people, write Pi as 3,14159265 (watch the comma!!)
Microsoft Windows is a very nice program which helps us to read this kind of real-numbers in the right way. To make the story a bit shorter:
Your function gives back numbers in comma-format, but -to make our dutch lives a little bit better, WM2D wants numbers written with a point.

For those people who have the same problems, I have rewritten the function.

Code: Select all

Function Nmbr(ByVal Nr As Double) As String
Dim p As Integer
Dim T As String
  T = Format(Nr, "0.000")
  p = InStr(T, ",")
  If p > 0 Then Mid(T, p, 1) = "."
  Nmbr=T
End Function


Sub Main() 
 Ro = 1.000    'outside Radius 
 Td = 0.05     'Tooth depth 
 Ar = 0.250    'Angle relief 
 Nt = 60       'Number of teeth 
 CW = 1        'CW = 1 else = 0 for CCW 

 Rr = Ro - Td   'Root radius 
 T$ = "" 
 For a = 0 to 359 step 360 / Nt 
  If CW then 'Teeth point CW 
   T$ = T$ + Nmbr(Rr) + Chr(9) 
   T$ = T$ + Nmbr(a + Ar) 
   T$ = T$ + Chr(13) + Chr(10) 
    
   T$ = T$ + Nmbr(Ro) + Chr(9) 
   T$ = T$ + Nmbr(a) 
   T$ = T$ + Chr(13) + Chr(10)  
  Else      'Teeth point CCW 
   T$ = T$ + Nmbr(Ro) + Chr(9) 
   T$ = T$ + Nmbr(a) 
   T$ = T$ + Chr(13) + Chr(10)  

   T$ = T$ + Nmbr(Rr) + Chr(9) 
   T$ = T$ + Nmbr(a + Ar) 
   T$ = T$ + Chr(13) + Chr(10) 
  End If 
 Next 
 Clipboard.SetText T$ 
  
 T$ = "Data is in clipboard, ready to paste." 
 T$ = T$ + Chr$(13) + Chr$(10) + "Set Geometry "    
 T$ = T$ + "to 'Curved Body' and 'Shape coordinates'" 
 T$ = T$ + Chr$(13) + Chr$(10) 
 T$ = T$ + "then click 'Paste' and unclick 'Curved Body'." 
 Msgbox T$ 

End Sub 
Don't make me start to explain how we have to deal with the date format (mm-dd-yyyy)
Last edited by ME on Sun Aug 07, 2005 9:06 pm, edited 1 time in total.
Marchello E.
-- May the force lift you up. In case it doesn't, try something else.---
graham
Devotee
Devotee
Posts: 1050
Joined: Sun Jul 04, 2004 3:49 pm
Location: connecticut usa

re: Working Models Ratchet Making Code

Post by graham »

Jim, when you say "Make a polygon" , do you mean make a right angled triangle ?
I've tried your code and so far have NOT had the success that our friend Ken has had .
I copied and your code and got lost somewhere along the way because When I tried to paste where Ken did I came up with a message telling me something about not being able to convert my paste into proper values.

Where am I going wrong ??

Thanks,

Graham
User avatar
ME
Addict
Addict
Posts: 3512
Joined: Wed Jun 08, 2005 6:37 pm
Location: Netherlands

re: Working Models Ratchet Making Code

Post by ME »

Thanx to this idea of Jim I am starting to learn how to program WM2D...

So here is some code without copy/paste:

Code: Select all

Dim Doc		as WMDocument

'__________________________________________________________

FUNCTION Ang( ByVal Percentage as Double ) as Double
'==============================
' In:  Percentage of a circle
' Out: Angle in Radians
'==============================

	Ang = Percentage * 2 * Pi
END FUNCTION

'__________________________________________________________

FUNCTION Ratchet( X,Y, Ro, Td, Ar, Nt, CW )
'===========================================
'  Create Ratchet
'
' X   - Horizontal Location
' Y   - Vertical Location
' Ro  - outside Radius 
' Td  - Tooth depth 
' Ar  - Angle relief 
' Nt  - Number of teeth 
' CW  - 1:ClockWise, 0:CounterClockWise
'===========================================

Dim Body     as WMBODY


	Rr = Ro - Td   'Root radius 
	VC = 0         ' Vertex count


Set Body = Doc.NewBody("polygon")
	Body.PX.Value = X: Body.PY.Value = Y

	For a = 0 to 359 step 360/Nt
		if CW then ' Teeth point CW
			Vc=Vc+1 : Body.AddVertex VC, Rr*cos(Ang(a+Ar)/360), Rr*sin(Ang(a+Ar)/360)
			Vc=Vc+1 : Body.AddVertex VC, Ro*cos(Ang(a/360)),    Ro*sin(Ang(a/360))
		else       ' Teeth point CCW
			Vc=Vc+1 : Body.AddVertex VC, Ro*cos(Ang(a/360)),    Ro*sin(Ang(a/360))
			Vc=Vc+1 : Body.AddVertex VC, Rr*cos(Ang(a+Ar)/360), Rr*sin(Ang(a+Ar)/360)
		end if
	Next a

	' delete three default vertices
	Body.DeleteVertex Vc+3  
	Body.DeleteVertex Vc+2
	Body.DeleteVertex Vc+1

End Function

'__________________________________________________________

Sub Main()
'====================
'       MAIN 
'====================

  Set Doc   = WM.ActiveDocument 

  ok=Ratchet( 0,0, 1.000, 0.05, 0.25, 60, 1)

end sub
Marchello E.
-- May the force lift you up. In case it doesn't, try something else.---
User avatar
Tinhead
Enthusiast
Enthusiast
Posts: 162
Joined: Wed Nov 05, 2003 7:56 pm
Location: New Zealand
Contact:

re: Working Models Ratchet Making Code

Post by Tinhead »

scraehmmm .. and here with input dialog box.
Just a quick mixup, no error checking or else.

copy the unzipped script into the Workingmodel/Script folder and after a restart of WM2D it will show up in the Script menu ;o)

Cheers,
Rainer
Attachments
the dialog
the dialog
copy to this folder !
copy to this folder !
Create_Ratchet.zip
Ratchet creator script
(1.35 KiB) Downloaded 538 times
User avatar
ME
Addict
Addict
Posts: 3512
Joined: Wed Jun 08, 2005 6:37 pm
Location: Netherlands

re: Working Models Ratchet Making Code

Post by ME »

Cool! That makes it even better.
Is there a way to create such a dialog, or is it handcoded?

btw: I have the Demo-version
Marchello E.
-- May the force lift you up. In case it doesn't, try something else.---
User avatar
Ed
Addict
Addict
Posts: 2049
Joined: Mon Jul 26, 2004 7:13 pm
Contact:

re: Working Models Ratchet Making Code

Post by Ed »

In the script editor, go to the Edit menu and select Insert New Dialog.
User avatar
Tinhead
Enthusiast
Enthusiast
Posts: 162
Joined: Wed Nov 05, 2003 7:56 pm
Location: New Zealand
Contact:

re: Working Models Ratchet Making Code

Post by Tinhead »

Ed already mentioned where to find it :o)

Further more: If you go to the folder
../Program Files/Workingmodel/Program

you will find several xxx.HLP files in there. DG.HLP explains the dialog boxes, but also check the other ones. Quite useful.

Cheers,
Rainer

P.S. I'm using the demo version too, thats why I need those scripts so desperately ;o)
User avatar
ken_behrendt
Addict
Addict
Posts: 3487
Joined: Wed Mar 02, 2005 7:45 am
Location: new jersey, usa
Contact:

re: Working Models Ratchet Making Code

Post by ken_behrendt »

Tinhead...

I tried your code and it also works great! However, it would really be cool if there was some way of making an icon or tool appear on the Workspace side or top bar that could bring up that ratchet parameter box without having to go through the Script Editor...

Anyway, here's my second coded ratchet which was made to be 3 ft in diameter with 12 teeth...

ken
Attachments
Works better that trying to assemble a ratchet from pieces...
Works better that trying to assemble a ratchet from pieces...
On 7/6/06, I found, in any overbalanced gravity wheel with rotation rate, ω, axle to CG distance d, and CG dip angle φ, the average vertical velocity of its drive weights is downward and given by:

Vaver = -2(√2)πdωcosφ
User avatar
Tinhead
Enthusiast
Enthusiast
Posts: 162
Joined: Wed Nov 05, 2003 7:56 pm
Location: New Zealand
Contact:

re: Working Models Ratchet Making Code

Post by Tinhead »

Hi Ken,

I have no idea if you can add custom icons to the toolbars, but if you copied the script to the location I specified it should show up when you open the script menu.

Cheers,
Rainer
Attachments
Should be here
Should be here
bluesgtr44
Devotee
Devotee
Posts: 1970
Joined: Sat Feb 26, 2005 8:31 pm
Location: U.S.A.

re: Working Models Ratchet Making Code

Post by bluesgtr44 »

WOW! this worked great for me, tinhead and ME! Do you have any other designs you could post this way? How about a ring made from a polygon?


Steve
Finding the right solution...is usually a function of asking the right questions. -A. Einstein
User avatar
Ed
Addict
Addict
Posts: 2049
Joined: Mon Jul 26, 2004 7:13 pm
Contact:

Re: re: Working Models Ratchet Making Code

Post by Ed »

Tinhead wrote:Ed already mentioned where to find it :o)
I don't see where you mentioned the generic creation of dialog boxes (the question) in WM2D...you only described how to run the script in the Editor.

-Ed
User avatar
ME
Addict
Addict
Posts: 3512
Joined: Wed Jun 08, 2005 6:37 pm
Location: Netherlands

re: Working Models Ratchet Making Code

Post by ME »

Do you have any other designs you could post this way? How about a ring made from a polygon?
Sorry but you can't create a ring (a circle with a hole in it)

But in case you want something... try this.
Run the script, and run the simulation.. it's fun!! but not a perfect ring

Code: Select all

'=====================================
' Working Model Script
'
' Scriptname: MakeRing
' Function  : Polygon Ring Creation
' Version   : 1.0
'
' Copyright : (c)2005 ME-Designs 
' Programmer: Marchello E
' Date      : Aug 9 2005
'======================================
'__________________________________________________________

Dim Doc		as WMDocument
'__________________________________________________________

FUNCTION Ang( ByVal Percentage as Double ) as Double
'==============================
' In:  Percentage of a circle
' Out: Angle in Radians
'==============================

	Ang = Percentage * 2 * Pi
END FUNCTION

'__________________________________________________________

FUNCTION MakeBlock(            _
	ByVal X			as Double, _ '  X-position
	ByVal Y			as Double, _ '  Y-position
	ByVal W			as Double, _ '  Width
	ByVal H			as Double, _ '  Height
	ByVal Pin		as Boolean _ '  IsPinned
	)
'==============================
' Make simple Circle
'==============================

Dim Block   as WMBODY
Dim Anchor1	as WMConstraint

	Set Block = Doc.NewBody("rectangle")

	Block.Name        = "Floor"

	Block.PX.Value    = X
	Block.PY.Value    = Y
	Block.Width.Value = W
	Block.Height.Value = H

	If Pin then
		'// Don't know how to do an Anchor... yet

		Set Anchor1 = Doc.NewConstraint("pin")
		Set	Anchor1.Point(1).Body = Block
		Anchor1.Point(1).PX.Value = 0
		Anchor1.Point(1).PY.Value = 0

   		Anchor1.Point(2).PX.Value = X
		Anchor1.Point(2).PY.Value = Y

	end if

END FUNCTION

'__________________________________________________________

FUNCTION MakeCircle(            _
	ByVal X			as Double, _ '  X-position
	ByVal Y			as Double, _ '  Y-position
	ByVal R			as Double  _ '  Radius
	)
'==============================
' Make simple Circle
'==============================

Dim Circle   as WMBODY

	Set Circle = Doc.NewBody("circle")

	Circle.Name        = "Ring Circle"

	Circle.PX.Value    = X
	Circle.PY.Value    = Y
	Circle.Radius.Value= R

END FUNCTION

'__________________________________________________________

Function MakeRing(				 _
	ByVal X			  as Double, _ '  Position X
	ByVal Y           as Double, _ '  Position Y
	ByVal InnerRad    as Double, _ '  Outer Radius
	ByVal OuterRad    as Double, _ '  Inner Radius
	ByVal N			  as Integer _ '  Number of Radial points
	)
'===========================================
'   Try to make a ring
'===========================================

Dim Ring   as WMBODY
Dim i	   as Integer 
Dim Vc	   as Integer ' Vertex counter

Dim MidRad as Double: MidRad=(InnerRad*1+OuterRad*3)/4 ' Try something here

	Set Ring = Doc.NewBody("polygon")

	Ring.PX.Value = X
	Ring.PY.Value = Y
	Ring.Name     = "Ring"

    '----------------------
	' Draw Outer circle
	'----------------------
	For i = 0 to N            '** Maybe: 0 to N-1
		Vc=Vc+1 : Ring.AddVertex VC, OuterRad*cos(Ang(i/N)), OuterRad*sin(Ang(i/N))
	Next i

    '----------------------------
	' Try to make a 'good' corner
	'----------------------------

	Vc=Vc+1 : Ring.AddVertex VC, MidRad*cos(Ang(0.25/N)), MidRad*sin(Ang(0.25/N))

    '----------------------
	' Draw Inner circle
	'----------------------

	For i = N to 0 step -1    '** Maybe: N-1 to 0 step -1
		Vc=Vc+1 : Ring.AddVertex VC, InnerRad*cos(Ang(i/N)), InnerRad*sin(Ang(i/N))
	Next i

    '----------------------------
	' Try to make a 'good' corner
	'----------------------------

	Vc=Vc+1 : Ring.AddVertex VC, MidRad*cos(Ang(-0.25/N)), MidRad*sin(Ang(-0.25/N))

	'------------------------------
	' delete three default vertices
	'------------------------------
	for i=1 to 3
		Ring.DeleteVertex Vc+1
	next i
	Ring.Curved=True ' Undocumented property (-: found in DLL file :-) // what about colors?

End Function

'__________________________________________________________

Sub Main()
'====================
'       MAIN 
'====================
 Set Doc   = WM.ActiveDocument 

	ok=MakeRing  ( 0, 0,   1.5,  1,  50)   '// My ring attempt


	' ok=MakeCircle( 0, 0,   0.95 )        '// Almost as big as the inner circle

	ok=MakeCircle( 0.49, 0,    0.5 )   
	ok=MakeBlock(  0.21546096,   -1.8,  5, 0.5,  True )   

end sub
Marchello E.
-- May the force lift you up. In case it doesn't, try something else.---
User avatar
Ed
Addict
Addict
Posts: 2049
Joined: Mon Jul 26, 2004 7:13 pm
Contact:

Re: re: Working Models Ratchet Making Code

Post by Ed »

Tinhead wrote:Ed already mentioned where to find it :o)
Tinhead, sorry...I don't know what I was on when I wrote my previous response! I thought you were saying you (Tinhead) already said where to find it, instead of that I (Ed) already mentioned it. :-)

I need to get the oil changed on my eyeballs!

-Ed
Post Reply