Having a problem with pwm

01 Sep 2012

Trying to boot my pc up with a pwm signal

NPN Transistor
Collector = V+ Motherboard Pin
Base = 1k resistor - PWM(p26)
Emitter = Gnd Motherboard Pin

Here is the code

#include "mbed.h"
PwmOut PCBOOT(p26);
int main()
{
  PCBOOT = 255;
  wait(1);
  PCBOOT = 0;
}

Any idea why this wont work? It worked once or twice but not anymore, i can still boot the pc up if i tap the pins together and shut the pc down if i hold them together for 5 seconds.. Anyone out there with any knowledge as to why this does not wanna boot the pc?

01 Sep 2012

I wouldn't expect that you'd need a PWM signal for that, but rather just a singly pulsed signal.

#include "mbed.h"
DigitalOut PCBOOT(p26);
int main()
{
  PCBOOT = 1;
  wait(1);
  PCBOOT = 0;
}
01 Sep 2012

Just tried it, does not work? Any ideas? this is what's boggling me!

02 Sep 2012

what would be the most visual way of testing the digital signal from a pwn(p26) pin?

02 Sep 2012

It sounds like you need to verify that the pin is actually turning on the transistor, and so on down the line...

Tools to use in preferencial order, best to worst;

  • Oscilloscope
  • Volt meter
  • LED with current limiting resistor

Good luck!

02 Sep 2012

Digital = 1 is HIGH which is 255 Analog = 255 is also high

Is this correct?

02 Sep 2012

. . wrote:

Digital = 1 is HIGH which is 255 Analog = 255 is also high

Is this correct?

Digital = 1 = HIGH ... yes.

Analog - not sure, I haven't played with the analog portion of the chip.

Don't use Analog, or PWM functions for turning on a transistor to turn on a power supply, stick with DigitalOut.

02 Sep 2012

Do you have the ground of your motherboard connected with the ground of your mbed?

02 Sep 2012

I think that could be it! lets find out!

02 Sep 2012

I connected moherboard - to mbed - but now the p26 stays high and just turns on/off the pc if i plug the pin in to (p26) regardless of the digital 0 or 1???

02 Sep 2012

Could it be the resistor between the pin (p26) and the base of the NPN transistor? which resistor should i use from the sparkfun resistor kit?

02 Sep 2012

1kOhm should be fine, that shouldnt result in problems. When you say p26 stays high, did you measure that, or do you think so because he continues rebooting? Try connecting otherwise manually the resistor instead of to p26, to either 3.3V or GND, to see if that works.

Edit: And sure you got right program and pin? By default pins are high (pull up enabled).

02 Sep 2012

boot = 0; wait(5); boot = 255; wait(0.040); boot = 0;

Shuts the computer down 5 seconds after 255 is submitted

Pinning 3.3v to the resister which is the base of the npn resistor boots the computer up immediately

02 Sep 2012

what is the collector connected. to???

if it is 5Volt rail then you are shorting out USB!!

the current spike is potentially enough to lock up PC

Ceri

02 Sep 2012

The collector is connected to the motherboards V+ pin of the boot button The emitter is connected to the motherboards ground pin of the boot button

02 Sep 2012

Here is an image of the messy setup lol /media/uploads/Elitism/npntrans.jpg Hopefully someone can help :(

02 Sep 2012

I would really use digitalout instead of PWM. Also because I dont think 255 is always high for PWM. Well the result may be it, but normally it is a float between 0.0 and 1.0.

Regarding your mbed setup, when I use an mbed on an experiment print I put it on those headerpins you have now besides it, then you can remove it again if you want to.

You say 5 seconds after '255' is submitted, it shuts down again. Did you test what happens when you connect NPN to ground, and are you sure it is 5 seconds after '255' is set as PWM out? So then it should do the first 5 seconds do nothing, then boot, then 5 seconds nothing, then shut down. It would make alot more sense already if it immediatly boots, then 5 seconds nothing, then shut down. The issue could then possibly be that during time mbed needs to start the pins are high (due to pull ups).

02 Sep 2012

when i restart the mbed, it waits 5 seconds, then it boots it up Either with DigitalOut = 1 or AnalogOut = 255; But because the Digital/Pwm pin is obviously sending too much voltage even when the pin is analog 0 or digital low it's keeping the transistor high allowing the motherboard v+ to contact the motherboard ground within the transistor

I'm wondering why a 1kohm resistor is not working properly, or should i change it with something else instead of a resistor?

02 Sep 2012

Here is the code i'm using right now which describes my last post

boot = 0;
wait(5);
boot = 255;
wait(0.040);
boot = 0;
02 Sep 2012

Ok i think i found the problem Aparently the connection is already made and the pc button breaks the connection which triggers boot, not makes the connection! :)

02 Sep 2012

Not Quite The Power and Reset on a standard ATX board are held high and are pulled low by the respective buttons. The buttons don't break anything they short the reset or power pin to ground, so the buttons do make the connection , but to low(gnd) not high.

The easiest way to achieve this (and the safest to your mbed and motherboard) is to use an opto http://en.wikipedia.org/wiki/Opto-isolator Consider the diagram in the top right of the wikki page pin 1 would go to your Mbed output pin 2 would go to your mbed ground through a 130ohm resistor (to limit the current on the mbed pin) pin 3 would goto your mobo power button+ pin 4 would go to your mobo power button-

in essence your simply swapping the switch for opto you can do exactly the same fro the reset button

you DO NOT need to use analog out/pwm or anything else, just a digital IO. the way you keep saying your analoug out = 255 i geuss you have used an 8bit device , mbed is 32bit and analogue out is a normalized 0 to 1 so 1.0=3.3v 0.5=1.25v 0.0=0.0v. You DON'T NEED IT in fact the opposite you want to make sure your switch is either open or closed not half closed

02 Sep 2012

Well it works perfect the way i set it up and i am using digitalout not pwm

the pin is using a 1kohm resistor on the base of the transistor to the digital pin

Collector = v+ Emitter = gnd

The connection is made, and the botton breaks the connection

because i have to use boot = 0; to make the pc boot and it does not shut it down after 5 seconds like before, it works, so its all good :)

02 Sep 2012

well an NPN will work one way a PNP will work the other ,definatley pull to ground either way but glad you got it working opto is still the better way to do it. As then your electrically isolated from the PC pins. No danger of ground loop issues and the likes.