1. 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!
  2. 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
  3. 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.

DD-Wheel with Hoverboard Motor

Discussion in 'Direct Drive Wheels' started by Benu, Jan 21, 2019.

  1. danove_b

    danove_b Active Member

    Joined:
    Nov 11, 2017
    Messages:
    164
    Location:
    Sweden
    Balance:
    1,345Coins
    Ratings:
    +53 / 2 / -0
    Had a couple of hours today to write some code for the Leonardo with the linked code as a guideline. It works well with calculated values. have no idea if it gonna work if I include the Hid code also.

    My simple test code:

    PROGMEM const unsigned char sine256[] = {
    127,130,133,136,139,143,146,149,152,155,158,161,164,167,170,173,176,178,181,184,187,190,192,195,198,200,203,205,208,210,212,215,217,219,221,223,225,227,229,231,233,234,236,238,239,240,
    242,243,244,245,247,248,249,249,250,251,252,252,253,253,253,254,254,254,254,254,254,254,253,253,253,252,252,251,250,249,249,248,247,245,244,243,242,240,239,238,236,234,233,231,229,227,225,223,
    221,219,217,215,212,210,208,205,203,200,198,195,192,190,187,184,181,178,176,173,170,167,164,161,158,155,152,149,146,143,139,136,133,130,127,124,121,118,115,111,108,105,102,99,96,93,90,87,84,81,78,
    76,73,70,67,64,62,59,56,54,51,49,46,44,42,39,37,35,33,31,29,27,25,23,21,20,18,16,15,14,12,11,10,9,7,6,5,5,4,3,2,2,1,1,1,0,0,0,0,0,0,0,1,1,1,2,2,3,4,5,5,6,7,9,10,11,12,14,15,16,18,20,21,23,25,27,29,31,
    33,35,37,39,42,44,46,49,51,54,56,59,62,64,67,70,73,76,78,81,84,87,90,93,96,99,102,105,108,111,115,118,121,124

    };

    byte angle;
    byte ph0, ph1, ph2;

    byte CalcTorque(byte angle, float torque) {
    byte sineVal;

    sineVal = pgm_read_byte_near(sine256 + angle);

    if (sineVal > 127) {
    sineVal = ((sineVal - 127) * torque) + 127;
    return sineVal;
    }
    sineVal = 127 - ((127 - sineVal) * torque);
    return sineVal;
    }

    void SetTorque(byte SteeringAngle, float Torque) {

    if (Torque >= 0) {
    Torque = abs(Torque);
    ph0 = CalcTorque(SteeringAngle + 0, Torque);
    ph1 = CalcTorque(SteeringAngle + 85, Torque);
    ph2 = CalcTorque(SteeringAngle + 170, Torque);
    }
    else {
    Torque = abs(Torque);
    ph0 = CalcTorque(SteeringAngle + 0, Torque);
    ph2 = CalcTorque(SteeringAngle + 85, Torque);
    ph1 = CalcTorque(SteeringAngle + 170, Torque);
    }

    OCR1C = ph0; // pwm pin 11
    DDRB |= 1 << 7; // Set Output Mode B7
    TCCR1A |= 0x08; // Set PWM value

    OCR1B = ph1; // pwm pin 10
    DDRB |= 1 << 6; // Set Output Mode B6
    TCCR1A |= 0x20; // Set PWM value

    OCR1A = ph2; // pwm pin 9
    DDRB |= 1 << 5; // Set Output Mode B5
    TCCR1A |= 0x80; // Activate channel
    }

    void setup()
    {
    pinMode(9, OUTPUT); // pin9= PWM output / frequency output
    pinMode(10, OUTPUT); // pin10= PWM output / frequency output
    pinMode(11, OUTPUT); // pin11= PWM output / frequency output
    Setup_timer1();
    }

    void loop() {

    delayMicroseconds(20000);
    angle++;
    //Commutation angle and torque level -1.0 - 1.0 as parameters
    SetTorque(angle, 0.1);
    }



    void Setup_timer1() {
    // TCCR1A configuration
    // 00 : Channel A disabled D9
    // 00 : Channel B disabled D10
    // 00 : Channel C disabled D11
    // 01 : Fast PWM 8 bit
    TCCR1A = 1;

    // TCCR1B configuration
    // Clock mode and Fast PWM 8 bit
    TCCR1B = 1 | 0x08;

    // TCCR1C configuration
    TCCR1C = 0;
    }
  2. Benu

    Benu Member

    Joined:
    Mar 19, 2018
    Messages:
    102
    Location:
    Germany
    Balance:
    940Coins
    Ratings:
    +29 / 0 / -0
    The DD-Wheel powered by a Hoverboard motor works! The wheel did its first laps. No broken thumbs or blue smoke so far.

    I used throttle and shifter from my DFGT. A load cell connected to the Arduino is the brake. Although there are still things to tune the wheel feels good. The motor is not even warm. After a couple of laps its still room temperature. The FETs on the driver board are at 35 Celsius.

    Next things to do:
    • Currently I only use 100 different force values from the Arduino as input to the motor. That has to be improved. Does anyone know how many different values the AIWave Arduino is able to deliver?
    • Increase torque. As precaution I limited it to 3 Nm. According to the Hoverboard manufacturer the motor should be able to deliver 12 Nm.

    DD-Wheel with Hoverboard motor 1.jpg DD-Wheel with Hoverboard motor 2.jpg
    • Like Like x 1
  3. Benu

    Benu Member

    Joined:
    Mar 19, 2018
    Messages:
    102
    Location:
    Germany
    Balance:
    940Coins
    Ratings:
    +29 / 0 / -0
    Did you test with the motor attached?
  4. danove_b

    danove_b Active Member

    Joined:
    Nov 11, 2017
    Messages:
    164
    Location:
    Sweden
    Balance:
    1,345Coins
    Ratings:
    +53 / 2 / -0
    No, just LED for the moment. I have som btn8982 that I have for another project, so I might solder together something in the future. I'm quite sure it's gonna work fine now.


    SetTorque(angle, 0.5);
    https://photos.app.goo.gl/Gw622n4oUEvZUhQE8


    SetTorque(angle, 1.0);
    https://photos.app.goo.gl/YA1hrzvCThSnFNmX7

    I assume you feeding the h-bridges with 12 V at the moment. How much of that (%) do you need to get the 3 Nm (stall) torque?
    also interested in where you got the magnetic ring.

    Awesome if you make some video of the wheel in action!
  5. Benu

    Benu Member

    Joined:
    Mar 19, 2018
    Messages:
    102
    Location:
    Germany
    Balance:
    940Coins
    Ratings:
    +29 / 0 / -0
    Yes, 12V from a second hand server power supply. To get the 3 Nm I feed 6 A from the driver board. The overcurrent protection of the driver board will jump in at 30 A, so there is some headroom. But as I said in an earlier post, I am limiting the current feed from the driver at 6 A right now. I need to check if the motor parameters are correct, before increasing current output to the motor.
    AMS, the manufacturer of the AS5306, was so kind to send me samples of the encoder chip and magnetic rings.
    'will do that.

    In the mean time I increased the output resolution of the FFB force values to my wheel to at least double the resolution of the AIWave PWM signal.
    From my observation of the AIWave Arduino PWM signal I guess at 4 kHz the Arduino sends 1024 different values and at 8 kHz 1535 different values. Can anyone confirm that?
    That gives a really smooth ride now.
  6. danove_b

    danove_b Active Member

    Joined:
    Nov 11, 2017
    Messages:
    164
    Location:
    Sweden
    Balance:
    1,345Coins
    Ratings:
    +53 / 2 / -0


    My own system I use right now is partly based on an early version of AIWave. I have the highest frequency and then you have a PWM resolution of 800 steps. Sounds a bit backwards that you have more resolution with higher frequency. Should be the opposite...
    • Agree Agree x 1
  7. Frederiksen

    Frederiksen New Member

    Joined:
    Dec 5, 2018
    Messages:
    22
    Balance:
    199Coins
    Ratings:
    +0 / 0 / -0
    I have held off on buying stuff that I need to make one of these direct drive wheels hoping for an eBay discount to come up. Now I'm interested in this hoverboard motor idea. I have a $5 eBay coupon that expires in 2 days. What is one thing around that price that I will definitely need whether I choose the hoverboard motor method of the my1020?
  8. Benu

    Benu Member

    Joined:
    Mar 19, 2018
    Messages:
    102
    Location:
    Germany
    Balance:
    940Coins
    Ratings:
    +29 / 0 / -0
    The one thing you need for all DIY wheels is a force feedback game controller. That may be an Arduino Leonardo for the AIWave Firmware or an STM Discovery board for the MMOS Firmware. Most people in this thread are using an Arduino Leonardo.
  9. Frederiksen

    Frederiksen New Member

    Joined:
    Dec 5, 2018
    Messages:
    22
    Balance:
    199Coins
    Ratings:
    +0 / 0 / -0
    Thanks for your reply. I read some places that a stm board would be better and more precise, but on this forum I read that it is about the same. What do you think? Also is this the right Leonardo?
    http://vi.vipr.ebaydesc.com/ws/eBay...der=1&oneClk=1&secureDesc=0&oversion=4a17e6f0
  10. Benu

    Benu Member

    Joined:
    Mar 19, 2018
    Messages:
    102
    Location:
    Germany
    Balance:
    940Coins
    Ratings:
    +29 / 0 / -0
    Sorry, but I have not tried the STM Discovery board. So I cannot tell which one is "better".
    You can find the Arduino Leonardo here in the shop of the creators of Arduino. When you buy from other sources on the internet you can compare the offer.
  11. Czary

    Czary New Member

    Joined:
    Aug 11, 2013
    Messages:
    14
    Occupation:
    Duty Officer
    Location:
    Poland
    Balance:
    289Coins
    Ratings:
    +3 / 1 / -2

    Hi, 3Nm at 6 Amps looks very good !
    I was looking for multi pole magnetic rings, and I think that automotive ABS magnetic ring might do the trick :



    The cheapest I've found are Ford Fiesta (mk 6) and Ford Focus (mk 1) parts, priced 3 € each in my country ;)
  12. danove_b

    danove_b Active Member

    Joined:
    Nov 11, 2017
    Messages:
    164
    Location:
    Sweden
    Balance:
    1,345Coins
    Ratings:
    +53 / 2 / -0
    I'm not 100% sure, but it might be to low resolution for a steering wheel. A roughly estimation from what I see I'd say it's about 100 pulses per rotation, and that's not enough. Honestly I had no knowledge that the car manufacturers had moved over to this technique for the ABS systems.
  13. Benu

    Benu Member

    Joined:
    Mar 19, 2018
    Messages:
    102
    Location:
    Germany
    Balance:
    940Coins
    Ratings:
    +29 / 0 / -0
    You have to know the pole width to decide if a magnetic ring is usable for a specific encoder chip. The encoder circuits I found available use 1mm (AS5311 + iC-MHL100), 1.28mm (iC-MU) and 2mm (iC-MHL200) pole widths. On a ring the poles are shaped like pizza slices. To the outer radius of the ring the poles are wider than closer to the inner radius. That gives you some leniency when sourcing the ring.

    The resolution given for these encoder circuits is per "revolution" of a pole pair. So when you got a magnet ring with 100 poles (= 50 pole pairs) your cpr will be 50 x "the resolution per revolution".

    E.g. the AS5311 delivers 256 cpr per revolution (pole pair). With a 128 pole (64 pole pairs) ring that accounts to 64 x 256 = 16384 cpr. As we will be using the incremental ouput of the AS5311 65536 ppr = 4 x 16384. The AS5311 can best be sourced as evaluation board. You save yourself the trouble of soldering 0.65 mm SMD pins.
    • Informative Informative x 2
    Last edited: Mar 7, 2019
  14. Benu

    Benu Member

    Joined:
    Mar 19, 2018
    Messages:
    102
    Location:
    Germany
    Balance:
    940Coins
    Ratings:
    +29 / 0 / -0
    The hoverboard motor torque is now increased to 6.3 Nm.

    I also found out that my earlier statement of needing 6 A to get 3 Nm is likely wrong. It seems to be far less is needed. The statement was based on values delivered by the STM development environment. But these values are in an internal unit not pure Amps. So I put a multimeter in series with V+ line from the 12V supply.
    • without load the meter reads 0.15 A.
    • at 3 Nm the meter reads 0.96 A
    • at 6.3 Nm the meter reads 4.6 A
    When racing with 3 Nm max the motor is not even warm. The FETs are at 35 Celsius.
    Racing with 6.3 Nm max (15 minutes test) the motor is mildly warm and the FETs are at 46 Celsius.
    That looks promising.
  15. danove_b

    danove_b Active Member

    Joined:
    Nov 11, 2017
    Messages:
    164
    Location:
    Sweden
    Balance:
    1,345Coins
    Ratings:
    +53 / 2 / -0

    To get the 6.3 Nm, do you need to put out full voltage (12 v top to top)?
  16. Benu

    Benu Member

    Joined:
    Mar 19, 2018
    Messages:
    102
    Location:
    Germany
    Balance:
    940Coins
    Ratings:
    +29 / 0 / -0
    I guess so. But I do not know how long the duty cycle of the inverter FETs is and if there is some headroom. Do you want to use a power supply <12V?
  17. danove_b

    danove_b Active Member

    Joined:
    Nov 11, 2017
    Messages:
    164
    Location:
    Sweden
    Balance:
    1,345Coins
    Ratings:
    +53 / 2 / -0
    I think 8 Nm is enough and just want to know if it's possible with 12 v or if I must use 24 v.
    Thank you for your reports. Hope I have time this weekend to do some test with half-bridges...
  18. Benu

    Benu Member

    Joined:
    Mar 19, 2018
    Messages:
    102
    Location:
    Germany
    Balance:
    940Coins
    Ratings:
    +29 / 0 / -0
    I agree, 8 Nm should be plenty. My selfmade rim is 29 cm and racing with 6.3 Nm is almost a workout.
    Like to hear how your test get along during the weekend.
  19. Gadget999

    Gadget999 Active Member

    Joined:
    Dec 27, 2015
    Messages:
    640
    Location:
    London
    Balance:
    5,056Coins
    Ratings:
    +122 / 4 / -0
    My Motion Simulator:
    2DOF, Arduino

    can we see a video ?
  20. Benu

    Benu Member

    Joined:
    Mar 19, 2018
    Messages:
    102
    Location:
    Germany
    Balance:
    940Coins
    Ratings:
    +29 / 0 / -0
    Yes, will do that over the weekend.
    • Like Like x 1