Author Topic: A real time clock created with EJS4  (Read 40430 times)

Fu-Kwun Hwang

  • Administrator
  • Hero Member
  • *****
  • Posts: 3062
    • Enjoy the fun of physics with simulations
A real time clock created with EJS4
« on: February 20, 2009, 11:01:59 pm »
This applet is created with EJS 4. You can find out how to find information about world time with java.
-*-

Full screen applet or Problem viewing java?Add http://www.phy.ntnu.edu.tw/ to exception site list
Press the Alt key and the left mouse button to drag the applet off the browser and onto the desktop. This work is licensed under a Creative Commons Attribution 2.5 Taiwan License
  • Please feel free to post your ideas about how to use the simulation for better teaching and learning.
  • Post questions to be asked to help students to think, to explore.
  • Upload worksheets as attached files to share with more users.
Let's work together. We can help more users understand physics conceptually and enjoy the fun of learning physics!

chumunroshan

  • Newbie
  • *
  • Posts: 4
Re: A real time clock created with EJS4
« Reply #1 on: February 22, 2009, 11:59:14 pm »
thanks. that was very useful

lookang

  • Hero Member
  • *****
  • Posts: 1772
  • http://weelookang.blogspot.com
    • lookang web
Re: A real time clock created with EJS4
« Reply #2 on: February 24, 2009, 10:08:32 am »
i have discussion of collection of clock telling time digital interactive over here http://66.7.205.91/~lookangc/index.php?topic=333.msg752#msg752

some of the people here might be interested to look at them to get good ideas/features to modify the EJS open source version by Prof. Fu-Kwun Hwang

EJS could be a future platform for virtual labs/simulations for collaborations under creative commons licenses.
« Last Edit: February 24, 2009, 12:04:09 pm by lookang »

lookang

  • Hero Member
  • *****
  • Posts: 1772
  • http://weelookang.blogspot.com
    • lookang web
Re: A real time clock created with EJS4
« Reply #3 on: June 02, 2011, 02:12:00 pm »
strange when i download the source xml and recompile it in Ejs 4.3.31 or 4.27.

on drag of the sliders, the clock goes all over the clock unlike the version above.

any idea what is wrong? ;D

Full screen applet or Problem viewing java?Add http://www.phy.ntnu.edu.tw/ to exception site list
Press the Alt key and the left mouse button to drag the applet off the browser and onto the desktop. This work is licensed under a Creative Commons Attribution 2.5 Taiwan License
  • Please feel free to post your ideas about how to use the simulation for better teaching and learning.
  • Post questions to be asked to help students to think, to explore.
  • Upload worksheets as attached files to share with more users.
Let's work together. We can help more users understand physics conceptually and enjoy the fun of learning physics!

lookang

  • Hero Member
  • *****
  • Posts: 1772
  • http://weelookang.blogspot.com
    • lookang web
Re: A real time clock created with EJS4
« Reply #4 on: August 22, 2011, 05:05:03 pm »
Dear Prof Hwang,

I tried to remix the clock.

but i could not replicate the drag on of the minute and hour hand in your simulation model to have a second hand drag-able with the perfect transition of the second hand from 1 to 59. I have created a second hand drag-gable ( http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=2276.0 ) but with bugs i cannot eliminated thus, i seek your help :)

i do not understand the codes inside the minute hand and the hour hand.
for example: in the minute hand
ctam=Math.atan2(mx,my);// ctaangle of minute hand
if(ctam<0)ctam+=pi2;
vm=(int)(ctam/pi2*T);
if(Math.abs(vm-vms)>40.){// why 40? arbitrary
 if(vms<30){ // why 30? i thought it should be 60 minutes?
   vh=vh-1; // original was vh+=1; i think
   testm=-1; // my codes to debug which lines is executed
   }
 else if(vms>30){ // why 30? i thought it should be 60 minutes?
   vh=vh+1;
   testm=1; // my codes to debug which lines is executed
   }
 if(vh==12 || vh==0){ // this should not impact the drag right? i have not implemented it
  if(hadd>0)hadd=0;
  else hadd=12;
  if(hours24)vh2=vh+hadd;
  }
}
set();
//cta=(vs+vm*60+vh*3600*5)*pi2/T;

where
public void set () {
vs=vs+vm*60+vh*3600*5;
cta=vs*pi2/T;
}


could i request 1 thing? ;D

an add-on to your simulation to have the second hand drag-gable without the bugs i have created in my remixed sim found here http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=2276.0

please add some useful comments lines // so i can follow the program logic more closely to your thoughts.
Thanks!!


« Last Edit: August 22, 2011, 05:15:13 pm by lookang »

Fu-Kwun Hwang

  • Administrator
  • Hero Member
  • *****
  • Posts: 3062
    • Enjoy the fun of physics with simulations
Re: A real time clock created with EJS4
« Reply #5 on: August 23, 2011, 01:38:22 am »
The angle for minute hand is vm, vms is previous angle 

Quote
if(vms<30){ // why 30? i thought it should be 60 minutes?

ctam=Math.atan2(mx,my);
vm=(int)(ctam/pi2*T);

The angle is zero degree when value for minute is 15.
The angle for minute=0 is 30 degree.

 if(vms<30)vh--;// counterclockwise rotating so hour value decrease by 1: vh-- is the same as vh=vh-1;
 else if(vms>30)vh++;// clockwise rotating  so hour value increase by 1: vh++ is the same as vh=vh+1;

if(Math.abs(vm-vms)>40.){// this is related to how fast user drag it, the value was found by try and error (I think)

lookang

  • Hero Member
  • *****
  • Posts: 1772
  • http://weelookang.blogspot.com
    • lookang web
Re: A real time clock created with EJS4
« Reply #6 on: August 23, 2011, 02:11:28 pm »
dear prof!

i discovered a bug that i cannot solve alone.
maybe you can see if it can be solve?
attached is the animated gif
the bug occurs when the hand hour is drag pass the 12 mark, to the left can produced the bug ( the hour hand jumps to 11 instead of staying at 12)

thanks!

i also noticed if the user drag the hour hand pass the 12 mark left and right a few times
the time appears to have another bug as the time change from 11.59 AM to 12.01 PM and turn back, it should be 11.59AM but the bug remains it at 11.59 PM.
do you notice that too :)

for ur info
i look forward to any bug fixes  :D
« Last Edit: August 23, 2011, 02:16:14 pm by lookang »

lookang

  • Hero Member
  • *****
  • Posts: 1772
  • http://weelookang.blogspot.com
    • lookang web
Re: A real time clock created with EJS4
« Reply #7 on: August 29, 2016, 06:11:02 pm »
dear prof hwang,

i found a bug when time is say time is HR : MM : SS

when MM =59 and SS = 59
clock is suppose to be HR = HR +1 when SS becomes 60 in the next time step dt.

but instead the HR jumps back to HR causing the clock to be trap in a infinite loop of HR.


attached is my ejss source and model files

can you fix the bug on your ejs (so i can examine your solution) or my ejss(so i can continue building it)?

thanks!
« Last Edit: August 29, 2016, 06:13:14 pm by lookang »

Fu-Kwun Hwang

  • Administrator
  • Hero Member
  • *****
  • Posts: 3062
    • Enjoy the fun of physics with simulations
Re: A real time clock created with EJS4
« Reply #8 on: August 31, 2016, 12:26:53 pm »
Please check out the following

Full screen applet or Problem viewing java?Add http://www.phy.ntnu.edu.tw/ to exception site list
Press the Alt key and the left mouse button to drag the applet off the browser and onto the desktop. This work is licensed under a Creative Commons Attribution 2.5 Taiwan License
  • Please feel free to post your ideas about how to use the simulation for better teaching and learning.
  • Post questions to be asked to help students to think, to explore.
  • Upload worksheets as attached files to share with more users.
Let's work together. We can help more users understand physics conceptually and enjoy the fun of learning physics!

lookang

  • Hero Member
  • *****
  • Posts: 1772
  • http://weelookang.blogspot.com
    • lookang web