New oscilloscope for arduino (Mac only)

For previous history & correspondance, please see http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1256923269

Macintosh running with OS 10.4 (Tiger) and arduino-15 version.

Sketch downloaded from GitHub - alvieboy/arduino-oscope: A simple yet useful oscilloscope for arduino duemilanove

Mac Scope display java software downloaded from http://www.alvarolopes.com/resources/oscope/

RXTX package downloaded from RXTX for Mac OS X

ARDUINO SIDE

Two arduino boards have been tested.

Duamilanove with Atmega328: sketch compiles then dowloads correctly

Mega: sketch does not compiles due to following error

In function 'void setup_adc()':
PRR &= ~BIT(PRADC); /* Disable ADC power reduction */
error: 'PRR' was not declared in this scope

MAC SIDE

Created a folder on desktop containing:

arduino-oscope.jar
fixperm-217.sh
librxtxSerial.jnilib
RXTXcomm.jar

Opened a Mac terminal window then launched

$ cd Desktop     (or the folder where you downloaded the script)
$ sudo sh ./fixperm-217-leo.sh
Password: <your administrator password>

Then lauched $ java -jar arduino-oscope.jar which gave these results

Experimental:  JNI_OnLoad called.
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version   = RXTX-2.1-7
found /dev/tty.modem
found /dev/cu.modem
found /dev/tty.usbserial-A9007U6Z
found /dev/cu.usbserial-A9007U6Z
found /dev/tty.Nokia6131-NokiaPCSui-1
found /dev/cu.Nokia6131-NokiaPCSui-1
found /dev/tty.Nokia6131-Dial-upnetwor-2
found /dev/cu.Nokia6131-Dial-upnetwor-2
found /dev/tty.Bluetooth-PDA-Sync
found /dev/cu.Bluetooth-PDA-Sync
found /dev/tty.Bluetooth-Modem
found /dev/cu.Bluetooth-Modem
found /dev/tty.Nokia6131-NokiaPCSuite-1
found /dev/cu.Nokia6131-NokiaPCSuite-1

The Arduino Oscope was succesfully launched then selection of /dev/tty.usbserial-A9007U6Z giving this result on terminal shell

Select
RXTX Warning:  Removing stale lock file. /var/lock/LK.001.009.016
Port /dev/tty.usbserial-A9007U6Z open successfully
Pinging device

Moving a bit "trigger level" with mouse gives this result on terminal shell

New trigger 0
New trigger 2
New trigger 3
New trigger 5
New trigger 6
New trigger 8
New trigger 9
New trigger 11
New trigger 11
New trigger 11
New trigger 9
New trigger 6
New trigger 5
New trigger 3
New trigger 0
New trigger 0

Moving "holdoff samples" with mouse does not display anything on terminal shell.

Moving "prescaler" with mouse gives this result on terminal shell

New prescaler 5 (32)
New prescaler 7 (128)

Clicking "dual channel" seems to not work and gives this result on terminal shell

Num samples: 962
Invalid packet 135 in state PING, expecting 227

P.S. Double-clicking on "arduino-oscope.jar" icon lauches scope without need to lauch terminal.

Directly connecting 5V pin from duamilanove to Analog pin0 does not show any change on display so I'm not sure scope is working or if I've missed some set up on my Mac.

I wanted to insert Capture Screen Shot (JPEG) on this post but does not know how to do it ?

Thank you in advance

Hi,

PRR &= ~BIT(PRADC); /* Disable ADC power reduction */

You can comment out that line.

RXTX Warning:  Removing stale lock file. /var/lock/LK.001.009.016

Port /dev/tty.usbserial-A9007U6Z open successfully
Pinging device

Sometimes the internal state machine is not ready for packets. Can you try either use my last sketch version ? If it still does not work, often closing/opening the application will fix it. I'm working on protocol changes so that you can reset the state machines before starting. I'll implement that on 2.0 version of protocol. I'll post details on a separate thread.

Álvaro

Excellent news, i've "commented out" the line PRR &= ~BIT(PRADC); so compilation then loading on MEGA works now succesfully :wink:

Please confirm i'm using your last sketch version which I downloaded from GitHub - alvieboy/arduino-oscope: A simple yet useful oscilloscope for arduino duemilanove

Same question about your last java version which I downloaded from http://www.alvarolopes.com/resources/oscope

Please instruct a simple self-generation or testing so I can see scope signal change on my screen.

Muito obrigado

Right now, Alvaro's arduino scope dual channel scope works fine on both MEGA or DUAMILANOVE boards except for some reason, it freezes after a while which means no more scope display along with no more RX/TX between Mac and arduino board.

I would be interested to know if other Mac's users have similar issue on Mac OS 10.4 Tiger and arduino 15 version.

I've found a more easy install version of RXTX via this link
http://www.efianalytics.com/TunerStudio/mac/MacInstructions.html
taking care of RXTXcomm.jar & librxtxSerial.jnilib

For those interested in generating specific PWM frequency and duty cycle outside of standard arduino PWM libraries, i've used 16-bit timer on my mega board to generate both channels then connect both pin outputs via 10K resistor towards both analog inputs (0 and 1). I take this opportunity to fix a little error on my other threads found thanks to arduino scope:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1252073278/15#28
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1257113480/0#9

On a side note with MEGA board, just use

PRR0 &= ~BIT(PRADC);

instead of using on DUAMILANOVE board

PRR &= ~BIT(PRADC);

which means Alvaro's scketch is universal on both boards.

I've tried to narrow down that problem and I have found a potential race condition while messing with flags. This is related to arduino sketch, not java or Mac. Can you please give it a try ?

Other think that might be happening is packet loss from mac to arduino, but I sincerly doubt it.

Another question: does it freeze without your intervention, or while you change the controls ?

Álvaro

Hi Alvaro - The freezing happens with both mega or duamilanove boards. I'm glad to hear it is not related to Mac or Java but only arduino sketch because i really hope success with arduino scope for many of us wether PC, Linux, Mac,...

To answer your query and after many trials yesterday & this morning: it freezes after a while without intervention on my side and as I mentionned to you privately, there is no packet loss detected by software when I lauch Mac terminal shell. To lauch again the scope, I usually press one time, sometimes two times the dual channel button with my mouse so it works again then freezes after a while but the working duration is random (can be a few seconds, sometimes one minute).

Hope it helps

Hi,

I had a friend testing this on a Mac, and he did not experience any freeze.

You tested again with my latest sketch, right ?

If you did, then my conclusion is that somehow your packets are reaching arduino with losses or checksum errors. We can try to narrow that down if you feel you have the time.

Other thing I can do is retry the "SAMPLE" command if it does not get a response in, let's say, one second.

Do you have any errors in "dmesg" about the ftdi driver ? I often have.

Álvaro

I had a friend testing this on a Mac, and he did not experience any freeze.

I'm using iMac G5 running with Mac OS Tiger, what is your friend Mac & OS ?

I'm using arduino version 15, what is your arduino version to compile then download ?

You tested again with my latest sketch, right ?

I believe so, tested the sketch you sent me by mail yesterday but to be sure, please send me again your last sketch.

BTW. Do you happen to have a java scope window providing time scale ?

Do you have any errors in "dmesg" about the ftdi driver ? I often have.

We did test together via skype chat yesterday, no error message at all.

I'm using iMac G5 running with Mac OS Tiger, what is your friend Mac & OS ?

Not sure, I'll ask him. I remember he had to switch to Java 32 bit, cause he's on a 64-bit platform.

I believe so, tested the sketch you sent me by mail yesterday but to be sure, please send me again your last sketch.

So you did not use latest :slight_smile: That was before I fixed the race condition.
You can always get the latest version here: GitHub - alvieboy/arduino-oscope: A simple yet useful oscilloscope for arduino duemilanove

We did test together via skype chat yesterday, no error message at all.

Yes we did, but we only checked for errors coming from the application, not from the operating system itself.

Please try that last sketch (commitID d0e216e376c8cd44dbf82fa28029d106534cc7af, message "Fix a potential race acessing gflags ")

Direct link: http://github.com/alvieboy/arduino-oscope/raw/master/oscope.pde

You can see what I changed using this: Fix a potential race acessing gflags · alvieboy/arduino-oscope@d0e216e · GitHub

I really hope it helps.

Álvaro

Not sure, I'll ask him. I remember he had to switch to Java 32 bit, cause he's on a 64-bit platform.

I'm using Mac OS X version 10.4.11 on 1.8GHz powerPC G5 and also on a 2.0 GHz PowerPC G5. I don't understand or know how to swtich Java 32bit versus 64 bit :frowning:

You can always get the latest version here: GitHub - alvieboy/arduino-oscope: A simple yet useful oscilloscope for arduino duemilanove

I'll try your new sketch (.pde and .h) but I cannot find your new arduino-oscope.jar !
What should i do to compile or build arduino-oscope.jar from your java files on my Macintosh ?

I'll try your new sketch (.pde and .h) but I cannot find your new arduino-oscope.jar !

It's also there, in the downloads section.

What should i do to compile or build arduino-oscope.jar from your java files on my Macintosh ?

You need JDK and ant. Perhaps you already have that installed. I'll send you more instructions by email.

Álvaro

It's also there, in the downloads section.

I've downloaded the all thing but cannot see any *.jar !
Can you provide direct link to it inside GitHub - alvieboy/arduino-oscope: A simple yet useful oscilloscope for arduino duemilanove
Thx

Sorry for the late reply ;(

You can download it here:

http://cloud.github.com/downloads/alvieboy/arduino-oscope/oscope-snapshot-v2-20091112.zip

it says access denied :frowning:

Some problem with github....

Try this one:

http://alvie.com/files/projects/oscope/arduino-oscope-snapshot-20091112.zip

Ok, I've tried with this new release but still after a while, screen freezes :frowning:

I think to have found the problem which seems to appear on Mac but not in PC sinc eyou said it always worked on PC. When java scope scree freezes, i quit your arduino-scope.jar then relauch it & it works ok then after a while it freezes again. Looking at the structure of your arduino.pde, wether I launch or not lauch java scope, it just spools via loop() any activity coming from Mac or PC.

If you don't mind, could you send me a zip with a Mac oriented java builder script along with your java scope libraries.

Thank you

You only need j2sdk, ant and the git checkout.

You will need to place "rxtxcomm.jar" on a directory named "lib", inside "Java-UI".

typing "ant" on "Java-UI" directory should build the java version with no hassle.

I suspect you're either losing bytes or some kind of corruption. Maybe try with a slower baud rate ?

Álvaro

Ok ALvaro, I've finally figured out why i could not run or find ant on my Macintosh.
Xcode developper Tools were in my Tiger DVD so I installed on my Mac.
Got many tools now and among them, ant works fine.
I just typed ant and building went succesfully with build.xml file you provided me after creating a lib directory containing RXTXcomm.jar file.

Only bad news, screen scope still freezes after a while :frowning: I was hoping my Mac java compile version would have created a more stable jar code than the one you made via PC.

Try decreasing the baud rate to 57600 in both sketch and java.

If it does not freeze using 57600, then it's certainly some problem with either RXTXcomm for Mac, or bad USB cable, or bad drivers, or... anything else.

Anyway if this does not solve it, I'll implement a "retry" in java version so that it restarts sampling if arduino does not respond.

Álvaro

Ok, i'm totally new with Xcode but i've successfully modified the sketch and java code to generate arduinsocope.jar running at 57600 baud. Now, the scope image works fine, no freezing at all :slight_smile:

The double channel views works for Prescaler of 128, 64 & 32 but stops working properly at Prescaler 16 (some green & yellow pulse glitches on both views plus yellow view has incorrect low level value having in mind I generate PWM signal).

If I select single channel with Prescaler 16 & 8, it works fine but gives incorrect views with Prescaler 4 or 2.

Thank you for everything.