APS Excellence in Physics Education Award
November 2019

Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

Import data to EJS post and replies

Return to the Import data to EJS thread
Login to post to this thread

Import data to EJS
Felix Yepez
6 Posts

I am interested working with EJS. I want to make an analysis of the vibrations in a DC motor shaft, i have already acquired data (signal 4 to 20 mA)  from proximity sensors located in the longitudinal and radial axis of the motor shaft. My system allows me to export data in csv, xls or txt.

My question is, Can I import the data directly into EJS and perform my simulation? (i want to make a Fourier analysis, orbit diagram and other graphics and then access them remotely via internet). I've read that it can be done in cooperation with Matlab. What do you recommend? What would be the most reliable solution?


Replies to Import data to EJS

Re: Import data to EJS -
Francisco Esquembre
237 Posts

Sure. You can read data either from the disk or from a URL on the Internet.

The attached example shows how to do it. (It also shows how to write data to disk.)

The example uses a plain TeXT file.

Notice that accusing disk is only possible when running the Java simulation as a program (JAR file), not as an applet.

Reading from the Internet (from a URL) is possible also as an applet, though.

Paco

Attached File: ejs_src_WritingAndReadingASCII.zip



Re: Re: Import data to EJS -
Felix Yepez
6 Posts

How do I read data located in a TXT file on hard drive?

With the attached file I could only read data entered manually into the program but not from a specific direction.



Re: Re: Re: Import data to EJS -
Francisco Esquembre
237 Posts

Sorry. You did not attach a file.

In Java, it is possible, if you run as application. See example attached. Not if you run as applet.

In Javascript, it is difficult, but nor impossible. Working on it...

Paco



Re: Re: Re: Re: Import data to EJS -
Francisco Esquembre
237 Posts

Here is the example in Java! I forgot it!

Paco

Attached File: ejs_src_WritingAndReadingASCII1.zip



OSP Projects:
Open Source Physics - EJS Modeling
Tracker
Physlet Physics
Physlet Quantum Physics
STP Book