problem with sendAnalog and 14bit int limit

hello all, this is my first post here with Firmata.

when the analog values are sent using sendAnalog, is it possible to send an 18bit int or a float? if not, can we get the sendAnalog function updated to allow this? it appears to have a 14bit limit, a max of 16384.

Thanks for any suggestions guys.

when the analog values are sent using sendAnalog, is it possible to send an 18bit int or a float?

The analogRead function returns an int with a minimum value of 0 and a maximum value of 1023. That is certainly within the range that the sendAnalog function can handle.

Since analogRead returns an int, sending a float using sendAnalog does not seem like a reasonable thing to need to be able to do.

if thats true that analogread has the limit you said, how come i can use it in processing to send a max value of 16384 via osc to maxmsp?

I don't believe that you CAN use analogRead() in Processing. The analogRead() function is an Arduino-specific function.

this block is doing it. i just read the documentation that confirms what you said, but in practice, i am sending these values and it is working. in any case, is there anyway we can still adress the first question? if you had 18bits of information to send from the arduino to processing how else could you do it if the firmata analogread function is inadequate?

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

void draw()
{
int i;

//read data from all the analog pins and send them out as osc data
for (i = 0; i <= 5; i++)
{
int analogInputData = arduino.analogRead(i); //analog pin i is read and put into the analogInputData variable scale 14bit max val of 16384 to 20480 = ratio of 5/4
OscMessage analogInputMessage = new OscMessage("/analog/"+i); //an OSC message in created in the form ‘analog/i’
analogInputMessage.add(analogInputData); //the analog data from pin i is added to the osc message
oscP5.send(analogInputMessage, myRemoteLocation); //the OSC message is sent to the set outgoing port and IP address
}
}

I don’t believe that you CAN use analogRead() in Processing. The analogRead() function is an Arduino-specific function.

this block is doing it.

No, it isn’t. That block is calling Firmata::analogRead(), which is a completely different function.

Now, I will agree that Firmata::analogRead() sends a message to the Arduino, asking it to perform an analogRead() function call, and to return the value from analogRead().

The output from Firmata::analogRead() is a value in the range 0 to 1023, despite the comment you added.

if you had 18bits of information to send from the arduino to processing how else could you do it if the firmata analogread function is inadequate?

Information on the Arduino is stored in variables that come in specific sizes, all of which are multiples of 8 bits. A byte is 8 bits. An int is 16 bits. A float or a double are 32 bits, as is a long. So talking about 18 bits of information from an Arduino is meaningless.

If I was having trouble using Firmata to get the data from the Arduino, well, I’d give some serious thought to s**tcanning Firmata, and developing my own protocol for the Arduino and Processing to communicate.

But, if you think you are stuck with Firmata, explain where the “18 bits of information” are coming from, and we might be able to help you get the data from the Arduino to Processing within that straight-jacket’s limitations.

ps, despite our disagreement on what is happenning here, thankyou for your help.

i have used the firmata.sendanalog(analogPin, 16384) command at the end of the arduino firmata code to send a 14 bit value, all the way through to processing and then out to max/msp via osc… if i was wrong it wouldn’t work. would a video make a difference?

anyway back to the 18 bit problem. im using an 18 bit ADC SOIC chip, documented in this thread-
this links to an example with my modified code at the end.
http://forums.adafruit.com/viewtopic.php?f=31&t=12269&start=15#p114618

but we dont have to worry about the details of that. i can handle everything correctly so it generates a float or an int with 6 figures on the arduino side. if we say that is varA where can we go from there?

i have used the firmata.sendanalog(analogPin, 16384) command at the end of the arduino firmata code to send a 14 bit value, all the way through to processing and then out to max/msp via osc… if i was wrong it wouldn’t work. would a video make a difference?

No, the video would simply prove that doing something outside the bounds of reasonableness worked.

The Firmata::sendAnalog function looks like this:

void FirmataClass::sendAnalog(byte pin, int value) 
{
  // pin can only be 0-15, so chop higher bits
  Serial.print(ANALOG_MESSAGE | (pin & 0xF), BYTE);
  sendValueAsTwo7bitBytes(value);
}

So, you can use this function to send a 14 bit value.

That does not change that fact that the primary function of this method is to return the value read from an analog pin, and that the range of values read from an analog pin is 0 to 1023.

There seems to be some reason that Firmata can not pass a 8 bit byte, perhaps having to do with signed/unsigned bytes.