ImageJ - Arduino Mega 2560 - problems with the serial communication

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

ImageJ - Arduino Mega 2560 - problems with the serial communication

nckrzan
Hi everybody,

This time I just want to share with You  the good and probably important
information. Last days I learn a much about Arduino. I already known how
to use it and how it can improve my proferssional and amateur (hobbies)
efficiency.

However, during the work I found the serious problem. The ImageJ could
easy connect with the Arduino (Mega 2560), but the information couldn't be
exchanged between the ImageJ and the Arduino.

Moreover, I found that similar problem was common, especially for the
modern Arduino models (Uno and Mega). Some people exchanged or upgrades
the serial libraries to solve it. Others just bought the oldest Arduino
models - "because the newest Mega's weren't fully compatible with the
previous Arduinos". // in their opinion....

I also have spent ours with the email lists, Web, books and other Arduino
documentations. At least few minutes ago I found important information in
the web:

http://www.arduino.cc/playground/Interfacing/Java

In the paragraph titled: "Transmitting data to the arduino from the
computer" the author wrote:

"In my experience, it seems that the Serial connection must be connected
somewhere above 1 second (I have 1.5 seconds in my program) before a
transmission can be made. It seems that for at least the atmega168 and
diecimila, doing so ensures your transmission actually is transmitted. For
doing that, Thread.sleep(delay) is used and delay is specified in
milliseconds so I would use Thread.sleep(1500) after the Serial port is
established. It seems this might be due to the program resetting when a
serial connection is made, and the program has a necessary setup time. "



After the reading I just add the long delay in my program. And Macro
started to work without any new problem.

Ext.open("COM3",9600,"");
wait(10000);   //   <--- this part is necessary, probably 2 or 3 second
          // will be enough, but at least "wait (2000)" in obligatory !!!
active = Ext.alive();
if (active == 1)
                btcs = "Connected";
        else btcs = "Not connected";
        print("Arduino connection status: " + btcs);

Ext.write("1");     // without delay the sending command are unrecognized by
                    //the  Arduino

I hope it help many of newest person, starting the work with the Arduino...

Best regards,

Marcel Krzan
Reply | Threaded
Open this post in threaded view
|

Interfacing ImageJ with Arduino: (was: ImageJ - Arduino Mega 2560 - problems with the serial communication)

Wolfgang Schechinger
Hi Marcel and everybody,

some more general information for interfacing ATMEGA CPU based Arduino microcontrolers (http://www.arduino.cc) with varius hard- and software may be found here:

http://arduino.cc/playground/Main/InterfacingWithHardware
http://arduino.cc/playground/Main/InterfacingWithSoftware

Hope this is useful for homemade data acquisition projects or controlling hardware from within ImageJ etc.

Have fun + enjoy!

Wo
--
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de