NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
November 18, 2017, 09:49:29 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
The softest thing overcomes the hardest thing in the universe. ...Lao Tzu (570-490 BC)
Google Bookmarks Yahoo My Web MSN Live Netscape Del.icio.us FURL Stumble Upon Delirious Ask FaceBook

Pages: [1]   Go Down
  Print  
Author Topic: what is the elegant way to make EJS measure a true period of an oscillation?  (Read 6649 times)
0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
on: January 13, 2009, 11:07:15 am » posted from:SINGAPORE,SINGAPORE,SINGAPORE

what is the elegant way to make EJS measure a true period of an oscillation?

I want to make a pendulum to measure the true period.

i tried

if ( omega < 0.001 & omega > -0.001 ) {  // my inital idea how to detect the end points of the oscillation
  count = count+1;  // make count increase by 1 if condition met
}


if (  count ==2 ) {  // count =2
  T1 = t ;  // T1 = t
}

it doesn't work.

any tips work to do it?
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #1 on: January 13, 2009, 04:35:24 pm » posted from:Taipei,T'ai-pei,Taiwan

1. The AND operator operator you want is && not &.
 & is bitwise AND

2.
Code:
if ( omega < 0.001 && omega > -0.001 ) 
is not a good condition
What if acceleration is very small, omega still smaller then 0.001 in two or more time step.
And if the pendulum starts with omega=0, you might get half period only.

What about define a omegas to store previous omega and change the condition to

Code:
if( omega*omegas<0){
 count=count+1;
}
omegas=omega;/save old value
if(count==2){
 T=t-ts;// period=time differences, not necessary starts from t=0
 ts=t;
 count=0;//you need to reset the counter, unless you only want to calculate the first period
}
However, the above code work only if the pendulum starts with omega=0;
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #2 on: January 13, 2009, 10:00:43 pm »

indeed an elegant/clever way to find true period.

thanks!

will try to implement into my pendulum asap

if( omega*omegas<0){
 count=count+1;
}
omegas=omega;//save old value
if(count==2){
 T=t-ts;// period=time differences, not necessary starts from t=0
 ts=t;
 count=0;//you need to reset the counter, unless you only want to calculate the first period
}

will update my progress on your forum soon Smiley
« Last Edit: January 14, 2009, 03:41:47 pm by lookang » Logged
Pages: [1]   Go Up
  Print  
The softest thing overcomes the hardest thing in the universe. ...Lao Tzu (570-490 BC)
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
How to measure friction coefficient
Dynamics
Fu-Kwun Hwang 0 28389 Last post June 08, 2005, 09:08:06 am
by Fu-Kwun Hwang
How to make for Trail to connected true for angle 0 to 360 but not jump 360-0?
Questions related to EJS
lookang 1 4151 Last post December 11, 2009, 04:07:04 pm
by Fu-Kwun Hwang
Driven pendulum (forced oscillation)
Dynamics
Fu-Kwun Hwang 0 6412 Last post April 24, 2010, 02:48:14 pm
by Fu-Kwun Hwang
What is the distribution of period if the velocity are distributed linearly.
Kinematics
Fu-Kwun Hwang 0 5008 Last post May 24, 2010, 02:49:11 pm
by Fu-Kwun Hwang
What is the distribution of period if the velocity are distributed linearly.
kinematics
ahmedelshfie 0 2453 Last post May 25, 2010, 05:42:45 pm
by ahmedelshfie
Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.067 seconds with 22 queries.since 2011/06/15