tags:

views:

90

answers:

4

I use a photoelectric cell to time an event in a response time experiment. It works well in Matlab, but I wanted to control it in R. Would any of you be able to help me translate the Matlab code to R?

global AI ch0
AI = analoginput('nidaq', 1);
AI.InputType = 'SingleEnded';
ch0 = addchannel(AI,0);

Thanks!

+1  A: 

R does not support any kind of direct interaction with DAQ devices (at least for now). The only option you have is to write some C code to do this and bind it to R.

mbq
Or alternatively in Python + SciPy.
Hamish Grubijan
@Hamish If you think about ctyping niDAQ library, it is equivalent job to the hack that has to be done with R.
mbq
@mbq - it depends on how complicated the needs are.http://www.scipy.org/Cookbook/Data_Acquisition_with_NIDAQmxFor a real-time system it might be worthwhile grabbing data using a C module running atop RTLinux, then spitting it out to a file located on in-ram file system, then letting another program like Python+SciPy process it (as long as it can keep up with the buffer of data that is being collected).
Hamish Grubijan
+1  A: 

Write National Instruments and ask them to make an R package for their I/O devices. :)

John
+1 for boldness, unfortunatley -Inf for this working....
PaulHurleyuk
They would have said it about Mac support in the at the turn of the century. :) - (former NI junkie who will never touch the stuff again)
John
Don't want to be the party pooper, but shouldn't this be a comment?
Joris Meys
+2  A: 

You could play around with the R.matlab package. This allows you to read your MAT files in R, so you could simply save the input and analyse it in R. Alternatively, you could interact directly between Matlab and R. I didn't try it out before, but it should be possible to call the matlab code from within R. The provided manual on CRAN shows you how.

http://cran.r-project.org/web/packages/R.matlab/index.html

Joris Meys
+2  A: 

There is a program called windmill:

http://www.windmill.co.uk/index.html

(windows only I think) that interacts with serial devices, you could probably use that to get the information from your device to a file or pipe and then have R read from there.

You could also do a search for "gps" at rseek or in the R-help archives, there have been a few times that people have posted questions and answers about reading location information directly from gps devices into R, some of those replies may work for you as well.

Greg Snow

related questions