LPC2294 PWM pins dying?!?!

Hello, I am having some trouble with my LPC2294. This is my first project using an uC, I was able to get PWM working on PWM2 (P0.7) to control a servo.

The next day the pin was no longer working, not even as an standard output pin. It is constantly at 0v. I assumed that I did something to break it, so I switched to PWM4 (P0.8) last night. That worked for awhile, but it also has died in the same way (about an hour ago)

I am hoping that someone on here who is more knowledgeable than me can help me.

The only modifications done to it are replacing the male headers with female ones, and removing the power connector.

I am using this header board:

http://www.sparkfun.com/commerce/produc … cts_id=268

Here is the user manual:

http://www.keil.com/dd/docs/datashts/ph … 2_2294.pdf

Check the current draw. I’m pretty sure the maximum current output on any pin is 20mA (you should look into it), and you may be exceeding that. If you draw too much current it’s pretty easy to blow out peripherals (on PICs and AVRs), and the ARMs aren’t really designed out work as microcontrollers as much as microprocessors so I would imagine it’s even easier to blow out peripherals like that.

I guess the other questions I have are:

  1. How are you powering the servos?

  2. Did you try switching back to PWM2? Does it work again?

  3. Are you using an oscilliscope to check the output voltages? Or just a multi-meter. If it’s just a multimeter you probably won’t see the momentary spike from the PWM output…

  1. How are you powering the servos?

I am using a standard ATX power supply, using the 5v line. I am also powering the board with the same voltage source.

  1. Did you try switching back to PWM2? Does it work again?

No, PWM2 doesn’t work again.

  1. Are you using an oscilliscope to check the output voltages? Or just a multi-meter. If it’s just a multimeter you probably won’t see the momentary spike from the PW

Nope, no scope until school starts up again. I only have a multimeter on hand.

I just tested the current. On the signal line It is drawing 1mA max, on the power line it is 0.282A max.

When you say “powering the board using the 5V rail of an ATX supply” did you remember to put a minimum load on that?

Most ATX power supplies require that you draw a minimum amount of current or it will fry the power supply and fast. Check out the comments here: http://www.sparkfun.com/commerce/produc … ts_id=9774

Also, if you’re using the power straight out of the ATX it’s going to be VERY noisy. Do you have any smoothing/decoupling caps in there? That would hurt both the servos and the LPC.

If you’re just using a regular DMM to test the current you won’t necessarily see the maximum current draw during the 1 to 2ms blip in which you’re actually outputting a voltage. That current given by the DMM is the average over some sampling period.

I’m still going to guess that you’re just drawing too much current since it works for a while. But without a scope it’s hard to tell what’s wrong.

Yes, I have a minimum load on it.

I haven’t put any caps in, what size do you suggest? The only ones I am useing are the ones on the board itself.

I wish I had the cash do get a scope instead of relying my school’s.

Edit: How do you think I should prevent this from happening in the future? Resistor? Transistor? Both?

Well, this is one of those “I have guessed, I have no idea if I’m right” moments. If it is that, I would use something like a cheap op-amp or a transistor… I’d go see what other people are doing, but pretty much any buffer should do. You could even just go for a non-inverting buffer (aka a double not gate). If you just use a resistor then you’ll get weird issues with things like the signal dropping in voltage faster and thus very erratic behaviour from the servos.

If it turns out that part of the issue is no smoothing caps it might just be that the signal wasn’t getting above the noise floor. I’m curious if there’s an on-board 3.3V regulator in which case the signal might not have been high enough for the servo. Is the output on a GPIO pin 3.3V or 5V?

For the decoupling, in general you stick in a cap which has at least twice the voltage rating that you’re expecting (aka you need something with a voltage rating of at least 10V (I’d look for at least 16V)), and stick in a big one and one which has a tenth of that rating. So something like a 220uF and a 22uF cap should work. Both of these should be very close to where the power exits the supply. The 220 should suppress big transients and the 22 should provide current in the sudden very high draw moments.

There is both a 1.8v and 3.3v regulator, GPIO output is 3.3v. I have tested it with a transistor and resistor (between the pin and base on the transistor), the servo seems to be functioning fine.

I found a 100uF (biggest I could find in my spare parts bag) and a 10uF, do you think this would be sufficient, or should I keep looking?

Thank you for all your help :slight_smile:

100uF and 10uF is better than nothing! I normally just say “something big” but 100uF should probably be enough. In general when I’m testing things I make it ENORMOUS (200-400 uF) so that I don’t have to worry about a noisy supply causing problems, but making it as big as (or bigger) than a milli-Farad and two things will be true: you’re paying too much for that cap, and you’ll have trouble turning off the circuit if something goes wrong (that cap will keep it running!)

As for the 3.3V thing: a big part of this might just be that your signal isn’t passing the minimum threshold for the servo. 3.3V, while past the 60% mark, isn’t quite the 5V signal your servo is expecting.

The solution I’d probably go with is using a MOSFET with a 4.7k pulldown on the gate and the source, and have the drain be connected to 5V and the source connected to the servo input wire. The gate should be connected to the LPC pwm output. That would give you the 5V signal your servo expected and not tax the output of your LPC. (I can explain the 4.7k pulldowns if you need me to)

Glad I can help!

Why a MOSFET instead of a BJT? (Sorry, I really don’t know the difference)

If you don’t mind would you explain the pulldowns?

Ouch. Hope you got the 2294 at the sale price.

As kitscuzz suggests, the cause may have been simple over-current. It might also have been inductive spikes. The textbook protection for that would be a pair of diodes, one with anode to ground and the other with cathode to your uC supply. You connect a resistor - say 47 or 100 ohms - between your uC I/O pin and the junction of these diodes. The junction of the resistor and diodes is what you connect to your external device. Ideally through yet another resistor - if you can add it and still have enough drive.

That abbreviated explanation raises a lot more questions than it answers, but a full analysis (even if I could give it) would take many pages.

For most applications, kitscuzz’s suggestion of a separate driver transistor solves two problems at once: You can get more drive if you need it, and you can hope that any inductive spike will fry your driver transistor rather than your uC.

If the servo is an off-the-shelf standard part, you might want to post a link to info on it.

hsutherl:
Ouch. Hope you got the 2294 at the sale price.

As kitscuzz suggests, the cause may have been simple over-current. It might also have been inductive spikes. The textbook protection for that would be a pair of diodes, one with anode to ground and the other with cathode to your uC supply. You connect a resistor - say 47 or 100 ohms - between your uC I/O pin and the junction of these diodes. The junction of the resistor and diodes is what you connect to your external device. Ideally through yet another resistor - if you can add it and still have enough drive.

I think he would want a reverse-biased diode across an inductive load. If that slows things too much, another suppression method could be used.

A diode is certainly another possible solution if inductive loads are what’s blowing the LPC. I think the signaling levels may also be an issue, which is why I was rolling with a transistor as a solution.

(Sorry the following is so verbose, I hope it helps!)

Anyway, to answer your question Alexander: I would use a MOSFET rather than a BJT mostly just so that you don’t have to worry about the way that BJTs behave. A BJT has a lot of neat properties that let you use them as amplifiers and lots of neat analog functions, but for digital stuff I generally use MOSFETs. Note: I’ve gone into teacher-y mode by now, feel free to skip this next bit! If you don’t already know, MOSFETs essentially work by having a voltage induce an electrical field using a structure which behaves a lot like a capacitor (this is the gate), and that electrical field allows for current to flow from the source to the drain. There’s a definition which tells you how the gate-to-source/drain voltage changes the amount of current which can flow from drain-to-source (or vice versa), but essentially all you need to understand is that as long as the voltage on the gate is significantly large the connection between the source and gate will (nearly) flow freely. This allows you to treat the transistor like a switch which is digitally controlled.

Now, all of that lets me explain the pulldowns… or, rather, pulldown. I actually only should have put one pulldown in there, which should be the 4.7kOhm on the source to ground :oops: . Sorry about that. Essentially, as I just explained, since the model for the transistor (in this very limited case) can look like a switch controlled by the LPC, when you turn the MOSFET “off”, the input to the servo will not go to ground, it will actually just float, disconnected from everything. Whether or not your servo reads any of the following noise as ground or 5V is completely up to chance. The 4.7k resistor will pull the disconnected line to ground, allowing your transistor to behave the way it has to: with positive logic from your LPC connecting the servo to positive voltage, and ground connecting the servo to ground.

Hope that helps!

Yup, I did get it at the sale price :slight_smile:

I tried your MOSFET solution kitscuzz, but I can’t get it to work properly. I have Source connected to ground using a 4.7k resistor, and drain connected to 5v. When I apply 5v to Gate I get about 2v on Source. I am getting the same result with both of my two shiny new MOSFETs. This is my first time using one, so I am sure that I made some rookie mistake. Thanks for the explanation, it makes sense.

I am not sure, but I think this is it. It has a different label that says Parallax and has STD checked.

http://www.parallax.com/Store/Accessori … fault.aspx

Thanks guys :slight_smile:

Try flipping it around (swap source and drain).

PS: I may have also made a dumb mistake here, I’m not above them :stuck_out_tongue:

I got have a nice constant 5v on Drain with

Gate to signal (5v)

Drain 4.6k to ground

Source to 5v

Edit: Drain remains at 5v even when Gate is at 0v

Not even if you pull the gate to ground?

If you let the gate float it’s not the same as being tied to 0V

Oops, I was reading the picture that came with the packaging wrong, I mixed up Source and Gate. I had the it in my breadboard backwards XD

My servo is not happily moving around. :slight_smile:

Edit: the servo is now happily moving around yay typos!

AlexanderD:
Oops, I was reading the picture that came with the packaging wrong, I mixed up Source and Gate. I had the it in my breadboard backwards XD

My servo is not happily moving around. :slight_smile:

not happily moving around? :frowning:

Oops, it is now happily moving around, that’s what I get for not sleeping enough.

So, unless there is anything else that you feel like teaching me, or have any further suggestions…

Thank you guys, I like SparkFun even more now, I is a happy geek :slight_smile: