1. Do not share user accounts! Any account that is shared by another person will be blocked and closed. This means: we will close not only the account that is shared, but also the main account of the user who uses another person's account. We have the ability to detect account sharing, so please do not try to cheat the system. This action will take place on 04/18/2023. Read all forum rules.
    Dismiss Notice
  2. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Now a Download Plan!
  3. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  4. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

Building a new 6DIY

Discussion in 'DIY Motion Simulator Projects' started by Flymen, Aug 22, 2018.

  1. pmvcda

    pmvcda aka FlyPT

    Joined:
    Nov 3, 2010
    Messages:
    1,846
    Location:
    Portugal
    Balance:
    14,096Coins
    Ratings:
    +2,169 / 16 / -0
    My Motion Simulator:
    6DOF
    Thank's for the offer, but I'm in Portugal. Sending me this and with our customs,it's going to be a problem.
    They will be lost and it will be more expensive to send them than to buy some here.
    I thought about using just some tape because I'm thinking of making some covers for all the actuator.
    • Like Like x 1
  2. Flymen

    Flymen Flymen Gold Contributor

    Joined:
    May 19, 2018
    Messages:
    334
    Location:
    Montreal, Canada
    Balance:
    2,409Coins
    Ratings:
    +191 / 2 / -0
    My Motion Simulator:
    DC motor, 6DOF
    photo frame.jpg up date platform and set up
    phot frame modif.jpg
    • Like Like x 3
  3. Flymen

    Flymen Flymen Gold Contributor

    Joined:
    May 19, 2018
    Messages:
    334
    Location:
    Montreal, Canada
    Balance:
    2,409Coins
    Ratings:
    +191 / 2 / -0
    My Motion Simulator:
    DC motor, 6DOF
    set up001.JPG set up 1.JPG set up01.JPG

    Need your suggestion before to hold everything , thanks !!! SilentChill, pmvcda, Pierre Lalancette, sixdegreeofflight,seattime, and all of us !!!!
    • Like Like x 6
    Last edited: Oct 11, 2018
  4. Flymen

    Flymen Flymen Gold Contributor

    Joined:
    May 19, 2018
    Messages:
    334
    Location:
    Montreal, Canada
    Balance:
    2,409Coins
    Ratings:
    +191 / 2 / -0
    My Motion Simulator:
    DC motor, 6DOF
  5. Thanos

    Thanos Building the Future one AC Servo at a time... or 6

    Joined:
    Jul 6, 2017
    Messages:
    1,346
    Occupation:
    Electronics Engineer
    Location:
    United States
    Balance:
    2,692Coins
    Ratings:
    +1,043 / 9 / -0
    My Motion Simulator:
    AC motor, Motion platform, 4DOF, 6DOF
    Can you make a list of the parts you have to see compatibility?
    Motor drives model?
    Encoder model?
  6. Flymen

    Flymen Flymen Gold Contributor

    Joined:
    May 19, 2018
    Messages:
    334
    Location:
    Montreal, Canada
    Balance:
    2,409Coins
    Ratings:
    +191 / 2 / -0
    My Motion Simulator:
    DC motor, 6DOF
    Some good news and up date !!!!:)
    A - Encoder rotary with LS7366Rsh problem with 200 ppm (RHS15)
    1. Speed ( 1700 rpm) with signal A and B 2v/div , 20us/div . Arduino monitor serie counter work good ( 0 – 1700 rpm ) . https://www.youtube.com/watch?v=gh4fTqsVAyk
    2. Speed ( 3900 rpm ) ) with signal A and B 2v/div , 20us/div . . Arduino monitor serie counter stop 1800- 3900 rpm ). https://www.youtube.com/watch?v=3yd8UW7-7aQ
    3. Speed 0-3900 rpm both sides and stop . https://www.youtube.com/watch?v=gcnw1yKj_hU
    The problem is each capacitors of each chanel A and B . The board has low pass filters at the inputs terminals. Exemple : We must remove C37 and C34 capacitors (for channel 1).
    After this remove everything work well ! :grin Card and connectors 70$us with shipping . Thanks Ben Mignano ( conceptor )
    Connectors and pins : https://www.mouser.com/ProductDetai...JyKqCNAFlrJ9ZaH2Op8FmQZHbEs5z/xaT2PBLp%2b3w==

    https://www.mouser.com/ProductDetail/Molex/50212-8100?qs=sGAEpiMZZMvvAo%252bip5liNyX3NX3PPZb4

    https://www.amazon.com/XH2-54mm-XH3-96mm-Terminals-SN-01BM-%EF%BC%880-08-0-5mm2%EF%BC%89/dp/B00YGLKBSK/ref=sr_1_1_sspa?ie=UTF8&qid=1540492304&sr=8-1-spons&keywords=iwiss+sn-01bm&psc=1
    LS7366Shield6ChRed_Back.png
    upload_2018-10-25_19-32-31.png
    IMG_0749.JPG
    Last edited: Oct 29, 2018
  7. Flymen

    Flymen Flymen Gold Contributor

    Joined:
    May 19, 2018
    Messages:
    334
    Location:
    Montreal, Canada
    Balance:
    2,409Coins
    Ratings:
    +191 / 2 / -0
    My Motion Simulator:
    DC motor, 6DOF
    Others solution( B) to control the drive B30A8 with Arduino 0-5 v PWM signal :
    A) (uni-directionnel PWM)with ampli 0-10 v with signal +10 /-10 volt from the drive but.. , one of my drive ( and i don't know why… may be after a couple test with ampli ) have +10v/-14 v . for this raison i will forget it because I don't want to see this incident with another drives .
    B)( Bi -directionnel PWM)This solution need two Arduino uno to control 6 drives ( one for control encoders with LS7366Rsh , and two others for control 6 drives ) .
    Each output PWM of the Arduino will have RC filter with R=10k and C=100uF = 0-4.2 v/DC to control REF IN ( drive ). Normaly this input is 0-10 volt but i have a pot ( REF Gain )in my drive to control this input at 0-5 volt or less . thanks for your code pmvcda. https://www.xsimulator.net/community/members/pmvcda.4322/

    With this drive , I have 3 Pots to control the motor ( current limit , Ref Gain and Off set ) this will help me to control of each side and power of actuator that I need when I will testing this with me on the racing chair !:think
    55950
    • Like Like x 1
    Last edited: Nov 2, 2018
  8. Flymen

    Flymen Flymen Gold Contributor

    Joined:
    May 19, 2018
    Messages:
    334
    Location:
    Montreal, Canada
    Balance:
    2,409Coins
    Ratings:
    +191 / 2 / -0
    My Motion Simulator:
    DC motor, 6DOF
    Dessin carte arduino.png
    Hi everyone ,@pmvcda,silentchill,@wannabeaflyer,@noorbeast ,
    I would like to know if someone have this set up ?
    I have the code arduino for encoders ( card 1) but only this !
    The code is like a spaghetti for me ... and how mix those cards together !
    Thanks for your help ! :)
    I will try to learn more here :
    https://learn.adafruit.com/category/learn-arduino
    https://forum.arduino.cc/index.php?topic=576880.0

    1-Communication Arduino :
    SPI Communication ( Master and slaves ) :https://arduino.stackexchange.com/questions/16348/how-do-you-use-spi-on-an-arduino
    I2C comm : https://electronics.stackexchange.c...-devices-into-a-single-pin-a4-sda-and-a5?rq=1

    2- Program code idea:
    section : void setup()
    a) go at home switch( reset at zero encoder) and back at middle PT and wait there .

    This is the code for Card Master ( Encoder lineaire) .
    Code:
    /**********************************************************************
    * © 2017 LSI Computer Systems Inc.
    *
    * FileName:        LS7366R LS7366RSH.ino
    * Dependencies:    Header (.h) files if applicable, see below
    * Processor:       ATMEGA16U2
    * Compiler:        Arduino® (IDE)v1.8.5  or higher
    *
    * SOFTWARE LICENSE AGREEMENT:
    * LSI Computer Systems Incorporated ("LSI/CSI") retains all ownership and
    * intellectual property rights in the code accompanying this message and in all
    * derivatives hereto.  You may use this code, and any derivatives created by
    * any person or entity by or on your behalf, exclusively with LSI/CSI,s
    * proprietary products.  Your acceptance and/or use of this code constitutes
    * agreement to the terms and conditions of this notice.
    *
    * CODE ACCOMPANYING THIS MESSAGE IS SUPPLIED BY LSI/CSI "AS IS".  NO
    * WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
    * TO, IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A
    * PARTICULAR PURPOSE APPLY TO THIS CODE, ITS INTERACTION WITH LSI/CSI,S
    * PRODUCTS, COMBINATION WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.
    *
    * YOU ACKNOWLEDGE AND AGREE THAT, IN NO EVENT, SHALL LSI/CSI BE LIABLE, WHETHER
    * IN CONTRACT, WARRANTY, TORT (INCLUDING NEGLIGENCE OR BREACH OF STATUTORY DUTY),
    * STRICT LIABILITY, INDEMNITY, CONTRIBUTION, OR OTHERWISE, FOR ANY INDIRECT, SPECIAL,
    * PUNITIVE, EXEMPLARY, INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, FOR COST OR EXPENSE OF
    * ANY KIND WHATSOEVER RELATED TO THE CODE, HOWSOEVER CAUSED, EVEN IF LSI/CSI HAS BEEN
    * ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT
    * ALLOWABLE BY LAW, LSI/CSI'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY RELATED TO
    * THIS CODE, SHALL NOT EXCEED THE PRICE YOU PAID DIRECTLY TO LSI/CSI SPECIFICALLY TO
    * HAVE THIS CODE DEVELOPED.
    *
    * You agree that you are solely responsible for testing the code and
    * determining its suitability.  LSI/CSI has no obligation to modify, test,
    * certify, or support the code.
    *
    * REVISION HISTORY:
    *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    * Author            Date      Comments on this revision
    *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    * Ben Mignano     10/02/17    First release of source file
    *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    *
    * ADDITIONAL NOTES:
    * This code is tested on Arduino Uno R3 and the shield LS7366RSH Development Boards*/
    // the LS7366R communicates using SPI, so include the library:
    #include <SPI.h>
    #define ENABLE    1
    #define DISABLE   0
    /***MDR0 configuration data - the configuration byte is formed with***
    ***single segments taken from each group and ORing all together.***/
    //Count modes
    #define NQUAD   0x00 //non-quadrature mode
    #define QUADRX1  0x01 //X1 quadrature mode
    #define QUADRX2  0x02 //X2 quadrature mode
    #define QUADRX4  0x03 //X4 quadrature mode
    //Running modes
    #define FREE_RUN  0x00
    #define SINGE_CYCLE 0x04
    #define RANGE_LIMIT 0x08
    #define MODULO_N  0x0C
    //Index modes
    #define DISABLE_INDX  0x00  //index_disabled
    #define INDX_LOADC   0x10  //index_load_CNTR
    #define INDX_RESETC  0x20  //index_rest_CNTR
    #define INDX_LOADO   0x30  //index_load_OL
    #define ASYNCH_INDX  0x00  //asynchronous index
    #define SYNCH_INDX   0x80  //synchronous index
    //Clock filter modes
    #define FILTER_1   0x00  //filter clock frequncy division factor 1
    #define FILTER_2   0x80  //filter clock frequncy division factor 2
    /* **MDR1 configuration data; any of these***
    ***data segments can be ORed together***/
    //Flag modes
    #define NO_FLAGS   0x00  //all flags disabled
    #define IDX_FLAG   0x10  //IDX flag
    #define CMP_FLAG   0x20  //CMP flag
    #define BW_FLAG   0x40  //BW flag
    #define CY_FLAG   0x80  //CY flag
    //1 to 4 bytes data-width
    #define BYTE_4    0x00  //four byte mode
    #define BYTE_3    0x01  //three byte mode
    #define BYTE_2    0x02  //two byte mode
    #define BYTE_1    0x03  //one byte mode
    //Enable/disable counter
    #define EN_CNTR   0x00  //counting enabled
    #define DIS_CNTR   0x04  //counting disabled
    /* LS7366R op-code list */
    #define CLR_MDR0     0x08
    #define CLR_MDR1     0x10
    #define CLR_CNTR     0x20
    #define CLR_STR     0x30
    #define READ_MDR0   0x48
    #define READ_MDR1   0x50
    #define READ_CNTR   0x60
    #define READ_OTR     0x68
    #define READ_STR     0x70
    #define WRITE_MDR1   0x90
    #define WRITE_MDR0   0x88
    #define WRITE_DTR   0x98
    #define LOAD_CNTR   0xE0
    #define LOAD_OTR     0xE4
    //the lines are used by 74HC138 chip to select the cable select lines
    int nSS_ENC_A2_pin = 10;//C  A2
    int nSS_ENC_A1_pin = 9; //B  A1
    int nSS_ENC_A0_pin = 8; //A  A0
    //CLK Select DFLAG DF-F
    int CLK_SEL_DFAG_pin = 4;
    //Enable ENC_SS
    int EN_ENC_SS_pin = 5;
    //Blue LED
    int LED_ACT_pin = 6;
    //DFLAG
    int DFLAG_pin = 3;
    //LFLAG
    int LFLAG_pin = 2;
    #define Slave_Select_Low PORTB &= ~(1 << PB4)
    #define Slave_Select_High PORTB |= (1 << PB4)
    //function prototypes
    void blinkActLed(void);
    long getChanEncoderValue(int encoder);
    unsigned int getChanEncoderReg(int opcode, int encoder);
    void rstEncCnt(int encoder);
    void setSSEnc(bool enable, int encoder);
    void clearStrReg(int encoder);
    void setSSEncCtrlBits(int value);
    void Init_LS7366Rs(void);
    void setDFlagChMux(int encoder);
    void loadRstReg(unsigned char op_code);
    void writeSingleByte(unsigned char op_code, unsigned char data);
    unsigned char readSingleByte(unsigned char op_code);
    //Global Variables
    int IsrDFlag;
    int DFlagCh;
    int IsrLFlag;
    int LFlagCnt[6];
    //*****************************************************
    void setup()
    //*****************************************************
    {
      int a =0;
     
        Serial.begin(9600);
        pinMode(LED_ACT_pin, OUTPUT);
     
     pinMode(CLK_SEL_DFAG_pin, OUTPUT);
     pinMode(EN_ENC_SS_pin, OUTPUT);
     
        pinMode(nSS_ENC_A2_pin, OUTPUT);
        pinMode(nSS_ENC_A1_pin, OUTPUT);
        pinMode(nSS_ENC_A0_pin, OUTPUT);
        digitalWrite(LED_ACT_pin, LOW);
     
     digitalWrite(CLK_SEL_DFAG_pin, LOW);
     digitalWrite(EN_ENC_SS_pin, LOW);
     
        digitalWrite(nSS_ENC_A2_pin, HIGH);
        digitalWrite(nSS_ENC_A1_pin, HIGH);
        digitalWrite(nSS_ENC_A0_pin, HIGH);
     
     pinMode(DFLAG_pin, INPUT);
     pinMode(LFLAG_pin, INPUT_PULLUP);
     
      //initialize the register in all of the 6 chips
        Init_LS7366Rs();
     
     //set Ch1 DFLAG to INT1
      IsrDFlag = 0;
     DFlagCh = 1;
     setDFlagChMux(DFlagCh);
      IsrLFlag = 0;
      for (a = 0; a< 6; a++){
        LFlagCnt[a] = 0;
      }
     
      attachInterrupt(digitalPinToInterrupt(DFLAG_pin), ISR_DFlag, FALLING );
      attachInterrupt(digitalPinToInterrupt(LFLAG_pin), ISR_LFlag, FALLING );
    } //end func
    //*************************************************
    //main loop
    //*****************************************************
    void loop()
      //*****************************************************
      {
        int a = 0;
     int tmpStr = 0;
        for ( a = 1; a <= 6; a++)
        {
          Serial.print(" Ch");
          Serial.print(a);
          Serial.print("=");
          Serial.print(getChanEncoderValue(a),DEC);
          Serial.print(";");
     
          Serial.print(" STR=");
          Serial.print(getChanEncoderReg(READ_STR,a),BIN);
          Serial.print(";");
        }
     Serial.print("\t");
     Serial.print(" DFLGCh=");
     Serial.print(DFlagCh);
     Serial.print(";");
     
     Serial.print(" LFLG=");
     Serial.print(digitalRead(LFLAG_pin));
     Serial.print(";");
     Serial.print(" Cnt=");
     
     for ( a = 0; a < 6; a++)
        {
      Serial.print(LFlagCnt[a]);
      Serial.print("/");
        }
     
     Serial.print(";");
        Serial.print("\r\n");
        ///////////////
        if(IsrDFlag)
        {
          DFlagCh++;
          if(DFlagCh > 6){
            DFlagCh = 1;
          }
          setDFlagChMux(DFlagCh);//check next encoder
          IsrDFlag = 0;
        }
        ///////////////
        if(IsrLFlag)
        {
        for(int a=1;a<=6;a++){
          tmpStr = getChanEncoderReg(READ_STR,a);
          tmpStr &= 0b00100000;//test CMP
          if(tmpStr){
            LFlagCnt[a-1]++;
            clearStrReg(a);
          }
        }
        IsrLFlag = 0;
       }
     ///////////////
        blinkActLed();
      } //end loop
    //*************************************************
    //*****************************************************
    void blinkActLed(void)
    //*****************************************************
    {
    static boolean LedBlink;
      LedBlink = !LedBlink;
      digitalWrite(LED_ACT_pin, LedBlink);
    }
    //*************************************************
    //*****************************************************
    long getChanEncoderValue(int encoder)
    //*****************************************************
    {
        unsigned int cnt1Value, cnt2Value, cnt3Value, cnt4Value;
        long result;
     
        setSSEnc(ENABLE, encoder);
        SPI.transfer(READ_CNTR); // Request count
        cnt1Value = SPI.transfer(0x00); // Read highest order byte
        cnt2Value = SPI.transfer(0x00);
        cnt3Value = SPI.transfer(0x00);
        cnt4Value = SPI.transfer(0x00); // Read lowest order byte
        setSSEnc(DISABLE, 0);
     
        result = ((long) cnt1Value << 24) + ((long) cnt2Value << 16) + ((long) cnt3Value << 8) + (long) cnt4Value;
        return result;
    } //end func
    //*************************************************
    //*****************************************************
    unsigned int getChanEncoderReg(int opcode, int encoder)
    //*****************************************************
    {
        unsigned int Value;
     
        setSSEnc(ENABLE, encoder);
        SPI.transfer(opcode);
        Value = SPI.transfer(0x00); // Read byte
        setSSEnc(DISABLE, 0);
        return Value;
    } //end func
    //*************************************************
    //*****************************************************
    void rstEncCnt(int encoder)
    //*****************************************************
      {
        setSSEnc(DISABLE, encoder);
        SPI.transfer(CLR_CNTR);
        setSSEnc(DISABLE, 0);
      } //end func
    //*************************************************
    //Channel Encoder Slave Select Control
    //*************************************************
    void setSSEnc(bool enable, int encoder)
    //*************************************************
    {
     if(encoder>0)
      setSSEncCtrlBits(encoder-1);
     
       if(enable)
        digitalWrite(EN_ENC_SS_pin, HIGH);
       else
        digitalWrite(EN_ENC_SS_pin, LOW);
     
    } //end func
    //*************************************************
    //*************************************************
    void setSSEncCtrlBits(int value)
    //*************************************************//*************************************************
    {
       switch (value)
       {
        case 0:
          digitalWrite(nSS_ENC_A2_pin, LOW);
          digitalWrite(nSS_ENC_A1_pin, LOW);
          digitalWrite(nSS_ENC_A0_pin, LOW);
          break;
     
        case 1:
          digitalWrite(nSS_ENC_A2_pin, LOW);
          digitalWrite(nSS_ENC_A1_pin, LOW);
          digitalWrite(nSS_ENC_A0_pin, HIGH);
          break;
     
        case 2:
          digitalWrite(nSS_ENC_A2_pin, LOW);
          digitalWrite(nSS_ENC_A1_pin, HIGH);
          digitalWrite(nSS_ENC_A0_pin, LOW);
          break;
     
        case 3:
          digitalWrite(nSS_ENC_A2_pin, LOW);
          digitalWrite(nSS_ENC_A1_pin, HIGH);
          digitalWrite(nSS_ENC_A0_pin, HIGH);
          break;
     
        case 4:
          digitalWrite(nSS_ENC_A2_pin, HIGH);
          digitalWrite(nSS_ENC_A1_pin, LOW);
          digitalWrite(nSS_ENC_A0_pin, LOW);
          break;
     
        case 5:
          digitalWrite(nSS_ENC_A2_pin, HIGH);
          digitalWrite(nSS_ENC_A1_pin, LOW);
          digitalWrite(nSS_ENC_A0_pin, HIGH);
          break;
     
        case 6:
          digitalWrite(nSS_ENC_A2_pin, HIGH);
          digitalWrite(nSS_ENC_A1_pin, HIGH);
          digitalWrite(nSS_ENC_A0_pin, LOW);
          break;
        case 7:
          digitalWrite(nSS_ENC_A2_pin, HIGH);
          digitalWrite(nSS_ENC_A1_pin, HIGH);
          digitalWrite(nSS_ENC_A0_pin, HIGH);
          break;
     
        default:
          digitalWrite(nSS_ENC_A2_pin, HIGH);
          digitalWrite(nSS_ENC_A1_pin, HIGH);
          digitalWrite(nSS_ENC_A0_pin, HIGH);
       break;
      } //end switch
    } //end func
    //*************************************************
    //*************************************************
    void clearStrReg(int encoder)
    //*************************************************
    {
          setSSEnc(ENABLE, encoder);
          SPI.transfer(CLR_STR);// Select STR || CLEAR register
          setSSEnc(DISABLE, 0);
    } //end func
    //*************************************************
    //*************************************************
    void setDFlagChMux(int encoder)
    //*************************************************
    {
     setSSEncCtrlBits(encoder);
     //Clock D-FF
        digitalWrite(CLK_SEL_DFAG_pin, LOW);
        digitalWrite(CLK_SEL_DFAG_pin, HIGH);
        digitalWrite(CLK_SEL_DFAG_pin, LOW);
    } //end func
    //*************************************************
    //*************************************************
    // LS7366 Initialization and configuration
    //*************************************************
    void Init_LS7366Rs(void)
    //*************************************************
    {
        int a = 1;
     
        // SPI initialization
        SPI.begin();
        SPI.setClockDivider(SPI_CLOCK_DIV128);      // SPI at 125Khz (on 16Mhz clock)
        setSSEnc(DISABLE, 0);
        delay(100);
        Serial.print("\r\n");
        Serial.print("\r\n");
     
        //initialize the 6
        for (a = 1; a <= 6; a++)
        {
          //********
          setSSEnc(ENABLE, a);
          SPI.transfer(WRITE_MDR0);// Select MDR0 | WR register
          SPI.transfer(FILTER_2|DISABLE_INDX|FREE_RUN|QUADRX1);// Filter clock division factor = 1 || Asynchronous Index ||
                             // disable index || free-running count mode || x4 quadrature count mode
          setSSEnc(DISABLE, 0);
     
          Serial.print(" TX MDR0=");
          Serial.print(FILTER_2|DISABLE_INDX|FREE_RUN|QUADRX1,HEX);
          Serial.print(";");
          Serial.print(" RX MDR0=");
          Serial.print(getChanEncoderReg(READ_MDR0,a),HEX);
          Serial.print(";");
          //********
          //********
          setSSEnc(ENABLE, a);
          SPI.transfer(WRITE_MDR1);// Select MDR1 | WR register
          SPI.transfer(CMP_FLAG|BYTE_4|EN_CNTR);//4-byte counter mode || Enable counting || FLAG on CMP (B5 of STR)
          setSSEnc(DISABLE, 0);
          Serial.print(" TX MDR1=");
          Serial.print(CMP_FLAG|BYTE_4|EN_CNTR,HEX);
          Serial.print(";");
          Serial.print(" RX MDR1=");
          Serial.print(getChanEncoderReg(READ_MDR1,a),HEX);
          Serial.print(";");
          //********
          //********
          setSSEnc(ENABLE, a);
          SPI.transfer(WRITE_DTR);// Select DTR | WR register
          SPI.transfer(0x00);// DTR MSB
          SPI.transfer(0x00);// DTR
          SPI.transfer(0x00);// DTR
          SPI.transfer(0x0A);// DTR LSB
          setSSEnc(DISABLE, 0);
          //********
          //********
          setSSEnc(ENABLE, a);
          SPI.transfer(LOAD_CNTR);
          setSSEnc(DISABLE, 0);
          Serial.print(" Ch");
          Serial.print(a);
          Serial.print("=");
          Serial.print(getChanEncoderValue(a),HEX);
          Serial.print(";");
          //********
          //********
          setSSEnc(ENABLE, a);
          SPI.transfer(CLR_CNTR);// Select CNTR || CLEAR register
          setSSEnc(DISABLE, 0);
          //********
          //********
         clearStrReg(a);   //reseting the counter value inside the encoder chips to 0
          rstEncCnt(a);
           //********
          //********
          Serial.print(" STR=");
          Serial.print(getChanEncoderReg(READ_STR,a),BIN);
          Serial.print(";");
          Serial.print("\t");
          //********
          //********
           Serial.print("\r\n");
        }
    } //end func
    //*************************************************
    //*************************************************
    void loadRstReg(unsigned char op_code) //dataless write command
    //*************************************************
    {
    unsigned char spi_data;
     Slave_Select_High;        // Keep SS/ High for LS7366 deselect
     Slave_Select_Low;        // Switch SS/ low for new command
     SPDR = op_code;          // Send command to LS7366
     while (!(SPSR & (1<<SPIF))) // Wait for end of the transmission
     {
     };
     spi_data = SPDR;           // Reset SPIF
     Slave_Select_High;         // Switch SS/ high for end of command
    }
    //*************************************************
    //*************************************************
    void writeSingleByte(unsigned char op_code, unsigned char data) //single byte write command
    //*************************************************
    {
    unsigned char spi_data;
     Slave_Select_High;   // Keep SS/ High for LS7366 deselect
     Slave_Select_Low;   // Switch SS/ low for new command
     SPDR = op_code;   // Send command to LS7366
     while (!(SPSR & (1<<SPIF))) // Wait for end of the transmission
     {
     };
     spi_data = SPDR;   // Reset SPIF
     SPDR = data;    // Send data to be written to LS7366 register
     while (!(SPSR & (1<<SPIF))) // Wait for end of the transmission
     {
     };
     spi_data = SPDR;   // Reset SPIF
     /*additional bytes can be sent here for multibyte write, e.g., write_DTR*/
     Slave_Select_High;   // Switch SS/ high for end of command
    }
    //*************************************************
    //*************************************************
    unsigned char readSingleByte(unsigned char op_code) //single byte read command
    //*************************************************
    {
    unsigned char spi_data;
     Slave_Select_High;   // deselect the the LS7366
     Slave_Select_Low;   // Switch SS/ low for new command
     SPDR = op_code;   // send op_code for read to LS7366
     while (!(SPSR & (1<<SPIF))) // Wait for end of transmission
     {
     };
     spi_data = SPDR;   // Reset SPIF
     SPDR = 0xFF;    // Start dummy transmission to read data from LS7366
     while (!(SPSR & (1<<SPIF))) // Wait for end of the transmission
     {
     };
     spi_data = SPDR;   // Reset SPIF
     /*additional bytes can be received here for multibyte read, e.g., read_OTR*/
     Slave_Select_High;   // Switch SS/ high for end of command
    return spi_data;
    }
    //*************************************************
    //*****************************************************
    void ISR_DFlag()
    //*****************************************************
    {
      IsrDFlag = 1;
    }
    //*************************************************
    //*****************************************************
    void ISR_LFlag()
    //*****************************************************
    {
     IsrLFlag = 1;
    }
    //*************************************************
    
    Last edited: Oct 31, 2018
  9. Flymen

    Flymen Flymen Gold Contributor

    Joined:
    May 19, 2018
    Messages:
    334
    Location:
    Montreal, Canada
    Balance:
    2,409Coins
    Ratings:
    +191 / 2 / -0
    My Motion Simulator:
    DC motor, 6DOF
  10. Thanos

    Thanos Building the Future one AC Servo at a time... or 6

    Joined:
    Jul 6, 2017
    Messages:
    1,346
    Occupation:
    Electronics Engineer
    Location:
    United States
    Balance:
    2,692Coins
    Ratings:
    +1,043 / 9 / -0
    My Motion Simulator:
    AC motor, Motion platform, 4DOF, 6DOF

    I see all the parts you are using. I can guarantee you the wiring will be a real spaghetti. I tried that approach with my AMC1280USB and encoder2position modules and signal conditioners etc. I end up using so many wires that I kept having noise issues and loose connections and wrong wiring sometimes. It frustrated me so much that I build the wiring into PCB with only absolute needed wires going to the servo drives and the limit sensors:





    The AMC-HS controller, is compatible with the servo drive on the link:
    "Differential Reference Input (±10 V Operating Range)"
    "INHIBIT IN - TTL level (+5 V) inhibit/enable input. Leave open to enable drive. Pull to ground to inhibit drive. Inhibit turns off all power devices"
  11. Flymen

    Flymen Flymen Gold Contributor

    Joined:
    May 19, 2018
    Messages:
    334
    Location:
    Montreal, Canada
    Balance:
    2,409Coins
    Ratings:
    +191 / 2 / -0
    My Motion Simulator:
    DC motor, 6DOF
    IMG_0826.JPG
    There are just crazy people who don"t change their ideas ( Il n’y a que les fous qui ne changent pas d’idées )!
    Finaly , it will be a *pot* because with encoders it too complicated . With LS7366Rsh card I could receive all pulses but transfert it with code Arduino card was too complicated for me , and I saw the coupling slide a bit from motor shaft with 50 lbs pound !! I must change the coupling for bigger and more grip ! I'm waiting for 5 others pots and couplings to set up all others actuators !
    Last edited: Nov 15, 2018
  12. Flymen

    Flymen Flymen Gold Contributor

    Joined:
    May 19, 2018
    Messages:
    334
    Location:
    Montreal, Canada
    Balance:
    2,409Coins
    Ratings:
    +191 / 2 / -0
    My Motion Simulator:
    DC motor, 6DOF
    This morning i received all coupling to set up actuators !:thumbs
    they are really stronger and more powerful grip !!!
    with Dirt rally, anything will slip on shaft with it !:thumbs

    Attached Files:

    • Like Like x 1
  13. Flymen

    Flymen Flymen Gold Contributor

    Joined:
    May 19, 2018
    Messages:
    334
    Location:
    Montreal, Canada
    Balance:
    2,409Coins
    Ratings:
    +191 / 2 / -0
    My Motion Simulator:
    DC motor, 6DOF
    Hi everybody ,
    the six actuator are finished and running on SMC3, but a few are diferent than others .. like the problems with the cheap chinese…. lead screw ( curve , mark or spot on them and, noise and vibration) potentiometer destroyed by my fault or parasite in the signal, dimention of carbon tubes in the insert (two are diferent and more resistant and leaves some printer mark ). I will make some video …. the test will be with 60 pounds each with her drives to try to put them identical or similar ( speed and torque )

    Attached Files:

    • Like Like x 3
    • Winner Winner x 1
    Last edited: Dec 6, 2018
  14. Gadget999

    Gadget999 Well-Known Member

    Joined:
    Dec 27, 2015
    Messages:
    1,886
    Location:
    London
    Balance:
    11,543Coins
    Ratings:
    +453 / 9 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, 6DOF
    how many turns do your pots have ?
  15. Flymen

    Flymen Flymen Gold Contributor

    Joined:
    May 19, 2018
    Messages:
    334
    Location:
    Montreal, Canada
    Balance:
    2,409Coins
    Ratings:
    +191 / 2 / -0
    My Motion Simulator:
    DC motor, 6DOF
    Vishay 10 turns , 10 k ohms
    The pots( cable) are very sensible to noise . exemple: wire extern , this cable must be alone or shielded with ground at both sides.,and the pot must rotate free with no pressure !!!
    It why I maded it with bearing système !!see pics

    Attached Files:

    • Like Like x 2
    Last edited: Dec 7, 2018
  16. Flymen

    Flymen Flymen Gold Contributor

    Joined:
    May 19, 2018
    Messages:
    334
    Location:
    Montreal, Canada
    Balance:
    2,409Coins
    Ratings:
    +191 / 2 / -0
    My Motion Simulator:
    DC motor, 6DOF
    … no more
    It's no easy to set up this and find a good tuning !! I need of yours ideas !!SilentChill, pmvcda, Pierre Lalancette, sixdegreeofflight and otherss






    60 LBS charge x 6 = 360 lbs total charge ! why : 200 lbs= Body , 120 lbs= Racing chair and more , and extra 40 lbs
    But , less weight you have better is !
    the last one video with 60 lbs !:popcornno more ! :grin

    Attached Files:

    • Like Like x 3
    Last edited: Dec 8, 2018
  17. Gadget999

    Gadget999 Well-Known Member

    Joined:
    Dec 27, 2015
    Messages:
    1,886
    Location:
    London
    Balance:
    11,543Coins
    Ratings:
    +453 / 9 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, 6DOF
    It looks like a good powerful actuator :)

    Does the pot signal in the smc program bounce when the actuator is bouncing ?

    I suggest you try a few exoeriments with the pid

    Double the I number and see what happens

    Double the d number and observe

    And again same for P

    If it gets worse cut the numbers in half

    P is how hard it pushes
    I is how quickly it responds
    D is how smooth it stabilises

    What motors are you running ?
    • Informative Informative x 3
    • Like Like x 1
    Last edited: Dec 8, 2018
  18. wannabeaflyer2

    wannabeaflyer2 Well-Known Member

    Joined:
    Jun 12, 2015
    Messages:
    724
    Location:
    london uk
    Balance:
    8,286Coins
    Ratings:
    +950 / 7 / -0
    My Motion Simulator:
    2DOF, Arduino, Motion platform, 6DOF
    Hi @Gadget999 great way of interpreting PID to the ordinary Guy . loved that simplified yet nice way of explaining the function of each element ( yes I know theres more to it) but that was a cool way of putting it Cheers
    • Agree Agree x 2
  19. Gadget999

    Gadget999 Well-Known Member

    Joined:
    Dec 27, 2015
    Messages:
    1,886
    Location:
    London
    Balance:
    11,543Coins
    Ratings:
    +453 / 9 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, 6DOF
    I use a form of PID with fuzzy logic in my day job and i know it is quite complex - It can go bad in the wrong hands

    i use that simple explanation to try and get customers to understand what they are changing

    there is software that will analyse a pid loop and make automatic adjustments - not suited to a Simulator in my opinion

    a good video here --
    • Like Like x 4
  20. wannabeaflyer2

    wannabeaflyer2 Well-Known Member

    Joined:
    Jun 12, 2015
    Messages:
    724
    Location:
    london uk
    Balance:
    8,286Coins
    Ratings:
    +950 / 7 / -0
    My Motion Simulator:
    2DOF, Arduino, Motion platform, 6DOF
    Hi @Gadget999 I totally agree its more complex than the analogy suggests, but for me it seemed to sum up the key bullet points ref definitions the very basics of the each elementss of P,I,D terminology ... thanks for the Video link its all good stuff :)