Solved: MOSFET n/p channel for driving motor fw/bw

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

Hi guys,

 

I have a problem that i faced for a week now and could not find a solution for it.

 

Am using a 2 MOSFET (N/P) channel to drive a motor forward and backward, the part that am using is AO6604 ( 6-TSOP ), datasheet can be found here,

 am using ATTINY214, flashing is done by UPDI, now here comes the comes the dilemma:

 

- Once I connect my custom board to flash the program I get a short circuit immediately, once I remove the the mosfets and flash the program, the program is flashed. I solder again the mosfet and comes the 2nd problem.

- Although from the outputs of the MCU to the n channels and p channels outputs the exact behaviour I want the to and works fine, the p channel cannot switch on. there is a resistort of 470 ohm between each gate and pin.

 

on my setup am using:

 

For first MOSFET:

- PA6 ----> Motor reverse highside p channel configuration at initialization, output HIGH

- PA7 ----> Motor forward lowside n channel configuration at initialization, output LOW

 

For second MOSFET:

- PB3 ----> Motor forward highside p channel configuration at initialization, output HIGH

- PB2 ----> Motor reverse lowside n channel configuration at initialization, output LOW

 

does anybody has experince with this ? I appreciate a lot,

 

Regards,

Moe

 

 

This topic has a solution.
Last Edited: Thu. Dec 13, 2018 - 11:51 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

It is too difficult to follow what your describing, they came up with a way to show circuits a few years back called a schematic, please show us yours!

Then maybe some one can help you.

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274

 

 

 

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

 

ah sorry, here is it, pins are connected and configured as described before,

 

regards,

Moe

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

What voltage is +BATT?

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

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

4.2V is at +BATT

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

To save people looking it up...

 

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

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

ah yeah, exactly, thanks!

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

Sorry, another question, what AVR are you using?

 

 

Moe123 wrote:

- Once I connect my custom board to flash the program I get a short circuit immediately, once I remove the the mosfets and flash the program, the program is flashed. I solder again the mosfet and comes the 2nd problem.

 

While you are programming your board the chip is held in reset so all your IO lines float. You will need pull-up and pull-down resistors on all four Gates. 

 

Moe123 wrote:

- Although from the outputs of the MCU to the n channels and p channels outputs the exact behaviour I want the to and works fine, the p channel cannot switch on. there is a resistort of 470 ohm between each gate and pin.

 

Can you show the code that initialises and drives the IO lines to your MOSFETS?

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

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

I am using ATTINY214, I initialize first the GPIO's at the very beginning,

 

enabling the pull-up on all pins like this has shown spikes in voltage when switching on the MOSFET, hence i turned it off.

int8_t gpio_init()
{

	PORTB_set_pin_level(MOTOR_FW_HS_PIN	,true);
	_delay_ms(10);
	PORTB_set_pin_dir(MOTOR_FW_HS_PIN, PORT_DIR_OUT);
	_delay_ms(10);

	PORTA_set_pin_level(MOTOR_FW_LS_PIN	,false);
	_delay_ms(10);
	PORTA_set_pin_dir(MOTOR_FW_LS_PIN, PORT_DIR_OUT);
	_delay_ms(10);

	/* PORT setting on PA6 */
	PORTA_set_pin_level(MOTOR_BW_HS_PIN, true); //ok
	_delay_ms(10);
	PORTA_set_pin_dir(MOTOR_BW_HS_PIN, PORT_DIR_OUT);
	_delay_ms(10);
	/* PORT setting on PB2 */
	// Set pin direction to output
	PORTB_set_pin_level(MOTOR_BW_LS_PIN,false);
	_delay_ms(10);
	PORTB_set_pin_dir(MOTOR_BW_LS_PIN, PORT_DIR_OUT);
	_delay_ms(10);

	return 0;

}

 

EDIT: datasheet: http://ww1.microchip.com/downloa...

Last Edited: Tue. Dec 11, 2018 - 05:28 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

the reason why I initialized the direction first is to avoid the short circuits...but still, the problem remained

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

Moe123 wrote:
Once I connect my custom board to flash the program I get a short circuit immediately

 

What do the port pins do when an AVR is in RESET? 

Assuming the port pins are connected to the gates of the MOSFET's, and one side is Batt+ and the other side is GND, what are the gates doing?

 

Jim

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274

 

 

 

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

Moe123 wrote:
enabling the pull-up on all pins like this has shown spikes in voltage when switching on the MOSFET, hence i turned it off.

 

I believe what Brian means in #8 is that you need external pull-ups on the PMOS and external pull-downs on the NMOS, so that they are all off by default until they receive signals from the MCU.

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

Whilst not related to the problem - why 470ohm resistors in series with the gates? 22ohm maybe.

Last Edited: Tue. Dec 11, 2018 - 08:58 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
why 470ohm resistors in series with the gates?

Because he prefers a slow turn on/off !???

 

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274

 

 

 

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

I'd add that they should be fairly ferocious pull-"off" (up or down, whichever's required) resistors.  2k would not be too low.  S.

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

As with most little uC projects, I would tacle this with a USD Logic anayser (Everyone should have one, really no excuse to not buy one) and my Rigol scope (bit too expenisve for some).

 

Without such tools you can start by replacing your motor with 2 LED's (2 different colors would be nice, Red and Green?) and then putting series resistors between the pins2 of the AO6604 and +Vbat.

The Resistors protect the FET's and also act as series resistors for the LED's.

Then first get the LED's working and then you can think again about using a motor.

With a motor you can also put some resistors in series. Somewhere between 5 and 20 Ohm probably works.

Your motor will have less power, but the FET's are still protected.

Using a current limited power supply instead of batteries is also a good idea.

Doing magic with a USD 7 Logic Analyser: https://www.avrfreaks.net/comment/2421756#comment-2421756

Bunch of old projects with AVR's: http://www.hoevendesign.com

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

Hi guys,

 

UPDATE: I found a major mistake in the PCB, I've added a cap between the two pins of FW and RW "its unmounted" but unfortunately I forgot to refresh the board "design mistake" which caused short circuit between the two MOSFETs because of the GND plane on TOP. this explains the strange behaviour of the P channels and why doesnt the gates fully switch ON.

 

I would like to add that as Brian suggested for my next Prototype adding a Pull-up / Pull-down resistors is forsure a good idea, Thanks all for your kind help and support.

 

470 ohm between gates was to slow things down a little bit, but I will test it with smaller resistors in my next protytypes.

Brian, Jim, El Tangas, Kartman, Paul, Scroungre ,thanks all for your help and valuable ideas , i took note of them.

 

Regards,

Moe

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

Moe123 wrote:

Hi guys,

 

UPDATE: I found a major mistake in the PCB, I've added a cap between the two pins of FW and RW "its unmounted" but unfortunately I forgot to refresh the board "design mistake" which caused short circuit between the two MOSFETs because of the GND plane on TOP. this explains the strange behaviour of the P channels and why doesnt the gates fully switch ON.

 

I would like to add that as Brian suggested for my next Prototype adding a Pull-up / Pull-down resistors is forsure a good idea, Thanks all for your kind help and support.

 

470 ohm between gates was to slow things down a little bit, but I will test it with smaller resistors in my next protytypes.

Brian, Jim, El Tangas, Kartman, Paul, Scroungre ,thanks all for your help and valuable ideas , i took note of them.

 

Regards,

Moe

 

EDIT: there was no need for all that long delays at initialization and so on, a NOP(); function would be sufficient "as in my case".

 

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

Next round:

 

Make a note to add some 10 cent logic gates that prevent both gates turning on at the same time, regardless of what the program is doing.   Feed your micro into these gates & they will help prevent "oops" destruction.

Software may go corrupt or crash at any moment. 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!