vhn2sp30 Motor control works only when controller is powered on first

Go To Last Post
27 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

 

Good Scenario :

I have designed a motor controller using vhn2sp30 motor driver from ST microelectronics and Atmega328P is the controller. I power on the microcontroller from a different source (USBasp is connected to PC which turns on atmega328P) and program it using Arduino. I have connected a motor to output pins and when I connect battery power to VHN2SP30 chip, the motor starts running. Everything seems to be working as expected.

 

Bad Scenario:

The trouble starts the other way around. I connect the battery to VHN2SP30 chip and then power on the Atmega328P chip from another 5v source, but the motor does not rotate. There is also a regulator connected to Battery input which provides regulated 5v supply to AVR chip. Even in this case, the motor does not work. I tried removing the regulator / keeping the regulator. Whatever I do, it does not make the motor rotate. The only way is to power on AVR chip from an external source and then connect the battery.

 

Very Bad Scenario:

The third scenario is when the battery is connected and the motor is spinning, when I press the reset button, it resets the chip and then the motor stops. I need to remove battery supply to motor driver and reconnect it.

 

Does anybody know why this might be happening?

 

More information:

1. There is a 35v, 470uF electrolytic capacitor attached to motor driver power pins

2. A 100uF 10v tantalum capacitor is connected to 5v and Ground pins (to output of regulator)

3. Regulator used is LM1084 from Texas instruments

4. Battery is fully charged with capacity of 2200uA and 11.1V

5. Tried different motors from tiny toy motor to metal gear motors, but the result is the same.

6. There are two LED's connected which turns on when motor turns on either direction. In the Good scenario (when motor is spinning) the LED turns on to indicate direction. In the bad scenario, when motor is not connected, the LED still turns on to indicate direction. However in the same bad scenario, when the motor is connected, the LED turns off.

 

Can someone help me find a reason or a solution to this issue?

 

Best Regards,

Praveen

This topic has a solution.

Robot building is all about sharing & learning
-----------------------------------
www.robotplatform.com

Last Edited: Tue. Jun 20, 2017 - 08:40 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In the datasheet - table4 diaga/b pins. What does it say? how are you ensuring these pins are in the correct state?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In the datasheet - table4 diaga/b pins. What does it say? how are you ensuring these pins are in the correct state?

 

I have an external pull up resistor connected to 5v and that makes sure driver is enabled (as per attached schematic). Regarding the code, this is the code I have. I have not pulled them low in the program.

 

#define BRAKEVCC 0
#define CW   1
#define CCW  2
#define BRAKEGND 3
#define CS_THRESHOLD 100

/*  VNH2SP30 pin definitions
 xxx[0] controls '1' outputs
 xxx[1] controls '2' outputs */
int inApin[2] = {7, 4};  // INA: Clockwise input
int inBpin[2] = {8, 9}; // INB: Counter-clockwise input
int pwmpin[2] = {5, 6}; // PWM input
int cspin[2] = {2, 3}; // CS: Current sense ANALOG input
int enpin[2] = {0, 1}; // EN: Status of switches output (Analog pin)

int statpin = 13;

void setup()
{
  Serial.begin(9600);
  
  pinMode(statpin, OUTPUT);

  // Initialize digital pins as outputs
  for (int i=0; i<2; i++)
  {
    pinMode(inApin[i], OUTPUT);
    pinMode(inBpin[i], OUTPUT);
    pinMode(pwmpin[i], OUTPUT);
  }
  // Initialize braked
  for (int i=0; i<2; i++)
  {
    digitalWrite(inApin[i], LOW);
    digitalWrite(inBpin[i], LOW);
  }
  // motorGo(0, CW, 1023);
  // motorGo(1, CCW, 1023);
}

void loop()
{
  motorGo(0, CW, 1023);
  motorGo(1, CCW, 1023);
  delay(500);

  motorGo(0, CCW, 1023);
  motorGo(1, CW, 1023);
  delay(500);
  
  if ((analogRead(cspin[0]) < CS_THRESHOLD) && (analogRead(cspin[1]) < CS_THRESHOLD))
    digitalWrite(statpin, HIGH);
}

void motorOff(int motor)
{
  // Initialize braked
  for (int i=0; i<2; i++)
  {
    digitalWrite(inApin[i], LOW);
    digitalWrite(inBpin[i], LOW);
  }
  analogWrite(pwmpin[motor], 0);
}

/* motorGo() will set a motor going in a specific direction
 the motor will continue going in that direction, at that speed
 until told to do otherwise.
 
 motor: this should be either 0 or 1, will selet which of the two
 motors to be controlled
 
 direct: Should be between 0 and 3, with the following result
 0: Brake to VCC
 1: Clockwise
 2: CounterClockwise
 3: Brake to GND
 
 pwm: should be a value between ? and 1023, higher the number, the faster
 it'll go
 */
void motorGo(uint8_t motor, uint8_t direct, uint8_t pwm)
{
  if (motor <= 1)
  {
    if (direct <=4)
    {
      // Set inA[motor]
      if (direct <=1)
        digitalWrite(inApin[motor], HIGH);
      else
        digitalWrite(inApin[motor], LOW);

      // Set inB[motor]
      if ((direct==0)||(direct==2))
        digitalWrite(inBpin[motor], HIGH);
      else
        digitalWrite(inBpin[motor], LOW);

      analogWrite(pwmpin[motor], pwm);
    }
  }
}

 

 

 

Attachment(s): 

Robot building is all about sharing & learning
-----------------------------------
www.robotplatform.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Any help please?

Robot building is all about sharing & learning
-----------------------------------
www.robotplatform.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What is the PCB for the Mega?

Are all Vcc and the AVcc pins tied to Vcc?

Are ALL of the Grounds, and Agnd, tied to Ground?

Do ALL Vcc and AVcc pins have a 0.1 uF by-pass cap across their pins?

 

Is there any powered input INTO the micro, when you power up the Motor power supply first, BEFORE the power is applied to the Micro?

Note that the Micro should be powered up first if there is any INPUT signal to the micro that could be High before the micro is powered up.

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To follow up on JC's note.

 

Look at the "Absolute Maximum Ratings" at the start of the "Electrical Characteristics". There, you will find an entry that looks like

Voltage on any Pin except RESET
with respect to Ground ................................-0.5V to V
CC+0.5V 

Now, what do you think that means when the MCU is off? Then, Vcc = 0. So, the maximum input on ANY pin when the unit is unpowered is +0.5V. Period. It is your task as designer to insure that this condition is met. Its not just AVRs. Even standard generic CMOS logic has a spec like this.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

 

What is the PCB for the Mega?

 

Please find attached complete schematic which shows the mega. There was one Enable Pin which had a pull-up resistor (5v) connected to AVR input pins. All others are pulled down and 0V when AVR starts.

Secondly, the battery power is fed into a regulator. The moment I provide power to the chip, the same flows through a regulator and powers the AVR also. I guess this should start the AVR.

 

Are all Vcc and the AVcc pins tied to Vcc? Yes. AVCC and VCC are tied together.

Are ALL of the Grounds, and Agnd, tied to Ground? All ground pins (3,5,21) are connected.

Do ALL Vcc and AVcc pins have a 0.1 uF by-pass cap across their pins? Yes. One for VCC and one for AVCC

 

I have removed the circled pull-up resistor on the enable pin and turning it ON in software. However, the result is still the same. When I Power on AVR and then the battery, it functions well. If I power just the battery, the LED after the regulator turns on, but still the motor does not spin. Scratching my head soldering and desoldering each component, but seems like a never end. Does anybody see a mistake in the schematic and suggest me please?

Attachment(s): 

Robot building is all about sharing & learning
-----------------------------------
www.robotplatform.com

Last Edited: Mon. Jun 19, 2017 - 05:27 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Now, what do you think that means when the MCU is off? Then, Vcc = 0. So, the maximum input on ANY pin when the unit is unpowered is +0.5V. Period. It is your task as designer to insure that this condition is met. Its not just AVRs. Even standard generic CMOS logic has a spec like this.

When the motor controller is powered on, the AVR also simultaneously turns on since a regulator is connected to Battery which feeds the avr VCC and ground pins. So, I guess this should not be an issue where VCC is 0 and motor controller is turned on.

 

Robot building is all about sharing & learning
-----------------------------------
www.robotplatform.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What status does the vnh chip give you? It's obviously upset about something.
220uF on the output of the regulator seems excessive.
Why the mosfet switching the 0V? That is fraught with danger. Have you tried shorting the fets to see if they are causing the issue. If you want to switch the power to the vnh chips, switch the supply.

Last Edited: Mon. Jun 19, 2017 - 08:25 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Both the outputs are high when the motor is not spinning. However, when I check the input pins to motor driver, one is high, one is low while pwm is at 2.5v.

When I connect battery after powering the avr, then one of the output is high and the other low making the motor shaft spin.

MOSFET switches to zero when all is well and MOSFET ground is connected to ground. If battery is reverse connected, it protects the driver as the gate voltage is zero.

Even when the fet is shorted, it does not make any difference. I even removed it and connected ground of driver to ground plane. Still no difference.

This is really difficult to debug for me and working on it from 2 days to set it right. Any comments should be helpful.

Robot building is all about sharing & learning
-----------------------------------
www.robotplatform.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The chip gives you diagnostic outputs - what do they tell you?
What have you done to narrow down the problem.

Have you considered where the battery voltage flows when you disconnect the 0V from the vnh chip with your mosfet? It will probably find its way to the inputs via the protection diodes. Bad idea methinks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Don't drive the EN pin with an output and read it with a multimeter or MCU input to see if there are any faults. Also remove the GND FET's and use a P-fet on positive side ( https://hackadaycom.files.wordpr... ) or just a polarised power input. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you Kartman. I have tied both DIAGA/ENA and DIAGB/ENB and connected it to an AVR pin. As per their truth table, I need to check each of those inputs, but I do not have a way out. Motor Output A and B, both are at high voltage 8.8 and 9v. Since this is the first time I am working on this driver, not sure on the complete picture yet.

 

Have you considered where the battery voltage flows when you disconnect the 0V from the vnh chip with your mosfet? It will probably find its way to the inputs via the protection diodes. Bad idea methinks.

Since the battery is connected to a regulator, it anyways flows to the AVR chip. What is the best way to identify if the voltage is going to the IO pins through the diodes? Removing the regulator and check?

 

 

Robot building is all about sharing & learning
-----------------------------------
www.robotplatform.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

praveen_khm wrote:
Thank you Kartman. I have tied both DIAGA/ENA and DIAGB/ENB and connected it to an AVR pin. As per their truth table, I need to check each of those inputs, but I do not have a way out. Motor Output A and B, both are at high voltage 8.8 and 9v. Since this is the first time I am working on this driver, not sure on the complete picture yet.  

I do not understand what you just said.

Basically you can repeat the problem. Make sure you make note of the diag states when the chip fails. Isolate each of the control pins and repeat., making notes each time. This should not take too long. Once you've done the tests you should be able to derive a conclusion.

 

 

praveen_khm wrote:
Since the battery is connected to a regulator, it anyways flows to the AVR chip. What is the best way to identify if the voltage is going to the IO pins through the diodes? Removing the regulator and check?  

The regulator has no part to play in this. Suffice to say that disconnecting the 0V of the driver chip is a bad idea.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
Make sure you make note of the diag states when the chip fails

 

I checked each pin when the chip is running and when it fails.

 

When chip is running:

OUTA : 12V

OUTB : 0V

INA : 5V (HIGH)

INB : 0V (LOW)

ENABLE : 5V (HIGH)

PWM : 5V (HIGH)

 

When chip fails, everything is the same except for OUTB which shows 10V.

Checked this against the fault truth table 13 in the datasheet, but does not seem to make any sense to me (or maybe I do not know how to understand that).

 

Kartman wrote:
Basically you can repeat the problem.

If you can kindly check the schematic, enable 1 and enable 2 pins are shorted so that it is easier for me to enable the chip from a single pin through AVR and hence not able to isolate them. If there is something I did not understand here, or could not see the mistake, please let me know.

Robot building is all about sharing & learning
-----------------------------------
www.robotplatform.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To further my experiment, I removed the mosfets, regulator, protection diode (on mosfet). Shorted Driver ground and ground plane. Connected the battery and when checking ground against each of input and output pins of the driver using a multimeter, there is no voltage against any of those pins. To summarize, there is no voltage leak flowing from the driver pins to the AVR pins / to VCC. Any other test suggested?

Robot building is all about sharing & learning
-----------------------------------
www.robotplatform.com

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Figure 33 tells you how to reset the lockout. Have you tried this?
What do you mean you are not able to isolate the diag pins? 10 seconds is all it takes to lift the pin.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
Figure 33 tells you how to reset the lockout. Have you tried this? What do you mean you are not able to isolate the diag pins? 10 seconds is all it takes to lift the pin.

 

Well, that was more than 10 seconds, but thanks for telling me a way. I wondered if I have to cut off a track from the board. Pulling the pin was an easier option.

 

Now the troubleshooting. I physically pulled the enable pins out. Connected a resistor externally and pulled them high. The motor turns and when I press the reset button, motor stops working.

Both the enable pins are high even in the fault condition (which should mean there is no fault as such). The output pins are both high again. Sad that after spending so much time, I am still not able to find a solution. sad

Robot building is all about sharing & learning
-----------------------------------
www.robotplatform.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And the people over on EEVBlog and Pololu's forums have not solved it for you either. Gee "we" must all be clueless. angry

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Drowning man syndrome.
The solution is obvious, one just needs to look.
Again, have you tried to reset the lockout?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

valusoft wrote:
And the people over on EEVBlog and Pololu's forums have not solved it for you either. Gee "we" must all be clueless. angry

And the folks in Arduino forum too.

 

Kartman wrote:
The solution is obvious, one just needs to look. Again, have you tried to reset the lockout?

Yes. I did try to pull the input high. But the issue is that there seems to be no fault condition. Both the Enable pins are high. If I do not connect a motor, the LED will be turned on faintly. When motor is connected, it turns off.

I did try to toggle OUTa and OUTb and LED toggles (though very dim) and again once motor connected, it turns off.

 

When the motor is spinning (I pull the battery power and connect it again), the LED lights up brightly. One other issue as mentioned before is PWM does not work on the pin whatever the scenario is. If it is 1023, then it works, else no.

 

As a last solution, I am desoldering each and every component one by one and testing it.

 

Robot building is all about sharing & learning
-----------------------------------
www.robotplatform.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How about the pcb?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
How about the pcb?

All the connections are intact and tracks are good.

 

Is there any powered input INTO the micro, when you power up the Motor power supply first, BEFORE the power is applied to the Micro?

This is one thing which I am checking now. If I still do not get a result, I will be left over with a pile of desoldered components and the PCB.

 

Robot building is all about sharing & learning
-----------------------------------
www.robotplatform.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How do you 'know' the tracks are 'good'? What you perceive as good might actually be woefully inadequate.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
How do you 'know' the tracks are 'good'? What you perceive as good might actually be woefully inadequate.

 

Signal pins are 12mil, Power (5v) and Ground Pins are 25mil. Battery Power Pins and motor output pins are more than 60mil (actually they are isolated pads). So, I hope that is not an issue.

Stuck without a solution. I have a "SparkFun Monster Moto Shield" which has the same circuitry and sits on top of an arduino. It works well there, but not this new board.

Robot building is all about sharing & learning
-----------------------------------
www.robotplatform.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

working a way out and removed all the components.

Robot building is all about sharing & learning
-----------------------------------
www.robotplatform.com

Last Edited: Tue. Jun 20, 2017 - 06:56 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks to all those who pitched in to help. Kartman, apart from debugging, I found lot new ways to test the board and read the datasheet from you. Thank you.

For those who are curious, the issue got resolved. The Issue was the PWM pin. As per the schematic, it shows a 1K resistor connected on either side of PWM which was to be 10K. (A single zero makes a lot of difference)

Removed that and replaced with a 10k resistor and it works like a charm. Found this solution on the Arduino forum. Once again, thank you guys.

Robot building is all about sharing & learning
-----------------------------------
www.robotplatform.com

Last Edited: Tue. Jun 20, 2017 - 08:10 AM