Pages: [1]   Go Down
Author Topic: How to send 10bit analog.Read() data efficiently to Processing???  (Read 534 times)
0 Members and 1 Guest are viewing this topic.
Israel
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Learning in order to teach!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I have been driven mad by the following problem in my first ever Processing + arduino project.

Project: Basically I am trying to send as many analog.read data from the arduino via the USB to Processing to display them on a MacBook, kind of a poor-man's scope application. In order not to limit my sampling by the speed of the serial port, I want to acquire an array of 2byte words (10bit per ADC sample) as quickly as the ADC settling time allows and then push the array through the serial port to the Mac. When that is done, the next ADC burst of data will be acquired, transferred, displayed and so on...

Problem: The interpretation of all primitive data types (integer, byte) is different on the two platforms. In Processing integers are 4 bytes and bytes are signed, while on the arduino the integers are 2 bytes and bytes are unsigned. I could move to char or strings, but that is rather inefficient in terms of effective data rates - I think my burst rate would suffer a factor of 2 slow down.

Summary:If you have written an efficient way to transfer 10bit output from the ADC to Processing please let me know.

Many thanks for reading!
« Last Edit: January 28, 2012, 05:11:24 pm by SonicArmin » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The interpretation of all primitive data types (integer, byte) is different on the two platforms. In Processing integers are 4 bytes and bytes are signed, while on the arduino the integers are 2 bytes and bytes are unsigned.
Have you tried defining an unsigned byte variable in Processing? If that works, you can then send data as bytes from the Arduino and receive the data as unsigned bytes in Processing.
Logged

Israel
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Learning in order to teach!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Have you tried defining an unsigned byte variable in Processing? If that works, you can then send data as bytes from the Arduino and receive the data as unsigned bytes in Processing.

Yes, I tried that - there is no unsigned byte in Processing. That would have been too easy  smiley-cry
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, Processing obviously knows nothing about the need for unsigned types. The keyword unsigned is unrecognized. Idiots.

Perhaps using another application to read the data and draw the pictures would be possible.

Logged

Pages: [1]   Go Up
Jump to: