Chien Meccano Meccanoïd

Postez ici les photos et commentaires de vos créations personnelles.
Moose
Membre Actif
Membre Actif
Messages : 71
Enregistré le : 01 déc. 2020, 07:02

Chien Meccano Meccanoïd

Message par Moose »

Fabriqué à partir de deux grands mécanoïdes et entraîné par esp32.

Modifié en dernier par Moose le 25 févr. 2021, 05:01, modifié 1 fois.

Avatar du membre
marc80
Modérateur
Modérateur
Messages : 424
Enregistré le : 27 juil. 2020, 14:22
Localisation : 80500 Montdidier

Re: Chien Meccano Meccanoïd

Message par marc80 »

As tu le programme correspondant ? Certains d'entre nous (dont je suis) seraient intéressés par le télécharger)

Nota. J'ai ajouté la référence Meccanoïd dans ton sujet pour le retrouver plus facilement.
Bon Meccano à tous ! :020:  Marc
 

Moose
Membre Actif
Membre Actif
Messages : 71
Enregistré le : 01 déc. 2020, 07:02

Re: Chien Meccano Meccanoïd

Message par Moose »

// As requested

#include <MeccaBrain.h>

// Borrowed heavily from tatyanavolkova Update demo_meccanoids.ino https://github.com/robotscity/meccanoid ... anoids.ino
// Pins to connect Meccanoids' servos, where chain 1 is left arm, chain 2 is left leg and chain 3 is right arm chain 4 is right leg

const int chainPin1 = 32;
const int chainPin2 = 33;
const int chainPin3 = 25;
const int chainPin4 = 26;


MeccaBrain chain1 (chainPin1); 
MeccaBrain chain2 (chainPin2);
MeccaBrain chain3 (chainPin3);
MeccaBrain chain4 (chainPin4);


// Joints mapping:
// Chain 1 - Left Arm. 1.0 is Shoulder, 1.1 is Arm, 1.2 is Elbow
// Chain 2 - Right Arm. 2.0 is Shoulder, 2.1 is Arm, 2.2 is Elbow
// Chain 3 - Right Leg. 3.0 is Shoulder, 3.1 is Arm 3.2 is Elbow
// Chain 4 - Left Leg. 4.0 is Shoulder, 4.1 is Arm 4.2 is Elbow



// Servo colors
const byte JOINT_BLACK = 0xF0;  
const byte JOINT_RED = 0xF1; 
const byte JOINT_GREEN = 0xF2; 
const byte JOINT_BROWN = 0xF3; 
const byte JOINT_BLUE = 0xF4; 
const byte JOINT_VIOLET = 0xF5; 
const byte JOINT_SEA = 0xF6; 
const byte JOINT_WHITE = 0xF7;

  


void setup () {
  
  pinMode (chainPin1, OUTPUT);
  pinMode (chainPin2, OUTPUT);
  pinMode (chainPin3, OUTPUT);
  pinMode (chainPin4, OUTPUT);
  Serial.begin (9600);

  // Awake all servos
  
  for (int i = 0; i <50; i ++)
  {
    chain1.communicate ();
    chain2.communicate ();
    chain3.communicate ();
      chain4.communicate ();
  }
  delay (200);


// set all servos to center 
      chain1.setServoPosition (0, 112);   
      chain1.setServoPosition (1, 112);   
      chain1.setServoPosition (2, 112);   
      chain1.communicate ();
      chain2.setServoPosition (0, 112);    
      chain2.setServoPosition (1, 112);    
      chain2.setServoPosition (2, 112);
      chain2.communicate ();
      chain3.setServoPosition (0, 112);    
      chain3.setServoPosition (1, 112);
      chain3.setServoPosition (2, 112);
      chain3.communicate ();
      chain4.setServoPosition (0, 112);     
      chain4.setServoPosition (1, 112);
      chain4.setServoPosition (2, 112);
      chain4.communicate ();
      delay (1000);

// set the servos to identify each leg

  chain1.setServoColor (0, JOINT_RED);
  chain1.setServoColor (1, JOINT_RED);
  chain1.setServoColor (2, JOINT_RED);
  chain1.communicate ();
  chain2.setServoColor (0, JOINT_SEA);
  chain2.setServoColor (1, JOINT_SEA);
  chain2.setServoColor (2, JOINT_SEA);
  chain2.communicate ();
  chain3.setServoColor (0, JOINT_VIOLET);
  chain3.setServoColor (1, JOINT_VIOLET);
  chain3.setServoColor (2, JOINT_VIOLET);
  chain3.communicate ();
  chain4.setServoColor (0, JOINT_WHITE);
  chain4.setServoColor (1, JOINT_WHITE);
  chain4.setServoColor (2, JOINT_WHITE);
  chain4.communicate ();




}

void loop () {

  // frame one
      
      chain1.setServoPosition (1, 107);
      chain1.setServoPosition (2, 200);
      chain1.communicate ();
      delay (500);
      
      chain2.setServoPosition (1, 160);
      chain2.setServoPosition (2, 90);
      chain2.communicate ();
      delay (500);
      
      chain3.setServoPosition (1, 90);
      chain3.setServoPosition (2, 122);
      chain3.communicate ();
      delay (500);
      
      chain4.setServoPosition (1, 90);
      chain4.setServoPosition (2, 122);
      chain4.communicate ();
      delay (2500);
  
  // frame 2    
  
      chain1.setServoPosition (1, 132);
      chain1.setServoPosition (2, 190);
      chain1.communicate ();
      delay (500);
 
      chain2.setServoPosition (1, 170);
      chain2.setServoPosition (2, 122);
      chain2.communicate ();
      delay (500);
      
      chain3.setServoPosition (2, 102);
      chain3.setServoPosition (1, 110);
      chain3.setServoPosition (2, 142);
      chain3.communicate ();
      delay (500);
 
      chain4.setServoPosition (1, 90);
      chain4.setServoPosition (2, 140);
      chain4.communicate ();
      delay (2500);

// Frame 3

      chain1.setServoPosition (1, 160);
      chain1.setServoPosition (2, 122);
      chain1.communicate ();
      delay (500);

      chain2.setServoPosition (1, 170);
      chain2.setServoPosition (2, 122);
      chain2.communicate ();
      delay (500);

      chain3.setServoPosition (1, 150);
      chain3.setServoPosition (2, 122);
      chain3.communicate ();
      delay (500);

      chain4.setServoPosition (1, 122);
      chain4.setServoPosition (2, 122);
      chain4.communicate ();
      delay (500);
      
/ * still working on the final 5 frames    
      chain1.setServoPosition (1, 167);
      chain1.setServoPosition (2, 250-180);
      chain1.communicate ();
      delay (500);

      chain2.setServoPosition (1, 167);
      chain2.setServoPosition (2, 250-180);
      chain2.communicate ();
      delay (500);

      chain3.setServoPosition (1, 167);
      chain3.setServoPosition (2, 250-180);
      chain3.communicate ();
      delay (500);

      chain4.setServoPosition (1, 167);
      chain4.setServoPosition (2, 250-180);
      chain4.communicate ();
      delay (500);
      
  * /
  
  }

Moose
Membre Actif
Membre Actif
Messages : 71
Enregistré le : 01 déc. 2020, 07:02

Re: Chien Meccano Meccanoïd

Message par Moose »

it is very important to make the wire harness as described on this link.

https://meccontrol.com/help/software/de ... servomotor



 

Moose
Membre Actif
Membre Actif
Messages : 71
Enregistré le : 01 déc. 2020, 07:02

Re: Chien Meccano Meccanoïd

Message par Moose »

Meccabrain.h mis à jour pour corriger les variables de tableau

Code : Tout sélectionner

/*

UPDATED NOV 2019  MOVED ARRAY VARIABLES TO BOTTOM OF PRIVATE DECLARATION




       LEGAL NOTICE:
      Meccano™, MeccaBrain™, MeccanoTech™ and Meccanoid™ are trademarks of Meccano.  All rights reserved.     
      The information contained in this document is Proprietary to Spin Master Ltd.   
      This information should not be used in the creation and sale of any commercial product.”
*/
#ifndef MeccaBrain_h
#define MeccaBrain_h

#include "Arduino.h"

class MeccaBrain{


    public:
        MeccaBrain(int pin);
        
        byte outputByteInfo(int num);
        byte inputByteInfo();
        byte checkSumByteInfo();
        
        char moduleTypeInfo(int num);
        byte moduleNumInfo();
        byte getLEDorder();
        byte getLEDbyte1();
        byte getLEDbyte2();    

        void setLEDColor(byte red, byte green, byte blue, byte fadetime);
        
        void communicate();        
        void sendByte(byte servoData);
        byte receiveByte();
        byte calculateCheckSum(byte Data1, byte Data2, byte Data3, byte Data4);
        
        byte inputBytesInfo(int servoNum);
        void setServoColor(int servoNum, byte color);
        ;
        void setServotoLIM(int servoNum);
        byte getServoPosition(int servoNum);
        
        byte servoPositionsInfo(int servoNum);
        void setServoPosition(int servoNum, byte pos);

    private:
        int _pmwPin;
        int servoNumber;
        int inputCounter = 0;
        int moduleNum = 0;
        int printModNum = 0;
        int ledOrder = 0;
        int bitDelay = 417;
        int receiveArray[8];
        
        
        byte inputByte;
        
        byte checkSum;
        byte servoPos;
        byte LEDoutputByte1 = 0x00;
        byte LEDoutputByte2 = 0x47;
        byte header = 0xFF;
        byte outputByte[4];
        byte printOutputByte[4];
        
        char moduleType[4];
        byte inputBytes[];
               int servo1Positions[];
        int servo2Positions[];
        int servo3Positions[];
        int servo4Positions[];
    
        
};

#endif
Modifié en dernier par Moose le 14 mars 2021, 05:12, modifié 2 fois.

Avatar du membre
marc80
Modérateur
Modérateur
Messages : 424
Enregistré le : 27 juil. 2020, 14:22
Localisation : 80500 Montdidier

Re: Chien Meccano Meccanoïd

Message par marc80 »

Merci.
Je vais essayer, dès que j'en ai la possibilité.

Thanks. I will try when possible.
Bon Meccano à tous ! :020:  Marc
 

Moose
Membre Actif
Membre Actif
Messages : 71
Enregistré le : 01 déc. 2020, 07:02

Re: Chien Meccano Meccanoïd

Message par Moose »

J'espère refaire avec cette nouvelle bibliothèque arduino.

https://github.com/alexfrederiksen/Mecc ... ino#readme

Je vous remercie JeanGar

Répondre