EzDevInfo.com

firmata

firmata protocol implemented in javascript firmata

Firmata over Bluetooth on Arduino?

I have Firmata working fine on an Arduino Uno, communicating over cable USB to Processing.

I want to get rid of the cable, and run the connection over Bluetooth transport (with a BlueSMIRF module). I am unclear on what I need to do to Firmata to tell it to use the BT module rather than the (unconnected) USB cable interface. In particular, do I need to hack Firmata itself to add initialization code which is

  1. specific to the BT module I'm using, or
  2. more generally, needed to tell Firmata to use a port other than the cabled USB?

Thanks

D


Source: (StackOverflow)

Firmata over nRF24

I'm having some technical problems... I'm trying to use Firmata for arduino but over nrf24, not over Serial interface. I have tested nRF24 communication and it's fine. I have also tested Firmata over Serial and it works.

Base device is simple "serial relay". When it has data available on Serial, read it and send it over nRF24 network. If there is data available from network, read it and send it through Serial.

Node device is a bit complex. It has custom Standard Firmata where I have just added write and read override.

Diagram

Read override id handeled in loop method in this way:

while(Firmata.available())
    Firmata.processInput();

// Handle network data and send it to Firmata process method
while(network.available()) {
    RF24NetworkHeader header;
    uint8_t data;
    network.read(header, &data, sizeof(uint8_t));
    Serial.print(data, DEC); Serial.print(" ");
    Firmata.processInputOverride(data);
    BlinkOnBoard(50);
}

currentMillis = millis();

Firmata processInputOverrride is little changed method of processInput where processInput reads data directly from FirmataSerial, and in this method we pass data down to method from network. This was tested and it should work fine.

Write method is overloaded in a different way. In Firmata.cpp I have added an method pointer that can be set to a custom method and used to send data using that custom method. I have then added custom method call after each of the FirmataSerial.write() call:

Firmata.h
...
size_t (*firmataSerialWriteOverride)(uint8_t);
...

void FirmataClass::printVersion(void) {
  FirmataSerial.write(REPORT_VERSION);
  FirmataSerial.write(FIRMATA_MAJOR_VERSION);
  FirmataSerial.write(FIRMATA_MINOR_VERSION);
  Firmata.firmataSerialWriteOverride(REPORT_VERSION);
  Firmata.firmataSerialWriteOverride(FIRMATA_MAJOR_VERSION);
  Firmata.firmataSerialWriteOverride(FIRMATA_MINOR_VERSION);
}

I have then set the overrided write method to a custom method that just writes byte to network instead of Serial.

size_t ssignal(uint8_t data) {
    RF24NetworkHeader header(BaseDevice);
    network.write(header, &data, sizeof(uint8_t));
}

void setup() {
...
Firmata.firmataSerialWriteOverride = ssignal;
...
}

Everything seems to be working fine, it's just that some data seems to be inverted or something. I'm using sharpduino (C#) to do some simple digital pin toggle. Here's how output looks like: (< came from BASE, > sent to BASE)

> 208 0
> 209 0
...
> 223 0
> 249
< 4 2 249 
and here communication stops...

That last line came inverted. So i tough that I only need to invert received bytes. And it worked for that first command. But then something happens and communication stops again.

> 208 0
> 209 0
...
> 223 0
> 249 // Report firmware version request
< 249 2 4
> 240 121 247 // 240 is sysex begin and 247 is systex end
< 240 121
< 101 0 67 0 0 1 69 0 118
< 117 0 115 0
< 0 70 0 105 0 116 0 111 0 109
< 0 97 0
< 0 109
< 116 0 97 0 247
> 240 107 247

So what could be the problem here? It seems that communication with Firmata works but something isn't right...

-- EDIT --

I solved that issue. The problem was that I didn't see Serial.write() calls in sysex callback. Now that that is solved, I came up to another problem... All stages pass right (I guess) and then I dont get any response from Node when I request pin states

...
< f0 6a 7f 7f 7f ... 7f 0 1 2 3 4 5 6 7 8 9 a b c d e f f7 // analog mapping
> f0 6d 0 f7 // sysex request pin 0 state and value
> f0 6d 1 f7 
> f0 6d 2 f7
...
> f0 6d 45 f7
// And I wait for response...

There is no response. Any ideas why would that happen? Node receive all messages correctly and code for handling pin states exist.


Source: (StackOverflow)

Advertisements

Firmata with Arduino Mega 1280, can't read all input pins

I got an Arduino Mega 1280 and want to communicate with it via Firmata. That sounds easy...

So my problem: If I use the StandardFirmata Firmware for the Arduino, which is included in Arduino 1.0, I can set output Pins, and send a signal to them ((highlighting a led on pin 24):

arduino.digitalWrite(24, Arduino.HIGH);

But I cannot read any digital input from my Mega. As I found out, some people had the problem with reading on ports higher than 13. I can't verify it, my input signals start at port 23. example:

if (arduino.digitalRead(25) == Arduino.HIGH){
  println("is high");
  }

Now I installed the AllInputsFirmata on my Mega, it is also preinstalled in Arduino 1.0. Now it is no problem to read from an digital input: example:

if (arduino.digitalRead(25) == Arduino.HIGH){
  println("is high");
  }

But this time, I can't send any signal out.

So, what is going on?

(Yes, I tested it with the FirmataTest software, and there everything goes alright!)


Source: (StackOverflow)

Python PyQt Timer Firmata

I am pretty new to python and working with firmata I am trying to play around with an arduino .

Here is what I want to happen:

  • Set arduino up with an LED as a digital out
  • Set potentiometer to analog 0

  • Set PyQt timer up to update potentiometer position in
    application

  • Set a threshold in PyQt to turn LED on (Analog in has 1024bit resolution, so say 800 as the
    threshold)

I am using this firmata library : Link

Here is the code that I am having trouble with:

import sys from PyQt4 import QtCore, QtGui from firmata import *

 # Arduino setup
 self.a = Arduino('COM3')
 self.a.pin_mode(13, firmata.OUTPUT)

 # Create timer
    self.appTimer = QtCore.QTimer(self)

    self.appTimer.start(100)
    self.appTimer.event(self.updateAppTimer())


def updateAppTimer(self):
    self.analogPosition = self.a.analog_read(self, 0)
    self.ui.lblPositionValue.setNum()

I am getting the error message:

Traceback (most recent call last): File "D:\Programming\Eclipse\IO Demo\src\control.py", line 138, in myapp = MainWindow() File "D:\Programming\Eclipse\IO Demo\src\control.py", line 56, in init self.appTimer.event(self.updateAppTimer()) File "D:\Programming\Eclipse\IO Demo\src\control.py", line 60, in updateAppTimer self.analogPosition = self.a.analog_read(self, 0) TypeError: analog_read() takes exactly 2 arguments (3 given)

If I take 'self' out I get the same error message but that only 1 argument is given

What is python doing implicitly that I am not aware of?

Blockquote


Source: (StackOverflow)

How to break out of a subrule once a certain part of the rule is met?

Currently parsing Midi messages for the Firmata protocol in Rebol 3, and came across a situation I haven't seen before.

Basically, I have a generic rule to copy bytes between the framing bytes. However that rule is eating the framing bytes. I have reduced the code to the following:

data: #{
    F06C00010101040E7F000101010308040E7F00010101040E7F0001010103
    08040E7F000101010308040E7F00010101040E7F00010101040E7F0001010103
    08040E7F000101010308040E7F000101010308040E7F00010101040E7F000101
    01040E7F00010101020A7F00010101020A7F00010101020A7F00010101020A7F
    00010101020A06017F00010101020A06017FF7
}

sysex-start: #{F0}
sysex-end: #{F7}
capability-query: #{6B}
capability-response: #{6C}
capability-end: #{7F}

received-rule: [
    sysex-start
    capability-response-rule 
    sysex-end
]

capability-response-rule: [
    capability-response
    [
        capability-end |
        some [copy pin 1 skip]
    ]
]
parse data received-rule

The issue is that some [copy pin 1 skip] is gobbling up the sysex-end binary.

  • Is there a way I can restructure the rule (without moving sysex-end into the subrule)?

  • Is there a parse keyword that would help in this case of breaking out of the subrule?

(Note: I'm aware that I'm not interpreting the data according to the spec.)


Source: (StackOverflow)

How to use Arduino Uno analog pins as digital pins with pyfirmata

I am trying to use Arduino analog pins (A0-A5) as digital pins (D14-D19) with pyfirmata. I'm doing a simple blink test with D14 (or A0) to test this:

#!/usr/bin/python

# Blink test with analog as digital pins

# Import required libraries
from pyfirmata import Arduino, util
from pyfirmata import INPUT, OUTPUT, PWM  
from time import sleep

# Associate port and board with pyFirmata
port = '/dev/cu.usbmodem1451'
board = Arduino(port)

# Pause to sync
sleep(1)

led = board.get_pin('d:14:o')
time = 1

while True:
    led.write(1)
    print ("On")
    sleep(time)
    led.write(0)
    print ("Off")
    sleep(time)

To enable analog pins to act as digital pins, I've gone into pyfirmata's boards.py file (as show in the github repo at https://github.com/tino/pyFirmata/blob/master/pyfirmata/boards.py) and changed line #3 from

digital': tuple(x for x in range(14)),

to

digital': tuple(x for x in range(20)),

I don't get an error when I run my python script, but the LED doesn't blink (don't worry, I'm positive the LED was in the right way).

Does anyone know how I can effectively instantiate digital pin 14 as an output pin with pyfirmata (as in the line led = board.get_pin('d:14:o'))

By the way (not that I think this affects anything) but I'm running Mac OSX with Yosemite. Thank you!


Source: (StackOverflow)

How do I send arduino a firmata command to turn on a pin

I'm trying to implement the firmata protocol and having a bit of a difficult time deciphering the spec for writing digital pins:

I have noted the following parts of the spec of Firmata 2.3

* type                command  channel    first byte            second byte 
------------------------------------------------------------------------------
* digital I/O message   0x90   port       LSB(bits 0-6)         MSB(bits 7-13)

and

/* two byte digital data format, second nibble of byte 0 gives the port number (e.g. 0x92 is the third port, port 2)
 * 0  digital data, 0x90-0x9F, (MIDI NoteOn, but different data format)
 * 1  digital pins 0-6 bitmask
 * 2  digital pin 7 bitmask 
 */

I'm having some difficulty interpreting the spec. I've looked at other implementations, but haven't been able to see the relationship between the spec and implementation.

So let's say I am wanting to turn on the Arduino LED (pin 13), I know it will be on the second port, port 1, so the first byte will be #{91}.

I'm getting confused about the bitmask for the second two bytes though. I know what a bitmask is, so I want to enable the right bit for the pin.

  • Why is the bitmask so large for the digital pins? I'm familiar with using bitmasks on the digital outputs of PLCs, which seems much different (one pin, one bit)

  • My thought is that pin 13 would be the 7th pin on port 1. Since I don't care about the other pins, I would mark the pin in the 2nd byte #{40} and I don't need any pins set for the third byte #{00}?

I don't think my interpretation of the bitmasks is correct, and it's probably where my error is

Am I on the right track for this? Is this the right command for setting a pin high or low?


Source: (StackOverflow)

Windows Powershell not quitting script with Ctrl-C

So I am running Python 3.4 scripts on Windows, and when I run a particular script, I have an infinite loop (while True:) which I am using, but when I try to quit the script with Ctrl-C, it is not exiting the script. It prints Keyboard Interrupt, as if it has quit, but then just leaves the blinking cursor and will not let me type, so I have to exit out with the red X.

import serial 
import time
import pyfirmata 
#from pyfirmata import Arduino, util, PWM

board = pyfirmata.Arduino('COM4', baudrate = 9600, timeout = 5)
time.sleep(2)       #sleep in units of sec

it = pyfirmata.util.Iterator(board)
it.start()


digital1 = board.get_pin('d:5:p')
digital2 = board.get_pin('d:6:p')
digital3 = board.get_pin('d:10:p')
digital4 = board.get_pin('d:11:p')  
digital = (digital1, digital2, digital3, digital4)

distObject = 1.5         #start warning at 4 inches away from objects (arbitrary)
forceGraspL = 0
forceGraspR = 0
maxForceL = 60      
maxForceR = 60
motorMaxForceL = maxForceL / 2
motorMaxForceR = maxForceR / 2

while True:
    left = 0
    right = 0       
    leftMid = 0
    rightMid = 0    
    distPerc = 0
    MOTORS = (left, right, leftMid, rightMid)


    if (distObject != 0 and distObject < 4 and forceGraspL == 0 and forceGraspR == 0):
        left = 0.9
        distPerc = round(distObject / 4.0 * 100)


    elif (forceGraspL != 0 or forceGraspR !=0):
        if (forceGraspL < motorMaxForceL and forceGraspR < motorMaxForceR):
            left = forceGraspL / motorMaxForceL
            right = forceGraspR / motorMaxForceR    

        elif (forceGraspL < maxForceL and forceGraspR < motorMaxForceR):
            left = 1
            leftMid = (forceGraspL - motorMaxForceL)/ motorMaxForceL
            right = forceGraspR / motorMaxForceR
        elif (forceGraspL < motorMaxForceL and forceGraspR < maxForceR):
            left = forceGraspL / motorMaxForceL
            right = 1  
            rightMid = (forceGraspR - motorMaxForceR)/ motorMaxForceR
        elif (forceGraspL < maxForceL and forceGraspR < maxForceR):
            left = 1
            leftMid = (forceGraspL - motorMaxForceL)/ motorMaxForceL
            right = 1  
            rightMid = (forceGraspR - motorMaxForceR)/ motorMaxForceR
        else:
            left = 1
            leftMid = 1
            rightMid = 1 
            right = 1

        if (distPerc < 100 and distPerc > 0):
            for pin in range(1, length(digital)):
                digital[pin].write(MOTORS(pin))
            time.sleep(.5)
            for pin in range(1, length(digital)):
                digital[pin].write(0)
            time.sleep(.5)

        else:
            for pin in range(1, length(digital)):
                digital[pin].write(MOTORS(pin))

Any suggestions on what in my script might be causing this problem is greatly appreciated. I can tell that the problem is in this script because I have tried other scripts with infinite loops, and the Ctrl-C works for those.


Source: (StackOverflow)

How do you make an image stay on screen in Processing with an Arduino switch?

I am connecting Processing and an Arduino pushbutton. It's successfully connected with Standard Firmata. What I want to happen is that when the button is pressed, an image will show up in Processing but also stay on the screen, just like the LED, and then when the button is pressed again, the image will disappear from the screen. I'm just testing it with shapes for now. I have tested it with an LED and that works fine. Any ideas what I'm doing wrong? This is the code I have:

void draw()
{
  buttonState = arduino.digitalRead(buttonPin);

  if (buttonState == arduino.HIGH && buttonPressed == 0)
  {
    buttonPressed = 1;
    rect(10, 10, 10, 10);
    text("hello", 10, 10);
  }
  if (buttonState == arduino.LOW && buttonPressed == 1)
  {
    buttonPressed = 0;
    rect(50, 50, 10, 10);
  }
} 

Source: (StackOverflow)

Node.js with socket.io and firmata on raspbian (model B) runs slow

I´m running a Raspberry Pi Model B (512MB RAM) with a 16 gB 300MB/s SD-card and recent raspbian with all updates.

On this machine I´ve set up a apache2-server, node.js with socket.io and firmata.

Within my web-application, video streaming is a key feature.

When I access my webserver just for streaming the videos (without node/socket.io/firmata), everything streams with a good performance. But when I switch on node.js/socket.io/firmata it's rather slow, it takes 5-7 seconds to start streaming the videos.

I had problems installing node.js in the first place. Node.js from source compiled/installed like a charm, but when I tried to run it, I got this mysterious "Illegal instruction" message.

As an alternative I took the precompiled debian-packages and installed them using dpkg using this repo:

http://revryl.com/2014/01/04/nodejs-raspberry-pi/

They say that nodejs will run slower, but that´s not acceptable for me.

Any hints?

Thanks and regards!


Source: (StackOverflow)

Python- Firmata and Arduino, script structure effecting firmata

When using this script to blink an LED on pin12, the script will not get past line27 where pin12 is set high. There is no error message.

    import json
    import urllib
    from firmata import *
    from pprint import pprint
    import time
    import serial

    countTweet = 0
    a = Arduino('COM13') #Insert this before the while loop = it never actually works
    a.delay(2)          

    while True:
        try:
            response = urllib.urlopen('http://search.twitter.com/search.json?q=%23happy&result_type=recent&rpp=1&filter:retweets').read()
        except IOError:
            pprint('no internet connection')
            time.sleep(5)
            continue
        j = json.loads(response)
        if j['results']:
            text = j['results'][0]['text']
            tID = j['results'][0]['id']
        else:
            pprint('bad JSON')
        if countTweet != 0 and lastID != tID:
            pprint('new ID')
            a.pin_mode(12, firmata.OUTPUT)  #Gets stuck here
            a.delay(2)
            a.digital_write(12, firmata.HIGH)
            a.delay(2)
            a.digital_write(12, firmata.LOW)
            pprint('done firmata')
            lastID = tID
            pprint (text)
            pprint ('1')
        else:
            pprint("FLC") #First loop complete: To gather the existing tweet before we start
            lastID = tID
            countTweet += 1
        time.sleep(15)

How do I structure this script so that Firmata/Serial works on each loop? I am interested to learn why the above script doesn't work at all but the LED example below will.

    from firmata import * 

a = Arduino('COM13')
a.pin_mode(12, firmata.OUTPUT)
a.delay(2)

while True:
    a.digital_write(12, firmata.HIGH)
    a.delay(2)
    a.digital_write(12, firmata.LOW)
    a.delay(2)

The Arduino is running oldStandardFirmata

#include <EEPROM.h>
#include <Firmata.h>

/*==============================================================================
 * GLOBAL VARIABLES
 *============================================================================*/

/* analog inputs */
int analogInputsToReport = 0; // bitwise array to store pin reporting
int analogPin = 0; // counter for reading analog pins

/* digital pins */
byte reportPINs[TOTAL_PORTS];   // PIN == input port
byte previousPINs[TOTAL_PORTS]; // PIN == input port
byte pinStatus[TOTAL_PINS]; // store pin status, default OUTPUT
byte portStatus[TOTAL_PORTS];

/* timer variables */
unsigned long currentMillis;     // store the current value from millis()
unsigned long previousMillis;    // for comparison with currentMillis


/*==============================================================================
 * FUNCTIONS                                                                
 *============================================================================*/

void outputPort(byte portNumber, byte portValue)
{
  portValue = portValue &~ portStatus[portNumber];
  if(previousPINs[portNumber] != portValue) {
        Firmata.sendDigitalPort(portNumber, portValue); 
        previousPINs[portNumber] = portValue;
        Firmata.sendDigitalPort(portNumber, portValue); 
    }
}

/* -----------------------------------------------------------------------------
 * check all the active digital inputs for change of state, then add any events
 * to the Serial output queue using Serial.print() */
void checkDigitalInputs(void) 
{
    byte i, tmp;
    for(i=0; i < TOTAL_PORTS; i++) {
        if(reportPINs[i]) {
            switch(i) {
            case 0: outputPort(0, PIND &~ B00000011); break; // ignore Rx/Tx 0/1
            case 1: outputPort(1, PINB); break;
            case 2: outputPort(2, PINC); break;
            }
        }
    }
}

// -----------------------------------------------------------------------------
/* sets the pin mode to the correct state and sets the relevant bits in the
 * two bit-arrays that track Digital I/O and PWM status
 */
void setPinModeCallback(byte pin, int mode) {
    byte port = 0;
    byte offset = 0;

    if (pin < 8) {
      port = 0;
      offset = 0;
    } else if (pin < 14) {
      port = 1;
      offset = 8;     
    } else if (pin < 22) {
      port = 2;
      offset = 14;
    }

    if(pin > 1) { // ignore RxTx (pins 0 and 1)
        pinStatus[pin] = mode;
        switch(mode) {
        case INPUT:
            pinMode(pin, INPUT);
            portStatus[port] = portStatus[port] &~ (1 << (pin - offset));
            break;
        case OUTPUT:
            digitalWrite(pin, LOW); // disable PWM
        case PWM:
            pinMode(pin, OUTPUT);
            portStatus[port] = portStatus[port] | (1 << (pin - offset));
            break;
        //case ANALOG: // TODO figure this out
        default:
            Firmata.sendString("");
        }
        // TODO: save status to EEPROM here, if changed
    }
}

void analogWriteCallback(byte pin, int value)
{
    setPinModeCallback(pin,PWM);
    analogWrite(pin, value);
}

void digitalWriteCallback(byte port, int value)
{
    switch(port) {
    case 0: // pins 2-7 (don't change Rx/Tx, pins 0 and 1)
        // 0xFF03 == B1111111100000011    0x03 == B00000011
        PORTD = (value &~ 0xFF03) | (PORTD & 0x03);
        break;
    case 1: // pins 8-13 (14,15 are disabled for the crystal) 
        PORTB = (byte)value;
        break;
    case 2: // analog pins used as digital
        PORTC = (byte)value;
        break;
    }
}

// -----------------------------------------------------------------------------
/* sets bits in a bit array (int) to toggle the reporting of the analogIns
 */
//void FirmataClass::setAnalogPinReporting(byte pin, byte state) {
//}
void reportAnalogCallback(byte pin, int value)
{
    if(value == 0) {
        analogInputsToReport = analogInputsToReport &~ (1 << pin);
    }
    else { // everything but 0 enables reporting of that pin
        analogInputsToReport = analogInputsToReport | (1 << pin);
    }
    // TODO: save status to EEPROM here, if changed
}

void reportDigitalCallback(byte port, int value)
{
    reportPINs[port] = (byte)value;
    if(port == 2) // turn off analog reporting when used as digital
        analogInputsToReport = 0;
}

/*==============================================================================
 * SETUP()
 *============================================================================*/
void setup() 
{
    byte i;

    Firmata.setFirmwareVersion(2, 0);

    Firmata.attach(ANALOG_MESSAGE, analogWriteCallback);
    Firmata.attach(DIGITAL_MESSAGE, digitalWriteCallback);
    Firmata.attach(REPORT_ANALOG, reportAnalogCallback);
    Firmata.attach(REPORT_DIGITAL, reportDigitalCallback);
    Firmata.attach(SET_PIN_MODE, setPinModeCallback);

    portStatus[0] = B00000011;  // ignore Tx/RX pins
    portStatus[1] = B11000000;  // ignore 14/15 pins 
    portStatus[2] = B00000000;

//    for(i=0; i<TOTAL_PINS; ++i) { // TODO make this work with analogs
    for(i=0; i<14; ++i) {
        setPinModeCallback(i,OUTPUT);
    }
    // set all outputs to 0 to make sure internal pull-up resistors are off
    PORTB = 0; // pins 8-15
    PORTC = 0; // analog port
    PORTD = 0; // pins 0-7

    // TODO rethink the init, perhaps it should report analog on default
    for(i=0; i<TOTAL_PORTS; ++i) {
        reportPINs[i] = false;
    }
    // TODO: load state from EEPROM here

    /* send digital inputs here, if enabled, to set the initial state on the
     * host computer, since once in the loop(), this firmware will only send
     * digital data on change. */
    if(reportPINs[0]) outputPort(0, PIND &~ B00000011); // ignore Rx/Tx 0/1
    if(reportPINs[1]) outputPort(1, PINB);
    if(reportPINs[2]) outputPort(2, PINC);

    Firmata.begin(115200);
}

/*==============================================================================
 * LOOP()
 *============================================================================*/
void loop() 
{
/* DIGITALREAD - as fast as possible, check for changes and output them to the
 * FTDI buffer using Serial.print()  */
    checkDigitalInputs();  
    currentMillis = millis();
    if(currentMillis - previousMillis > 20) {  
        previousMillis += 20;     // run this every 20ms
        /* SERIALREAD - Serial.read() uses a 128 byte circular buffer, so handle
         * all serialReads at once, i.e. empty the buffer */
        while(Firmata.available())
            Firmata.processInput();
        /* SEND FTDI WRITE BUFFER - make sure that the FTDI buffer doesn't go over
         * 60 bytes. use a timer to sending an event character every 4 ms to
         * trigger the buffer to dump. */

        /* ANALOGREAD - right after the event character, do all of the
         * analogReads().  These only need to be done every 4ms. */
        for(analogPin=0;analogPin<TOTAL_ANALOG_PINS;analogPin++) {
            if( analogInputsToReport & (1 << analogPin) ) {
                Firmata.sendAnalog(analogPin, analogRead(analogPin));
            }
        }
    }
}

Source: (StackOverflow)

Can I use Xbee one with jumper on USB and another Xbee with jumper on xbee?

Can I communicate to xbee modules both connected to their libelium shields over arduino boards. But one arduino needs shields jumper on USB as it runs firmata thus received commands from PC, whilst the other xbee should have the shield jumper on xbee as it only needs usb for power.

This will be of great assistance, am progressing slowly by myself, have deleted my previous two questions as to cause minimal load here, always updating my progress rather than leaving old question here.


Source: (StackOverflow)

SerialPortEventListener Implementation

I am playing with the Firmata protocol which allows you to control Arduino through a serial protocol. I am reading sensor values using SerialPortEventListener listening for DATA_AVAILABLE event. But i notice a lot of latency it takes a second for the updated sensor values to be registered by my application, protocol runs at a baud rate of 57600. My question is does the event listener run on a separate thread or does both my application and listener run in the same thread and my application slow things down.

EDIT: To make my self clear, i am just asking in theory would it be faster to read serial transmission in a separate thread or using the event listener?


Source: (StackOverflow)

Adding a delayMicroseconds function to the standard firmata for running Arduino with Processing

I'm using the standard firmata to interface with Java Processing and run an arduino project. The Arduino class used to interface processing with java does not have a method for delayMicroseconds or any other delay on the arduino board. In most examples you need to use delay techniques in the java environment but these all operate on the order of milliseconds (1000 microseconds).

So I can edit the StandardFirmata sketch, the Firmata.java file and the Arduino.java file that makes all these necessary connections to run Processing. Does anyone understand how this code breaks down well enough so that I could add my own delay function that carries through to the arduino class. I don't understand how this code interfaces between the C and Java sides. A better understanding of this would probably help the most.

If you want to look at the reference code it can be found at: http://arduino.cc/en/reference/firmata#.UwfW_vldV0Y https://github.com/firmata/processing/tree/master/src


Source: (StackOverflow)

Processing can't find Arduino?

I'm using the Arduino library in Processing. But none of the example sketches are working. I've tried changing the serial port using Arduino.list[0] and Arduino.list[1]. If I choose any higher number it throws an error, so I assume it only sees two serial devices.

My Arduino is connected and working. I have no problem using it through the Arduino application.

What are some other possible problems?

There is an example sketch on page Arduino and Processing that I have been using to troubleshoot.


Source: (StackOverflow)