ImageJ + Arduino Uno = no communications

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

ImageJ + Arduino Uno = no communications

Steve Nanchy
Has anyone had any success communicating with an Arduino microcontroller with ImageJ (yes, I know MicroManager is supposed to be able to do it, but MM can't be used at the current time).

I'd like to use the "Serial port Macro Extensions" plugin (http://imagejdocu.tudor.lu/doku.php?id=plugin:utilities:serial_macro_extensions:start from http://rsbweb.nih.gov/ij/plugins/index.html) to communicate with an Arduino Uno to grab analog voltages while capturing images at various times.  I seem to have things properly set now so that I can still run the Arduino development environment to program my board while having ImageJ open for interactive troubleshooting, but while the plugin's instructions tell the user how to address the port ('COM1', 'COM2', etc.) under Windows, there's no mention of the proper syntax to use under Mac OS X (running 10.6.5).

I've tried the usual "/dev/tty.usbmodem1d11" (usual for OS X; "COMx" doesn't work either) and some variations, but it doesn't seem to want to cooperate.
The macro doesn't crash, so I can figure I have no port conflicts - I'm just not specifying it properly to the plugin.

Sample macro I'm using (while the Uno is slamming out ASCII characters 20h-7Fh followed by a 10h, at 9600/8/N/1):
run("serial ext");
Ext.open("/dev/tty.usbmodem1d11",9600,"");  //or: Ext.open("COM1",9600,"");
ports = Ext.ports();  print("ports  ="+ports+".");
active = Ext.active();  print("active  ="+active+".");
data = Ext.read();  print("data  ="+data+".");


'Log' window results:
ports  =.
active  =0.
data  =.
(the periods show me there are no hidden characters)


Comments?  Ideas?  Fixes?  Thanks.

________________________________

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the named addressee you should not disseminate, distribute, retain, or copy this e-mail or any attachments. If you have received this email in error please delete and notify the sender.
Reply | Threaded
Open this post in threaded view
|

Re: ImageJ + Arduino Uno = no communications

Jerome Mutterer-3
Stephen,

Do you have the arduino working fine in the Arduino environment ? If yes,
you can find out the exact port name in the Arduino menu Tools>Serial Port.
When upgrading the the Uno, I had the replace the RXTX library by the one
distributed with the Arduino software (look in the Arduino.app package).

Let me know if this works in your case.

Jerome


On Tue, Jan 18, 2011 at 12:14 AM, Nanchy III, Stephen <
[hidden email]> wrote:

> Has anyone had any success communicating with an Arduino microcontroller
> with ImageJ (yes, I know MicroManager is supposed to be able to do it, but
> MM can't be used at the current time).
>
> I'd like to use the "Serial port Macro Extensions" plugin (
> http://imagejdocu.tudor.lu/doku.php?id=plugin:utilities:serial_macro_extensions:startfrom
> http://rsbweb.nih.gov/ij/plugins/index.html) to communicate with an
> Arduino Uno to grab analog voltages while capturing images at various times.
>  I seem to have things properly set now so that I can still run the Arduino
> development environment to program my board while having ImageJ open for
> interactive troubleshooting, but while the plugin's instructions tell the
> user how to address the port ('COM1', 'COM2', etc.) under Windows, there's
> no mention of the proper syntax to use under Mac OS X (running 10.6.5).
>
> I've tried the usual "/dev/tty.usbmodem1d11" (usual for OS X; "COMx"
> doesn't work either) and some variations, but it doesn't seem to want to
> cooperate.
> The macro doesn't crash, so I can figure I have no port conflicts - I'm
> just not specifying it properly to the plugin.
>
> Sample macro I'm using (while the Uno is slamming out ASCII characters
> 20h-7Fh followed by a 10h, at 9600/8/N/1):
> run("serial ext");
> Ext.open("/dev/tty.usbmodem1d11",9600,"");  //or: Ext.open("COM1",9600,"");
> ports = Ext.ports();  print("ports  ="+ports+".");
> active = Ext.active();  print("active  ="+active+".");
> data = Ext.read();  print("data  ="+data+".");
>
>
> 'Log' window results:
> ports  =.
> active  =0.
> data  =.
> (the periods show me there are no hidden characters)
>
>
> Comments?  Ideas?  Fixes?  Thanks.
>
> ________________________________
>
> This email and any files transmitted with it are confidential and intended
> solely for the use of the individual or entity to whom they are addressed.
> If you are not the named addressee you should not disseminate, distribute,
> retain, or copy this e-mail or any attachments. If you have received this
> email in error please delete and notify the sender.
>
Reply | Threaded
Open this post in threaded view
|

Re: ImageJ + Arduino Uno = no communications

Bill Christens-Barry
In reply to this post by Steve Nanchy
Stephen,

Once you've identified the port for the Arduino, can you communicate with it from a terminal? If you can, then macro code I use with Mac OS 10.6.6 to suss out and converse with an mbed device might help:


    print("\\Clear");
    run("serial ext");
    ports = Ext.ports();
    print(lengthOf(ports));
    indSDL = indexOf(ports, ";");
    firstPort = substring(ports, 0, indSDL);
    print(firstPort);
    Ext.open(firstPort, 9600, "DATABITS_8 STOPBITS_1 PARITY_ODD");
    for (i = 0;i < 20; i++) {
        Ext.write("something" + fromCharCode(13, 10));
        wait(20);
        resp = Ext.read();
        print(i + "   something ==> " + resp);
    }
    Ext.close();

This code was able to print (line 7) the correct identity of an Arduino Mega just now, although the writes and reads weren't appropriate for this device.

Note that the syntax of the Ext.open() command is different from what you show, although this is downstream of identifying the device. Note also that this presumes that the Arduino shows up as the first device in the ports list; otherwise, or if you have multiple devices, you need to work through the list.

hth...

Bill Christens-Barry
Reply | Threaded
Open this post in threaded view
|

Re: ImageJ + Arduino Uno = no communications

gerrit
In reply to this post by Jerome Mutterer-3
you can see which ports are available from a terminal session by typing:

ls /dev/tty.*

kindly,
Gerrit.
Reply | Threaded
Open this post in threaded view
|

Re: ImageJ + Arduino Uno = no communications

Steve Nanchy
In reply to this post by Steve Nanchy
Thanks for all the replies.  I've tried things but am no closer to a solution..

Jerome: the Arduino app works fine as it is.  I'd done that install when upgrading to version 022.  As long as the 'RXTXcomm.jar' and 'librxtxSerial.jnilib' are located in my /Library/Java/Extensions/ folder (which ImageJ requires to do any serial port operations) the Arduino doesn't work - it will show that ANY port specified in the Arduino app's 'Tools/Serial Port' menu is "in use by another application.  try quitting... etc.".

Bill: see above.  Also, (using IJ v1.44n) your macro prints a zero and crashes on line 6 (since indSDL returns a -1).  IJ (using this RXTX) doesn't seem to be seeing ANY ports - modem, bluetooth, anything.

Gerrit: thanks. I know what one.  all the ports show up (even tty.usbmodem1d11 that the Arduino application uses) but nothing is 'seen' by IJ when it is instructed to look for ports.

Even having to quit one app to work with the other would be sufficient for my work - it isn't really necessary to have them both open at the same time; which would make things easier when it comes to programming - but it seems like RXTX wants to take over everything (preventing Arduino from using any port) and then it doesn't SEE any ports.  I've also tried connecting my (known good) Keyspan USB<>RS-232 adapter and it is also not seen by IJ.  But Arduino and Keyspan are both recognized by System Profiler, so the machine knows they are there.
Reply | Threaded
Open this post in threaded view
|

Re: ImageJ + Arduino Uno = no communications

Bill Christens-Barry
In reply to this post by Steve Nanchy
Steve,

The macro code I gave works fine here whenever my Arduino Mega shows up in /dev. It also works fine using at least two other types of USB-connected microcontrollers.  On occasion I have seen the error message you saw, although I think this only happened when the device hadn't yet appeared or if I had previously left the port open by mistake. You could trap the indISL error by modifying the macro code.

It took me many tries to get RXTX working on my machine. What finally did it was apparently finding the right versions of the various pieces among many that purport to be right. I wonder if the problem lies there. It sounds as though you have no evidence that RXTX is working correctly - is this true?

Bill

{
Thanks for all the replies.  I've tried things but am no closer to a solution..

Jerome: the Arduino app works fine as it is.  I'd done that install when upgrading to version 022.  As long as the 'RXTXcomm.jar' and 'librxtxSerial.jnilib' are located in my /Library/Java/Extensions/ folder (which ImageJ requires to do any serial port operations) the Arduino doesn't work - it will show that ANY port specified in the Arduino app's 'Tools/Serial Port' menu is "in use by another application.  try quitting... etc.".

Bill: see above.  Also, (using IJ v1.44n) your macro prints a zero and crashes on line 6 (since indSDL returns a -1).  IJ (using this RXTX) doesn't seem to be seeing ANY ports - modem, bluetooth, anything.

Gerrit: thanks. I know what one.  all the ports show up (even tty.usbmodem1d11 that the Arduino application uses) but nothing is 'seen' by IJ when it is instructed to look for ports.

Even having to quit one app to work with the other would be sufficient for my work - it isn't really necessary to have them both open at the same time; which would make things easier when it comes to programming - but it seems like RXTX wants to take over everything (preventing Arduino from using any port) and then it doesn't SEE any ports.  I've also tried connecting my (known good) Keyspan USB<>RS-232 adapter and it is also not seen by IJ.  But Arduino and Keyspan are both recognized by System Profiler, so the machine knows they are there.
}
Reply | Threaded
Open this post in threaded view
|

Re: ImageJ + Arduino Uno = no communications

Michael Schmid
In reply to this post by Steve Nanchy
Hi Steve,

one problem that I have found with RXTX:

At least under Linux and Mac OS X, RXTX needs to write a lockfile to  
make sure that there are no access conflicts with other applications.  
Under OS X, this is usually in /var/lock. So you have to make sure  
that the directory /var/lock exists and the user running ImageJ has  
write access to this directory. With some RXTX versions, the lock  
files may be also in /var/spool/uucp.

See also
   http://rxtx.qbang.org/wiki/index.php/Trouble_shooting

Keyspan USB-Serial adapter: Under Mac OS X, and probably under most  
other operating systems, it needs a driver that is usually not  
present in the standard distribution of the operating system. Without  
installing the driver you won't see it as serial device.

Hope this helps,

Michael
________________________________________________________________

On 20 Jan 2011, at 20:02, Steve Nanchy wrote:

> Thanks for all the replies.  I've tried things but am no closer to  
> a solution..
>
> Jerome: the Arduino app works fine as it is.  I'd done that install  
> when upgrading to version 022.  As long as the 'RXTXcomm.jar' and  
> 'librxtxSerial.jnilib' are located in my /Library/Java/Extensions/  
> folder (which ImageJ requires to do any serial port operations) the  
> Arduino doesn't work - it will show that ANY port specified in the  
> Arduino app's 'Tools/Serial Port' menu is "in use by another  
> application.  try quitting... etc.".
>
> Bill: see above.  Also, (using IJ v1.44n) your macro prints a zero  
> and crashes on line 6 (since indSDL returns a -1).  IJ (using this  
> RXTX) doesn't seem to be seeing ANY ports - modem, bluetooth,  
> anything.
>
> Gerrit: thanks. I know what one.  all the ports show up (even  
> tty.usbmodem1d11 that the Arduino application uses) but nothing is  
> 'seen' by IJ when it is instructed to look for ports.
>
> Even having to quit one app to work with the other would be  
> sufficient for my work - it isn't really necessary to have them  
> both open at the same time; which would make things easier when it  
> comes to programming - but it seems like RXTX wants to take over  
> everything (preventing Arduino from using any port) and then it  
> doesn't SEE any ports.  I've also tried connecting my (known good)  
> Keyspan USB<>RS-232 adapter and it is also not seen by IJ.  But  
> Arduino and Keyspan are both recognized by System Profiler, so the  
> machine knows they are there.
Reply | Threaded
Open this post in threaded view
|

Re: ImageJ + Arduino Uno = no communications

Steve Nanchy
In reply to this post by Steve Nanchy
Than you Michael - I looked through the wiki previously and must have missed that:  I created /var/lock/ from root, set access to 'everybody', and IJ sees the Arduino fine now.  It's something to remember for the machine that will eventually run my macro...