1. Hundreds of coffees, endless nights of debugging and coding, and countless feedback by our beta testers led to this new major release. SimTools 2.4 is probably the version with the most upgrades and improvements in a single release ever. Look at everything Dustin has included:
    SimTools 2.4 all features.
    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 Download Package Now!
  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 here. Do not following these rules will lead to permanent exclusion from this website: Read the forum rules.

DIY AC SERVO Direct Drive FFB Wheel

Discussion in 'Direct Drive Wheels' started by Alexey, Sep 27, 2019.

  1. Alexey

    Alexey Well-Known Member

    Joined:
    Sep 23, 2014
    Messages:
    448
    Occupation:
    Electronics Technician
    Location:
    Adelaide, Australia
    Balance:
    7,793Coins
    Ratings:
    +592 / 2 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    Quite some time ago when I used to be far more active on this site I purchased an AC servo motor for under $100 and set off to get the thing working. Between scratching my head and not having enough time to scratch my arse I finally had an epiphany when reading up on 3 phase control fundamentals. I had been searching for information on how to control 3 phase motors and coming up more confused then when I had started off, mostly because all of the literature that was freely available was describing a motor that was in motion/accelerating/ramping up etc. But there was nothing on motionless torque control! The only method I had left was experimentation. This is where I got my control method idea.

    The first thing I tried was just applying DC to each coil and watching the response. I had noticed that by varying the combination of positive on one coil and negative on others would set the motor in specific rotor positions.
    After some googling on what I had seen I came across a rotor position truth table which I used to sequentially shift the rotor position in a 360 degree circle. By putting +12v on the phase assigned with "1'' and 0V on the phases assigned with "0" you can step through this sequence. What you can see in the picture is that the motor repeats the sequence after 180 degrees of rotation. What this means is that if you apply +VCC to phase A and oV to phases B and C the rotor will snap to the shown position, if you force the rotor by hand past 90 degrees the rotor will then snap in the exact opposite orientation. Each "sector" has a 30 degree separation.
    Truth table.jpg
    With knowledge I set about creating some arduino code to sequentially step through these transitions.
    After more head scratching I figured out how to utilise the horde of Monster motor drivers that I have acquired over the years. You cannot normally use the H-Bridge as you are stuck with only flipping one pair of coils. That will not be able to cycle through all of the required phase sectors. I have no idea how I came up with this but it damn well worked. Here is a simplistic breakdown on coil activation:
    Switching method.jpg Follow the current flow from top to bottom via the closed switches in red. So how do we use this on a bi directional H bridge? This is how:

    A normal persons H-Bridge:
    Normal.png
    My crazy idea:

    Crazy.png
    wtf is this? stay with me here. Go back to the current flow picture. notice the switch setup? It is identical to the left side of a DC motor H-Bridge! How does this work with a Monster motor you ask? (maybe not but I'll tell you anyway :) ). The way you change directions on a Monster Motor driver is to apply 5v on pins A1 or B1 for clockwise or anti clockwise. When those pins are activated they turn on either (S1 and S4) or (S2 and S3).
    By alternating those pins I can turn on either S1 or S2. This re creates the same current paths as the current flow picture. Here is a crazy picture to depict this flow for phase sector "1 0 0": The blue line shows the current path.
    H Bridge setup.png
    So you can now see that by using 3 different H-bridges we can flip A1 and B1 to toggle through the phase sector sequences.

    Some simple code in arduino and I was able to automatically toggle through the different phase sectors and watch the motor spin. great success!

    Continued:
    • Like Like x 3
  2. Alexey

    Alexey Well-Known Member

    Joined:
    Sep 23, 2014
    Messages:
    448
    Occupation:
    Electronics Technician
    Location:
    Adelaide, Australia
    Balance:
    7,793Coins
    Ratings:
    +592 / 2 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    So now we can direct the motor to go to whatever position we want the next step is to somehow get the motor to give our hands some torque! One thing that I noticed when moving the rotor by hand is that when you apply power to one of the phase sectors the rotor wants to center itself on that sector. We can use that behaviour as directional torque! Say for instance we are holding the wheel and the rotor is centered on sector "1 0 0" and we tell the motor to go to sector "1 1 0" the motor tries to spin clockwise and exerts a force on our hands. Bam! there is your FFB!!

    As it turns out the maximum torque that the motor will exert is if we activate phase sectors that are 30 degrees away from the current physical rotor position. Essentially we need to code that every time we get a FFB signal from the game that needs to be at phase sectors 30 degrees in the required direction. By varying the PWM to the H bridge we can also control the amount of torque applied.

    Force direction.jpg
    So we have to physically know the position of the rotor with a high degree of accuracy. Fortunately the Arduino Due has this covered. There is some code available which uses timers to read 2 channels. This can be used to read and track an A and B channel of an encoder. Here is the code. So far I have not been able to miss any counts.

    void setup() {
    pmc_enable_periph_clk(ID_TC0);
    TC_Configure(TC0,0, TC_CMR_TCCLKS_XC0);

    TC0->TC_BMR = TC_BMR_QDEN // Enable QDEC (filter, edge detection and quadrature decoding)
    | TC_BMR_POSEN // Enable the position measure on channel 0
    //| TC_BMR_EDGPHA // Edges are detected on PHA only
    //| TC_BMR_SWAP // Swap PHA and PHB if necessary (reverse acting)
    | TC_BMR_FILTER // Enable filter
    | TC_BMR_MAXFILT(63) // Set MAXFILT value
    ;

    // Enable and trigger reset
    TC0->TC_CHANNEL[0].TC_CCR = TC_CCR_SWTRG | TC_CCR_CLKEN;
    Serial.begin (9600);

    }

    void loop() {

    int16_t count = REG_TC0_CV0;

    }

    "count" stores the encoder position. we can Serial.print(count); to read this value. The encoder already attached to the back of my servo only gives me 270 counts per revolution but for testing this is just fine.
    So by knowing what "count: is at each phase I know what "count" value is 30 degrees away.
    Now, to get the motor to turn in a direction and continue to spin we need to cycle through the phase sector activation. This would give us a constant torque in one direction as we spin the motor by hand. If we were to draw this sequencing and smooth it out it would look like a sine wave, with each phase separated by 60 degrees. This is very fortunate because there is a formula that can automate this calculation!

    PWM of Phase sector = MaxPWM x cos ( (2 x PI / (amount of counts to complete a cycle)) x (current position +- desired phase sector 30 degrees away).

    So it will look like this: PWM = 255 x cos((2xPI / 135) x (count + 22)
    30 degrees on my encoder is 22 counts. We use 135 in the amount of counts to complete a cycle because we have to remember that at 180 degrees of rotation the phase sector sequence resets!

    So this calculation only calculates for what strength we want phase A to be. To get the phase sequencing strengths for the rest of the phases we can offset the "count" by the amount of required counts to get to that phases "home". For my setup phase B is 44 counts away and phase C is 91 counts away. Our formula looks like this now:

    PWMA = (255 * cos(( ((2*PI)/135)) * (count + 35)));
    PWMB = (255 * cos(( ((2*PI)/135)) * ((count - 44) + 35)));
    PWMC = (255 * cos(( ((2*PI)/135)) * ((count - 91) + 35)));

    Now you might notice a few different numbers. This is actually what I have in my code as it is now. The +35 is a number I am trying out just to smoothen out transitions between phase sectors. the - 44 and 91 are the phase offsets.
    Those three formulas are the brains in providing directional torque in one direction. The opposite direction calculation looks like this:

    if (DIRECTION == LOW){ //ANTI-CLOCKWISE ROTATION

    PWMA = (255 * cos(( ((2*PI)/135)) * (count - 35)));
    PWMB = (255 * cos(( ((2*PI)/135)) * ((count - 44) - 35)));
    PWMC = (255 * cos(( ((2*PI)/135)) * ((count - 91) - 35)));
    }

    So the way I am using all of this is to use the MMos FFB to receive the FFB from the game, reading the direction and PWM and plugging that into my arduino code. The PWM value that I read from the MMos is passed through an RC filter to give me an analog 0 - 3.3V signal which is them mapped to 0 - 255 and used as the master PWM value. A bit of explaining on how I use this:

    We have to go back a few steps here and look back on our phase sector formula. Because this is a sine wave formula it gives us a negative PWM value. Analog.Write() cannot have a negative value! Also when the results are in the negative values that coil needs to be the negative side of the phase sector value. So we have some clashes here. we cannot write a negative value PWM but we also need a PWM value to activate the negative side of the H bridge. So, my solution was to map the value of the PWM calculation to 0 - 255 and constrain that value to those numbers. I still keep that calculated PWM and say that whenever the value goes below 0 that means that that phase needs to flip to become a "0" on the phase sector and write to that phase the PWM value that is read from the MMos.

    So:

    offset = analogRead(analogPin);
    PWMNEG = map (offset, 0, 1024, 0, 255);
    consPWMNEG = constrain (PWMNEG, 0, 255);

    // PHASE A CALCULATIONS

    PWMAmath = map(PWMA, 0, 255, 0, 255);
    consPWMA = constrain (PWMAmath, 0, 255);

    if (PWMA <= 0){
    PWMAcalc = consPWMNEG;
    DIRAA = LOW;
    DIRAB = HIGH;
    }

    if (PWMA >= 1){
    PWMAcalc = consPWMA;
    DIRAA = HIGH;
    DIRAB = LOW;
    }

    offset is where I read the value of the incoming PWM from the MMos I then map that value to PWMNEG and constrain that value and store that number in consPWMNEG.

    I then get the calculated value from our sine wave formula, map that to 0 - 255 and constrain that and store it value to consPWMA.

    I then look at the calculated PWMA value (the one that can still go from -255 to +255) and say, if that value is in the positive range then use that calculated value and that is the PWM strength of the "1" in our phase sector. If that calculated value is in the negative range then ignore that value because this phase sector needs to be a "0". We then flip our A1 and B1 channels on its attached H Bridge and write the value of the incoming PWM signal from the MMos. This way it ensures that no matter what strength our sine wave formula has calculated we are governed by what strength the current "0" phase sector value is being written to. Thus the MMos PWM governs the FFB strength. Because we are writing the MMos PWM value to the NEGATIVELY activated coil, it doesn't matter what the positively activated coils receive as the negatively activated coils will control the overall current flow. Imagine two valves controlling the flow of water in a pipe, with one valve above the other. It doesn't matter how much you turn on the valve that is above the bottom valve as the bottom valve will only let through by the amount that you turn it on.

    So why bother with he PWM strength calculations in the first place then if we are essentially ignoring them anyway? Well we are actually using them as a timing signal as the when we flip the "0" and "1" in our phase sectors. you can see the flips in the above code where DIRAA and DIRAB flip from HIGH to LOW.

    So now onto our force direction, we read the DIR from the MMos and remember in our sine wave formula where we plug in a value for our desired 30 degree phase sector offset? well depending on our desired direction we either add or subtract that offset. simples!


    DIRECTION = digitalRead(DIR);

    if (DIRECTION == HIGH){ //CLOCKWISE ROTATION

    PWMA = (255 * cos(( ((2*PI)/135)) * (count + 35)));
    PWMB = (255 * cos(( ((2*PI)/135)) * ((count - 44) + 35)));
    PWMC = (255 * cos(( ((2*PI)/135)) * ((count - 91) + 35)));
    }
    if (DIRECTION == LOW){ //ANTI-CLOCKWISE ROTATION

    PWMA = (255 * cos(( ((2*PI)/135)) * (count - 35)));
    PWMB = (255 * cos(( ((2*PI)/135)) * ((count - 44) - 35)));
    PWMC = (255 * cos(( ((2*PI)/135)) * ((count - 91) - 35)));
    }

    This is where I got to today. Connected everything up and fired up rfactor. Great success!
    For the purpose of a FFB wheel this code works! and you get the force detail of what your car is doing.
    More testing needs to be done and some sort of deadzone needs to be applied or filtered as the transition at top dead center gives a quick jolt through the wheel. Not sure what is causing this but it's day zero of testing and I'm sure ill find out what is causing this jolt. Maybe my control method is junk, I don't know. I just tried to go through this in a logical physically represented fashion in my mind and it works!


    So if anyone wants to try this out I'd be happy to help guide you out in the process of getting this together.
    Currently I am neatening my code and will post it in the post below this one. Requirements are that you need an arduino Due and a H bridge motor driver that has PWM and a direction pin! An STM32F4 Discovery is also mandatory as you will need the MMos utility. A 3 phase AC servo motor and an quadrature encoder. A hand full of 1k ohm resistors and a 20 - 40 uf capacitor.


    Things that need to improve:

    Reading the incoming PWM from the MMos should be read as a digital signal using timers. I need to figure out a way that does not hog processor time.

    Top dead center jolt is offputting

    The upgrade to VFD drive. I have a cheap 1KW VFD drive bought from ebay for $70. This unit does work and powers the motor well. the reason why the unit is cheap is because it has a very crude control method of just ramping up speed and that is all. What I will do is remove the microprocessor and replace it with my arduino. There will be some control method changes as the driver stage of the VFD is actually meant to drive 3 phase motors so there wont be any of this flipping nonsense. Well kind of.

    The best thing that I can do is learn to program the STM32F4 board. That means I can write shitty code and just muscle my will upon the system. The arduino is standing still compared to the speed of the STM chip.
    Last edited: Sep 27, 2019
  3. Alexey

    Alexey Well-Known Member

    Joined:
    Sep 23, 2014
    Messages:
    448
    Occupation:
    Electronics Technician
    Location:
    Adelaide, Australia
    Balance:
    7,793Coins
    Ratings:
    +592 / 2 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    My motor came from an industrial sewing machine. IMG_0585.JPG IMG_0586.JPG
    Last edited: Sep 27, 2019
  4. Alexey

    Alexey Well-Known Member

    Joined:
    Sep 23, 2014
    Messages:
    448
    Occupation:
    Electronics Technician
    Location:
    Adelaide, Australia
    Balance:
    7,793Coins
    Ratings:
    +592 / 2 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    Ensure that you have added SAM board definitions to the arduino board manager or this will throw an error.
    other arduino boards do not have the timers used here!

    Also attached is the arduino ino file
    Arduino Due code here:


    ////////////////////////////
    // Monster Motor Output
    const int M1CW = 3;
    const int M1CCW = 4;
    const int M1PWM = 5;

    const int M2CW = 6;
    const int M2CCW = 7;
    const int M2PWM = 8;

    const int M3CW = 9;
    const int M3CCW = 10;
    const int M3PWM = 11;

    int DIR = 22; // Pin that reads DIR from MMos
    int DIRECTION; // Stores the value here

    int analogPin = A0; // Pin that reads the PWM from MMos

    int offset = 0; // the rest here stores values from calculations
    int PWMNEG;
    int consPWMNEG;

    int PWMA;
    int PWMB;
    int PWMC;

    int DIRAA;
    int DIRAB;

    int DIRBA;
    int DIRBB;

    int DIRCA;
    int DIRCB;

    int PWMAmath;
    int PWMBmath;
    int PWMCmath;

    int PWMAcalc;
    int PWMBcalc;
    int PWMCcalc;

    int consPWMA;
    int consPWMB;
    int consPWMC;

    void setup() {

    pinMode(M1CW, OUTPUT);
    pinMode(M1CCW, OUTPUT);
    pinMode(M1PWM, OUTPUT);

    pinMode(M2CW, OUTPUT);
    pinMode(M2CCW, OUTPUT);
    pinMode(M2PWM, OUTPUT);

    pinMode(M3CW, OUTPUT);
    pinMode(M3CCW, OUTPUT);
    pinMode(M3PWM, OUTPUT);

    pinMode(analogPin, INPUT);
    pinMode(DIR, INPUT);


    //////////////////////////////////
    // this part calibrates the center position of the steering wheel, This part must run before the MMos board is activated!
    // If the MMos board is activated before the arduino has time to calibrate the center position might not hold properly
    // Needs more testing to see what this does

    //A = 1
    digitalWrite(M1CW, HIGH);
    digitalWrite(M1CCW, LOW);
    analogWrite(M1PWM, 255);

    //B = 0
    digitalWrite(M2CW, LOW);
    digitalWrite(M2CCW, HIGH);
    analogWrite(M2PWM, 255);

    //C = 0
    digitalWrite(M3CW, LOW);
    digitalWrite(M3CCW, HIGH);
    analogWrite(M3PWM, 255);

    delay (1000); // This part holds the motor in the ZERO position ready for the arduino to read the encoder

    //A = 0
    digitalWrite(M1CW, LOW); // Let go of the position and start the encoder reading immediately after, DONT MOVE THE WHEEL!
    digitalWrite(M1CCW, LOW);
    analogWrite(M1PWM, 0);

    //B = 0
    digitalWrite(M2CW, LOW);
    digitalWrite(M2CCW, LOW);
    analogWrite(M2PWM, 0);

    //C = 0
    digitalWrite(M3CW, LOW);
    digitalWrite(M3CCW, LOW);
    analogWrite(M3PWM, 0);

    pmc_enable_periph_clk(ID_TC0);
    TC_Configure(TC0,0, TC_CMR_TCCLKS_XC0);

    TC0->TC_BMR = TC_BMR_QDEN // Enable QDEC (filter, edge detection and quadrature decoding)
    | TC_BMR_POSEN // Enable the position measure on channel 0
    //| TC_BMR_EDGPHA // Edges are detected on PHA only
    //| TC_BMR_SWAP // Swap PHA and PHB if necessary (reverse acting)
    | TC_BMR_FILTER // Enable filter
    | TC_BMR_MAXFILT(63) // Set MAXFILT value
    ;

    // Enable and trigger reset
    TC0->TC_CHANNEL[0].TC_CCR = TC_CCR_SWTRG | TC_CCR_CLKEN;
    // serial used to debug
    Serial.begin (9600);

    }

    void loop() {

    int16_t count = REG_TC0_CV0; // Get the count value and store in "count"

    DIRECTION = digitalRead(DIR); // read the MMos directional value and store in DIRECTION
    offset = analogRead(analogPin); /// read the MMos PWM value and store it in "offset"

    PWMNEG = map (offset, 0, 1024, 0, 255); //map the incoming MMos PWM to a usable value range
    consPWMNEG = constrain (PWMNEG, 0, 255); // make sure this value stays within useable range and store that in cons PWMNEG


    // Phase calculations

    if (DIRECTION == HIGH){ //CLOCKWISE ROTATION SINE CALC

    PWMA = (255 * cos(( ((2*PI)/135)) * (count + 35)));
    PWMB = (255 * cos(( ((2*PI)/135)) * ((count - 44) + 35)));
    PWMC = (255 * cos(( ((2*PI)/135)) * ((count - 91) + 35)));
    }

    if (DIRECTION == LOW){ //ANTI-CLOCKWISE ROTATION SINE CALC

    PWMA = (255 * cos(( ((2*PI)/135)) * (count - 35)));
    PWMB = (255 * cos(( ((2*PI)/135)) * ((count - 44) - 35)));
    PWMC = (255 * cos(( ((2*PI)/135)) * ((count - 91) - 35)));
    }

    //////////////////////////////////////////////////

    // PHASE A Control

    PWMAmath = map(PWMA, 0, 255, 0, 255); // maps the sine wave calculation to a useable range for a pwm output, pwm cant be a negative value!
    consPWMA = constrain (PWMAmath, 0, 255); // ensure that no negative PWM can be assigned, store that into consPWMA

    if (PWMA <= 0){
    PWMAcalc = consPWMNEG;
    DIRAA = LOW; // flips to a "0"
    DIRAB = HIGH;
    }

    if (PWMA >= 1){
    PWMAcalc = consPWMA;
    DIRAA = HIGH; // flips to a "1"
    DIRAB = LOW;
    }




    ////////////////////////////////////////////////////

    // PHASE B Control

    PWMBmath = map (PWMB, 0, 255, 0, 255);
    consPWMB = constrain (PWMBmath, 0, 255);

    if (PWMB <= 0){
    PWMBcalc = consPWMNEG;
    DIRBA = LOW;
    DIRBB = HIGH;
    }

    if (PWMB >= 1){
    PWMBcalc = consPWMB;
    DIRBA = HIGH;
    DIRBB = LOW;
    }

    ///////////////////////////////////////////////////

    // PHASE C Control

    PWMCmath = map (PWMC, 0, 255, 0, 255);
    consPWMC = constrain (PWMCmath, 0, 255);

    if (PWMC <= 0){
    PWMCcalc = consPWMNEG;
    DIRCA = LOW;
    DIRCB = HIGH;
    }

    if (PWMC >= 1){
    PWMCcalc = consPWMC;
    DIRCA = HIGH;
    DIRCB = LOW;
    }


    //OUTPUT TO H BRIDGE

    //Phase A
    digitalWrite(M1CW, DIRAA); //Direction Pin
    digitalWrite(M1CCW, DIRAB); //Direction Pin
    analogWrite(M1PWM, PWMAcalc); //PWM Pin


    //Phase B
    digitalWrite(M2CW, DIRBA);
    digitalWrite(M2CCW, DIRBB);
    analogWrite(M2PWM, PWMBcalc);

    //Phase C
    digitalWrite(M3CW, DIRCA);
    digitalWrite(M3CCW, DIRCB);
    analogWrite(M3PWM, PWMCcalc);

    }

    Attached Files:

  5. Alexey

    Alexey Well-Known Member

    Joined:
    Sep 23, 2014
    Messages:
    448
    Occupation:
    Electronics Technician
    Location:
    Adelaide, Australia
    Balance:
    7,793Coins
    Ratings:
    +592 / 2 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    What I am hoping to achieve here is that someone with a bigger brain than me can point out any errors and also enable further development so that there can be an affordable Direct drive wheel system.
    So far I haven't seen anything that has matured to an widespread direct drive system. I'm hoping that this also does not turn into a dead project.
  6. Alexey

    Alexey Well-Known Member

    Joined:
    Sep 23, 2014
    Messages:
    448
    Occupation:
    Electronics Technician
    Location:
    Adelaide, Australia
    Balance:
    7,793Coins
    Ratings:
    +592 / 2 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    Reserved: Will attach circuit drawing here
  7. Alexey

    Alexey Well-Known Member

    Joined:
    Sep 23, 2014
    Messages:
    448
    Occupation:
    Electronics Technician
    Location:
    Adelaide, Australia
    Balance:
    7,793Coins
    Ratings:
    +592 / 2 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino


    Only running at 16V at the moment, will bump up the voltage as the system matures.
    Last edited: Oct 8, 2019
  8. Huan Nguyen

    Huan Nguyen New Member

    Joined:
    Oct 15, 2018
    Messages:
    5
    Balance:
    9Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, AC motor, SCN5, SCN6, SimAxe, Arduino, JRK, Joyrider, SimforceGT, Motion platform, 4DOF, 6DOF
    Like. Do you have videos
  9. Alexey

    Alexey Well-Known Member

    Joined:
    Sep 23, 2014
    Messages:
    448
    Occupation:
    Electronics Technician
    Location:
    Adelaide, Australia
    Balance:
    7,793Coins
    Ratings:
    +592 / 2 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    I'm just tidying up some of the cabling as it looks like a savage rat had attacked it all. I'll post up a video in two days as the motor isn't here with me right now. As it is right now, the wheel works with games much like any other MMos FFB wheel system. I have the monster motor driver running at 16V and the strength of the wheel feels a bit less than what you would get from a G27 but much more smooth and responsive. When I get to higher voltages the wheel will surpass the Logitech systems easily.

    Right now I am working on tearing apart a VFD and injecting the arduino as the motor controller. I've identified the requirements for the high voltage driver and am theorising on firstly running it on a lower voltage and then bumping it up to 240V.
    • Friendly Friendly x 2
    • Like Like x 1
  10. Alexey

    Alexey Well-Known Member

    Joined:
    Sep 23, 2014
    Messages:
    448
    Occupation:
    Electronics Technician
    Location:
    Adelaide, Australia
    Balance:
    7,793Coins
    Ratings:
    +592 / 2 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    Video added above
  11. OZHEAT

    OZHEAT Member

    Joined:
    Oct 26, 2015
    Messages:
    151
    Location:
    Australia
    Balance:
    1,841Coins
    Ratings:
    +79 / 6 / -0
    My Motion Simulator:
    3DOF, DC motor
    Good to see you trying something new Alexey.
    I'm not really sure but you are trying to run a 3 phase induction motor like a 3 phase stepper motor.
    What I disagree with is the way you are trying to do torque control with the PWM, it is very similar to the way stepper controllers use to achieve micro stepping.
    I suggest you look at what a chopper drive is and apply that to your code instead.
  12. Alexey

    Alexey Well-Known Member

    Joined:
    Sep 23, 2014
    Messages:
    448
    Occupation:
    Electronics Technician
    Location:
    Adelaide, Australia
    Balance:
    7,793Coins
    Ratings:
    +592 / 2 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    Not like a stepper but more like how you would control a brushless with SVPWM. Using the rotors physical position to calculate the next coil sequence that will cause the rotor to turn in a specific direction.
    So what you calculate is: what position do I want to rotor to be attracted to in relation to the current position of the rotor. A position that is 60 degrees away attains maximum rotor attraction/force.
    So what I do is always point the rotor 60 degrees away and pwm the voltage applied. The PWM duty cycle then determines the torque because the rms voltage is related to torque. Whether rms voltage and torque is linear I don't know, also I do not know that the torque vs voltage relashionship is with this motor as.
    This information is almost impossible to find as all references point to SPEED vs voltage and torque, my speed is effectively zero.
    So what I try to look at is literature that talks about static torque, which again is lightly brushed over in all literature as the primary use for these motors is speed!

    I've looked into chopper drivers but cannot find any references to using them in a 3 phase system. From what I have read so far, the chopper driver is a way of planting a pwm on top of another pwm for fine tuning current passing through a system. But still, the PWM control method has to remain with an adjustemt system built on top of that.

    In a way I already am "chopping" the output pwm by applying a pwm to both directional and pwm pins on the h bridge, just that I am not monitoring the current (also need a higher pwm frequency that "chopps"). which is actually possible on the Monster motor driver as is has a current sense pin. I don't intend on staying with he H bridges anyway so not much more development will go into them as I need higher voltages.

    As it runs now I can control the torque with pwm with the H-bridges but as I move to the VFD driver I am going to have to think of another way.
    Attached is the driver stage of the VFD that I am hacking up.

    I could adapt a chopper to the pwm inputs of the driver stage but in terms of current sensing I am unsure as the voltages are quite hazardous.

    The biggest problem I have at the moment is that there doesn't seem to be any freely available literature specific to what I am trying to do. Anything that has already been devloped by third parties is held close to them and not released to the public.

    Cheers!

    Attached Files:

  13. Thanos

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

    Joined:
    Jul 6, 2017
    Messages:
    500
    Occupation:
    Electronics Engineer
    Location:
    United States
    Balance:
    3,476Coins
    Ratings:
    +433 / 4 / -0
    My Motion Simulator:
    AC motor, Joyrider, Motion platform, 4DOF, 6DOF
    I have a FFB source code but its not in C language (arduino). Its for AVR atmega8 with 12mhz crystal to emulate USB1.1 device directly.

    I could share it with you in case it helps adapt it in arduino, or use as alternative to the MMOS...
  14. Alexey

    Alexey Well-Known Member

    Joined:
    Sep 23, 2014
    Messages:
    448
    Occupation:
    Electronics Technician
    Location:
    Adelaide, Australia
    Balance:
    7,793Coins
    Ratings:
    +592 / 2 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    I'd love to take a look, I'm still quite a newbie when it comes to coding but I am learning as much as I can. It would be great to condense everything down to one board.
  15. Thanos

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

    Joined:
    Jul 6, 2017
    Messages:
    500
    Occupation:
    Electronics Engineer
    Location:
    United States
    Balance:
    3,476Coins
    Ratings:
    +433 / 4 / -0
    My Motion Simulator:
    AC motor, Joyrider, Motion platform, 4DOF, 6DOF
    I'll send you link on PM. Did I mention it emulates a G25??

    See the diagram for now:

    FFB-joystick diagram part1.gif

    G25 FFB controller PCB layout example.jpg

    Thanks
    Thanos
    • Like Like x 1
  16. Thanos

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

    Joined:
    Jul 6, 2017
    Messages:
    500
    Occupation:
    Electronics Engineer
    Location:
    United States
    Balance:
    3,476Coins
    Ratings:
    +433 / 4 / -0
    My Motion Simulator:
    AC motor, Joyrider, Motion platform, 4DOF, 6DOF
    And here is a collection of REALLY old videos when I was developing that FFB code and electronics and eventually testing on an AC motor (direct!!)









    • Like Like x 5