Go Down

Topic: What Adurino do I need for Meccanoid? (Read 31803 times) previous topic - next topic

Chagrin

It's a slow data rate but I'd assume it's a robust one -- and that's probably the tradeoff they were making. 2400 baud really isn't that bad when you compare it to how quickly the servos move anyway, and if you have "a lot" of servos you can still create separate strings and use SoftwareSerial for the various strings.

DuaneDegn

It's a slow data rate but I'd assume it's a robust one -- and that's probably the tradeoff they were making. 2400 baud really isn't that bad when you compare it to how quickly the servos move anyway, and if you have "a lot" of servos you can still create separate strings and use SoftwareSerial for the various strings.
I don't understand how SoftwareSerial will be helpful. I'm pretty sure SoftwareSerial blocks the flow of the program.

I mentioned my reasons for wanting to control the position of each servo at 50Hz in this post.

I think SoftwareSerial would slow the program down too much to use the strategy I described.

I don't know why they're using 2400bps, I suppose it could be to insure reliable communication but it's certainly possible to have reliable communication at 50 times the speed of the Meccanoid communication protocol.

Darwin7

It's a slow data rate but I'd assume it's a robust one -- and that's probably the tradeoff they were making. 2400 baud really isn't that bad when you compare it to how quickly the servos move anyway, and if you have "a lot" of servos you can still create separate strings and use SoftwareSerial for the various strings.
So, Adruino wouldn't be a good choice because of its slow rate to send data? I'll try my best in getting it to program even though I'm new to the Adruino hardware. My project for Meccanoid was to make him more social and less "voice commands" to use him. Like making a code where he would move around on his own, and maybe notice movements by ultrasonic sensors, but will just have to see what Adruino can do. Still, Adruino Uno would be the best way to go, right?

esegre

you have to open  arduino library at :
http://www.meccano.com/meccanoid-opensource

and select arduino library

DuaneDegn

So, Adruino wouldn't be a good choice because of its slow rate to send data?
The slow data rate is on the Meccanoid side. I'm not sure what you can do to get around this. A Mega has multiple hardware serial ports but I don't know how much sending a bunch of serial data will slow down your program.

I haven't looked at the Meccanoid library to see how they handle the incoming data. I don't know if the code blocks the program while it receives the data.

You should be able to use the Meccanoid hardware like other robot hardware. You use your sensors to detect obstacles and control the motors to move where you want to go. In some ways the Meccanoid hardware should make many tasks easier.

The main trick will be learning to use the protocol but the library should make this easier than trying to figure it out on your own.

Darwin7

You should be able to use the Meccanoid hardware like other robot hardware. You use your sensors to detect obstacles and control the motors to move where you want to go. In some ways the Meccanoid hardware should make many tasks easier. The main trick will be learning to use the protocol but the library should make this easier than trying to figure it out on your own.
Well thanks, DuaneDegn. I'll look into buying a Adruino Uno or a Mega and some sensors and get Meccanoid going. Before I get started, is there any tutorials on how to program on Adruino? I'm fairly new, and from this information you guys gave me, I'm ready to start programming Meccanoid on the PC. If you could give me link, that will be fine. Thanks everyone for your help! :)

DuaneDegn


Ccarrere

Whoa!

Check this:

http://www.toysrus.com/buy/robotics/meccano-meccanoid-expansion-pack-6027006-75961386

For $20.00 USD you can get one of these servos! Now - read that PDF I posted. You'll find that these motors can both be controlled via a daisy-chained serial connection - AND they can relay back position information!!!

$20.00 gets you a low-cost version of Robotis or Herculux "smart" digital servo! I was just lamenting the other day on that I wished a servo manufacturer would do something like this - I never expected Meccano would do it! They should sell these in multi-packs!

That robot of theirs is pretty expensive - about $190.00! But $160.00 of that is in the 8 servos. If you bought two of these robots (16 servos) - plus a couple of expansion packs (a total of about $400.00) - you could build yourself a very low-cost humanoid bipedal robot. You might have to 3D print some parts (plus you'd have to add a controller, and sensors, and such) - but for around $500.00 you could have a very cheap humanoid robot to play with - and smart servos.

You can only approach this price currently using standard servos and bracket kits from Chinese suppliers. I'm not sure what the bearings or gearing is in those smart servos - likely plastic bushings and gears - but they are so darn cheap!

I just wish I didn't have a ton of other backburner projects on my list - or I would tackle this in a heartbeat!

Edit: I just realized I made a mistake - the 8 servo robot isn't $190.00, but rather closer to $500.00 retail! Darn! Still - 18 of those servos alone would only cost $360.00, which is still very low cost. You would probably have to 3D print certain brackets (though they do come with some brackets that might work ok for part of the project)...
My wife just gave me the Meccano G15 robot (2' tall, 4 servos) for Christmas. It was $99 at ToysRUs. They dropped the price from $150 just before Christmas.

volkova_ta

Hi guys,

I succesfully connected the Meccanoid servos to Arduino. It appeared to be not hard at all. I used Arduino Mega and Sensor Shield.

The only problem is to find appropriate connectors. Meccanoids battery has Mini-Tamiya female connector. So you need to buy one Mini-Tamiya male at a hobby RC cars store, it is quite common.

Motors are plugged differently, so you need to buy at a local electronics store 2 different male connectors: one is CWF-2 (it is called so in Russia, a small white one), and another one I cannot figure out, so I used simply PLS-2, it fits. Tomorrow I am going to try try my good old Motor Shield to drive his DC motors, and after that I write a complete tutorial.

What I liked that fully charged Meccanoid battery gives you about 7V, so I didn't use any voltage converter, I simply plugged it into Arduino's VIN.

I think that for simplicity, to control Meccanoid via Arduino you need to choose a one-board like DFRduino Romeo, which already has servo pins and motor driver. I am going to give it a try. But if you don't have any, you can simply use Arduino + motor shield.

Here is my test code, it works with 4 servos plugged into each other. I tried it on Arduino Mega, but you may use Uno and any other Arduino which has PWM ports:

Code: [Select]
#include <MeccaBrain.h>

//for Uno and like
/*
const int pwmPin1=9;
const int pwmPin2=10;
const int pwmPin3=11;
*/
//for Mega and like
const int pwmPin1=44;
const int pwmPin2=45;
const int pwmPin3=46;

MeccaBrain chain1(pwmPin1); //each chain allows to plug up to 4 smart modules
MeccaBrain chain2(pwmPin2);
MeccaBrain chain3(pwmPin3);
 
void setup() {

}

void loop() {
 chain1.setServoPosition(0, 0);
 chain1.communicate();
 delay(1000);
 chain1.setServoPosition(0, 255);
 chain1.communicate();
 delay(1000);

 chain1.setServoPosition(1, 0);
 chain1.communicate();
 delay(1000);
 chain1.setServoPosition(1, 255);
 chain1.communicate();
 delay(1000);

 chain1.setServoPosition(2, 0);
 chain1.communicate();
 delay(1000);
 chain1.setServoPosition(2, 255);
 chain1.communicate();
 delay(1000);

 chain1.setServoPosition(3, 0);
 chain1.communicate();
 delay(1000);
 chain1.setServoPosition(3, 255);
 chain1.communicate();
 delay(1000);
}

DuaneDegn

#24
Jan 09, 2016, 08:08 pm Last Edit: Jan 09, 2016, 08:08 pm by DuaneDegn
Here's the image attached to the volkovo_ta's reply.



How to insert uploaded images.

Thanks for the information about the servos.

goodinventor

Hello,

I have a question. Will female jumper wires fit into the Smart Servo ports in the MeccaBrain? I plan on connecting some of my own sensors to the MeccaBrain to expand the functionality.

Darwin7

Hi guys,

I succesfully connected the Meccanoid servos to Arduino. It appeared to be not hard at all. I used Arduino Mega and Sensor Shield.

The only problem is to find appropriate connectors. Meccanoids battery has Mini-Tamiya female connector. So you need to buy one Mini-Tamiya male at a hobby RC cars store, it is quite common.

Motors are plugged differently, so you need to buy at a local electronics store 2 different male connectors: one is CWF-2 (it is called so in Russia, a small white one), and another one I cannot figure out, so I used simply PLS-2, it fits. Tomorrow I am going to try try my good old Motor Shield to drive his DC motors, and after that I write a complete tutorial.


Code: [Select]
#include <MeccaBrain.h>

//for Uno and like
/*
const int pwmPin1=9;
const int pwmPin2=10;
const int pwmPin3=11;
*/
//for Mega and like
const int pwmPin1=44;
const int pwmPin2=45;
const int pwmPin3=46;

MeccaBrain chain1(pwmPin1); //each chain allows to plug up to 4 smart modules
MeccaBrain chain2(pwmPin2);
MeccaBrain chain3(pwmPin3);
 
void setup() {

}

void loop() {
 chain1.setServoPosition(0, 0);
 chain1.communicate();
 delay(1000);
 chain1.setServoPosition(0, 255);
 chain1.communicate();
 delay(1000);

 chain1.setServoPosition(1, 0);
 chain1.communicate();
 delay(1000);
 chain1.setServoPosition(1, 255);
 chain1.communicate();
 delay(1000);

 chain1.setServoPosition(2, 0);
 chain1.communicate();
 delay(1000);
 chain1.setServoPosition(2, 255);
 chain1.communicate();
 delay(1000);

 chain1.setServoPosition(3, 0);
 chain1.communicate();
 delay(1000);
 chain1.setServoPosition(3, 255);
 chain1.communicate();
 delay(1000);
}

That's great! One question however, does this code work with Meccanoid's motors? I want to focus on the arms and controlling the LED eyes first. Thanks for the info on connecting the servos.

DuaneDegn

#27
Jan 10, 2016, 05:40 pm Last Edit: Jan 10, 2016, 05:41 pm by DuaneDegn
I thought the motors work like normal DC motors?

I noticed volkova_ta's code give the strong impression PWM pins are required to use with the servos.

Code: [Select]
//for Uno and like
/*
const int pwmPin1=9;
const int pwmPin2=10;
const int pwmPin3=11;
*/
//for Mega and like
const int pwmPin1=44;
const int pwmPin2=45;
const int pwmPin3=46;


The Meccanoid library calls the I/O pins "_pmwPin" which may be a typo for "_pwmPin" but I'm not sure.

The thing is, the library doesn't use "analogWrite". Only "digitalWrite" is used. You should be able to use any I/O pins with the Meccanoid servos.

The "sendByte" function gives us a clue why the baud is so low. They're bit banging the serial output with digitalWrite.

This is basically a very slow software serial. It blocks the code while the data is being transmitted. It would be interesting to see if the Meccanoid servos would respond to the Arduino's serial output.

Code: [Select]
void MeccaBrain :: sendByte(byte servoData){
  pinMode(_pmwPin, OUTPUT);                                    
  digitalWrite(_pmwPin,LOW);
  delayMicroseconds(bitDelay);                  // start bit - 417us LOW

  for (byte mask = 00000001; mask>0; mask <<= 1) {   // iterate through bit mask
    if (servoData & mask){                           // if bitwise AND resolves to true
      
      digitalWrite(_pmwPin,HIGH);              // send 1
      
    }else{                                      // if bitwise and resolves to false
      
      digitalWrite(_pmwPin,LOW);               // send 0
    }
    delayMicroseconds(bitDelay);                //delay
  }
  
  digitalWrite(_pmwPin,HIGH);
  delayMicroseconds(bitDelay);         // stop bit - 417us HIGH
  
  digitalWrite(_pmwPin,HIGH);
  delayMicroseconds(bitDelay);         // stop bit - 417us HIGH
  
}


This sure seems like a backwards way of using "smart servos".

Darwin7

Sorry if I'm not paying attention, but there is also cords that plug up the servos (head, arms) to the MeccaBrain. Is there a place to put it on the Adruino? The holes inside of the cord piece may indicate it would plug up to the MeccaBrain by its pins. Once I make sure this can happen, I'll have to make sure the servos are daisy chained while in its humanoid form.

DuaneDegn

I'm not sure if there's an easy way for the MeccaBrain to work with the Arduino.

I was under the impression the Arduino code was there to use if you wanted to use an Arduino instead of the MeccaBrain.

I'm not sure if I have this straight or not.

Go Up