javascriptarduinoservofirmata

Power supply to Tinkerkit's braccio fails when working with firmata.js


I am trying to control Tinkerkit's braccio (https://store.arduino.cc/tinkerkit-braccio) with firmata.js. I have an Arduino UNO and have uploaded StandardFirmata on it.

The braccio comes in made of 6 servos and comes with a shield.

The problem is that trying to control the servos with firmata.js has no effect, even with the pins set correctly to SERVO mode. I checked with the oscilloscope and saw that the power pin on the shield does not hold at 5V when I start running StandardFirmata on the Arduino. The PWM signal is fine.

Should I try to connect the servos directly on Arduino without the shield?

When I ran a script on the Arduino that used only the braccio's library it worked fine and the power pin was always at 5V. For that reason I don't think this has something to do with the shield, but I also found no indication of this issue on firmata's library. So I have ran out of ideas.

Has anyone already faced something like this?

Don't know if it is helpful, but here is a piece of the code. It is still very basic:

const Board = require('firmata');
const serialport = require('serialport');

Board.requestPort(function (error, port) {
  if (error) {
    console.log(error);
    return;
  }

  board = new Board(port.comName, { samplingInterval: 1000 });

  board.on('open', function () {
    console.log('  board opened');
    alert('board opened')
  });

  board.on('ready', function () {
    console.log('  board ready');
    board.pinMode(11,board.MODES.SERVO);
    board.pinMode(10,board.MODES.SERVO);
    board.pinMode(9, board.MODES.SERVO);
    board.pinMode(6, board.MODES.SERVO);
    board.pinMode(5, board.MODES.SERVO);
    board.pinMode(3, board.MODES.SERVO);

    board.servoWrite(11,60);
    board.servoWrite(10,85);
    board.servoWrite(9,85);
    board.servoWrite(6,85);
    board.servoWrite(5,85);
    board.servoWrite(3,60);
  });
});

Solution

  • Keep using the Braccio shield BUT set pin 12 as a digital OUTPUT then set it HIGH.

    Although I can't find any documentation for the Braccio shield, if you look at the Braccio library source code, you'll see they do something "odd" in void _Braccio::_softStart(). This appears to be to do with "soft-starting" the servos but, as far as I can see, it just sits there pulsing pin 12 HIGH/LOW for 2 to 6 sends, then sets it HIGH. I don't see how that achieves a soft start as the servos are not being controlled whilst that's happening.

    Anyway, that function leaves PIN 12 HIGH. If it's LOW, the servos won't respond.