I NEED HELP 5V TO 10V PWM

VegasWinner

Well-Known Member
Be very careful creating a common ground between the arduino and the meanwell driver. Seperate grounds is recommended.
Two things can happen. First the signal can go backwards, high is low, or the signal needs to be inverted because sunrise/sunset run backwards.
Both can be resolved with just inverting the pwm signal. That is fine if you are using your arduino for dimming only because the pwm signal will go low, relay off while light is high meaning on. Conflict
If you are hoping to both dim and control on/off functionality both signals need to be in sync.
 

Yesdog

Well-Known Member
Be very careful creating a common ground between the arduino and the meanwell driver. Seperate grounds is recommended.
Two things can happen. First the signal can go backwards, high is low, or the signal needs to be inverted because sunrise/sunset run backwards.
Both can be resolved with just inverting the pwm signal. That is fine if you are using your arduino for dimming only because the pwm signal will go low, relay off while light is high meaning on. Conflict
If you are hoping to both dim and control on/off functionality both signals need to be in sync.
So the common ground was actually what i was concerned/worried about initially. Also read a few places on the Pi forums that yes- you may get feed back in various situations via ground trying to regulate an external circuit. This is where my electronics knowledge takes a sharp dive- can you run the base of a transistor from a voltage source with an uncommon ground? I seem to remember seeing circuits where you could wire a full circuit from collector to emitter, then run an isolated voltage source on the base (like a 9v battery). I can't for the life of me remember if this needed a common ground. But it seemed to me it would, otherwise you can't build a charge gradient across the base?

Also, in your hand-drawn dual-transistor design you posted above... isn't the DIM- connected to the arduino ground? Does the parallel resistor (across the dimmer leads) in that design help protect against feedback?
 

wietefras

Well-Known Member
@Yesdog, Common ground works fine. It's not 110V, but 10V.

Still, like I said, I also like the decoupling of the optocoupler. It's pretty much the same circuit as the one with the transistor, but then without the common ground.

The PWM and GND of the Arduino are connected to the input of the optocoupler and the DIM+ and DIM- on the output. Plus adequate resistors.

Also make sure you bolt your driver down because apparently they can start running backwards if you don't add a 10V source ;)
 

Isawthelight

Well-Known Member
So when you say backwards, do you mean it just inverts the PWM duty cycle? Or like.... does the driver actually flip polarity on its outputs? Inversion I can deal with- but flipping polarity just... sounds like something the driver should protect itself against? AKA impossible?




Ok, cool... so it sounds like im on the right track then, so If i go the single transistor route, this should really be about it right? The shared ground should drain any additional current from the base, but still leave an unimpeded path from the DIM+ to the DIM- when the base is hot?

EDIT: (the 'common' ground here would be the arduino/pi ground) and yes, it will invert the duty cycle

Shouldn't the Dim 10volts be modeled as a 0.1 milliAmp constant current source with 10v at 100k and 1v at 10k? The Vce (sat) (voltage between collector and emitter) of a saturated bipolar transistor is going to be greater than 0.2 volts, so you are not really shorting Dim+ to ground.
 

ya bongo

Well-Known Member
Shouldn't the Dim 10volts be modeled as a 0.1 milliAmp constant current source with 10v at 100k and 1v at 10k? The Vce (sat) (voltage between collector and emitter) of a saturated bipolar transistor is going to be greater than 0.2 volts, so you are not really shorting Dim+ to ground.
yes, here shown with 75K resistor
mw din model.JPG
and this is the phase correct Dimmer with a 10V source
dim.JPG
and without
dim without.JPG
 

Yesdog

Well-Known Member
Ok, so I think I'm just going to go the optocoupler route lol. I just wanted to avoid getting another box of 20 of a component ill probably just use once =\ Sorry, box of transistors I just bought :(

So, I think im going to get some of these: http://mkpochtoi.narod.ru/pc817_ds.pdf PC817

I really have no idea what a Current Transfer Ratio does for me- but if I get the pi/arduino side of things to about 1mA, shouldn't matter right (nor should voltage on that side, just cant put more than 20mA)? And then... on the 'output' side, there's no gain or anything possible right? Just somewhere between 0-100% resistance
 
Last edited:

Yesdog

Well-Known Member
Shouldn't the Dim 10volts be modeled as a 0.1 milliAmp constant current source with 10v at 100k and 1v at 10k? The Vce (sat) (voltage between collector and emitter) of a saturated bipolar transistor is going to be greater than 0.2 volts, so you are not really shorting Dim+ to ground.
Such an idiot, this makes so much more sense now. I keep forgetting a power source has to be either a voltage or current source. So DIM+ isn't a 10V source, its a 0.1mA source. Holy fucking shit, this kinda makes sense now. So any 0.1mA source with a 10k resistor is 1V. My god.

yes, here shown with 75K resistor
View attachment 3827592
and this is the phase correct Dimmer with a 10V source
View attachment 3827600
and without
View attachment 3827612
Ok, so I think I feel better using a transistor now that I know what the hell the dimmer actually is. Sharing a ground should be fine then?
 

Yesdog

Well-Known Member
Alright, I think I settled on this. Goes from 4.5mV to 10V exactly on the 0.1mA constant current source of DIM+, with DIM- on a shared ground. Also doesn't invert, and can use two of the same low-amp NPNs. Should work with 5V or 3.3V on either combination of the power supply in at the top, and the PWM logic itself.

The 100k resistor is important for getting a steady 10V, the other resistors don't seem to matter at all- just there to keep current within range.

(the 100uA current source is the DIM +/- circuit)



Circuit simulator: http://tinyurl.com/z3dzkjw


other simulator that seemed to be a bit better:

 
Last edited:

Yesdog

Well-Known Member
Alright... one last final modification. I added a... voltage divider? at the top between the collector and base of the 2 transistors- this should give the left path a much lower resistance and not trickle any meaningful charge to the base of the right path. Also added a 100 ohm resistor to the 'open' path, which i might remove- just wanted something to stabilize the low voltage. I've yet to find a simulator that will accurately simulate these damn N3904s... but I think it should work ok.

Anybody know what kind of amperage I should aim for at the base of the NPNs? The base of each NPN is between 2-3mA when active, no more than 700mV.

EDIT: also, another reason i like this circuit: the 100k ohm resistor sets the 'max' amplitude of the PWM. So I could replace this with a 50k ohm resistor at at 100% duty cycle, the driver should be getting a 100% PWM of 5V instead of 10V, so at full blast from the PWM source i can still physically limit the driver intensity- which is good cause ill probably be under-utilizing my driver by about 20%.

 

VegasWinner

Well-Known Member
I believe 500ma is a good target for your circuit. You can got to easyead.com and make the circuit board or you can use pcb blank. Nice job.
 

Yesdog

Well-Known Member
Here's what I got on the bread board:

<Removed, because of fucking... EBC vs CBE>

Not getting the expected ohm readings from my meter though- once the gates start flipping i never get back to 80K ohms. Guessing maybe the ohm meter doesnt provide enough current to saturate the collector? Either way, I can guarantee it won't go *over* 80K ohms, or whatever I limit to. So gonna try to hook it up with 1 LED and see what happens. Worried about 1 36v LED and a 185V driver though lol.

EDIT: I've got the 10k resistor on the upper angled blue part, can just move that to the lower blue spot across the DIM+/- to switch to 10% max. Here's hoping i don't fry myself....
 
Last edited:
Top