1
\$\begingroup\$

I am not an electrical engineer. I am a mechanical engineer and trying to improve myself in electronics. So, if there is a silly question please forgive me :)

I am developing a 24V BLDC motor controller, which adjusts the motor speed via PWM that comes from another circuit. However, this PWM is 16-32V. I have to lower this voltage to 5V to read via my STM8A MCU. The PWM frequency is 100Hz.

My main goal is;

  • Convert this PWM to 5V
  • Invert the PWM to read LOW side as HIGH (I know we can solve it by software, but I would like to do it using hardware)
  • MCU pulls (Edit: pulls to GND) the PWM line to send feedback (e.g. 1sec Gnd means overvoltage)

I saw a circuit online and made my own. (You can see it below.) But, I couldn't understand it completely.

  • Why there is a 24V DC and R2 in this circuit?
  • How can I know the PWM current?
  • Do you think there is a problem with the circuit?

schematic

simulate this circuit – Schematic created using CircuitLab

##Edit Insufficient information created misunderstanding. So, I'll try to give more detail.

My BLDC controller is for trucks. There are only 3 inputs for this controller. 24V (Truck battery voltage), GND and PWM. The controller consist of a MCU, gate driver, and h-bridge. There is a 5V regulator for MCU. PWM voltage is the same voltage as VBAT. It is typically 24V but I wrote the range of it. So, we can consider it as 24V.

My circuit should send some feedbacks to the ECU. Because there is only 1 pin for communication, I send the feedbacks by pulling the PWM line to GND. As you understand from the circuit, PWM should be 5V also my feedback is 5V. There are 6 error feedbacks and I can read all of them. They all have a specific time to be GND. For example, if the motor is stuck I pull the PWM to GND for 4sec, if there is overcurrent I pull PWM to GND for 1sec. So, my question is not about overvoltage protection or reading circuit, just sending feedback.

I have no information about the source impedance or PWM generator.

Also, the maximum working temperature for this circuit is 140°C. So, it is hard to find an optocoupler for these temperatures.

\$\endgroup\$
7
  • \$\begingroup\$ "via PWM that comes from another circuit." , which circuit (what kind) ? Why this signal voltage fluctuates so much 16-32V? "Why there is a 24V DC and R2 at this circuit?" it's a voltage from "another circuit" and a pull up resistor - it may be totally different in your case. Does this "another circuit" accepts the status feedback? \$\endgroup\$ Commented Dec 8, 2020 at 21:42
  • \$\begingroup\$ You won't be able to "send feedback" unless the thing driving the PWM has substantial source impedance in the positive direction, eg using it's own 24 volt supply and equivalent to R2 and Q1 to drive the PWM signal. Then you don't need R2 and the 24 volt supply on your end. \$\endgroup\$ Commented Dec 8, 2020 at 22:19
  • \$\begingroup\$ I tried to keep the post simple but I think less information creates misunderstanding. Sorry about that. This is an automotive circuit (I hope it will be) so "another circuit" is the car ECU. 24V is the battery voltage (input circuit for the PCB). There is only 3 input of the PCB (VCC, GND, and PWM) Normally, input and PWM voltages are 24V but it can fluctuate between 16-32V sometimes. Marko, I'll try your circuit. Chris, in this situation, should I know the source impedance of the ECU? \$\endgroup\$
    – Hilti_
    Commented Dec 8, 2020 at 22:26
  • \$\begingroup\$ You are correct. Insufficient info. Define block diagram with signals of all inputs,outputs functions and all signal characteristics and known ECU types, & sensors.. eg. define overvoltage while uC logic inputs are high impedance. Motor control usually are best monitored with current sensing and Hall rotor sensing \$\endgroup\$
    – D.A.S.
    Commented Dec 8, 2020 at 22:32
  • 1
    \$\begingroup\$ @Hilti_ You've described three external "pins" for your circuit -- Vcc (which I assume is a 5 V power supply rail), ground (the reference point and current return), and PWM (which I gather goes from something near ground -- but with no serious description) to anywhere from 16 V to 32 V, nominally 24 V. Are their any other "pins" so to speak? (I see "feedback" which I won't say I entirely understand, but should for example.) Anything else? Please discuss more about what to expect from the PWM when it is not near 16 V - 32 V but is at the opposite condition -- what's the range there? Etc. More! \$\endgroup\$
    – jonk
    Commented Dec 9, 2020 at 0:03

2 Answers 2

1
\$\begingroup\$

Your PWM generator is the key for understanding.

Its output needs to go to 0V and to the PWM high level (maybe some 24V?) in an alternating fashion. That's its functionality.

Your microprocessor is a logic device with an input and an output - with both using logic levels of 0V and 5V. Attaching the input is simple if you want it non-inverted, then just a resistive 5 to 1 divider can do the job. If you want it inverted, then a transistor will do the job. Mine prefers the NPN, if possible, as it is ground attached and circuits often share grounds much easier than the supply voltage. For the output a transistor is also nice, but applied the other way around.

What you (and me up to now in this response) have ignored, is the fact that the PWM might drive its output with dual transistor logic, or it might use single transistor logic with either a pull up or a pull down logic in an internal or external form. The most common form is probably the so-called "open collector" concept. This is used on various bus systems where multiple participants are allowed to pull down the voltage on the bus to zero. It works like OR logic: if none pulls it down, then the bus wire is high. If one or more or even all will pull the level down, then its low.

So it's up to you to find out how the output of your PWM is designed, in order to know if you can have a "feedback" or "error terminate" second operator on that wire. The precondition for this "open collector" design is a single external or internal pull-up resistor to high level - and the PWM only having a pull-down transistor - and the processor participant on the bus also only adds a pull-down transistor for its feedback output.

And now to your other question:

  • How to determine a current? (in your case: of the PWM)

Let the current flow through a measurement resistor and then determine the voltage across it. Ohm's law for resistors has a linear relationship between current and voltage.

For example, if you want to read 100mA of current and it goes via a 100 ohm resistor, then a voltage of 1V will appear across its terminals. As you are doing something with a microprocessor, you might have an analog-to-digital-conversion (ADC) feature built in. For ease of use, measuring current via a resistor and a processor works best if the resistor is in the return path towards ground of your application current. Typically currents might be high and thus resistors are of a low ohm value. So please be aware that in the real world, this also means there will be noticeable power dissipation of maybe more than 1 Watt - matching "shunt" resistors are out there. Other methods are measuring coil transformers (for that the transformer and coils are in shortcut alike operation mode, doing current transformation rather than voltage transformation).

Other options for measurement of small to big signals are differential operation amplifiers. They have many advantages, e.g. up and downscaling at large selectable factors, filtering, ground problem elimination and many more.

Let's hope that's something you could pick up and apply to your particular scenario.

Regarding resistors in your diagram:

  • R1 is controlling the base current for the transistor nearby. (It also has a coupling effect to make it more stable in amplification - but that's a typical audio amplification case, but we have logic, so I doubt it's the case here. It might move to the base input of the transistor - unless it's meant to be sort of a voltage protection, to decouple the 5V and 24V even a bit more).
  • R2 is the pull-up resistor for your bus wire (and your PWM should never have such a pull-up component as well, neither a resistor nor a transistor).
  • R3 is the "load" resistor for the logic - as logic does not need much current, it's a high value.
  • R4 is limiting the base input current of your feedback transistor and signal - with 5V it is probably less than 0.5 mA due to the base-emitter path having some voltage drop as well.
\$\endgroup\$
1
  • \$\begingroup\$ 24V hints for a truck or similar industrial vehicle. a bus using the pull up and feed back method is e.g. I2C - but its definitely not limited to solely that one. \$\endgroup\$ Commented Dec 8, 2020 at 23:40
0
\$\begingroup\$

Almost the same, but improved since it has a galvanic isolation and inverted output. However your exaple implies that "another circuit" is sink output (open collector).

  • When the Q3 isn't conducting the LED of 1st opto glows and you get a low signal state on MCU input.
  • When Q3 conducts, the 1st opto LED doesn't glow, so you get a high signal state on MCU input
  • If the signal FDBCK from MCU is high, the 2nd opto LED glows and whatever state of Q3 is, the Vce voltage is low, so this feedback can be detected if Q3 is not conducting.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
3
  • \$\begingroup\$ Marko, the maximum working temperature for this circuit is 140°C. So, it is hard to find an optocoupler for these temperatures. \$\endgroup\$
    – Hilti_
    Commented Dec 9, 2020 at 17:36
  • \$\begingroup\$ @Hilti_ You will hardly find any component that works at that temperature, including transistors and resistors. But, I don't believe that you need such temp. range, what for? It has to work inside a steam boiler, or what? \$\endgroup\$ Commented Dec 9, 2020 at 20:32
  • \$\begingroup\$ Marko, this will be an automotive Grade 0 PCB. I will be placed under the hood of a truck. So, this temperature range is necessary. \$\endgroup\$
    – Hilti_
    Commented Dec 15, 2020 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.