cancel
Showing results for 
Search instead for 
Did you mean: 

is anything wrong in my invert.json?

tonyqian926
Associate II

I'm working on a custmoize inverter board .

and I wan't to use Three-Shunt variants for current sensing, I implemented it in hwVariants, according to the documentation.

See the following :

{
  "type": "inverter",
  "name": "testNow",
  "descVersion": 4,
  "contentVersion": "1.1",
  "PN": "testNow",
  "longDescription": "",
  "shortDescription": "",
  "link": "",
  "mcu": "STM32F303RCTx",
  "clockSource": "8_crystal",
  "clockFrequency": 72,
  "motorDrives": [
    {
      "name": "M1",
      "maxRatedVoltage": 600,
      "minRatedVoltage": 300,
      "maxRatedCurrent": 10,
      "features": [
        {
          "name": "CurrentSensing",
          "type": "CurrentSensing",
          "tRise": 2550,
          "hwVariants": [
            {
              "type": "ThreeShunt_AmplifiedCurrents",
              "help": " ",
              "shuntResistor": 0.01,
              "amplifyingNetworkImax": 9,
              "amplifyingNetworkVm": 3.3,
              "amplifyingNetworkPrating": 2.0,
              "offsetNetworkAttenuation": 1,
              "opAmpGain": 2,
              "polarizationOffset": 1.86,
              "signals": {

                "CURRENT_AMPL_U": [
                  {
                    "name": "PA7",
                    "help": "",
                    "cost": 0
                  }
                ],
                "CURRENT_AMPL_V": [
                  {
                    "name": "PA6",
                    "help": "",
                    "cost": 0
                  }
                ],
                "CURRENT_AMPL_W": [
                  {
                    "name": "PA3",
                    "help": "",
                    "cost": 0
                  }
                ]
              }
            },
            {
              "type": "SingleShunt_AmplifiedCurrents",
              "help": " ",
              "shuntResistor": 0.01,
              "amplifyingNetworkImax": 9,
              "amplifyingNetworkVm": 3.3,
              "amplifyingNetworkPrating": 2.0,
              "offsetNetworkAttenuation": 1,
              "opAmpGain": 2,
              "polarizationOffset": 1.86,
              "signals": {
                "CURRENT_AMPL": [
                  {
                    "name": "PA2",
                    "help": "",
                    "cost": 0
                  }
                ]
              }

            }
          ]
        },


        {
          "name": "PhaseVoltageGeneration",
          "type": "PhaseVoltageGeneration",
          "driverName": "",
          "driverPN": "",
          "minDeadTime": 100,
          "maxSwitchingFreq": 100,
          "tNoise": 2000,
          "hwVariants": [
            {
              "type": "DrivingHighAndLowSides",
              "help": "",
              "deadTime": 100,
              "highSideSwitchesDrivingPolarity": "Active high",
              "lowSideSwitchesDrivingPolarity": "Active high",
              "signals": {
                "PWM_CHU_H": [
                  {
                    "name": "PA8",
                    "help": "",
                    "cost": 0
                  }
                ],
                "PWM_CHV_H": [
                  {
                    "name": "PA9",
                    "help": "",
                    "cost": 0
                  }
                ],
                "PWM_CHW_H": [
                  {
                    "name": "PA10",
                    "help": "",
                    "cost": 0
                  }
                ],
                "PWM_CHU_L": [
                  {
                    "name": "PB13",
                    "help": "",
                    "cost": 0
                  }
                ],
                "PWM_CHV_L": [
                  {
                    "name": "PB14",
                    "help": "",
                    "cost": 0
                  }
                ],
                "PWM_CHW_L": [
                  {
                    "name": "PB15",
                    "help": "",
                    "cost": 0
                  }
                ]
              }
            }
          ]
        },





        {
          "name": "VBusSensing",
          "type": "VBusSensing",
          "busVoltageDivider": 136,
          "hwVariants": [
            {
              "type": "VBusSensing",
              "help": "",
              "signals": {
                "VBUS": [
                  {
                    "name": "PA1",
                    "help": "",
                    "cost": 0
                  }
                ]
              },
              "busVoltageDivider": 136,
              "busVoltageDividerR1": 1620,
              "busVoltageDividerR2": 12,
              "busVoltageDividerR3": null
            }
          ]
        }
      ]
    }

  ],

  "features": [
    {
      "name": "SerialPortCommunication",
      "type": "SerialPortCommunication",
      "hwVariants": [
        {
          "type": "Uart2WiresCommunication",
          "help": "",
          "signals": {
            "UART_TX": [
              {
                "name": "PC10",
                "help": "",
                "cost": 0
              }
            ],
            "UART_RX": [
              {
                "name": "PC11",
                "help": "",
                "cost": 0
              }
            ]
          }
        }
      ]
    }




  ]
}

 

and then the picture show in MC Workbench:

截屏2024-03-28 19.11.18.jpg截屏2024-03-28 19.10.48.jpg

 

only show one shunt Resistor. I don't know what's wrong with it. need to help!!!

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
cedric H
ST Employee

Hello @tonyqian926 ,

Your issue comes from the pin you selected.

PA7 -> ADC2_IN4

PA6 -> ADC2_IN3

PA3 -> ADC1_IN4

The algorithm uses only 2 phases among the 3 (depending on the angle). If there is only 1 ADC connected to the 3 phases, then it does the 2 sampling sequentially. But if there is 2 ADCs, the idea is to be able to do the sampling of the two phases in the same clock cycle. To do so, one of the 3 pins must be accessible to the 2 ADCs.

In your case the suggestion will be then :

- replacing PA3 by PA5 -> ADC2_IN2, then you will have a proposal using only ADC2.

- replacing PA6 by PC3 -> ADC1_IN9, ADC2_IN9, then you will be able to use 2 ADCs with the following schema :

(U,V) sampled by ADC2_IN4, ADC1_IN9

(U,W) sampled by ADC2_IN4, ADC1_IN4

(V,W) sampled by ADC2_IN9, ADC1_IN4

Here the phase V is shared between ADC1 and ADC2.

Regards

Cedric

View solution in original post

3 REPLIES 3
cedric H
ST Employee

Hello @tonyqian926 ,

Your issue comes from the pin you selected.

PA7 -> ADC2_IN4

PA6 -> ADC2_IN3

PA3 -> ADC1_IN4

The algorithm uses only 2 phases among the 3 (depending on the angle). If there is only 1 ADC connected to the 3 phases, then it does the 2 sampling sequentially. But if there is 2 ADCs, the idea is to be able to do the sampling of the two phases in the same clock cycle. To do so, one of the 3 pins must be accessible to the 2 ADCs.

In your case the suggestion will be then :

- replacing PA3 by PA5 -> ADC2_IN2, then you will have a proposal using only ADC2.

- replacing PA6 by PC3 -> ADC1_IN9, ADC2_IN9, then you will be able to use 2 ADCs with the following schema :

(U,V) sampled by ADC2_IN4, ADC1_IN9

(U,W) sampled by ADC2_IN4, ADC1_IN4

(V,W) sampled by ADC2_IN9, ADC1_IN4

Here the phase V is shared between ADC1 and ADC2.

Regards

Cedric

tonyqian926
Associate II

thanks very much, I can see 3 shunt now. 截屏2024-03-29 17.28.00.jpg

 

another question, there is some problem about the OCP function.  

the json file 

{
  "type": "inverter",
  "name": "testNow",
  "descVersion": 4,
  "contentVersion": "1.1",
  "PN": "testNow",
  "longDescription": "",
  "shortDescription": "",
  "link": "",
  "mcu": "STM32F303RCTx",
  "clockSource": "8_crystal",
  "clockFrequency": 72,
  "motorDrives": [
    {
      "name": "M1",
      "maxRatedVoltage": 600,
      "minRatedVoltage": 300,
      "maxRatedCurrent": 10,
      "features": [
        {
          "name": "CurrentSensing",
          "type": "CurrentSensing",
          "tRise": 2550,
          "hwVariants": [
            {
              "type": "ThreeShunt_AmplifiedCurrents",
              "help": " ",
              "shuntResistor": 0.01,
              "amplifyingNetworkImax": 9,
              "amplifyingNetworkVm": 3.3,
              "amplifyingNetworkPrating": 2.0,
              "offsetNetworkAttenuation": 1,
              "opAmpGain": 2,
              "polarizationOffset": 1.86,
              "signals": {

                "CURRENT_AMPL_U": [
                  {
                    "name": "PA7",
                    "help": "",
                    "cost": 0
                  }
                ],
                "CURRENT_AMPL_V": [
                  {
                    "name": "PC3",
                    "help": "",
                    "cost": 0
                  }
                ],
                "CURRENT_AMPL_W": [
                  {
                    "name": "PA5",
                    "help": "",
                    "cost": 0
                  }
                ]
              }
            },
            {
              "type": "SingleShunt_AmplifiedCurrents",
              "help": "Soldering the pins SENS1 to Vshunt_2 of connector J5 and the pins SENS3 to Vshunt_2 of the connector J6",
              "signals": {
                "CURRENT_AMPL": [
                  {
                    "name": "PA2",
                    "help": "CN7.36. Factory default. Solder R48.",
                    "cost": 0
                  }
                ]
              },
              "shuntResistor": 0.01,
              "amplifyingNetworkImax": 30,
              "amplifyingNetworkVm": 3.3,
              "amplifyingNetworkPrating": 4,
              "offsetNetworkAttenuation": 0.909,
              "opAmpGain": 5.7,
              "polarizationOffset": 1.710
            }



          ]
        },






        {
          "name": "OverCurrentProtection",
          "type": "OverCurrentProtection",
          "hwVariants": [
            {
              "type": "OnPowerStageOCP",
              "help": "How to enable this variant",
              "signals": {
                "OC_TRIGGER": [
                  {
                    "name": "PA2",
                    "help": "",
                    "cost": 0
                  }
                ]
              },
              "OCThreshold": 480,
              "OCComparatorThreshold": 0.3,
              "OCNetworkOffset": 0,
              "OCNetworkGain": 0.01,
              "OCSignalPolarity":"Active low"
            }
          ]
        },



        {
          "name": "PhaseVoltageGeneration",
          "type": "PhaseVoltageGeneration",
          "driverName": "",
          "driverPN": "",
          "minDeadTime": 100,
          "maxSwitchingFreq": 100,
          "tNoise": 2000,
          "hwVariants": [
            {
              "type": "DrivingHighAndLowSides",
              "help": "",
              "deadTime": 100,
              "highSideSwitchesDrivingPolarity": "Active high",
              "lowSideSwitchesDrivingPolarity": "Active high",
              "signals": {
                "PWM_CHU_H": [
                  {
                    "name": "PA8",
                    "help": "",
                    "cost": 0
                  }
                ],
                "PWM_CHV_H": [
                  {
                    "name": "PA9",
                    "help": "",
                    "cost": 0
                  }
                ],
                "PWM_CHW_H": [
                  {
                    "name": "PA10",
                    "help": "",
                    "cost": 0
                  }
                ],
                "PWM_CHU_L": [
                  {
                    "name": "PB13",
                    "help": "",
                    "cost": 0
                  }
                ],
                "PWM_CHV_L": [
                  {
                    "name": "PB14",
                    "help": "",
                    "cost": 0
                  }
                ],
                "PWM_CHW_L": [
                  {
                    "name": "PB15",
                    "help": "",
                    "cost": 0
                  }
                ]
              }
            }
          ]
        },





        {
          "name": "VBusSensing",
          "type": "VBusSensing",
          "busVoltageDivider": 136,
          "hwVariants": [
            {
              "type": "VBusSensing",
              "help": "",
              "signals": {
                "VBUS": [
                  {
                    "name": "PA1",
                    "help": "",
                    "cost": 0
                  }
                ]
              },
              "busVoltageDivider": 136,
              "busVoltageDividerR1": 1620,
              "busVoltageDividerR2": 12,
              "busVoltageDividerR3": null
            }
          ]
        },

        {
          "name": "TemperatureSensing",
          "type": "TemperatureSensing",
          "hwVariants": [
            {
              "type": "NTCThermistor",
              "help": "",
              "signals": {
                "TEMPERATURE_NTC": [
                  {
                    "name": "PB0",
                    "help": "",
                    "cost": 0
                  }
                ]
              },
              "v0": 1055,
              "t0": 25,
              "gain": 22.7,
              "maxSensorTemperature": 110
            }
          ]
        },

        {
          "name": "ICL",
          "type":"ICL",
          "hwVariants": [
            {
              "type": "InrushCurrentLimiter",
              "signals":{
                "ICL_ENABLE": [
                  {
                    "name":"PD2",
                    "help":"hello",
                    "cost": 0
                  }
                ]
              },
              "switchPolarity": "Active high",
              "capsDelayCharging": 100
            }
          ]
        }

      ]
    }

  ],

  "features": [
    {
      "name": "SerialPortCommunication",
      "type": "SerialPortCommunication",
      "hwVariants": [
        {
          "type": "Uart2WiresCommunication",
          "help": "",
          "signals": {
            "UART_TX": [
              {
                "name": "PC10",
                "help": "",
                "cost": 0
              }
            ],
            "UART_RX": [
              {
                "name": "PC11",
                "help": "",
                "cost": 0
              }
            ]
          }
        }
      ]
    }




  ]
}

 

the over current protection is not show on. I don't know why?截屏2024-03-29 17.34.52.jpg

 

 

it's ok now. I changed the oc_trigger pin to PA2(TIMx_BKIN).I hadn't noticed it before.

the json code is:

        {
          "name": "OverCurrentProtection",
          "type": "OverCurrentProtection",
          "hwVariants": [
            {
              "type": "OnPowerStageOCP",
              "help": "How to enable this variant",
              "signals": {
                "OC_TRIGGER": [
                  {
                    "name": "PA2",
                    "help": "",
                    "cost": 0
                  }
                ]
              },
              "OCThreshold": 480,
              "OCComparatorThreshold": 0.3,
              "OCNetworkOffset": 0,
              "OCNetworkGain": 0.01,
              "OCSignalPolarity":"Active low"
            }
          ]
        },

 

and the foc wizard show:截屏2024-03-30 10.28.41.jpg