Go Down

Topic: How to send 10bit analog.Read() data efficiently to Processing??? (Read 594 times) previous topic - next topic

SonicArmin

Jan 28, 2012, 10:00 pm Last Edit: Jan 28, 2012, 11:11 pm by SonicArmin Reason: 1
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!

PaulS

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.

SonicArmin


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  =(

PaulS

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.


Go Up