This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

BLDC runs backwards when using a QEP encoder, but only from certain motor start positions.

Other Parts Discussed in Thread: DRV8301

Hi

We are experiencing a problem using the TI evaluation board DRV8301-HC-EVM Rev D powering a Sonceboz motor (model 5642 - 5 pole pairs, low inductance). Our problem occurs when using lab 12b for velocity control with quadrature.

If we use a 1000 line encoder feeding into the QEP, we get one of two behaviours depending on the starting angle of the motor: either it is fine, or it runs backwards at full speed. When running backwards the problem appears to be something to do with the output – the velocity speedQEP_krpm is correctly measured as large and negative, the error signal is large and the controller is requesting (and getting) maximum current. The motor has 12 detents and starting from half of these gives the problem, the other half gives perfectly normal control. It is completely repeatable. If we use the FAST estimator instead of QEP (lab 5d), it works correctly in all start positions (although the RPM is not very smooth).

When working normally, EST_getAngle_pu() and ENC_getElecAngle() track reasonably well. When not working, the former angle rises as before but the encoder derived angle falls very slowly for about one (electrical) revolution; then both angles change so quickly that we cannot sample them.

Thanks for any help.

  • are you initializing the starting angle by using a large enough RES_EST_CURRENT and Enabling the flag for RsRecal? This needs to be done to create a relationship between the mechanical and electrical angle.
  • RsRecalc is enabled in lab 12b and I've not changed that. RES_EST_CURRENT, I thought, was used only for motor identification, nevertheless it is set to 3 amps for my 40 amp rated motor.

    Do you refer to this line of code where the relationship between mech and electrical angle is created?

    // if we are forcing alignment, using the Rs Recalculation, align the eQEP angle with the rotor angle

    if((EST_getState(obj->estHandle) == EST_State_Rs) && (USER_MOTOR_TYPE == MOTOR_Type_Pm))

    {

    ENC_setZeroOffset(encHandle, (uint32_t)(HAL_getQepPosnMaximum(halHandle) - HAL_getQepPosnCounts(halHandle)));

    }

    Thanks

  • From the User Guide:

    4.6.9 USER_MOTOR_RES_EST_CURRENT
    #define USER_MOTOR_RES_EST_CURRENT (1.0)
    During Motor ID, maximum current (Amperes, float) used for Rs estimation, 10-20%.
  • RES_EST is used in motor ID. It is also used anytime you recalibrate the Rs with the Flag discussed in lab03.

    in lab12 this is mentioned:

    This project will setup the calibrated angle of the encoder. This ensures that both the encoder and the motor are aligned on a zero degree electrical angle. This step is done when the FAST™ estimator is recalibrating the Rs value of the motor.

    if you have a load attached you need to insure that RES_EST is large enough to move the rotor so that it will align with the D axis.

  • Ah okay, I had missed that bit. I have no load on my motor so 3 amps ought be just fine. I shall try with more. Thanks.

    Hypothetically, what happens if, in my final solution, it is not safe or the load is too high to turn the motor?

    As in the original post, starting at exactly 6 out of 12 of the detents yields correct motor drive in the right direction (at ~0.1 krpm) and the other 6 detents yield the motor to spin as fast as possible backwards.

    Could this be the FAST electrical angle estimator not working so well?

    Incidentally, I have just observed this behaviour: if I hold the rotor shaft still while the motor is trying to drive it, of course the current gets high but I see the electrical angle from EST_getAngle_pu() jumping around between 0 and 1. I would have thought that if the rotor shaft was still then the electrical angle would also be pretty constant. Do you have any ideas?

    Many thanks
    Rich
  • "Could this be the FAST electrical angle estimator not working so well?"

    FAST feedback is not being used in lab12, only the angle produced from the encoder.

    I've sent to Adam @ LineStream and hope he will respond shortly. He is the expert on sensored motion control.
  • Hi there

    Indeed FAST is not being used for feedback, that is the intention. Am I wrong to assume that the FAST estimator is still running, even though its output is not in use? In lab 12b is it still valid to read EST_getAngle_pu()? EST_run() etc is still called from with CTRL_run() so I believe that FAST is still doing it's thing, even though it's output is not in use.

    Do you have a definition of electrical angle?

    Kind regards
    Rich
  • FAST is still running in these examples but as you noted the estimate is not being used in the control loop, so it can't cause the issue you are seeing.
    You can certainly read the angle, but if the rotor isn't moving the estimate will not be accurate.

    the electrical angle is given in radians, or converted to a per unit value and describes the orientation of the rotor north magnetic flux
  • Rich,

    I think Chris' answer is spot on.  We need a good alignment between the motor and the encoder in order to have good control of that motor.  If the encoder alignment is off by 90 degrees, it can result in the motor trying to apply positive torque but the motor rotating in the negative direction which results in the motor running away.

    The trick we use for alignment in Lab 12a-13e is really not designed to be used in a final application.  Ideally you would have some sort of absolute sensor or home switch in the system so that you don't need to rely on this method to align the encoder and motor at power up.  

    In the sensored labs, FAST is still running, but if you look at the CTRL_runOnline_User function in ctrlQEP.h file, the electrical angle comes from the encoder and not FAST.  So even though FAST is generating an electrical angle it isn't being used.

  • Hi Adam/Chris

    Okay so that electrical angle offset is no good - that is what I've been thinking for a while. So I shall determine an angle externally using three phase sensors that I have inside the motor.

    Can you recommend how accurate the electrical angle fed into CTRL_run() needs to be? I can determine from my motor's three sensors the electrical angle to with 60 degrees of electrical rotation - six different states. Is this enough? So the best I can do to report the angle is one of 0, 60, 120, 180, 240 and 300 degrees.

    Thanks, both, for your help.
    Rich
  • Rich,

    The electrical angle needs to be accurate to within 5 degrees. Otherwise you will not be able to hold torque very well. And as you saw earlier, depending on how accurate the electrical angle is this will have a direct control impact.

    Many customers will implement a homing routine using the index pulse of the encoder. You could even use FAST to slowly rotate the motor until the index pulse is encountered. Something along these lines would be my recommendation for how to proceed and be able to get a good electrical angle offset.
  • Adam

    Thanks for that recommendation. It's good to have some figures to work to and we can design our system accordingly. Something we need to explore is whether using FAST alone we have enough torque to turn the motor to find the index pulse.

    Are you pretty convinced that our motor spinning backwards issue is due to the electrical angle being so wrong half of the time?

    Cheers
    Rich
  • Rich,

    I'm quite convinced that is the issue. A way to prove it would be to increase the USER_MOTOR_RES_EST_CURRENT to a large value. In some motors for testing I've had to set it as high as USER_MOTOR_MAX_CURRENT. Obviously this isn't sustainable for a product, but it can be done to prove that the root cause is not getting a good alignment between motor and encoder.
  • Adam

    Pardon my ignorance but how does setting the RES_EST_CURRENT higher help? It is high enough to move the motor when it's not going to go the wrong way (I know which of the 6 out of 12 detents are "good" ones ...).

    Is one solution to use the estimator's electrical angle and at some convenient point use that as an offset to work with the QEP derived angle? I implemented something like that and while the motor was running out of control backwards, I activated the electrical estimator as an offset, which worked kind of. What do you think? My quadrature encoder has enough accuracy for 5 degrees electrical angle, but finding the index mark is not so convenient at the moment.

    Rich
  • Rich,

    As Chris mentioned before, the RES_EST_CURRENT is used to select the amount of current used during the resistance recalibration at startup. This will more strongly align the motor to the correct position for the encoder offset to be calibrated.

    When you have the motor in the "wrong" detent, does it move at all during resistance recalibration?

    You probably could start to move the motor using FAST, and use the difference between the FAST angle and the QEP angle as an offset until you hit the index where you can get a really good offset. But in doing that your angle offset would only be as good as FAST is reporting your electrical angle, so you would need to be moving the motor at or near a couple Hz in speed. So it would work as long as you can move the motor, but if you are trying to hold torque at 0 speed FAST won't work very well since it needs motion in order to get a good electrical angle estimation.
  • Hello again Adam

    Adam upon your advice I set RES_EST_CURRENT to a little higher - 10 amps - and my max current is 20 amps. Motor is rated to 40 amps. Ever since the first time I ran my lab 12b with 10 amps RES_EST, my program starts, runs about 164 ISR calls and a few background loops and then the program counter ends up at 0x3FF4FA. This is inside the bootloader. I'm not sure if it resets yet, I can find that out tomorrow morning. I suspect it is. The stack pointer interestingly is 0x000C not the 0x0400 like the manual says it should from reset. Maybe the proceeding bootloader code is modifying that.

    Do you know what is/has happened here? Is my eval board damaged? Obviously reverting back to 3 amps from 10 RES_EST doesn't cure this, and other labs now fail in the same way.

    Hope you can help here.
    Thanks
    Rich

  • Rich,

    Since you are using the DRV8301 board, 10A should not have damaged it.  I'm not 100% sure why the program counter is going back into the bootloader.  Is it possible that your power supply is causing the microprocessor to go into a low power state?

    Anything I suggest on this would be pure speculation.  Have you tried a different evaluation board to see if the problem is hardware related or software related?

  • Hi Adam,

    We clearly need to get the electrically aligned angle to the PARK and INV PARK routines (I'm looking at figure 3-3 of the InstaSpin manual), but do the values for Theta_Qep or the user demand angle User_PDSRef also need to have the electrical angle aligned to the motor or can they tolerate an offset? It looks to me as if they can - they are converted into a velocity demand and offsets get differentiated out. Here's why I ask.

    In our application, the controlled quantity is x, the linear displacement of an actuator which is an invertible but slightly non-linear function of the motor angle. We need to have high resolution angle input to get the required position tolerance and were intending to use 

    <electrical angle> = 5 * <motor angle determined from linear position>

    for both demand and calculated electrical angle (it’s a five pole pair motor). There is no alignment of the linear position of the actuator to the motor’s angle and this is the cause of our problem.

    We need to supply at least the Park and Inverse Park routines the correctly aligned electrical angle. We have Hall effect phase sensors on the motor which tell us which 60° electrical segment we are in and can use the transitions, plus possibly the FAST initial estimate, to get better alignment; in effect the function becomes

    <electrical angle> = 5 * <motor angle determined from linear position> + <angle offset estimate>

    where <angle offset estimate>  is the estimate of the electrical angle at x = 0.

    However our knowledge of the electrical angle as a function of the linear position is not sufficiently accurate for the requirement of ±5° electrical accuracy to maintain torque, and we must modify the electrical angle estimate every time we cross a 60° electrical segment. If we feed this updated value of  to the User_PDS Ref and ThetaQep, this will appear as a step change in both values with a delta like velocity. We can of course smooth the step changes, but this is disguising rather than solving the problem. It might be better to use the uncorrected angle estimate (not aligned to the rotor's electrical angle) for the control side, and just use the aligned angle for the Park and Inverse Park transforms. However I’m worried about what we don’t know!


    Sorry for the length of this, couldn't make it shorter without diagrams.

  • Graham,

    The angle ThetaQEP should be electrically aligned since that is the angle that is provided to PARK and INV PARK.

    User_PosRef shouldn't be an angle.  It should be the number of mechanical revolutions that you want the motor to rotate.  So this is a position step command.

    For SpinTAC Position Control, you only need to provide the electrical angle back into the SpinTAC Position Converter.  So if you have a scheme that can be used as the electrical angle to feed into the PARK & INV PARK, that same angle should be feed into the SpinTAC Position Converter which will translate the electrical angle into the mechanical revolutions that the rest of the position solution operates on.

  • Hi Adam

    We've pretty much solved this now. I've written code to inspect five Hall sensors that are in our motor to determine the absolute electrical angle. We then use this as an offset with the high resolution angle from a rotary encoder of 1000 lines. This works really well, down to very low speeds (best with forced angle off).

    Can I ask for completeness - what exactly does InstaSPIN consider to be zero electrical angle? Say, in terms of the A, B, C / U, V, W voltages cycle? We've worked out what we think but we'd like confirmation.

    Still no idea how our eval board blew out, but we've replaced the MOSFET and it's running again.

    Thanks
    Rich
  • Rich,

    Zero electrical angle should refer to aligned with the A phase of the motor.

  • Hi Adam

    Could you elaborate on this? Is there a diagram (maybe something googled, even) that you can point to where instaspin's zero would be?

    Kind regards
    Rich
  • Hi again

    Is this diagram correct to how InstaSPIN uses angle?

    www.digikey.com/.../article-2013march-introduction-to-brushless-dc-fig5.jpg

    At zero degrees the voltage through coil U (I presume this is A in InstaSPIN) is at zero and about to rise positive.

    Kind regards
    Rich
  • Rich,

    That diagram is for trapezodial control which is very different than field oriented (or vector) control. At zero degrees all positive current should be through phase U with phase V & W each having half of that amount of current and it should be negative.
  • Hi Adam

    Do you have a diagram, or is there a diagram on the net that explains this?

    You talk of current but most diagrams, including our motor's diagram, use voltage on the Y axis. Does this change things?

    Our motor is of a delta shape, not Y - does this change things?

    When you say "through phase U", between what two points would you measure that?

    I think its a topic area for users of InstaSPIN who are doing slow speed control and need accurate electrical angle. Some upgrade to the documentation would be most useful. Text and diagrams.

    Kind regards

    Rich

  • Rich,

    I don't have a diagram handy to explain this.  Your best bet would be to do some research around vector control to understand this control methodology better.

    Vector control is more concerned with current while trapezodial control is more concerned with the voltage.  So when I say all of the positive current is flowing into phase U it means that half of the current is flowing out phases V & W.

    Delta versus Y connected motors doesn't change anything.  The controller assumes Y connected motors, so it will treat your delta motor as if it was a Y, which is a valid way to control it.

  • Hi,
    I followed this conversation, it was verry interresting , RichB I have the same problem as you, of determing the absolute electrical angle. knowing I use an encoder of 1024 lines, and hall effect sensor : how can I concur this in instaSpin-Motion (Lab13a) ? and what is the code C to integrate Hall sensors into InstaSpin-Motion?
    Best regards,
  • Hi Sanet

    Firstly I wired up five GPIO lines to my five Hall sensors. I wrote a C function which converted five levels to an electrical angle in iq.

    In mainISR I wrote code at the top to run only once; it sampled the Hall sensors, set a flag to indicate the code should not run again, then alter enc.zero_offset (or whatever it's called) after knowing the electrical angle from the Halls. You will need to do some iq math to get this angle right. Also, you need to know what InstaSPIN _wants_ as the zero electrical angle.

    Altering enc.zero_offset is easier than trying to use the setter function, imho.

    So i have something like enc.zero_offset = derivedElecAngleIq;

    I can give you more details when I am back from holiday on Monday.

    Also of help to me was having a variable which allowed me to vary the electrical angle by an offset between the ENC having its elecrical angle read and where that angle is used. I think it is sent to CTRL. I will post that when i'm back.

    Rich

  • Hi Rich,

    Thank you for your reply, and see you next week.

    Enjoy your holiday.

    Best regards,
  • hi rich,

    Concerning the code of the Hall sensor, do you have more details?

    Regards,

  • Hi there

    Well, my Hall sensor is actually 5 Hall sensors, all inside my motor. They are completely specific to this motor; together they tell me the electrical angle to +-5 degrees electrical, or something like that.

    I've wired three of them into the J10 connector (luckily they are 5 volts) using those inputs in GPIO mode. The other two are wired into SW1 and SW2.

    I don't know what you have but if you need to read angles via Hall sensors then you will need to wire something up.

    Rich
  • My code for calculation of angle is this. Please only use this to understand what I am doing, then write your own.

    ---------------------------------------------------------------------------------------------------------------------------------------------------------------

    #define SEGMENT_SIZE 30
    #define MID_POINT_FROM_EDGE_OFFSET 15

    // indexed by the bits Sa, Sb, Sc, Ha, Hb in that order, MSB first.
    static const uint16_t motorSensorAngles[32] = {

            65535, // 000 00
            65535, // 000 01
            65535, // 000 10
            65535, // 000 11

            8,     // 001 00 F
            8,     // 001 01 y
            9,     // 001 10 F
            9,     // 001 11 y

            0,     // 010 00 F
            0,     // 010 01 y
            1,     // 010 10 F
            1,     // 010 11 y

            11,    // 011 00 y
            11,    // 011 01 F
            10,    // 011 10 y
            10,    // 011 11 F

            4,     // 100 00 F
            4,     // 100 01 y
            5,     // 100 10 F
            5,     // 100 11 y

            7,     // 101 00 y
            7,     // 101 01 F
            6,     // 101 10 y
            6,     // 101 11 F

            3,     // 110 00 y
            3,     // 110 01 F
            2,     // 110 10 y
            2,     // 110 11 F

            65535, // 111 00
            65535, // 111 01
            65535, // 111 10
            65535  // 111 11

    };

    _iq ANG_getElecAngle (uint16_t* hallBits, uint32_t* mapErrors, uint32_t* inDegrees)
    {
        
        _iq rtnElecAngle_pu;
        
        // Grab phases:
        uint32_t gpioBdata = ((GPIO_Obj*) hal.gpioHandle)->GPBDAT;
        uint32_t gpioAdata = ((GPIO_Obj*) hal.gpioHandle)->GPADAT;
        
        // Data needs to be Sa Sb Sc H1 H2:
        
        gpioAdata >>= 7;
        // H1 stored at b2
        // H2 stored at b0
        gpioAdata &= 0x05;
        uint16_t H_12 = (gpioAdata >> 1) | (gpioAdata & 0x01);
        
        gpioBdata >>= 8;
        gpioBdata &= 0x000007; // only 3 LSBs are valid
        uint16_t S_abc = ((gpioBdata & 1) << 2) | (gpioBdata & 2) | ((gpioBdata & 4) >> 2);
        
        *hallBits = (S_abc << 2) | H_12;
        
        if (motorSensorAngles[*hallBits] == 65535)
        {
          // do not update motorElecAngle
          *mapErrors += 1;
        }
        else
        {
          *inDegrees = (motorSensorAngles[*hallBits] * SEGMENT_SIZE) + MID_POINT_FROM_EDGE_OFFSET;
        }
        
        rtnElecAngle_pu = (((((uint32_t) 1) << 24)) / 360) * (*inDegrees);
        
        return rtnElecAngle_pu;
    }


  • This code is in my lab13a main C file (copy of). It uses the above function to alter the ENC offset.

    ---------------------------------------------------------------------------------------------------------------------------------------

    // Get angle:
        gMotorElecAngle_pu = ANG_getElecAngle((uint16_t*) &gMotorSegValue, (uint32_t*) &gElecAngleMapErrors, (uint32_t*) &gMotorElecAngle_deg);


        if (!gElecAngleCalibrated)
        {
            // Get calibrating:
            static uint16_t lastH12 = 0xFFFF;

            uint16_t currentH12 = 0x0003 & gMotorSegValue;

            if (lastH12 != 0xFFFF)
            {
                // compare to current
                if (lastH12 != currentH12)
                {
                    // found an edge somewhere
                    gElecAngleCalibrated = true;
                }
            }
            else
            {
                // update the "last" with a real value
                lastH12 = currentH12;
            }

            gElecOffsetQep_pu = (gMotorElecAngle_pu - gElecOffsetMotorToReal_pu);

            enc.enc_zero_offset = (_iq) (gElecOffsetQep_pu / 5);
            enc.enc_zero_offset &= 0x00FFFFFF;
        }

    -----------------------------------------------------------------------------------------------------------------------------------------

    That code comes just before this, in mainISR()

    // compute the electrical angle
    ENC_calcElecAngle(encHandle, HAL_getQepPosnCounts(halHandle));

  • Hi Rich,

    thank you verry much for your reply. 

    at first I have to chew your code, then I will adapt it with my project.

    Best regards,

  • Hi Rich,

    my motor contains a hall effect sensor (3 sensors, 1 for vcc, 1 for ground), knowing in project I use dvr8312 C2-kit, I wired them into J10 (following guide steps).

    how did you code this function : motorSensorAngles[32] ?

    do you have diagrams or something else of organisation chart following your code?

    Best regards

  • Ok, that array maps from 5 Hall sensor binary values to an offset into a function described in my motor datasheet. I'll attach a picture of that. This C code line then calculates an electrical angle:

    *inDegrees = (motorSensorAngles[*hallBits] * SEGMENT_SIZE) + MID_POINT_FROM_EDGE_OFFSET;


    Here's the angles diagram for my motor:

    So five Hall sensors: Sa, Sb, Sc, and H1 and H2. Together they make 2 ^ 5 = 32 possible values. However not all of the 32 values map onto the electrical diagram, some are invalid. So 65535 represents a sensor electrical lookup error.

    Firstly, are you sensors wired up correctly so that you can see the levels changing in software? I had to use pull-ups with my sensors, for example.

    Secondly, if you post your datasheet maybe I can help you create a lookup table similar to mine.

    Hope this helps - this part was quite a fun part of my project!

    Rich

  • EN_7000_05016.pdfHi Rech,

    waw thank you for your quick reply :)

    1- yes I connect them coorectely and  'pull-ups' with resistances R56,R57, R58 are installed in my card baord  drv 8312.

    2- my datasheet is attached (see page 24 & 26)

    Best regards,

  • Hi Rech,

    waw thank you for your quick reply :)

    1- yes I connect them coorectely and  'pull-ups' with resistances R56,R57, R58 are installed in my card baord  drv 8312.

    2- my datasheet is attached (see page 24 & 25)

    Best regards,

    4786.EN_7000_05016.pdf

  • Ok so you have three binary sensors in a typical 120 degree phase staggering.

    You have 2 ^ 3 = 8 binary possibilities, so the array should be length 8 not 32.

    The two conditions where the sensors read all zeros and all ones are both invalid states. That means that there should be two entries in the array of 65535. (65535 is chosen because it is the max value of an unsigned int - on this processor unsigned int is 16 bits.)

    Use the scheme where:
    UHallA is bit zero
    UHallB is bit one
    UHallC is bit two

    Print out the diagram and write on, for each 30 degree horizontal slice of the diagram, the integer derived from the three bits. Those are the array values. You need to adjust the two macros for your segment size too.

    Hang on:

    Are these Hall sensors indicating the electrical angle or the mechanical angle?

    Also: in the diagram on page 25 there are two complete cycles of UHallA for 360 degrees. The first 180 has the exact same pattern as the latter half. I think this means you cannot tell which half of the cycle you are in. What do you think?

    Rich
  • Rich,

    In one mechanical revolution (ie in my motor 2 electrical revolution because the motor number  poles are 4), hall sensors detect the passage of a magnetic pole

    witch allows switching of the coils by the control circuit. 

    on the page 24 is mentionned "Signal setup: The Hall signals are 120° out of phase with each other according to the phases. Due to the 4-pole version, the

    switching frequency is twice as high as the speed"  -----> 120 ° is mechanical one.

  • Any suggestions rich? 

  • <test> I posted earlier but it's not in this forum.
  • Hi Sanet

    I couldn't make clear sense of that manual, so I suggest you attach the three Hall outputs to an oscilloscope, turning the motor through one full rotation and watch what happens. That way you can be sure of what it is doing.

    Rich
  • Hi Rich,

    I introduce the eight states in the following function, according to this picture:

    static const uint16_t HallAngles[8] = {
    
    		// 65535 max of unint16_t
    
    		65535, // 000 // invalid value
    
            1,     // 001
    
    
            2,     // 010
    
    
            3,    // 011
    
            4,     // 100
    
    
            5,     // 101
    
            6,     // 110
    
            65535  // 111 // invalid value
    
    };
    

  • Can you explain more this portion of your code :

     gpioAdata >>= 7;
        // H1 stored at b2
        // H2 stored at b0
        gpioAdata &= 0x05;
        uint16_t H_12 = (gpioAdata >> 1) | (gpioAdata & 0x01);
    
        gpioBdata >>= 8;
        gpioBdata &= 0x000007; // only 3 LSBs are valid
        uint16_t S_abc = ((gpioBdata & 1) << 2) | (gpioBdata & 2) | ((gpioBdata & 4) >> 2);

    best regards,

     

  • In my motor I have five bits to sense angle with. They are arranged as two sensors, three bits called Sa, Sb and Sc. Then two more bits called H1 and H2.

    This code derives H_12 which is number where bit 0 represents H2 and bit 1 represents H1. Line 5 adjusts the data from the GPIO port to make this happen.

    Line 11 does a similar thing to align Sa, Sb and Sc into a three bit number.
  • This array is meant to map from [Uhall1, Uhall2, Uhall3] into an angle.

    Here is what I think it should be:

    static const uint16_t HallAngles[8] = // Map from (UhallA, UhallB, UhallC) => angle where UhallC is LSB and UhallA is MSB
    {
    /* states should be S0 to S5 */
    65535 // 0 => error
    3 // 1 => state 3
    5 // 2
    4 // 3
    1 // 4
    2 // 5
    0 // 6
    65535 // 7
    };

    That maps from a number formed from (UhallA, UhallB, UhallC) to an angle segment. They are not states (well the motor goes through these monotonically) they are angles.

    Rich
  • rich,

    I found this array following  Hall C LSB and Hall A MSB :

    65535 // 0 => error
    3 // 1 
    1 // 2
    5 // 3
    4 // 4
    6 // 5
    2 // 6
    65535 // 7 

    ?

  • Rich, I don't find as your suggestion, can you clarify it more (example 0 // 6)

    Regards,

  • Hi there Sanet


    Okay each row holds a number (the offset into the angle, or state as you call it, starting at 0 to 5). Then the // is a comment of the decimal value of index of that array entry. The number derived from your three Hall bits is the index into the array.

    So 0 // 6 (there should be a comma after the 0) is state 0 for array index 6.


    Please put commas after each number before the comments, I forgot those!

    Rich