PWM crosstalk or code issue..

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

Hello guys

I hope you can help.
I've been working on a simple PWM-motor control (see attached schematic).
Everything worked until I introduced a small piece of code which is supposed to short the motor terminals via T1 when I want it stopped.
I've replaced T1 with an LED going from MC33152.7 to +BATT. It is supposed to be on when the PWM is off and off when the PWM is on (on when motor is stopped, off when the motor is running).
But when I push the trigger button, I can see that the LED doesn't go off. Instead, the LED flashes in the same frequency as the PWM, which is really weird, considering that T1 is controlled via PB.1 which is on a completely different port than the PWM-pin (PA.7).

What might be the cause of this?
EDIT:
Code removed since the general question is solved.

Attachment(s): 

Last Edited: Wed. Mar 16, 2011 - 11:11 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To check your code, disconnect t1,t2,t3 and test your MC33152 inputs and outputs. If your code is working and the motor circuit is not then you know it's the circuit for the motor.

I am no genius when it comes to analog circuits but I don't see any kickback diodes to protect the fets and I thought you need a higher voltage on the Pfet gate than the source pin, when T1,T2 turn off the kickback voltage on the Pfet's drain turns the pfet off.

Above may be totally wrong on the pfet brake circuit but analyzing your code output should be easy when you disconnect the motor circuit.

I would be interested in learning how that pfet circuit works, If it were a simple relay switch I can see it would short the motor but my understanding of pfet's is limited.

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

For what it is worth, many Full-H bridges have a built-in "brake" function.

Jim

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

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

Unfortunately the maximum dimensions of the circuit prohibit me from using a full bridge. Thanks for the comment, though.

Metron9, I'll try your approach. At least I should be able to determine whether the problem is in the hard -or software. I suspect the last although I can't figure out why yet.

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

Is this question formulated in an unhelpful way? Or just too weird?

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

Quote:

Unfortunately the maximum dimensions of the circuit prohibit me from using a full bridge.

Quote:

Is this question formulated in an unhelpful way? Or just too weird?

Not my area of expertise, but setting the maximum dimensions before doing feasibility/prototype sounds like doing engineering from a marketing checklist.

To gain more interest, I'd like to see the dimensions of the full-bridge and half-bridge. Then I'd poke around for monolithic full-bridge and check the size. Of course, then we'd need to know the power requirements and how much heat needs to be dissipated.

Or choose an AVR model with dead-time insertion?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

What is dead-time insertion?

Also:

UPDATE: This is not a hardware issue. Looking at the signal on the mosfet gates, I can see that even with the trigger pulled, the PWM is on/off in intervals, so this is a programming issue where I didn't simulate well enough or think the code through. The program polls the trigger, then activates the PWM and after a while, for some reason, it stops the PWM, then restarts it. It looks like it's doing it every ~6mS, so it must be related to the simple de-bounce code, I made...

*looks at code frantically*

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

New question:

I'm trying to poll a single pin on port B to see if the attached button has been pressed or not.
Will this expression work as intended, or will it toggle the value of the particular pin:

   triggercheck=(PINB&=0x04); //Trigger-pin polled to see if it's still low. 

Is there a better way to poll a pin?

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

Malmkvist wrote:
triggercheck=(PINB&=0x04); ... Is there a better way to poll a pin?

No. That's more or less how it would be done; you might want to use a simple & instead of &= so that it isn't writing back to the PINB register though - triggercheck=(PINB&0x04); also, it will depend on how triggercheck is used, it will result in 0x00 or 0x04, not 0x00 or 0x01.

Martin Jay McKee

As with most things in engineering, the answer is an unabashed, "It depends."

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

Another tip you may want to try.

When you have unknowns such as if a button input is working or not. You can bypass the input in the code and set the variable with immediate data. In your testing of the hardware I would use some simple code to PWM the motor for a specified number of seconds and then break the motor for a specific number of seconds in a simple while loop bypassing all other code. Sometimes (or should that be usually) it's a connection problem with the hardware and running bullet proof test code for hardware verification can save a lot of time looking for a problem with many more variables.

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

This thread is sort of old. I eventually found the error to be an wrongly placed negation.
Gotta love copy/pasting code from one place in the program to another... :-/
Thanks for all your input, guys.