Sminkly
lvl.1
United Kingdom
Offline
|
Hi,
I was trying to control a ronin M using the D-bus connector and an arduino. I spent ages searching and though I could find a few videos that showed controlling ronin with futaba receiver, there was nothing concrete about how to do it using an arduino - to allow you to make a custom controller. (with a joystick and arduino could make a control for £30)
After hours of searching arduino forums etc, which although had some S-bus stuff, most of it was a bit too low level. I just wanted basic instructions of how to do it. I eventually worked out a method and I'm posting this here for anyone who want to do something with it.
I'm assuming you know a bit about arduinos so won't go into that(ie how to add a new library etc, do an internet search and you'll find all the answers).
I've tested this on a ronin-M so assuming it works with any other ronin with D-bus(which is really just futaba's S-bus).
To make it work you'll need this library - which was actually written to control the black magic micro cinema camera, but it is a simple way of sending sbus commands.
https://github.com/boldstelvis/BMC_SBUS
The only thing you may need to check is whether you need to use serial or serial1(as described in the github readme). I'm using an adafruit arduino so needed to change to serial1.
To control the ronin M the s-bus channels are
PAN - Channel 1
TILT - Channel 2
ROLL - Channel 4
(there may be other things you can control using the other s-bus channels but I don't know what they are).
The values you need to send are from 0-2047. This is speed data not postional(as far as I can tell). So 0 is fastest in one direction, 2047 fastest in the other. Sending 1023 is stop.
I was using a wii remote using a wiichuck adaptor and the library, but you could use any kind of control, ie potentiometers, rotational encoders etc. The wiichuck was a cheap option as it had a joystick and 2 buttons for £5. I use the trigger button to switch the x-axis of the joystick from pan to roll(if it's held down).
The d-bus connector has 3 pins, looking at the side of the ronin m the 3 pins from top to bottom are
Top - GRND
Middle - 5V
Bottom - Data
You could use the middle 5v to power an arduino(I think, for my tests I had arduino connector to computer via usb for programming/debugging).
The basics to make it work are connect the GRND to the arduino GRND and arduino serial TX(usually pin 1) to the Data pin.
The code I used is this:
// Include the BMC_SBUS library
#include "BMC_SBUS.h"
//Declare BMC_SBUS Object
BMC_SBUS mySBUS;
//Include Wiichuck Library
#include <WiiChuck.h>
//Declare Wiichuck Object
Nunchuck nunchuck;
// Sbus delay value
const int sbusWAIT = 7; //frame timing delay in msecs
// Declare sbus control channels
int panChannel = 1;
int tiltChannel = 2;
int rollChannel = 4;
void setup() {
// Start Wiichuck Object
nunchuck.begin();
// Start BMC_SBUS object
mySBUS.begin();
}
void loop() {
nunchuck.readData(); // Read inputs from wiichuck
// Get wiichuck data
int Yvalue = nunchuck.getJoyY();
int Xvalue = nunchuck.getJoyX();
int Zbutton = nunchuck.getButtonZ();
//Map wiichuck values which go from 0-255 to Sbus values 0-2047
// For no move send 1023
int sendValueY = map(Yvalue,0,255,0,2047);
int sendValueX = map(Xvalue,0,255,0,2047);
// Set sbus tilt
mySBUS.Servo(tiltChannel,sendValueY);
// Check if trigger(button Z) is pressed, if so send the X value to roll channel
if (Zbutton == 1) {
mySBUS.Servo(rollChannel,sendValueX);
} else {
mySBUS.Servo(panChannel,sendValueX);
}
// Update SBUS object and send data
mySBUS.Update();
mySBUS.Send();
// Delay for SBUS
delay(sbusWAIT);
}
That's it. You could do a lot more, for instance with more buttons etc have different speeds(by changing the map values).
Hope that helps out anyone else trying to do something similar.
|
|