Id
stringlengths
1
6
Tags
stringlengths
3
101
Answer
stringlengths
38
37.2k
Body
stringlengths
26
26.8k
Title
stringlengths
15
150
CreationDate
stringlengths
23
23
704826
|circuit-design|
<p>At 3 A, the diode solution is pretty good: a <a href="https://www.digikey.de/en/products/detail/nexperia-usa-inc/PMEG3050EP-115/2228695" rel="nofollow noreferrer">sufficiently dimensioned Schottky diode for barely 50ct</a> will have maybe 290 mV of drop across the diode. That means of the nominally 20 V, you still deliver 19.71 V to your load, meaning you're achieving an efficiency of 98.5 %. It might simply not be worth it optimizing any further: even with a completely lossless solution, you'd only be 1.5 % better! And you're using USB PD, which suggests your source of power isn't nearly as efficient to begin with.</p> <p>However, if you really need that 1.5 %, and cost nor complexity matter too much, you would buy what is typically sold as <em>ideal diode</em>: A MOSFET with the necessary control and gate voltage generation circuitry.</p> <p>Linear Technologies (now Analog Devices) used to have a lot of them. Take a look at LTC4376, which integrates the MOSFET, or LTC4412, which uses an external P-Channel MOSFET. There's also members of that family that work with N-Channel MOSFETs, but they are typically a bit more expensive because they need to integrate a charge pump power supply to generate the gate voltage which needs to be much higher than the highest voltage existing in the system.</p> <p>Here's the block diagram from the LTC4412 <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/ltc4412.pdf" rel="nofollow noreferrer">datasheet</a>. In your case, you'd omit the diode on the &quot;Auxiliary supply&quot; and just directly connect your screw terminal:</p> <p><a href="https://i.stack.imgur.com/MXO1p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MXO1p.png" alt="Block diagram of the LTC4412 showing gate drive, sense amplifier, control logic, histeresis and auxiliary functionality" /></a></p> <p>You can, in principle, very much build the same device from scratch; however, it's going to take quite a bit of space, and components, and also hand-tuning: The unique selling point of Analog Devices here is that you can buy an IC that has been optimized to switch reliably, at well-defined voltages, with no chance for oscillations, and no need to integrate around 20 discrete components on a board.</p> <p>But the whole magic in this compared to your non-functional approaches from before is:</p> <ul> <li>use a PMOS switch for high-side switching, as NMOS would need an extra, even higher voltage source</li> <li>have an actual sense for whether the left side is higher than the right</li> <li>amplify that sensing, to a degree where it produces a sharp edge when the USB PD voltage becomes sufficiently high</li> <li>implement a gate driver that pulls the PMOS gate voltage far below the source voltage</li> <li>add hysteresis, so that you don't build an oscillator when you start drawing current from USB, in the consequence, the USB voltage slightly sags, in consequence the PMOS gets deactivated, which leads to the voltage rising again…</li> </ul>
<p>I am designing a circuit that has two possible ways to receive 20V DC power, either from USB power delivery, or from a screw terminal.</p> <p>When the board is powered via USB power delivery (<code>USB_PD_20V</code>) at up to 3 A, I would like the screw terminal to act as an output for the 20V.</p> <p>However, when the power input is from the screw terminal, I would like to prevent any reverse current/polarity on <code>USB_PD_20V</code> (Note: <code>USB_PD_20V</code> will be at 0V when inactive).</p> <p>The straightforward solution suggested seems to be a Schottky diode, but I would prefer to lower power consumption if possible. Is there a circuit that could help with this problem? <a href="https://i.stack.imgur.com/W1beu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W1beu.png" alt="Schematic" /></a></p>
One-direction reverse polarity protection for two possible power sources
2024-03-04T15:47:12.513
704827
|pcb-design|antenna|esp32|impedance-matching|
<p>The pi impedance matching circuit can only be populated if the antenna is known, as it's not, it can be left to be implemented on the antenna. Leaving the passives will get rid of the impedance discontinuity issue.</p> <p>The impedance of the second design would probably need the surrounding ground plant to be furher away too, spending more area from the PCB.</p> <p>By the way,</p> <ol> <li><p>I would stay away from placing vias on pads, unless absolutely necessary. Pin 14 it might introduce a problem with the solder flow. Others unnecessary thermal imbalance.</p> </li> <li><p>I would &quot;fan out&quot; tracks from for example pins 2 and 3 of the IC, so that the pads stay the correct size. Otherwise solder mask will expose copper around the pad.</p> </li> </ol>
<p>I need to design an antenna trace (WiFi and Bluetooth) that connects an ESP32-S3 chip to an IPEX connector with an impedance matching circuit.</p> <p>I have some constraints that I need to work around:</p> <ul> <li>board space is very limited</li> <li>minimum part size is 0603 as it should be hand solderable</li> </ul> <p>I plan to have the boards manufactured by JLCPCB with 6 layers and 1mm PCB thickness. The stackup is (from top to bottom): SIG, GND, VDD, SIG, GND, SIG. Vias in pads are allowed in my design.</p> <p>A 50 Ohm microstrip on the top layer with the second layer as reference has a width of 0.155mm according to the JLCPCB impedance calculator.</p> <p>If I place the CLC matching circuit in the classic &quot;pi&quot; shape, I get this layout:</p> <p><a href="https://i.stack.imgur.com/YlXTc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YlXTc.png" alt="normal layout" /></a></p> <p>As you can see, there's a lot of unused space, and the trace width varies widely, which will result in bad performance, I assume.</p> <p>So I came up with this idea: Create a cutout on layers 2 and 3 (GND and VDD) and create a GND plane under layer 4 (SIG) under the antenna trace, which is connected to the main GND planes through the fencing vias. The 50 Ohm trace width for this layout would be 1.08mm, which is much more suitable for the pads of the parts of the CLC network. I also placed the parts closer together, so it looks like this: <a href="https://i.stack.imgur.com/xdyOj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xdyOj.png" alt="alternative layout" /></a></p> <p>Would the second layout also work, or should I stick to the first layout?</p> <p>Or should I ditch the matching network entirely? The ESP32-S3 design guidelines state:</p> <blockquote> <p>For the antenna and the antenna matching circuit, to ensure radiation performance, the antenna’s characteristic impedance must be around 50 Ω. Adding a CLC matching circuit near the antenna is recommended to adjust the antenna. However, if the available space is limited and the antenna impedance point can be guaranteed to be 50 Ω by simulation, then there is no need to add a matching circuit near the antenna.</p> </blockquote> <p>I do not have the means to measure and adjust the matching network anyways, so I would stick to the recommended values. Also, the choice of antenna that is connected to the IPEX connector is ultimately not in my hands. So should I just route a 50 Ohm trace from the antenna pin to the connector?</p> <p>This is for an open source project, I do not intend to sell this design.</p>
Which antenna trace design is better?
2024-03-04T16:10:21.103
704831
|pcb|stm32|analog|noise|emi-filtering|
<p>The input to the ADC is very high impedance and so it's relatively easy to inject noise into it. Look at the return path for the ADC trace, it's completely carved up by other traces, etc. There is literally no direct path. The green path is perhaps best, there may be a route via the purple path, not sure.</p> <p><a href="https://i.stack.imgur.com/AUUi9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AUUi9.png" alt="return paths" /></a></p> <p>The way to fix is to provide a good return path. Scratch away L1 solder resist near Q2 and solder on some fine wire to GND. Run the wire dead on top of the ADC trace as far as the stm32. Then at the chip run the wire as tight as you can to the package and land it either on pin 8 (vssa) or the gnd pin of the cap connected to pin 8.</p> <p><a href="https://i.stack.imgur.com/afZyU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/afZyU.png" alt="Wire extra return path" /></a></p> <p>This may or may not be enough. Your signal is going to carry any noise that the 3v3 rail has via R24/R26. Suggest you also add ceramic 100nF cap locally on the board from the top of R24 to the top of R26. This might help shunt any high frequency noise across the transistor and keep it out of your signal.</p> <p>None of this will fix the real problem that many traces don't have sensible return paths and so are both aggressors producing noise whenever they switch and victims recieving noise from any signal trying to traverse the gnd plane.</p> <p>You really need to add 2 more layers and use them for solid GND.</p> <p>You may be able to improve matters by using some strategically added gnd straps soldered across sections of the GND plane copper. The more you scratch away resist and solder on bits of copper braid that bridges from one GND land to another, the better the return paths, the less your design will be susceptible to noise. Looking at L2 if you can solder across the traces that radiate under the MCU and the long trace headed towards the motor driver you may very well go a long way towards reducing the problem.</p> <p>Others have pointed out that the big circular traces that run around the board edge are possibly coupling to the fields produced by your motor ... You may be producing severe voltage fluctuations on 3v3 and this may be disturbing the MCU and its analog performance will be terrible if this is happening. A shielded power cable is only any use if the shield isn't conducting your power. You don't describe the nature of your shielded cable so hard to be sure about that.</p> <p>If you can disconnect all cables that aren't critical to testing (buttons, LEDs, etc) that might help. Any one of these could be injecting noise.</p>
<p>A PCB design amateur here. Stumbled upon a hard problem right at my first PCB design. I have tried to comply with the layout rules of thumb for SI and EMC, but still encountered with strong EMI problems with the produced card. Need suggestions to remedy the interference problem. I also appreciate your suggestions for general design improvements.</p> <p>The main function of the PCB is to cyclically read the Q4 phototransistor analog output, which is irregular according to the transparency of the material, and activate relay coil over connector when it is above a certain threshold level. The side functions are RS485, NFC communications. The circuit functions normal when there is no noise source, but when a 0.25 kW industrial AC drive mounted on the chassis is activated by firing up the IGBT PWM, holding the motor even at 0 speed, the 8-bit analog signal fluctuates to extremes (0 to 255), where 0 corresponds to 0V, 255 to 3.3V and the minimum analog total sampling period is 16us at 8-bits. The noise coupled to the PCB is at multiples of 3kHz. In 1 second the SWD debug interface locks. In the STM32CubeMonitor diagram the blue curve is real time analog value with no filtering. The green, yellow and red curves should be constant. But when they start to fluctuate, SWD locks. The microcontroller is STM32F030C8T6. I use STM32CubeIDE for debugging. Power supply is Meanwell RS-25-5 SMPS. The Earth Ground of the testing place is very weak, but still I want to have a design that is robust. My Rigol DS1104 oscilloscope probes picks up noise from air, so I could not use them properly in this case.</p> <p>I have tried lots of things but couldn't get around this problem. Some of things I tried are:</p> <ul> <li>Thought that top and bottom layer ground pour via stitching is weak, so I soldered short jumper wires directly from the power connector GND (0 V) to seemingly weak GND nodes.</li> <li>I have used shielded power supply cables to the PCB.</li> <li>Thought that maybe +3.3 V supply trace forms loop around PCB. So I cut it through after phototransistor with no improvement.</li> <li>Used capacitor multiplier for power supply with no luck.</li> <li>After adding Opamp voltage follower to the phototransistor output, only small improvement was seen on the analog voltage quality.</li> <li>Adding bulk capacitors (multiple 1000 uF) on the 5 V supply rails.</li> <li>Disabled RS-485 and NFC.</li> <li>Grounded the outermost loop (Earth GND) with SMPS 0V</li> </ul> <p>Below are the schematic, layout and measurement diagram. Thank you.</p> <p>Schematic:</p> <p><a href="https://i.stack.imgur.com/OEaEN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OEaEN.png" alt="Schematic" /></a></p> <p>Top Layer:</p> <p><a href="https://i.stack.imgur.com/E9mYN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E9mYN.png" alt="Top Layer" /></a></p> <p>Bottom Layer:</p> <p><a href="https://i.stack.imgur.com/Rm7zS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Rm7zS.png" alt="Bottom Layer" /></a></p> <p>Top and Bottom Layers Together:</p> <p><a href="https://i.stack.imgur.com/FE4br.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FE4br.png" alt="Top and Bottom Layers" /></a></p> <p>Measurement Diagram:</p> <p><a href="https://i.stack.imgur.com/TKRVk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TKRVk.png" alt="Measurement Diagram" /></a></p>
My First PCB - EMI Problem on Poorly Earth Grounded Test Place
2024-03-04T16:23:00.557
704832
|dc|ground|robotics|shock|
<p>What you feel is static electricity that builds up on the robot body, which is insulated from earth by the wheels and tyres.</p> <p>It's not caused by the 24 V system so there's nothing to be gained by trying to connect a battery terminal to ground.</p> <p>Some companies make conductive rubber wheels and tyres that would conduct the charge to earth before it builds up. During manufacturing, a conductive material like carbon powder is put into the wheel or tyre compound.</p> <p>Otherwise, you could put a trailing wire or metal strip from the robot body to dangle on the ground. Some cars used to do this with a conductive strip so people didn't get a static shock when they got in or got out.</p>
<p>I've built a rubber tracked mobile robot and it has a metal chassis. I use a 24 VDC 30 Ah battery to power a system which includes two DC motors, motor controllers, an industrial PC and some sensors.</p> <p>Sometimes, not very often, it can happen that I get an electric shock when I touch the robot's frame. It is not dangerous, since it is just a 24 VDC system, but I would like to understand why this happens.</p> <p>Is it static electricity? There is no wire in contact with the metal chassis.</p> <p>To solve this problem, I connected the chassis to a floating wire that touches on the ground while the robot moves.</p> <p>However, I would like to understand how to solve the problem. Should I have to connect the battery GND to metal chassis?</p>
24 VDC system and metal ground
2024-03-04T16:39:04.387
704847
|mosfet|switches|switching-regulator|buck-boost|
<p>You've mixed up M2 and M4, but I get the gist. The input switches are subjected to up to the maximum input voltage (~56V). The output switches only have to block ~12V.</p> <p>It's not optimal to use a much higher voltage rated MOSFET than required- you can get a lower Rds(on) by sourcing a lower voltage MOSFET with a similar die size. As you can see, the Rds(on) is much smaller (1/3) for the lower voltage device.</p> <p>Using the higher voltage devices for both would lead to higher conduction losses. Using the lower voltage devices for both would exceed the device ratings for input voltages at the high end of the range.</p> <p>If you had a 4-switch buck-boost converter that was intended to operate with input voltage and output voltage approximately the same it would make more sense for all the MOSFETs to be the same. Anyway, you can decide whether the increased efficiency is worth another BOM item.</p>
<p>I have reviewed several buck-boost controller designs, including the <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/lt8390.pdf" rel="nofollow noreferrer">LT8390</a> nd I am puzzled by the selection of different switches for the buck and boost sections. For instance, on page 27, the circuit recommends the following switches:</p> <p><a href="https://i.stack.imgur.com/o4ZOM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o4ZOM.png" alt="Buck-boost switch" /></a></p> <p>Switch M1:<a href="https://www.mouser.com/datasheet/2/196/Infineon_BSZ100N06LS3_G_DataSheet_v02_04_EN-3361137.pdf" rel="nofollow noreferrer">BSZ100N06LS3</a></p> <p>Switch M4:<a href="https://www.digikey.be/htmldatasheets/production/1867250/0/0/1/bsz033ne2ls5.html" rel="nofollow noreferrer">BSZ033NE2LS5</a></p> <p><a href="https://i.stack.imgur.com/ze8jq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ze8jq.png" alt="BSZ100N06LS3" /></a></p> <p><a href="https://i.stack.imgur.com/ACH59.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ACH59.png" alt="BSZ033NE2LS5" /></a></p> <p>In my analysis, I am unable to comprehend why the MOSFET switch M1 couldn't be used in place of M4. I have observed this pattern in various designs, where these two switches are consistently different. I am seeking clarification on the reasons behind this discrepancy.</p>
Switch Selection in Buck-Boost Controller Designs
2024-03-04T18:05:04.947
704856
|signal|switching|toggle-switch|
<p>Cheapest approach is to use something like a <a href="https://www.ti.com/lit/ds/symlink/cd4051b.pdf" rel="nofollow noreferrer">CD4052</a> (okay for 5V supply) or 74HC4052 (better for 3.3V supply, good for 5V too). Power the analog mux with your Arduino supply.</p> <p>With the series resistors your inputs will never exceed 258mV so it's fine. Kind of a waste though. If you have an ADC that covers 0 to Vdd then you could simply connect the pot elements from 0 to Vdd and multiplex the wiper voltages. No resistors required.</p> <p>Then do whatever those 560kΩ resistors are supposed to be doing in your firmware.</p> <p>Analog switches have some series resistance (from 1kΩ to a few ohms or less depending on the part) and that resistance varies somewhat with the voltage so it's best to not load the output much. They don't have any offset voltage to speak of (microvolts), and very little leakage typically, so they're pretty good switches.</p>
<p>I have two different potentiometers. Each sets different voltage reference signal for a current source. How can I make an Arduino or any digital signal to switch between these two potentiometers? (No I don't want to waste power on a relay to switch a simple signal) A simple schematic is below:</p> <p><a href="https://i.stack.imgur.com/pLylS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pLylS.png" alt="schematic" /></a></p>
How to switch between two signals with a digital signal?
2024-03-04T19:13:19.880
704866
|cmos|flipflop|level-shifting|resistor-transistor-logic|
<p>Connect the switch to the gate of an N-channel MOSFET between the switch and the pullup. Pull the gate and source to -V and let the drain operate the flip-flop.</p> <p><img src="https://i.stack.imgur.com/fpeGS.png" alt="schematic" /></p> <p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2ffpeGS.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p>
<p>I have a circuit with a momentary switch connected between GND and a net with a pullup resistor (switch output is 0V while pressed). This switch signal is then buffered by a flip-flop before feeding additional CMOS circuitry. I had this circuit working nicely, but now need to change the supply voltages for the flip flop &amp; CMOS to use a bipolar supply (+6V/-6V) instead of the (12V/0V) used previously. Additionally, I still need the momentary switch to switch 0V, rather than -6V. Ideally, the phase should be unchanged. I am struggling to come up with a simple transistor-logic level-shifter to accomplish this goal.</p> <p>The image attached below shows my working circuit before updating the supply voltages. The other half of the flip-flop here is powered by a 12V/0V supply, but I want to change this to +6V/-6V. The switch pin to GND must remain unchanged, but any other modifications are acceptable to allow for level shifting to +6V/-6V logic signals to/from the flip-flop.</p> <p>Any suggestions would be greatly appreciated!</p> <p><a href="https://i.stack.imgur.com/ttbpI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ttbpI.png" alt="existing circuit before updating supply voltages" /></a></p>
How to translate 0V pulldown switch to negative voltage?
2024-03-04T19:55:49.823
704867
|555|sawtooth-waveform|
<p>You may want to try it with an actual 555, rather than a simulated one. You don't know how good the LTspice model is. It's not their (Linear or Analog's) product, and the model may be quite rudimentary. Its fidelity is not and won't ever be a marketable feature from their POV. You might have more luck with a general purpose circuit simulator that doesn't have its history tied to a chip maker. I'd expect the results to be better in MicroCap, but I have not actually tried, so feel free to correct me here.</p> <p>This is such a simple circuit you could breadboard it before ever touching the keyboard and mouse :)</p> <blockquote> <p>I see that the ramp discharges down to about 1.49V</p> </blockquote> <p>Be careful. <strong>The simulation of the ramp discharge</strong> behaves that way, yes. Do you want the simulation to work right, or the actual circuit? An actual 555 won't behave this way.</p> <p>This is thus an important first lesson in circuit simulation. There are tricky corner cases sometimes, and unless you understand how the simulator works, you can run into them inadvertently. Any time you expect things to switch when some voltage crosses a threshold, you have to be extra careful that the simulator has enough information in the model to capture this. Otherwise, the simulator's time resolution is dictated by slew rates of the signals and the time derivatives of the changes in various parameters of internal models.</p> <p>A higher fidelity transistor-based model of a bipolar 555 would easily capture this nonlinear behavior around the threshold point. I bet you the model in LTspice doesn't, so the simulator has no clue that a transition is about to happen. Some simulators have special comparator behavioral elements that capture transitions at the correct time, independently of the current time step used in simulation. But the model must use such an element, and use it properly. If it doesn't, you'll get this problem.</p> <p>A hint that the above is happening: forcibly decrease the time step to, say, 10ns. If the frequency changes when you force the time step to be smaller and smaller, you know it's a simulation problem related to state change rates. It's not necessarily a problem with the simulator core, mind you. All reasonable cores have a way of dealing with it. But the model of the 555 must be configured to make the core aware, otherwise it's not an oracle and can't predict that something interesting may be happening at a random point in time - not without possibly rather expensive backtracking. Time backtracking in a 555 simulation is cheap, but in complex circuits it slow things to a crawl. SPICE kernels work best when the time moves in one direction only.</p>
<p>So I found the variant of using an NE555 to generate a sawtooth signal by charging the capacitor using a constant current source. The simulation is shown below.</p> <p>The lower treshold is 1/3 * VDD and the higher treshold ist 2/3 * VDD according to the datasheet. R5 was chosen with 10k.</p> <p>The way I calculate C is as follows:</p> <p><span class="math-container">$$\begin{aligned} V_B &amp;= V_{DD} \cdot \frac {R_4} {R_3 + R_4} \\ I_E &amp;= \frac {V_{DD}-V_B-V_{BE}} {R_5} \\ C &amp;= \frac{I_E}{f} \frac {1} {V_{max}-V_{min}} \end{aligned}$$</span></p> <p><span class="math-container">\$V_B\$</span> is the base voltage, base current is neglected, <span class="math-container">\$V_{max} = 2/3 \cdot V_{DD} = 6{\rm\,V}\$</span>, <span class="math-container">\$V_{min} = 1/3 \cdot V_{DD} = 3{\rm\,V}\$</span>. I assumed base-emitter voltage with 0.65V</p> <p>Now, with a target frequency of 1kHz, the calculated C=128nF, I reach 868Hz instead of 1kHz, that is quite some deviation. The only thing that looks suspicious in the simulation is that the 6V threshold (upper treshold) is exactly 6V, but the lower treshold seems to be lower than the expected 3V. Now for this example it shows as 2.8V which is ok according to the datasheet.</p> <p>However, If I increase the frequeny to 10kHz, which is for sure not a very high frequency, things got more strange. The calculated C would be 12.8nF in this case. Doing another simulation with that capacitance shows a resulting frequency of 6.34kHz which is extremely far off the targeted 10kHz. Also I see that the ramp discharges down to about 1.49V, while the discharge process should stop at the lower 3V threshold.</p> <p>I suspected that the slew rate of the discharge ramp is too high so that the internal discharge circuitry is too slow to stop discharging right on time, therefore discharing too much. This again would then lead to a slower frequency.</p> <p>Since this circuit is found quite often, something must be wrong in my calculation or circuitry.</p> <p><a href="https://i.stack.imgur.com/5LJ5G.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5LJ5G.png" alt="enter image description here" /></a></p> <p>The waveform of the ramp for the 10kHz case and the current through R5 are shown below.</p> <p><a href="https://i.stack.imgur.com/lI0BP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lI0BP.png" alt="enter image description here" /></a></p>
LTSpice model of a NE555 as linear ramp generator has wrong frequency
2024-03-04T20:12:41.833
704871
|pcb-design|emc|ground-plane|
<p>In general the outputs have to share the ground with the inputs in audio amplifiers.</p> <p>However, a lot of effort is needed to ensure that the high-currents flowing in the output do not contaminate the input signal.</p> <p>Usually this means using a star-grounding where a common point is selected and input grounds and output grounds emanate from that point but no conductors have both the output current and input reference.</p> <p>For devices such as the TPA3123D2 the manufacturer will have designed it with these constrains and their design recommendations should be followed. Such recommendations are usually in the data sheet or application notes.</p> <p>See page 17 on the data sheet (<a href="https://www.ti.com/lit/ds/symlink/tpa3123d2.pdf?ts=1709539005754&amp;ref_url=https%253A%252F%252Fwww.google.com%252F" rel="noreferrer">TPA3123D2 datasheet</a>)</p> <p>Datasheet excerpt:</p> <ul> <li>Grounding—The AVCC (pins 19 and 20) decoupling capacitor and VBYP (pin 7) capacitor should each be grounded to analog ground (AGND, pins 8 and 9). The PVCCx decoupling capacitors and VCLAMP capacitors should each be grounded to power ground (PGND, pins 13, 14, 23, and 24). Analog ground and power ground should be connected at the thermal pad, which should be used as a central ground connection or star ground for the TPA3123D2.</li> </ul>
<p>Say I have an audio AC input(RCA stereo). This is underlaid by a ground plane before being terminated and fed to the amplifier. The output is SE(stereo audio from the TPA3123D2), however is also underlaid by the same ground plane underneath the input.</p> <p>Is this bad practice? Or should the grounds be separated? Blue is the ground plane, the three through holes at top left are the input. The 7-pin connector at the bottom is the output(significantly thicker traces).</p> <p>[<img src="https://i.stack.imgur.com/mkwcD.png" alt="Pcb design1" /></p>
Is it bad practice for audio inputs and outputs to share a common ground?
2024-03-04T20:26:05.417
704885
|voltage-reference|
<p>I don't know why you say current <span class="math-container">\$I_3\$</span> through R3 is <span class="math-container">\$I_3=\frac{\Delta V_{GS}}{R_3}\$</span>. I would say that <span class="math-container">\$\Delta V_{GS}\$</span> is the potential difference between the gates, and is <em>not</em> the voltage across R3. That seems to be the mistake you made, but I had trouble following your derivation, because I have no idea what <span class="math-container">\$V_{OUT1}\$</span> and <span class="math-container">\$V_{OUT2}\$</span> are.</p> <p>In any case, my approach is not like yours. Start with some labels:</p> <p><img src="https://i.stack.imgur.com/oRO5f.png" alt="schematic" /></p> <p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2foRO5f.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p> <p>Not that it's relevant, in case my previous statement wasn't clear:</p> <p><span class="math-container">$$ I_3 = \frac{V_{G2}}{R_3} $$</span></p> <p>Here <span class="math-container">\$V_{G2}\$</span> is the absolute potential at the gate of Q2, w.r.t 0V, and is not directly related to <span class="math-container">\$\Delta V_{GS}\$</span>.</p> <p>Due to negative feedback:</p> <p><span class="math-container">$$ V_{D1} = V_{D2} $$</span></p> <p>Therefore, both JFETs are passing the same current, and have equal <span class="math-container">\$V_{DS}\$</span>, which is the principle on which this design depends. The two transistors are biased to produce identical drain conditions, which is why we are able to say that the difference between absolute gate potentials will be the difference between the two transistors' respective <span class="math-container">\$V_{GS}\$</span>:</p> <p><span class="math-container">$$ \begin{aligned} \Delta V_{GS} &amp;= V_{GS1} - V_{GS2} \\ \\ &amp;= (V_{G1}-0V) - (V_{G2}-0V) \\ \\ &amp;= V_{G1}-V_{G2} \end{aligned} $$</span></p> <p>Gate-channel junctions are reverse biased, so gate currents are negligible, and need not be considered when calculating gate potentials:</p> <p><span class="math-container">$$ V_{G1} = V_{OUT} + I_{PTAT}R_1 $$</span></p> <p>R2 and R3 are a potential divider between OUT and ground:</p> <p><span class="math-container">$$ V_{G2} = V_{OUT}\frac{R_3}{R_2+R_3} $$</span></p> <p>Combining those last three equations:</p> <p><span class="math-container">$$ \begin{aligned} V_{G1} - V_{G2} &amp;= (V_{OUT} + I_{PTAT}R_1) - V_{OUT}\frac{R_3}{R_2+R_3} \\ \\ \Delta V_{GS} &amp;= I_{PTAT}R_1 + V_{OUT}\left(1 - \frac{R_3}{R_2+R_3} \right) \\ \\ &amp;= I_{PTAT}R_1 + V_{OUT}\frac{R_2}{R_2+R_3} \\ \\ V_{OUT} &amp;= \frac{\Delta V_{GS} - I_{PTAT}R_1}{\left(\frac{R_2}{R_2+R_3}\right)} \\ \\ &amp;= (\Delta V_{GS} - I_{PTAT}R_1)\frac{R_2+R_3}{R_2} \\ \\ &amp;= (\Delta V_{GS} - I_{PTAT}R_1)\left( 1 + \frac{R_3}{R_2} \right) \\ \\ \end{aligned} $$</span></p> <hr /> <h3>Update</h3> <p>There's an error in my circuit above. I've labelled nodes D1 and D2 representing drains, but actually the JFETs are source followers. It would have been better to label them S1 and S2. That doesn't change the behaviour at all, because JFETs are typically symmetrical, and you can swap drain and source without changing behaviour, it's just the labels that are misleading.</p> <p>A simulation using actual JFETs might have trouble solving for the DC operating point, because the op-amp will initially have 0V output, effectively forward-biasing the JFET junctions. That can be addressed by connecting the drains to a negative potential in the simulation, which I'll try in a moment.</p> <p>For now, though, I want to simulate behaviour with the following in mind:</p> <ul> <li><p>Those source followers will merely subtract the transistor's <span class="math-container">\$V_{GS(OFF)}\$</span>. That is, if <span class="math-container">\$V_{GS(OFF)}=2V\$</span>, then <span class="math-container">\$V_S = V_G - 2V\$</span>.</p> </li> <li><p>A source follower's voltage gain is <span class="math-container">\$\frac{\Delta V_S}{\Delta V_G}\approx+1\$</span>.</p> </li> <li><p>The constant current <span class="math-container">\$I_{PTAT}\$</span> through R1 will similarly just apply some fixed offset voltage to <span class="math-container">\$V_{OUT}\$</span>.</p> </li> </ul> <p><img src="https://i.stack.imgur.com/oWaCh.png" alt="schematic" /></p> <p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2foWaCh.png">simulate this circuit</a></sup></p> <p>In this scenario, <span class="math-container">\$\Delta V_{GS}\$</span> is:</p> <p><span class="math-container">$$ \Delta V_{GS} = V_{GS1} - V_{GS2} = -0.1V $$</span></p> <p>Also:</p> <p><span class="math-container">$$ I_{PTAT}R_1 = V_1 = -3V $$</span></p> <p><span class="math-container">$$ 1+\frac{R_3}{R_2} = 2 $$</span></p> <p>Therefore:</p> <p><span class="math-container">$$ \begin{aligned} V_{OUT} &amp;= (\Delta V_{GS} - I_{PTAT}R_1)\left( 1 + \frac{R_3}{R_2} \right) \\ \\ &amp;= \left[(-0.1) - (-3)\right] \times 2 \\ \\ &amp;= +5.8V \end{aligned} $$</span></p> <p>You may have noticed that I swapped the op-amp's inverting and non-inverting inputs. For this system to be stable, negative feedback should dominate. In other words, feedback factor <span class="math-container">\$\beta\$</span> must be larger at the inverting input. Clearly R2 and R3 produce a feedback factor <span class="math-container">\$\beta &lt; 1\$</span>, while for the other path <span class="math-container">\$\beta = 1\$</span>, and so I believe the inverting input should &quot;see&quot; the <em>greatest</em> change in potential in response to a change in <span class="math-container">\$V_{OUT}\$</span>, which corresponds to <span class="math-container">\$\beta = 1\$</span> in this design.</p> <p>I think I'll get some flak for suggesting this, but did Horowitz and Hill get the op-amp's inputs the wrong way around here?</p> <p>The other thing you might notice is that I've arranged for the offset V1 to be negative. The op-amp cannot produce negative output potentials, which it might have to do in order to properly bias Q1, if that offset were strongly positive. I don't think this is an &quot;error&quot; in the design, just something that isn't immediately obvious.</p> <p>As I mentioned before, I think for a simulation using JFETs to work, we must somehow arrange for it to be impossible for the JFET gate-channel junctions to be forward biased. The simplest way I can think of to achieve that is to set drain potential to be much more negative than the op-amp output could ever be:</p> <p><img src="https://i.stack.imgur.com/2OjHW.png" alt="schematic" /></p> <p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2f2OjHW.png">simulate this circuit</a></sup></p> <p>Notice that <span class="math-container">\$I_{PTAT}\$</span> is negative here, to place the offset to <span class="math-container">\$V_{G1}\$</span> in a range compatible with the op-amp's constrained output swing.</p> <p>The other point to note is that I've connected drains to −12V. That might not be necessary in your simulator. CircuitLab seems to work with drains grounded, but I'm still wary of the DC operating point being ambiguous when the junctions are forward biased.</p> <p><strong>Edit:</strong> Actually, now I think of it, there's no region in the graph of <span class="math-container">\$V_S\$</span> vs. <span class="math-container">\$V_G\$</span> where the slope is negative (which could potentially cause feedback to become positive), so I think you should be fine grounding the drains of JFETS.</p> <hr /> <p>The hardest part about getting this circuit to work is finding values that don't cause the op-amp to saturate. Using the 2N5460 JFET, for example, which has a significant <span class="math-container">\$V_{GS(OFF)}\approx3V\$</span>, the op-amp must produce a strongly positive output to bias Q1; remember that Q1's gate voltage is only a fraction of <span class="math-container">\$V_{OUT}\$</span>.</p> <p>Here's an implementation in LTSpice, using the 2N5460, with values tweaked to make it work:</p> <p><a href="https://i.stack.imgur.com/nvGwv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nvGwv.png" alt="enter image description here" /></a></p> <p>The .asc file from LTSpice:</p> <pre> Version 4 SHEET 1 880 680 WIRE -336 -32 -336 -48 WIRE -160 -32 -160 -48 WIRE 16 -32 16 -48 WIRE 144 96 144 80 WIRE -160 112 -160 48 WIRE 80 112 -160 112 WIRE 112 112 80 112 WIRE 256 128 176 128 WIRE 352 128 256 128 WIRE 16 144 16 48 WIRE 80 144 16 144 WIRE 112 144 80 144 WIRE 144 176 144 160 WIRE 16 192 16 144 WIRE 256 192 256 128 WIRE -480 224 -480 192 WIRE -160 288 -160 112 WIRE 16 288 16 272 WIRE -336 320 -336 48 WIRE -208 320 -336 320 WIRE 208 320 64 320 WIRE 256 320 256 272 WIRE 256 320 208 320 WIRE -480 336 -480 304 WIRE 256 368 256 320 WIRE -160 416 -160 384 WIRE 16 416 16 384 WIRE 256 496 256 448 WIRE -336 560 -336 320 WIRE 0 560 -336 560 WIRE 352 560 352 128 WIRE 352 560 80 560 FLAG 144 176 0 FLAG -480 336 0 FLAG -480 192 CC FLAG 144 80 CC FLAG 256 496 0 FLAG 352 128 OUT FLAG 80 144 S2 FLAG 16 416 0 FLAG 80 112 S1 FLAG 208 320 B FLAG 16 -48 CC FLAG -160 -48 CC FLAG -160 416 0 FLAG -336 -48 CC SYMBOL voltage -480 208 R0 SYMATTR InstName V1 SYMATTR Value 15 SYMBOL res 240 176 R0 SYMATTR InstName R2 SYMATTR Value 10k SYMBOL res 240 352 R0 SYMATTR InstName R3 SYMATTR Value 10k SYMBOL pjf 64 384 R180 WINDOW 0 60 57 Left 2 WINDOW 3 60 35 Left 2 SYMATTR InstName Q2 SYMATTR Value 2N5460 SYMBOL current 16 -32 R0 WINDOW 123 0 0 Left 0 WINDOW 39 0 0 Left 0 SYMATTR InstName I2 SYMATTR Value 1m SYMBOL pjf -208 384 M180 WINDOW 0 63 58 Left 2 WINDOW 3 62 34 Left 2 SYMATTR InstName Q1 SYMATTR Value 2N5460 SYMBOL current -160 -32 R0 WINDOW 123 0 0 Left 0 WINDOW 39 0 0 Left 0 SYMATTR InstName I1 SYMATTR Value 1m SYMBOL current -336 -32 R0 WINDOW 123 0 0 Left 0 WINDOW 39 0 0 Left 0 SYMATTR InstName Iptat SYMATTR Value -5m SYMBOL res 96 544 R90 WINDOW 0 -11 80 VBottom 2 WINDOW 3 -29 37 VTop 2 SYMATTR InstName R1 SYMATTR Value 1k SYMBOL voltage 16 176 R0 SYMATTR InstName V2 SYMATTR Value 0.1 SYMBOL OpAmps\\AD820 144 64 R0 SYMATTR InstName U1 TEXT -488 -56 Left 2 !.op </pre> <p>DC operating point results:</p> <pre> V(out): 10.2009 voltage V(b): 5.10044 voltage V(s2): 2.79732 voltage V(s1): 2.79728 voltage I(Iptat): -0.005 device_current I(I1): 0.001 device_current I(I2): 0.001 device_current </pre> <p>For this circuit:</p> <p><span class="math-container">$$ \Delta V_{GS} = 0.1V $$</span> <span class="math-container">$$ I_{PTAT}R_1 = -5V $$</span> <span class="math-container">$$ 1+\frac{R_3}{R_2} = 2 $$</span></p> <p><span class="math-container">$$ \begin{aligned} V_{OUT} &amp;= (\Delta V_{GS} - I_{PTAT}R_1)\left( 1 + \frac{R_3}{R_2} \right) \\ \\ &amp;= \left[(0.1) - (-5)\right] \times 2 \\ \\ &amp;= +10.2V \end{aligned} $$</span></p> <p>As you can see, <span class="math-container">\$V_{OUT}\$</span> gets very high. I recommend trying to modify the parameters, one by one, to see how easy it is to cause the op-amp to to leave its comfort zone, and why it can be challenging to find a confiuration that works.</p>
<p>I've been reading the Chapter 9 of The Art of Electronics, 3rd ed., and apparently the equation I derived for the following circuit is wrong.</p> <p><a href="https://i.stack.imgur.com/W7aYG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W7aYG.jpg" alt="The Art of Electronics, Chapter 9, Figure 9.93, pg 680" /></a></p> <p>My reasoning follows. Vout is the sum of the contributions coming from <span class="math-container">\$I_{PTAT} * R_1\$</span> and from the <span class="math-container">\$\Delta_{VGS}\$</span> voltage due to the asymmetrically doped JFET pair.</p> <p>So:</p> <p><span class="math-container">$$ V_{OUT1} = -I_{PTAT} * R_1 $$</span></p> <p>For the <span class="math-container">\$\Delta_{VGS}\$</span> contribution analysis, the current that flows through <span class="math-container">\$R_3 = \frac{\Delta_{VGS}}{R_3}\$</span> is the same current flowing from <span class="math-container">\$V_{OUT}\$</span> to ground, almost like a regular inverting amplifier. So:</p> <p><span class="math-container">$$ \frac{V_{OUT2}}{R_2+R_3} = \frac{\Delta_{VGS}}{R_3}, $$</span> <span class="math-container">$$ V_{OUT2} = \Delta_{VGS} \cdot \left( \frac{R_2}{R_3}+1 \right). $$</span></p> <p>Since <span class="math-container">\$V_{OUT}\$</span> is the sum of <span class="math-container">\$V_{OUT1}\$</span> and <span class="math-container">\$V_{OUT2}\$</span>, then:</p> <p><span class="math-container">$$ V_{OUT} = \Delta_{VGS} \cdot \left( \frac{R_2}{R_3}+1 \right) - R_1 \cdot I_{PTAT}$$</span></p> <p>That won't rearrange as the author's final equation.</p> <p>Edit: After Simon Fitch showed the correct analysis, I am including an unsuccessful simulation for further understanding.</p> <p>I simulated this circuit on Ltspice:</p> <p><a href="https://i.stack.imgur.com/FqujE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FqujE.jpg" alt="Ltspice" /></a></p> <p>Note that on the Figure 9.93 the source is connected the <span class="math-container">\$I_o\$</span> current source, and <strong>not</strong> to the ground. That is unexpected, since the most common way to control a JFET is by controlling <span class="math-container">\$V_{GS}\$</span>. I assume this is a graphic mistake on the book, although it really wouldn't matter if the opamp controls Q2's <span class="math-container">\$V_{DS}\$</span>, as long as the opamp <span class="math-container">\$V_{out}\$</span> can reach the <span class="math-container">\$I_o\$</span> current source compliance voltage. In the simulation above I've connected the source to the ground.</p> <p>I've used the same JFETs, so the first term of the equation <span class="math-container">\$(\Delta V_{GS} - I_{PTAT}R_1) = 0\$</span>, since <span class="math-container">\$\Delta V_{GS} = 0\$</span>.</p> <p>However, the simulation shows that <span class="math-container">\$V_{G1} - V_{G2} = 1.41V\$</span></p> <p><a href="https://i.stack.imgur.com/GZ7uA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GZ7uA.jpg" alt="VGS" /></a></p> <p>I also expected <span class="math-container">\$V_{D1}\$</span> and <span class="math-container">\$V_{D2}\$</span> to be the same because of the negative feedback loop, but that is also not the case:</p> <p><a href="https://i.stack.imgur.com/ETU37.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ETU37.jpg" alt="enter image description here" /></a></p> <p>Also, <span class="math-container">\$V_{out}\$</span> should be <span class="math-container">\$\require{cancel}\cancelto{0}{(\Delta V_{GS} - I_{PTAT}R_1)}+\left( 1 + \frac{R_3}{R_2}\right) = 5 V\$</span>, but we see different results:</p> <p><a href="https://i.stack.imgur.com/8JcIi.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8JcIi.jpg" alt="Vout" /></a></p> <p>Something is defintely wrong with this simulation, see there are currents into the JFET's bases:</p> <p><a href="https://i.stack.imgur.com/76bNl.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/76bNl.jpg" alt="IG" /></a></p> <p>I've tried diffferent values, and the opamp saturates quite easily, e.g, setting IPTAT = 10mA. This shouldn't be a problem if thi circuit was working correctly, with <span class="math-container">\$\Delta_{VGS} \sim 0.5V\$</span>:</p> <p><span class="math-container">$$V_{OUT} = (\Delta V_{GS} - I_{PTAT}R_1)\left( 1 + \frac{R_3}{R_2} \right)$$</span></p> <p><span class="math-container">$$V_{OUT} = (0.5 - 10 * 0.01) * (1 + \left(\frac{5k}{1k}\right))V = 2.4V$$</span></p> <p>I understand that the 0.5V difference the authors mention are manufacturing differences, but even the 0V expected using 2 equal JFETS, as simulated, should also work.</p> <p>Inverting drain and source, as the way it is shown on the book also won't help. What is the error in the simulation? Here is the Ltspice simulation file: <a href="https://drive.google.com/file/d/1QFUjGIxyA3o5WkSX9nDgn_ioa6cyFpPX/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1QFUjGIxyA3o5WkSX9nDgn_ioa6cyFpPX/view?usp=sharing</a></p>
(TAoE) JFET voltage reference derivation
2024-03-04T22:27:11.247
704888
|current|pcb-design|ground|grounding|surge-protection|
<p>Charge is drawn from the capacitor <em>and</em> battery, according to their relative impedance.</p> <p>Since the pulse is short, the capacitor's impedance can be quite low without needing massive values; pay attention to not just the value, but the ESR, as ESR will dominate for most types at these frequencies (~100kHz). You will probably want to consider aluminum polymer types.</p> <p>The battery's impedance can be increased by adding a series resistor, an LC filter network, or an active current limiting circuit. Consider:</p> <p><a href="https://i.stack.imgur.com/UP7Kv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UP7Kv.png" alt="enter image description here" /></a></p> <p>The LED current is carried by C1, and BT1 with ESR indicated (circled), as a current divider between them.</p> <p>For a battery current limit around 8A and a peak total load of 80A, the impedance divider needs to be 1:10. If the capacitor is say 20mΩ, the battery needs to be more than 200mΩ at these frequencies.</p> <p>Offhand, I would guess the battery impedance is lower than this. But it depends. It's hard to say, even given a datasheet, as they aren't concerned about time scales this short; in general, batteries do have capacitance (the impedance of the electrodes and electrolyte acting together, apart from the effect of chemical equilibria which is mediated by ionic diffusion in the ms+ time scales), so the impedance at these frequencies may be limited more by cable inductance than internal resistance.</p> <p>A resistor is a fine way to provide this impedance, when the duty cycle is very low. It sounds like this might be such an application (strobe light?). More generally, C1 and the added resistor, can be an extended CLC.. network which filters the current ripple from the left side, away from the battery; the design of this is covered by power supply filtering design guides.</p> <p>Note that 200mΩ at 100kHz corresponds to 3.2µH, so cable lengths on the order of this (stray inductance goes as length times μ<sub>0</sub>, times a geometry factor typically 0.2-0.5; ballpark 0.5µH/m is a good start), i.e. 6m or so, would be reasonable to provide such impedance. That's probably unrealistic for a portable device, so the resistor, filter network, or active limiter, is likely preferred here.</p> <p>80A in 5µs is moderately fast, and you may find it's worth switching (and bypassing, and supplying/filtering, potentially) the LED strings individually, rather than all together. Consider the stray inductance of the LED-switch-capacitor loop and what dI/dt the switching speed will generate. You may also need a TVS across the MOSFET (S to D) to clamp flyback voltage at turn-off.</p>
<p><a href="https://i.stack.imgur.com/kVesA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kVesA.png" alt="enter image description here" /></a>I have a use-case in which I require four bulk capacitors (470uF) charged to 6.4V. Each separate bulk capacitor will be used to provide the necessary energy to pulse a string of three LEDs at 5μs pulse durations (four strings of three LEDs in total). The peak current for each LED is expected to be 6.4A, leading to a worst-case scenario of 19.2A per string and a total combined current of 76.8A when all strings are flashed simultaneously.</p> <p>My system is designed such that the battery's maximum output to the system load will not exceed 4A, thanks to current limiting at the battery's positive terminal. However, due to the capacitors being slowly charged and then rapidly discharged, the surge current in the ground return path is significantly higher than what the battery typically outputs.</p> <p>My primary concern revolves around the ground return path for this surge current. Specifically, I'm wondering if a battery's negative terminal can typically handle such high surge currents without issue. If not, are there alternative strategies or solutions for grounding this amount of current?</p> <p>I apologize if this is a dumb question. I am still new to circuit design.</p> <p>The following are the specifications of my specific Li-Ion battery: Nominal Voltage: 7.2 V Typical Capacity: 3350 mAh Over Current Protection Range: 7.1 A - 8.7 A Max. Discharging Current: 1.5 C (LI NCR18650-BF 2s1p)</p>
Managing Ground Return for High Surge Currents in LED Capacitor Discharge Circuit
2024-03-04T22:38:58.480
704892
|operational-amplifier|high-voltage|circuit-protection|single-supply-op-amp|
<p>Either input (or both) can go to 32V <em>without damage</em> regardless of Vcc. This is very often <strong>not</strong> the case with op-amps, many require the input to be no more (or not much more) than Vcc to prevent damage, so don't get used to it. Sometimes they don't like differential voltages more than a diode drop or two. Depends on the op-amp and not always obvious from a first glance at the datasheet.</p> <p>If you want it to <em>work</em> as an op-amp then both inputs should be 1.7V (or thereabouts, check the <em>detailed</em> data over temperature etc.) below Vcc (and higher than about GND).</p> <p>If you want it to work as a comparator then <em>at least one</em> input must be within the above mentioned common-mode range. I don't know if the datasheet says that, but it's true.</p>
<p>I'm building a high-voltage regulator whose error amplifier is an op-amp.</p> <p>I'm relatively new to op-amps and currently using cheap single-supply LM324 so mistakes don't cost much. The error amplifier section is fed from a separate 5 V DC supply. I am trying to implement proper protection of the op-amp and got mixed up a bit while looking at the datasheet.</p> <p>In the maximum ratings section there is this footnote:</p> <blockquote> <p>For supply voltages less than 32 V, the absolute maximum input voltage is equal to the supply voltage.</p> </blockquote> <p>There is another footnote in the DC characteristics section:</p> <blockquote> <p>The upper end of the common mode voltage range is VCC −1.7 V, but either or both inputs can go to +32 V without damage, independent of the magnitude of VCC.</p> </blockquote> <p>I thought that footnote simply stated that <strong>common-mode</strong> voltage can go to +32 V without damage, but then the second part &quot;<strong>either or both inputs</strong> can go to +32 V without damage <strong>independent of the magnitude of VCC</strong>&quot; seems to contradict the first footnote in cases where Vcc is less than 32 V.</p> <p>What am I missing?</p> <p>I need to fully understand these concepts to implement proper protection in boundary conditions, like power-on, power-off, VCC supply failure or sag while the HV is still on, etc. The error amplifier input is connected to a voltage divider chain whose top voltage is in the range 150..300 V and maybe more, once I correctly tackle the design.</p> <p>For completeness here's the relevant section of the regulator - it is a shunt design. What you don't see at the left is a constant-current source feeding the shunt. The missing part on the op-amp input is a possible bias current offset compensation resistor, I'm still undecided as to whether it's necessary since the voltage divider tap can be adjusted over a small range. <a href="https://i.stack.imgur.com/keJEB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/keJEB.png" alt="Shunt regulator" /></a></p> <p><strong>March 8: conclusions</strong></p> <p>Key take-aways after going through recommended readings and a chapter on protection from a Walter Jung book on op-amp protection. As hinted in replies it appears that best practices are to <em>NOT</em> rely on built-in protection schemes or maximum ratings and rather bind the IC into a well-defined input and output voltage and current range. Integrated protections should be considered only as last-ditch protection.</p> <p>This allows flexibility in op-amp selection and replacement as one is no longer relying on integrated protection that may be absent in other replacement parts. It mainly involves a couple series resistors and a bundle of diodes of all types, Schottkys in places where reverse voltage limitation has to be less than 0.3V, low-leakeage regular ones otherwise, and back-to-back zeners for output voltage limitation.</p> <p>In my project there's also high voltage present at power-on due to capacitor C1 charging so the need for a shunt Vcc regulator that can sink current : TL431 and an extra 18V zener to protect it. The design now looks like the image below and so far boundary condition simulations seem to keep the op-amp in a secure operating environment at all times. Now I'm looking to see if back-to-back zeners could be replaced by MOVs.</p> <p><a href="https://i.stack.imgur.com/8JZIy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8JZIy.png" alt="Latest schematic revision" /></a></p> <p>Thank to all who replied, this was an interesting thread.</p> <p>-Joris</p>
Apparent contradiction in op-amp datasheet
2024-03-04T23:16:57.653
704893
|grounding|temperature|cables|thermocouple|rtd|
<p>It turns out there is an easy common solution I wasn't aware of. You can buy 3 pin type K thermocouple connectors. The third pin is meant for a ground reference to the shield drain wire! I would have to switch my thermocouple panel mount ports to 3 pin, but that's doable. I just didn't even realize this was something that was an option.</p> <p><a href="https://i.stack.imgur.com/OLvoJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OLvoJ.png" alt="enter image description here" /></a></p>
<p>I am building an electronic controller that measures the temperature on a metal chamber. Type K thermocouple sensors are placed on the metal chamber, and type k thermocouple extension cable connects the thermocouple junction at the measurement point to the electronic controller that processes the signal. The type k thermocouple extension cable we have has a foil shield because it is a noisy electrical environment. I'm confused about how to connect this shield on the thermocouple cable though, because when I search for type k connectors, they only have two prongs so I don't see a way for the extension cable shield to connect to ground at either the metal chamber or at the electronic controller. What am I missing? What do people usually do?</p> <p>It seems like most people don't buy thermocouple cable that has a shield, but we did from Omega (link <a href="https://www.omega.com/en-us/temperature-measurement/temperature-wire-and-cable/thermocouple-wires/expp-k-twsh-ul/p/EXPP-K-20-TWSH-UL-25" rel="nofollow noreferrer">here</a>). Is there a type of thermocouple connector that isn't just all plastic? If so I don't see it. Or do people manually tie the shield to a screw on the thermocouple port on the chassis? Just wondering what is typical here that I'm missing. Thanks!</p>
How do people ground cable shield on thermocouple cable?
2024-03-04T23:24:11.847
704902
|pcb|antenna|ground|
<p>Your confusion may be due to the dual meanings of the term &quot;ground plane&quot;.</p> <p>In designing a PCB (not an antenna) it's good practice to dedicate one copper layer to serve as a ground plane. It reduces unwanted RF radiation from the signals flowing on the board, as well as incoming noise from RF sources.</p> <p>In designing an antenna, the opposite result is desired -- you want it to radiate and receive RF, and for that it needs to be away from ground. That's why the design you chose specifies no ground plane on any layer under the antenna area.</p> <p>But -- many antennas, such as this one, are designed as monopoles. Think of these as really only half an antenna, requiring some kind of ground plane to serve as the other half. The ground layers on your PCB that are <em>away</em> from the antenna area serve this purpose.</p> <p>Notice that the reference design has the antenna at the end of a PCB, not embedded in a larger PCB. I think your disappointing results are due to the way you've sunken the antenna area into a notch in a larger PCB. Try removing more of the ground plane along the top edge of the PCB, at least until you reach those headers. It may help some. But the &quot;meander&quot; antenna design is not going to be as efficient as one that spreads the antenna trace out into something closer to a quarter-wavelength at the operating frequency.</p>
<p>I'm working on a PCB and want to incorporate a 2.4GHz PCB antenna but am a bit confused on how to handle the ground plane(s). This is a 4-layer PCB with Signals (and ground pour) on the top layer, ground on layers 2 and 3 and power on layer 4 (bottom).</p> <p>I'm new to the antenna part and have read some conflicting information. Some say to remove ground from &quot;under&quot; the antenna (but not sure what under means - just that layer or all layers). I've also read that a meander-style antenna need a reference ground plane, which I assumed means on layer 2.</p> <p>So putting this out to the community hoping someone with more experience can help me understand how to hand grounds.</p> <p>Here is a picture of the PCB - it's just a remote control that will transmit BLE data. Assume I have the 50-ohm impedance matched correctly, how should I hand ground? Remove from all four layers or include it on layer2.</p> <p>I've tried both and including it on layer 2 appears to be a disaster. But, not including it at all seems to work but I'm not getting great range (I quickly hit -80dBm or higher at 15 feet or less).</p> <p>For reference, the design is following information I found at <a href="https://www.st.com/resource/en/application_note/dm00470410-low-cost-pcb-antenna-for-24ghz-radio-meander-design-for-stm32wb-series-stmicroelectronics.pdf" rel="nofollow noreferrer">https://www.st.com/resource/en/application_note/dm00470410-low-cost-pcb-antenna-for-24ghz-radio-meander-design-for-stm32wb-series-stmicroelectronics.pdf</a></p> <p><a href="https://i.stack.imgur.com/VbDkr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VbDkr.png" alt="PCB with Antenna" /></a></p>
Ground plane for PCB Antenna
2024-03-05T02:09:01.397
704911
|relay|
<p>You could use an an NPN transistor in the ground lead to the relay, emitter to ground, collector to relay coil, base to vBatt through a resistor and a resistor from base to ground to ensure turnoff. As long as vBatt is high the transistor is on and the relay can operate, when vBatt is low the transistor is cut off and the relay won’t operate. You could use a MOSFET as an alternative, and you should add a diode across the coil for transient protection.</p> <p>It should look something like this:</p> <p><img src="https://i.stack.imgur.com/cXog8.png" alt="schematic" /></p> <p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fcXog8.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p>
<p>I have the following circuit for controlling an engine alternator regulator.</p> <p><a href="https://i.stack.imgur.com/GYCMq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GYCMq.png" alt="enter image description here" /></a></p> <p>When the regulator sees vBatt on it's input it enables a specific CC/CV charging profile.</p> <p>I have designed a, (untested), circuit, (which I hope is right), to turn the charge signal on/off and also have it default to off when the engine ignition is turned off.</p> <p>What I would like to do is integrate the blue circuit into the logic. If the blue circuit is switched off/goes open circuit, by the BMS then I would like the relay to also switch off. This will require the user to consciously enable charging after a BMS disconnect, rather than have it automatically restart if the BMS decides charging is OK.</p> <p>I believe that I am looking for a component that I can insert at position X which is controlled by the blue circuit. As the output is only 10mA I can't use a standard relay, which would not be ideal anyway, due to excessive power draw from the coil.</p> <p>Ideally also, the relay should not be able to be engaged if the BMS output is open circuit.</p> <p>Thanks</p> <p>Notes: All systems have a common ground reference. vBatt and vIgnition is 9 - 15v</p>
Modify auto power off circuit to switch off when power lost
2024-03-05T03:58:05.267
704913
|audio|
<p>Inductors are generally used in passive crossovers, those with no power source. If you’re going to be using amplification you may as well go with an active (powered) crossover which can be made using just op-amps, resistors and capacitors. You should be able to find circuits for these online.</p>
<p>I am trying to design a custom, audio line-level, crossover, to separate the AF into quadrants, according to the AF frequency, and then amplify these bands, to use as control circuits such as triacs or SCRs. Also, would it be possible to use toroidal cores for the inductors in the crossover section with LCR filters, or another type of filter together</p>
What would be some ideal parts for designing a custom audio crossover?
2024-03-05T04:52:30.107
704916
|glcd|
<p>It may be due to a compensation film on the polarizers that increases the contrast by reducing light leakage through the 'off' sections.</p> <p>For example, see this US patent <a href="https://patentimages.storage.googleapis.com/e6/a1/21/d919ec1c3c02f0/US7327422.pdf" rel="nofollow noreferrer">US7327422</a></p> <p>605 and 603 are the compensation film layers, and are inserted between the back polarizer 613 and the back LCD glass 607 as well as the 603 film under the front polarizer 611.</p> <p><a href="https://i.stack.imgur.com/aegzo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aegzo.png" alt="enter image description here" /></a></p> <p>Without access to those materials it is unlikely you could do much more than damage the LCD you have.</p>
<p>I recently bought a pair of these <a href="https://www.winstar.com.tw/es/products/graphic-lcd-display-module/monochrome-graphic.html" rel="nofollow noreferrer">128x64 graphical LCDs</a></p> <p><a href="https://i.stack.imgur.com/yhSaK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yhSaK.png" alt="128x64 graphical LCDs" /></a></p> <p>They do look really good with that blue background, but then I saw this:</p> <p><a href="https://i.stack.imgur.com/K3TSa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K3TSa.png" alt="black on white LCD" /></a></p> <p>And I started to wonder if it was possible to get that black on white look on my LCD. So, I decided to disassemble the metal shielding holding the actual glass. Now I know that the blue tint does not come from the backlight LED or the diffuser, but instead is something in the LCD itself:</p> <p><a href="https://i.stack.imgur.com/ip6zG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ip6zG.png" alt="back of the LCD glass" /></a></p> <p>I would like to avoid peeling off all the different layers the LCD has until I find a blue one and then replace it with something else, so I would appreciate to get some information from someone who knows more about how LCDs are assembled, and if that blue tint can be changed.</p>
Can the background of an LCD be changed?
2024-03-05T05:28:02.777
704923
|microcontroller|oscillator|clock|low-power|external|
<p>The oscillator might not be a good choise.</p> <p>The oscillator output is not a logic level square wave, but a 0.8Vpp Clipped Sine Wave. The data sheet for the whole Raltron RTV-104 series says that the oscillator output should be used with an AC coupling capacitor to remove DC bias.</p> <p>As there are no other details about the output DC specs so it may be incompatible with the MCU input.</p> <p>The MCU can be fed with logic level clock by bypassing the oscillator, but if the oscillator is enabled, the input voltage AC and DC specs are unknown, as it is assumed to connect directly to a crystal. It may work if the MCU is in crystal mode and the oscillator output is AC coupled to MCU crystal input pin.</p> <p>And like others have mentioned, the oscillator does not have an enable pin, the Vc is an analog control voltage input to fine-tune the output frequency.</p> <p>There might be ways to convert the oscillator output into logic level square wave with various methods but it will just be simpler and more reliable to choose another clock oscillator with logic level output.</p> <p>Especially if you don't need the accuracy, stability, and tunability of a VCTCXO, since you did not want to adjust it anyway.</p> <p>Edit: If you just want a stable and low-power solution, use a 8 MHz crystal with the MCU crystal pins and HSE. Better accuracy, lower power and cheaper than the LTC oscillator you asked about.</p> <p>Edit2: As the MCU package you will be using does not support HSE crystals, use a 32768 Hz LSE crystal to get a low power clock reference and use it to trim the internal HSI16 oscillator in software.</p> <p>Or, change the MCU to one that supports crystals directly.</p> <p>In general, ready made crystal oscillator modules that output square wave tend to consume several if not tens of milliamps so they should not be powered from a GPIO pin. Some of them have a shutdown pin to stop their operation to conserve power. Some of them have an output enable which simply disables the output, but the crystal oscillator will still consume same amount of current. But they are quite precise.</p> <p>Lower power and less precise oscillator modules do exist.</p> <p>So the balance of low cost, low power and high precision defines which solution you should pick.</p>
<p>I have to connect an oscillator (RTV-104EF13P-S-10.000-TR) to an MCU (STM32G051F8P6) in order to have a more precise clock.</p> <p>The datasheet provides very little information about the <code>Vc</code> pin function. I guess it is a power control but I could be wrong.</p> <p>The MCU datasheet also does not provide information about how the <code>OSC_EN</code> pin function works. I assume it should be driven LOW to disable the clock output but, again, could be wrong.</p> <p>Will my circuit (shown below) be able to disable the oscillator to save power?</p> <p>The oscillator only draws 1.5 mA but that is still significant in my application.</p> <p><img src="https://i.stack.imgur.com/uynbw.png" alt="schematic" /></p> <p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fuynbw.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p> <p>Edit: Accuracy should be less then or equal to +-10 ppm I assume IC like LTC6930IMS8 will be the best choice: It consume less then 1mA so it could be powered from OSC_EN pin</p>
How to connect oscillator to MCU for power saving operation
2024-03-05T07:42:10.870
704933
|transformer|three-phase|y-to-delta|
<p>Star</p> <p>line to line voltage = √3 x Winding voltage</p> <p>line current = winding current.</p> <p>Delta</p> <p>line to line voltage = winding voltage</p> <p>line current = √3 x winding current.</p> <p>The root 3 comes from the vector subtraction of two phases separated by 120 degrees.</p>
<p>I have got results from testing with delta/delta, delta/star, star/delta and star/star configurations. I've got the line and phase voltages for each configuration for both primary and secondary coils. I need to calculate the voltage across each winding and find the turns ratio. I'm just a bit confused about the winding voltage. Do I just use the line voltage? Is there a formula that I have been unable to find?</p>
How to find the "voltage across each winding" for different delta and star connections in a three phase transformer system?
2024-03-05T10:35:11.643
704936
|relay|triac|surge-protection|
<p>Triacs will turn on to (maybe) protect themselves with an overvoltage surge and voltage will be dropped across the load. The MOC3063 is only 600V rated so it will probably turn on first and trigger the triac. You could parallel the MOC3063 with a bipolar TVS to trigger the triac at a lower voltage than the MOC3063 rating.</p> <p>I don't think varistors will do much and are another point of potential failure. They are also have a very soft 'knee' and you might have to get higher voltage optos and thyristors for them to have much effect. If they are conducting regularly then they will wear out faster. If you have a specification to meet on the transient it will be easier to come up with a design. You might need to slow the dv/dt to keep the thyristor from damaging itself (or use a much heftier thyristor). The fundamental problem with protection is that the semiconductor devices are actually pretty fragile compared to possible transients (and compared with things like wires and mechanical contacts) unless you grossly overrate them, which costs money (and likely requires a lot more trigger current).</p> <p>You are apparently already zero-voltage switching, so noise is relatively low. As you probably know they don't actually switch right at the zero voltage point, however that noise is relatively consistent.</p>
<p>I am having 3 triacs and 3 relays that are used to control heater elements in triangle configuration. Atleast the triacs need some kind of surge protection since they can only handle 800V and surges/efts can be atleast 4kV.</p> <p>I would also want to protect the enviroment since switching 13 Amps in 3 phases is a big change that can cause problems to other devices. There is no current over the relays when they are switched. The triacs are first turned off and only then can the relay be switched on/off.</p> <p>The switching of triacs currently causes problems with the device that is controlling it. It resets the controller some times. I need to add protection there aswell, but that is another topic. It is still important to mitigate spikes caused by these triacs and relays.</p> <p>What kind of protection would you suggest? Options that I have been thinking about:</p> <ul> <li>Varistors to neutral</li> <li>Varistors in triangle</li> <li>Snubber circuit over Triacs</li> <li>Snubber circuit over Relays and Triacs</li> <li>TVS diodes over Triacs</li> </ul> <p>Description of the system: The Upper relays are always on if the system is heating. There are 3 heating modes for the system.</p> <ol> <li>Low heating where switching relay RSW is at L3. And only 2nd triac is open. In this mode current flows through all 3 Heating elements between L2 to L3.</li> <li>High heating where RSW is at L2 and all the Triacs are open. Here the heating elements are in triangle between L1, L2 and L3.</li> <li>Medium heating where RSW is at L2 and either L1 or L3 triac is not open. So there is full power between L2 and L1/L3</li> </ol> <p><a href="https://i.stack.imgur.com/cbQDh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cbQDh.png" alt="enter image description here" /></a></p>
Protecting Triac + Relay from surges
2024-03-05T11:08:10.873
704939
|emi-filtering|
<p>Of course it certainly <strong>can</strong> pick up interference.</p> <p>There is no minimum length where a wire suddenly stops picking up noise/interference.</p> <p>The length of the wire just determines how much interference it will pick up and what frequencies it will pick up.</p> <p>Another thing is, if the 1 inch of wire will pick up an amount that is significant to your application, and even if it does, if the input front-end of the circuit will be able to filter it out or otherwise deal with it.</p>
<p>In shielded EEG leads, the purpose is to resist capacitive coupling where interference current can couple to the high impedance electrode resulting in significant noise. I read &quot;A typical interference current is of the order of 20 nA, which, given an interelectrode impedance of even 10 kΩ, yields an interference voltage of 200 μV, a magnitude capable of drowning the EEG signal being measured, which is normally between 10 and 100 μV (Aurlien et al., 2004).&quot;</p> <p>I'd like to know if an unshielded exposed wire measuring mere one inch can like in photo below can attract interference current? Or is there a minimum length where it can't attract capacitive coupling/interference current?</p> <p><a href="https://i.stack.imgur.com/szvXq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/szvXq.jpg" alt="enter image description here" /></a></p>
Can 1 inch unshielded wire attract interference current?
2024-03-05T11:19:51.103
704951
|raspberry-pi|over-voltage-protection|reverse-polarity|over-current|
<p>The circuits and components you propose are rather useless and will in fact not work properly.</p> <p>The diode will make a voltage drop always, and since it is a regular diode, it will always drop about 0.7V and waste 2 watts at 3A. The RPi would see constant undervoltage of about 4.3V.</p> <p>Also the 5.1V or 5.6V zeners are not ideal devices and they would start to conduct much earlier than their rated voltage, and will draw more current as the voltage rises. If they are required to clamp a lot of current then they will draw a lot of current before they are supposed to clamp.</p> <p>According to Model 4B schematics, the 5V node on the GPIO connector is the exact same node that goes directly to the Type-C connector, so it will have exact same protection no matter if you power it via Type-C or via the GPIO header.</p> <p>Which means, no overcurrent protection anyway. There already is a TVS diode intended to protect from overvoltage and reverse polarity (as it conducts in reverse, hopefully making the source to limit current or burn a fuse).</p> <p>The difference is between the balance of trying to protect the supply from whatever you connect to it, or trying to protect the RPi from the supply, or trying to protect the RPi from what you might accidentally plug into it so a lot of current runs through it.</p> <p>The good thing about those mobile phone type supplies is that they generally detect overcurrent or short circuits and shut down due to overcurrent or undervoltage. Same might not be true if you use something more powerful.</p>
<p>I'm new to electronics but I'm trying to power a Raspberry Pi 4 (model b) using an external power supply for testing purposes[5V @ 3A]. This is possible via the GPIO, using pin 2 and pin 6 as ground but it doesn't have the same protections as the USB-C. The diagram attached is what I've researched would be a simple solution to protect the supply:</p> <ul> <li>A 3A fuse for over-current</li> <li>A (5.1V or 5.6V?) Zener Diode for over-voltage</li> <li>A regular diode for reverse polarity protection</li> </ul> <p>Would this be appropriate for something simple I could slap on a breadboard, if not, what should I change? And would a 5.6V Zener Diode be appropriate over-voltage protection to account for voltage losses so it better matches the official Raspberry Pi power supply @ 5.1V?</p> <p><a href="https://i.stack.imgur.com/TEmD5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TEmD5.jpg" alt="Wiring Diagram For Attempted Raspberry Pi Protection Circuit" /></a></p>
Appropriate Overcurrent, Overvoltage, and Reverse Polarity Protection Circuit for Raspberry Pi 4?
2024-03-05T13:28:10.537
704953
|power-electronics|opto-isolator|digital-isolator|
<p>You have filtered the PWM away with the 0.1 uF capacitor.</p>
<p><a href="https://i.stack.imgur.com/Xjqkw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Xjqkw.png" alt="enter image description here" /></a></p> <p>Im using digital isolator to isolate my PWM signals. Output VO does show any PWM output. What may be the issue here. I have used 1kohm at R1. Input side:</p> <p>PWM_H_In : PWM signal from function generator PWM_L_In : SGND</p> <p>Output side Supply: VDDH: +6V VEEH: -3V</p>
Digital isolator: Output is not coming as expected
2024-03-05T13:34:50.157
704959
|balun|
<p>Using reactive components, it is possible to match any arbitrary impedances <em>at a given frequency</em>. However, at <em>other</em> frequencies, the impedances will not match.</p> <p>Generally, there is no power benefit accrued to matching impedances by adding a resistor, as the resistor will dissipate power.</p> <p>The impedance ratio of a transformer type balun is the turns ratio <em>squared</em>. Since transformer type baluns generally have a small number of turns, the available impedance ratios are limited. An impedance ratio of 9:4 is not exactly 2:1 but it may be adequate for your use case. If it is not close enough, and you can live with more turns, impedance ratios of 16:9, and 49:25 are feasible.</p>
<p>I have a balanced balun with 1:1 impedance ratio, while I need 1:2. Is it possible to change the ratio by including some resistors/inductors to match 100 Ohm output?</p>
How to increase balun impedance ratio
2024-03-05T14:02:36.140
704965
|microcontroller|comparator|interface|
<p>As Marcus Muller pointed out, R13 is providing hysteresis, so the output will already be a very sharp, emphatic high or low.</p> <p>The pull-up resistor R14 to +3.3V is what determines the &quot;high&quot; output potential. That would be exactly +3.3V were it not for R13, which will shift that a little, slightly towards whatever the potential at its other end is. As long as you keep R13 very large compared to R14, this won't be an issue.</p> <p>Do not use C10 as you have it here. You risk damaging the output transistor of the comparator, and you also risk reducing the output rise rate to something too slow for the MCU input, resulting in spurious readings of that pin during transition.</p> <p>You have hysteresis, I see no need to filter or slew-rate limit the comparator output, so drop C10.</p>
<p>I would like to connect the output of a LM2903B comparator to my controller to read the output signal. Both the comparator supply voltage +13V and the controller supply 3.3V are referenced to the same ground.</p> <p>Do I need to place Schmitt trigger or a series resistor to the output of the comparator? What things do I need to consider to connect the output to a controller GPIO? The inverting input is a DC voltage which varies from 0V to +11V.</p> <p><a href="https://i.stack.imgur.com/0IWZu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0IWZu.jpg" alt="enter image description here" /></a></p>
Interfacing an LM2903B output to a microcontroller
2024-03-05T14:38:45.100
704988
|microcontroller|digital-logic|atmega|input|
<p>The problem is that the signal input to transistor is not 24V and 0V, but 24V and indeterminate floating voltage, possibly with a long wire connected to base acting as an antenna for receiving electrical noise.</p> <p>You need to pull the transistor base down to 0V with a resistor to prevent even a small disturbance from amplifying the base current to collector (emitter) current and pulling the MCU pin high.</p>
<p>I'm trying to read digital 24v in MCU so I used a voltage regulator to step it down to 5v then I got the 5v to pull down resistor with a transistor like that</p> <p><a href="https://i.stack.imgur.com/S5VpT.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S5VpT.gif" alt="enter image description here" /></a></p> <p>then I get the V out to the MCU pin which is DIO_read and some LEDs to other DIO_write,</p> <pre><code>int main(void) { DIO_Inti(); char x=0; while (1) { x=DIO_ReadPin(PIND0); if(x==HIGH) { DIO_WritePin(PINB1,HIGH); DIO_WritePin(PINB2,HIGH); DIO_WritePin(PIND6,HIGH); DIO_WritePin(PIND5,HIGH); DIO_WritePin(PIND3,HIGH); } else if(x==LOW) { DIO_WritePin(PINB1,LOW); DIO_WritePin(PINB2,LOW); DIO_WritePin(PIND6,LOW); DIO_WritePin(PIND5,LOW); DIO_WritePin(PIND3,LOW); } _delay_ms(100); } return 0; </code></pre> <p>}</p> <p>when the Vout is high the LEDs work well, when the Vout is low the LEDs blink randomly I don't know how that happens with the pulldown resistor.</p> <p>Here is the DIO_ReadPin function</p> <pre><code>DIO_PinVolt_t DIO_ReadPin(DIO_Pin_t pin) { DIO_PinVolt_t volt = LOW; // PORTB if (pin &gt;= PINB0 &amp;&amp; pin &lt;= PINB7) { volt = GET_BIT(PINB, (pin)); } // PORTC else if (pin &gt;= PINC0 &amp;&amp; pin &lt;= PINC6) { volt = GET_BIT(PINC, (pin - PINC0)); } // PORTD else if (pin &gt;= PIND0 &amp;&amp; pin &lt;= PIND7) { volt = GET_BIT(PIND, (pin - PIND0)); } return volt; } </code></pre> <p>can anyone help to explain and solve that?</p>
Led blanking while the DIO_Read is LOW and work well while DIO_Read is HIGH
2024-03-05T18:48:28.307
704989
|isolation|rs485|
<p>Some RS-485 transceivers are fully isolated, they contain e.g. transformers or capacitor coupled power supplies within the device package. Look at e.g. <a href="https://www.ti.com/product/ISOW1432" rel="nofollow noreferrer">https://www.ti.com/product/ISOW1432</a> - it can cope with 5000 volts.</p> <p>These work by having &quot;floating&quot; islands of circuitry operating off isolated power supplies. So the RS485 transciever doing the work is still some low voltage circuit, just it does not need a ground connection- the transmitter and receiver circuits are referenced to each others outputs - one transmit side signal is a few volts more negative, the other one a few volt more positive at all times.</p> <p>These devices can happily work with very large common mode voltages : their floating circuits are happily transferring differential data with only a few volts difference between the two data wires, so the actual transceiver hardware is operating about the same voltage to anything you call ground at both ends.</p> <p>Signalling to/from the electrical interface on the user side can be via transformers, capacitors or opto isolators. If you use transformers or capacitors, then the digital data would be modulated onto some kind of AC carrier to pass through the transformer or capacitor. Even at 12 megabits/sec this can be made to work.</p>
<p>Galvanically isolated RS-485 surely needs a signal ground, which leaves me puzzled about the following circuit -- which apparently sends the RS-485 signal correctly without the isolated grounds being connected.</p> <p>Photo shows a pair of Analog Devices <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/ADM2582E_2587E.pdf" rel="nofollow noreferrer">ADM2582E</a> drivers which are powered by completely separate batteries (and Recon R7850-05 DC convertors). When leftmost unit's <code>TXD</code> is connected to (its own) <code>GND</code> or <code>5V</code>, rightmost unit responds.</p> <p><strong>The question is simple: how is this working?</strong></p> <p>The Digilent board has a place for a header marked <code>ISOGND</code>, but it's not on the screw terminals and there's no header on the PCB, so they obviously have lots of customers which don't use it.</p> <p><a href="https://i.stack.imgur.com/8bVJ6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8bVJ6.png" alt="enter image description here" /></a></p> <p>This is the circuit above (with 1 kHz generator and switch on ISOGND link, added after photo taken.)</p> <p><img src="https://i.stack.imgur.com/qhLLV.png" alt="schematic" /></p> <p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fqhLLV.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p> <h2>Materials</h2> <p>The modules are Digilent PMOD RS485 isolated drivers based on the Analog Devices <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/ADM2582E_2587E.pdf" rel="nofollow noreferrer">ADM2582E</a> chip. <a href="https://i.stack.imgur.com/T88zz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/T88zz.png" alt="enter image description here" /></a><br /> <em>From <a href="https://digilent.com/reference/pmod/pmodrs485/reference-manual" rel="nofollow noreferrer">Digilent Documentation</a></em></p> <p>Module circuit diagram: <a href="https://i.stack.imgur.com/0Xdio.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0Xdio.png" alt="enter image description here" /></a><br /> <em>From <a href="https://digilent.com/reference/_media/reference/pmod/pmodrs485/pmodrs485_sch.pdf" rel="nofollow noreferrer">Digilent</a></em></p> <h2>Additions after comments</h2> <p><strong>Trace 1. Is the signal noisy?</strong> It was suggested in comments that the signal would look noisy: it does not. Following is from circuit above <code>U2.RXD</code> but with input at <code>U1.TXD</code> from 1kHz (microcontroller powered from left-hand power supply.) Rise/fall times measured at approx 7 ns. The signal at <code>U2.A</code> with scope ground on <code>U2.B</code> was equally clean.</p> <p><a href="https://i.stack.imgur.com/Ge5D2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ge5D2.png" alt="enter image description here" /></a></p> <p><strong>Same if non-isolated?</strong> One answer says it would look the same if the transceivers were non-isolated: I repeated the experiment with two Texas Instruments 75176 transceivers (without connecting grounds), again over 10 cm cable without grounds. Results were indistinguishable, as predicted.</p> <h2>Further tests</h2> <p>Many thanks to @Fredled for suggesting looking at these traces.</p> <p><strong>Trace 2. Receiver against its Isolated Ground</strong> This is <code>U2.A</code> with scope ground on <code>U2.ISOGND</code>, which is not connected to <code>U1.ISOGND</code>. (However, with <code>U1.ISOGND</code> connected to <code>U2.ISOGND</code> it looks the same.)</p> <p><a href="https://i.stack.imgur.com/iZLH9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iZLH9.png" alt="enter image description here" /></a></p> <p><strong>Trace 3. Receiver ground isolation</strong> This is <code>U2.ISOGND</code> with scope ground on <code>U2.GND</code>, with what appears to be 50 Hz background mains (from scope probes) and effects from the Recon switched-mode DC-DC converter and/or the converters inside the ADM2582. <a href="https://i.stack.imgur.com/l6By3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l6By3.png" alt="enter image description here" /></a></p> <p><strong>Trace 4. Receiver input against local non-isolated ground</strong> Consequently <code>U2.A</code> against <code>U2.GND</code> should be messy: and here is <code>U2.A</code> with scope ground on <code>U2.GND</code>; As well as the decay slopes at 1 kHz, the 50 Hz pattern is very visible at slower traces.</p> <p><a href="https://i.stack.imgur.com/AYJSm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AYJSm.png" alt="enter image description here" /></a></p> <h2>Traces with long wire, <code>U2.A</code> with scope ground at <code>U2.ISOGND</code></h2> <p>Finally, with these conditions we see noise removed by the joining of the signal grounds:</p> <ul> <li>Transmitter powered by low quality USB charger</li> <li>Receiver powered by 9V battery and Recon DCDC converter</li> <li>Signal going through ~150 m reel of twisted 0.5 mm solid cable sitting on a power cube</li> </ul> <p>It's worth noting that in both cases the output of the receiver <code>U2.RXD</code> looked the same.</p> <p><strong>Noise visible</strong> <code>U1.ISOGND</code> not connected to <code>U2.ISOGND</code></p> <p><a href="https://i.stack.imgur.com/YPI5E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YPI5E.png" alt="enter image description here" /></a></p> <p><strong>Noise removed</strong> <code>U1.ISOGND</code> connected to <code>U2.ISOGND</code> <a href="https://i.stack.imgur.com/ZII32.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZII32.png" alt="enter image description here" /></a></p>
Puzzle how isolated RS-485 (ADM2582) sends signal without signal ground
2024-03-05T18:57:40.247
705008
|voltage|led|
<p>LEDs are driven by a current limited source - not a constant voltage. In most cases for an indicator LED a simple resistor does the job. Your board probably has this built in and if you trace back from the LED solder pads you may be able to identify it.</p> <p><a href="https://i.stack.imgur.com/gdNHJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gdNHJ.png" alt="enter image description here" /></a></p> <p><em>Figure 1. Series connection of a resistor and LED. The voltmeters show the voltage drop across each element of the circuit. Image source: <a href="http://lednique.com/electrical-theory-basics/ohms-law-and-resistor-calculation/" rel="nofollow noreferrer">LEDnique</a>.</em></p> <p>If you remove the LED in the circuit above the voltmeter would read 5 V, that of the supply.</p> <p>If you can find the on-board resistor then you can connect the new LED with a high degree of confidence.</p>
<p>Sorry this is a very basic question from a complete novice.</p> <p>I need to replace a 3 mm through hole LED, I have tested the voltage coming from the board and it's 4.5 V. I can't find a 3 mm LED with 4.5 V; the highest I can find is 3.6 V. Will the 3.6 work or will it blow the LED?</p>
Basic LED voltage
2024-03-05T21:22:14.563
705031
|batteries|battery-charging|lipo|battery-chemistry|tracking|
<p>The worst that happens to Li batteries in vehicles is the heat stress.</p> <p>Depending on where the device is mounted, it may get as hot as 70C when in direct sunlight or 90C when the engine is running.</p> <p>The combination of fully charged Li battery and high temp is especially bad.</p> <p>A Li battery MAY tolerate temperatures this high if it is kept well below 50% state of charge. Pretty much possible, just charge to a lower voltage, but then you need a bigger battery for a given energy amount to be available. This also requires a precise and somewhat exotic charging control.</p> <p>Small, simple and cheap devices usually have neither the mass nor volume nor bill of materials nor engineering budget to spend on luxuries like longevity.</p> <p>Few customers are going to pay e.g. twice the price for a car tracker for a feature they can neither reliably test nor they are sure they need it in the first place.</p>
<p>This question is to clear my confusion because I cannot find a logical answer. Say a vehicle is installed with a vehicle tracker <code>(Battery specs: Li-Po 3.7V, 250mAh. Power consumption: Standby: 70mA@12V, Working: 100mA@12V)</code> for 2 years. The car owner took special care of his vehicle battery and there was not even a single day when his vehicle's battery went below 12 V.</p> <p>This means that the internal battery of the tracker was never used because it operates on 9-32 VDC which is provided by vehicle's battery. It never discharged. It means that the tracker's battery is healthy and should be able to power it up for at least 30 minutes (as it used to be when unboxed) even after 2 years.</p> <p>However, this is not the case practically. Tracker do not power up on their batteries after that much time. I was wondering how this can be proved mathematically/graphically because only then can I educate others with logic.</p> <p><a href="https://i.stack.imgur.com/Saq6Q.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Saq6Q.jpg" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/dlKCa.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dlKCa.jpg" alt="enter image description here" /></a></p>
Battery life of Li-Po battery if it is under constant charging
2024-03-06T06:37:44.563
705039
|digital-logic|fpga|verilog|system-verilog|
<blockquote> <p>Doesn't it create a race condition on some of these bits?</p> </blockquote> <p>No, there is no race condition between the bits. As you mentioned, the <code>function</code> is used to model combinational logic. It correctly uses blocking assignments (<code>=</code>).</p> <blockquote> <p>Can it make timing issues eventually?</p> </blockquote> <p>No, there are no timing issues. The function explicitly sets 4 bits of <code>MyFunc</code>: 1-4. But, all bits of <code>MyFunc</code> are set by the initialization line, no matter how big <code>DATA_SIZE</code> is:</p> <pre><code>MyFunc = DataIn; </code></pre> <p>Since there are assignments to all bits, this avoids inferring unintended latches.</p> <blockquote> <p>What is another better way to write the same combinatorial logic?</p> </blockquote> <p>Another way (not necessarily better) is:</p> <pre><code>always_comb begin MyFunc = DataIn; MyFunc[1] = X; if (I0) begin MyFunc[2] = Y; MyFunc[3] = K; MyFunc[4] = I1; end end </code></pre> <p>You would replace <code>MyFunc</code> with another signal name.</p> <p>One advantage of the <code>function</code> is that it can be called many times in the code without duplicating the 9 lines of code above and with a different set of input signals.</p>
<p>I encountered something weird in a Verilog code, and I have doubts about it.</p> <p>Someone used a <code>function</code> in Verilog in the following way:</p> <pre><code>Pipe #(.W($bits(Data))) MetaO (Clock, MyFunc(DataIn, I0, I1), DataOut); function [DATA_SIZE-1:0] MyFunc (input [DATA_SIZE-1:0] DataIn, input I0, input I1); MyFunc = DataIn; MyFunc[1] = X; if(I0) begin MyFunc[2] = Y; MyFunc[3] = K; MyFunc[4] = I1; end endfunction </code></pre> <p>So, what he tried to do here is to pipe <code>DataIn</code> to <code>DataOut</code>,<br /> but to manipulate <code>DataIn</code> bits before the pipe, so he used <code>function</code> as the input to the <code>Input</code> port of the pipe.</p> <p>My doubts are in the function itself.<br /> He first of all kind of initialized <code>MyFunc</code> with <code>DataIn</code>,<br /> and then in the following lines, assigns different values in the other bits depending on some stuff.</p> <p>Because it's eventually combinatorial logic, I ask myself if it's a correct way to write Verilog.</p> <p>Doesn't it create a race condition on some of these bits?<br /> Can it make timing issues eventually?</p> <p>What is another better way to write the same combinatorial logic?</p>
Functions in Verilog for combinational logic
2024-03-06T08:34:28.977
705048
|circuit-design|ground|pullup|logic-level|pulldown|
<p>I see two simple options. The first one uses a XOR gate to invert the button signal depending on the header status like this:</p> <p><img src="https://i.stack.imgur.com/5waYn.png" alt="schematic" /></p> <p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2f5waYn.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p> <p>The second idea supports your intention to change the GPIO resistor pull direction depending on the header signal like this:</p> <p><img src="https://i.stack.imgur.com/e4EKh.png" alt="schematic" /></p> <p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fe4EKh.png">simulate this circuit</a></sup></p>
<p>I'm designing a circuit containing a button with a pull-up/pull-down logic depending on whether I'm grounding a header. The button triggers a GPIO that will detect if the header is grounded thanks to the falling/rising edge when I push the button. On my GPIO I want to be able to know whether the header is grounded and if the button is being pressed.</p> <p>Here is the circuit I have designed so far : <a href="https://i.stack.imgur.com/iswdO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iswdO.png" alt="enter image description here" /></a></p> <p>You can try it out <a href="https://lushprojects.com/circuitjs/circuitjs.html?ctz=CQAgjCAMB0l3BWEAmAzNALAdkggnMmAGxFYKSpIZEhLm0CmAtGGAFADK4BIeNYPVMigiAZgEMANgGcGI5GwBKIJkN41VwohhGQQGPelS6o0BGwBO3YQJs9kCGnrDk4bAO7WUj8MgAc3k5syJBYIGoOToH6IABGAC4AdgD6AJaJbACSKJABtihYdsJ6MEhGHjl5PPn5kGzSXpEFwk3OIPEWAK4MFciF0X1FUGwADr4BTWD%204ZA6ECVsAObjM3PTQiXDIWGa4Bg6zvsxAMbisenJsQD28fFXALbBoStqfobCOqfnKelsx5WraKoWa6WDwSB4SFQ6EwvAqdDIWFQvx4MjEUxwdjLDZeShDBZWDABPjw4Qk5zgpYvGzTbS6CpTAJqMBYGhqOqeXZgI67ckVInqLx8zz5Ek1HgcoEgwaAyUy4E6GWtXq5QH5BXDEWCEH5ZWeCI%20RnROpWA1s4QavSuNzYi0gtQ4hZAA" rel="nofollow noreferrer">here.</a></p> <p>As you can see, if I'm grounding my header the circuit works with a pull-down logic, if the header is in the air we have a pull-up. It works well but I have two concerns about this circuit :</p> <p>The first one is that when my header is in the air I get 2.5V instead of 3.3V which might be a problem in the future. I'm looking for a solution to get a nice 3.3V.</p> <p>My second concern is that is find my logic a bit heavy and I'm looking for a simpler way to solve my problem (maybe without any diode?)</p> <p>Any kind of help will be very appreciated.</p>
Ground detection circuit
2024-03-06T09:37:10.457
705056
|feedback|
<p>From Figure 8.51 in the book, you can see that the author modeled the feedback network as G parameters, as in the images below (all taken from the book by Razavi above).</p> <p><a href="https://i.stack.imgur.com/P1tJL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P1tJL.png" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/Qfiph.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qfiph.png" alt="enter image description here" /></a></p> <p>The feedback factor <span class="math-container">\$ \beta \$</span> in this model is equal to <span class="math-container">\$ g_{21} \$</span>: <span class="math-container">$$ g_{21} = \frac{V_2}{V_1}\bigg|_{I_2=0} $$</span> In this case, <span class="math-container">\$ g_{21} = V_F/V_{out} \$</span> when there is no current from the MOSFET. <span class="math-container">$$\beta = g_{21} = \frac{R_S} {R_F + R_S}$$</span> <a href="https://i.stack.imgur.com/i7VJb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i7VJb.png" alt="enter image description here" /></a></p>
<p>The following is from the book <em><a href="https://electrovolt.ir/wp-content/uploads/2014/08/Design-of-Analog-CMOS-Integrated-Circuit-2nd-Edition-ElectroVolt.ir_.pdf" rel="nofollow noreferrer">Design of Analog CMOS Integrated Circuit</a></em>, page 307.</p> <p><a href="https://i.stack.imgur.com/u89b9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u89b9.png" alt="enter image description here" /></a></p> <p>KCL at node F.</p> <p><span class="math-container">$$ (V_{in} - V_F) g_{m1} + \frac{V_{out} - V_F} {R_F} = \frac{V_F} {R_S}$$</span></p> <p><span class="math-container">$$\Rightarrow V_F = \frac{V_{in} g_{m1} + V_{out} / R_F} {g_{m1} + 1/R_F + 1/R_S}$$</span></p> <p><span class="math-container">$$\Rightarrow \beta = \frac{1 / R_F} {g_{m1} + 1/R_F + 1/R_S} = \frac{R_S} {g_{m1} R_F R_S + R_F + R_S}$$</span></p> <p>However, the book said this</p> <p><span class="math-container">$$\beta = \frac{R_S} {R_F + R_S}$$</span></p> <p>Where am I wrong?</p>
How to calculate feedback \$\beta\$ in two common-source stages feedback
2024-03-06T10:40:02.347
705075
|digital-communications|sd|firmware|
<blockquote> <p>I am less sure why that would need 74 clock cycles</p> </blockquote> <p>It is about the delay being given with the clock cycle period as a unit of time. Since the clock cycle period is already there, it is convenient to use it as a measure of time, as you will soon see.</p> <blockquote> <p>rather than just enforcing a delay before commands as part of a timing diagram in the standard</p> </blockquote> <p>You'd be surprised at how much of a complication this may be to some implementers. If you already have a clock source, it's rather easy to specify delays relative to that clock source. When you specify a delay in absolute terms, without mentioning the clock, many people miss the simple implementation opportunity and think they need separate timers and so on.</p> <p>This specification suggests a simple implementation technique. Engineers with less experience can take that as a hint and use it. More experienced folks will interpret it in more general terms.</p>
<p>It is documented that the SD Bus Interface requires 74 clock cycles before the first command is sent:</p> <p><a href="https://i.stack.imgur.com/bjP63.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bjP63.png" alt="enter image description here" /></a></p> <p><em>Taken from SD Specifications Part 1 Physical Layer, Simplified Specification, Version 6.00</em> <a href="https://academy.cba.mit.edu/classes/networking_communications/SD/SD.pdf" rel="noreferrer">https://academy.cba.mit.edu/classes/networking_communications/SD/SD.pdf</a></p> <p>This leads me to have several related questions which do not appear to be documented in the standard:</p> <ol> <li>What does the SD card use these clock cycles for internally?</li> <li>Are the actions the SD card takes internally consistent every time, or do they vary based on the SD card contents or previous commands received?</li> <li>Are the actions the SD card takes consistent between manufacturers or SD card types? I.e. are the internal actions of the SD card dictated by a standard, or are manufacturers free to use these clock cycles as they see fit.</li> </ol>
What does an SD Card do internally during the 74 clock cycles at startup
2024-03-06T14:04:29.063
705093
|fpga|intel-fpga|synthesis|timing-analysis|
<p>Don't have go all the way to gate level. Break up a 32 bit compare into two behavioral 16 bit compares separated by a pipeline stage, and gated together as a fan in of 2 after the pipe.</p> <p>Check out this tutorial video By Greg Stitt which discusses your issue. His solution is to work to reduce the size/width of the compare. <a href="https://stitt-hub.com/timing-optimization-tutorial/" rel="nofollow noreferrer">Timing Optimization Tutorial</a></p>
<p>Timing closure in FPGAs is a challenging subject. There are many guidelines, one of them: pipelining, is to introduce new registers in the data path so that the overall combinational logic gets distributed in a way that the critical path delay through the gates will be lesser than the clock period minus setup time.</p> <p>Posting a snapshot of <a href="https://www.youtube.com/watch?v=UGGkKZylJBo" rel="nofollow noreferrer">this</a> video: <a href="https://i.stack.imgur.com/mMN3a.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mMN3a.png" alt="Intel FPGA guidelines for timing closure" /></a></p> <p>In this example a <code>DFF</code> is inserted at a desired position in the data path. My question is that, If I'm using a single <code>32-bit</code> comparator or similar functionality, it usually gets implemented as a cascading chain of similar combinational logic cells in the post-fit netlist. I convey the desired comparator behavior using <code>==</code> or <code>&gt;=</code> or <code>&lt;=</code> or <code>!=</code> or <code>&gt;</code> or <code>&lt;</code> etc. operators along with corresponding signals as a single line of code. How do I put a <code>DFF</code> somewhere between that operator? Or do I have to construct a gate level comparator and then manually put DFF at desired places?</p> <p>What are the guidelines if I use a <code>Boolean</code> expression with multiple signals and multiple <code>Boolean</code> or <code>arithmetic</code> operators?</p>
Guidelines for reducing levels of logic cells in FPGAs while using HDL operators in behavioral modelling
2024-03-06T16:49:54.937
705101
|identification|
<p>It's a <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/adm3061e-3062e-3063e-3064e-3065e-3066e-3067e-3068e.pdf" rel="nofollow noreferrer">Analog Devices ADM3066EARMZ</a> RS-485 transceiver.</p> <p><a href="https://i.stack.imgur.com/nrDIW.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nrDIW.jpg" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/O5rSX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/O5rSX.jpg" alt="enter image description here" /></a></p> <p>(Source: <a href="https://www.lcsc.com/product-detail/RS-485-RS-422-ICs_Analog-Devices-ADM3066EARMZ_C658147.html" rel="nofollow noreferrer">lcsc.com</a>)</p>
<p>Can anybody help me identify the IC marked &quot;MC 4&quot;?</p> <p><a href="https://i.stack.imgur.com/ik7YP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ik7YP.png" alt="enter image description here" /></a></p>
Identify IC marked "MC 4"
2024-03-06T17:21:27.583
705105
|electromagnetism|wifi|
<p>This is a well-known issue with signal interference between WiFi and USB3. In fact, the main peak of energy of 5Gbps USB3 signal is centered at Nyquist frequency of 2.5 GHz, not 5GHz, which is quite close to 2.4. When USB link transmits data in active state, the spectrum of signals looks like this (one of USB3 pattern, USB3 specifications 1.1 page 90):</p> <p><a href="https://i.stack.imgur.com/R41lo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/R41lo.png" alt="enter image description here" /></a></p> <p>Obviously the signal is supposed to be totally differential, and shielded twisted pairs should not emit much, but nothing is perfect, and USB3 cable connectors, cables and enclosures do emit parasitic sidebands. When in close proximity, USB3 interferes with WiFi, <a href="https://www.usb.org/sites/default/files/327216.pdf" rel="noreferrer">this article provides detailed explanation</a>.</p>
<p>I have an ESP32 connected to Wi-Fi 2.4GHz. It is positioned next to my PC's Wi-Fi USB dongle, which is connected to the same network at 5GHz. When the PC is on (the USB dongle is active), my ESP32 disconnects and reconnects from the Wi-Fi every 15–60 seconds on average. Why does this happen if they are at different GHz ranges? <a href="https://i.stack.imgur.com/B9ISb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B9ISb.png" alt="enter image description here" /></a></p>
Why does my ESP32 suffer from wifi stuttering when is next to wifi USB dongle?
2024-03-06T17:30:23.343
705113
|arduino|transistors|relay|
<p>Transistors are generally used for medium-power applications. High current BJTs are harder to come by and more expensive, and dissipate more power (Vce 0.6V drop). Like hacktastical said, BJTs don't handle AC voltages very well(output cannot swing below ground with a single supply).</p> <p>Relays are better for high-power applications, whether they are SSRs (solid-state) or electromechanical (coil drives a switch). SSRs don't need any external circuitry (consult datasheet first) but are more expensive. Electromechanical types only require a minimum amount of current to drive the coil, plus a flyback diode to suppress back-EMF. Relays also provide some degree of isolation and can handle AC loads.</p>
<p><a href="https://i.stack.imgur.com/Z6m2H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z6m2H.png" alt="my circuit" /></a></p> <p>I am still very fresh when it comes to circuits. This is a circuit that controls both an irrigation system and a solar tracking system. I have seen many circuits similar to mine where they would use a transistor instead of a relay, so my question is which is correct? Or do I need to have both to insure that my circuit runs smoothly?</p> <p>I would also really appreciate if you could give me recommendations to anything you see I could improve on in this circuit.</p>
Relays vs transistors
2024-03-06T18:47:22.417
705148
|microcontroller|stm32|uart|
<p>UART works by starting and ending one &quot;frame&quot; of data (typically 8 Bit) with a start and a stop bit on the signal line. As long as the receiver does not see any such start bit, it simply waits until finally the start bit arrives (the receiver might also time out at some point, but since you use HAL_MAX_DELAY, the STM will wait for ever).<br /> So <strong>without a delay</strong>, the STM immediately starts listening for the falling edge of the start bit.<br /> <strong>With the delay</strong>, the transmitter might already have started sending data when the STM finally starts listening, so you miss the data. <a href="https://i.stack.imgur.com/TP4sN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TP4sN.png" alt="enter image description here" /></a> <em>Imagesource: Chris828 on wikimedia, distributed under a CC-BY 4.0 license.</em></p>
<p>I'm using an MCU board(STM32 with HAL) and basically polling data from a device using serial protocol. The MCU sends a fixed byte array(6 bytes) to the device, and in response it receives a fixed byte array from the device(20 bytes).</p> <p>MCU &lt;---UART---&gt; Device</p> <p>The Baudrate is 9600, and the function which polls and returns the byte array is as follows:</p> <pre><code> uint8_t * ReturnInfoFromDevice(void) { static uint8_t Rx_data_Info[20]; uint8_t pollData[] = {0xBB, 0xAA, 0xD1, 0x00, 0x00, 0x00}; HAL_UART_Transmit(&amp;huart1, pollData, 6, HAL_MAX_DELAY); HAL_UART_Receive(&amp;huart1, Rx_data_Info, 20, HAL_MAX_DELAY); return Rx_data_Info; } </code></pre> <p>Now between two consecutive calls of ReturnInfoFromDevice, I add 200ms delay but something confused me regarding the UART communication in my code regarding polling data using the HAL_UART_Transmit and HAL_UART_Receive.</p> <p>As you see in my function, between HAL_UART_Transmit and HAL_UART_Receive I don't add any delay but still I receive data without any problem. On the other hand, if I add delay between HAL_UART_Transmit and HAL_UART_Receive I don't get any data.</p> <p>I was expecting the contrary, since at 9600 Baudrate byte transfer per second requires around 1ms, So in my case the total byte transfer is 20 + 6 = 26 bytes. Doesn't that mean we need minimum 26ms delay between HAL_UART_Transmit and HAL_UART_Receive?</p>
Confusion with polling data by an MCU using UART
2024-03-06T23:49:54.963
705149
|transistors|
<p>As others have said, it's a <a href="https://pdf1.alldatasheet.com/datasheet-pdf/view/100496/SANYO/2SB544.html" rel="nofollow noreferrer">Sanyo</a> (probably, they were the original manufacturer according to the Transistor Manual) <a href="https://pdf1.alldatasheet.com/datasheet-pdf/view/100496/SANYO/2SB544.html" rel="nofollow noreferrer">2SB544</a>, a 25V PNP general purpose transistor with the usual Japanese B-C-E pinout.</p> <p>These ones are the 2nd lowest (third highest) hFE bin- between 100 and 200 at 2V Vce and 50mA Ic. That is denoted by the 'E'.</p> <p>The other characters are probably date code, lot code, manufacturing site, that kind of thing.</p>
<p>I have this transistor with the <strong>E 8G</strong> and the three dots on them, can anybody tell me what its meaning is? Does it have to do with the manufacturer?</p> <p><a href="https://i.stack.imgur.com/f53tM.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/f53tM.jpg" alt="enter image description here" /></a></p>
Transistor code meaning
2024-03-06T23:57:45.350
705158
|transistors|
<p>Given the size of R145 the input on J34 is expected to be some high voltage, and that 'Q' implies an active part, the most likely part for this position is a diac.</p>
<p><a href="https://i.stack.imgur.com/FtyJr.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FtyJr.jpg" alt="enter image description here" /></a></p> <p>The letter &quot;Q&quot; shows that this is a transistor, but it only has 2 pins. Checked with diode mode and resistance mode on multimeter, both shows open circuit. Searched the marking but yielded no results. What kind of transistor is this?</p> <p>EDIT: The connection looks like this: <a href="https://i.stack.imgur.com/kxesS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kxesS.jpg" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/gD9tz.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gD9tz.jpg" alt="enter image description here" /></a></p>
Transistor with only 2 pins
2024-03-07T01:45:16.020
705202
|i2c|eeprom|
<p>Evidently, you've never heard of the Dallas <a href="https://en.wikipedia.org/wiki/1-Wire" rel="nofollow noreferrer">1-Wire protocol</a>. It allows the connection of an arbitrary number of devices to a bus, and the bus master can discover the unique identifier of each connected device.</p> <p>You can in fact purchase 1-wire EEPROMs for about $0.25 each.</p>
<p>So I have a interesting problem that someone could give their input. I'm working on a project where I have 100 &quot;devices&quot; each with its own EEPROM. The &quot;devices&quot; can be connected together in a stack up to 5. <a href="https://i.stack.imgur.com/NHgYf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NHgYf.png" alt="enter image description here" /></a></p> <p>If EEPROM has 3 or 4 bit address - eventually they will clash. If I could find EEPROM with 8 bit address I could achieve this, but I have spent many hours looking for programmable 8 bit address on EEPROM without any luck.</p> <p>One thing that I think might work would be some counter logic on the clock that would cascade the data packages down the line - I would lose speed and would be limited to fixed sized &quot;packages&quot;. But that would be fine as speed is not required in this application.</p> <p>Am I trying to solve a problem that already has a obvious solution? Maybe I'm just overcomplicating things and should add some super cheap microcontroller.</p>
Extending EEPROM I2C addressing
2024-03-07T08:55:38.917
705213
|power-electronics|control|control-system|
<p>I'm not an expert on electrical drives/resistors but your proposal to use a Kalman Filter to estimate the unmeasured temperature is not a bad idea, practicality and cost considerations aside.</p> <p>The reason I think this might be the case is that the temperature response of the braking resistor may be slower than the dynamic variations in the load on the system.</p> <p>As another user pointed out, you could just use a static predictive model to shutdown the device as soon as the instantaneous heating rate reaches the maximum continuous rate. This is probably safer but quite conservative since the true resistor temperature may be well below the critical temperature during transient (i.e. not steady-state) behaviour, which could be often in your application.</p> <p>Obviously, the best thing to do is to put a temperature sensor on the critical component, so this should be your first priority but I will assume this is not possible for some reason.</p> <p>Your concern about the unknown ambient temperature may be valid but what temperature does your braking resistor get up to? If it is very high, then differences between winter and summer ambient conditions may not be as big an error as you might think (depending on the local climate). At high temperatures, you may have to include radiative heat loss in the model.</p> <p>A Kalman filter also relies on an accurate model when predicting an unmeasured input, so you will need to get that model right. Ideally, you would estimate the dynamic model from experiments where you actually have resistor temperature measurements.</p> <p>At the end of the day, the benefits of the Kalman Filter are going to be:</p> <ul> <li>a dynamic estimate of the unknown state (resistor temperature) which might be better than an estimate based on a steady-state model</li> <li>smoothing of the estimate to reduce it's sensitivity to random measurement noise</li> </ul> <p>However, without an accurate model or ability to identify one using real measurements of the true resistor temperature, the Kalman Filter will be at least as risky as any other method.</p> <p>To evaluate whether these benefits justify the additional complexity of a Kalman Filter, I recommend constructing a simple simulation model of the system and running simulations with typical load cycles/variations, realistic measurement noises, and model errors. Simulate a Kalman Filter estimate compared to a simpler solution and see what the benefits are and how robust it is to errors in the model parameters.</p>
<p>Let's say I have an inverter fed three phase induction motor drive where in the braking phase (when the motor operates in a generator mode) the generated electrical power is dissipated in the braking resistor controlled via simple chopper.Below is a record of the voltage and current during the braking chopper operation:</p> <p><a href="https://i.stack.imgur.com/Zmaxk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Zmaxk.png" alt="enter image description here" /></a></p> <p>Due to the temperature protection implementation (in the control software of the drive) purposes I would need to know the temperature of the braking resistor (<span class="math-container">\$T_R\$</span>). Unfortunately I have no temperature sensor installed in the braking resistor. So I need to estimate the temperature in different manner. What I can exploit is the measurement of the dc link voltage (<span class="math-container">\$v_{dc}\$</span>) and the current through the braking resistor (<span class="math-container">\$i_R\$</span>).</p> <p>The idea which I have is to use the Kalman filter algorithm for the temperature estimation. To be able to do so I need to form a dynamic model for the estimation prediction. My idea was to exploit following differential equation</p> <p><span class="math-container">$$ \begin{eqnarray} \frac{\mathrm{d}T_R}{\mathrm{d}t} &amp;=&amp; \frac{1}{C}\cdot(q_{in} - q_{out}) \\ &amp;=&amp; \frac{1}{C}\cdot[v_{dc}\cdot i_R - h\cdot A\cdot(T_R - T_a)], \end{eqnarray} $$</span> where <span class="math-container">\$C\$</span> is the thermal capacity of the resistor, <span class="math-container">\$h\$</span> is the heat transfer coefficient, <span class="math-container">\$A\$</span> is the area of the resistor surface.</p> <p>As far as the estimation correction I would exploit the temperature dependency of resistance</p> <p><span class="math-container">$$ R = R_0\cdot\left[1 + \alpha\cdot(T_R - T_0)\right], $$</span> where <span class="math-container">\$R = \frac{v_{dc}}{i_R}\$</span> and the <span class="math-container">\$v_{dc}\$</span> and <span class="math-container">\$i_{R}\$</span> are the measured dc link voltage and current through the braking resistor.</p> <p>The problem which I have is how to resolve the fact that the ambient temperature (<span class="math-container">\$T_a\$</span>) in the model is also unknown for me. The only one idea which I have is to set the <span class="math-container">\$T_a\$</span> to constant value (let's say an average temperature for a given place). This approach could be usable in case the drive would be placed in some room. The opposite is truth for me. My drive is placed on open air.</p> <p>It means that there will be time instances when the average temperature will be very good estimate of the ambient temperature but in most cases there will be huge error. I am not sure whether in such a case I can still use the Kalman filter algorithm or whether the unknown ambient temperature rules out its usage. Thanks in advance for your opinion.</p>
Kalman filter for estimation of braking resistor temperature
2024-03-07T09:58:39.283
705225
|high-voltage|safety|esd|workbench|
<p>If you have two conductors separated by an insulator you have a capacitor. Charge can build up between the two conductors. There would need to be a path for current to flow to prevent that. There is also the problem of shock hazard. Your insulating mat may keep hit wires from shorting to the bench but could a person touching the bench also touch a wire? You need to make sure that any current flow through a person is severely limited, ESD wrist straps usually use a high value resistor so there’s not a direct connection to ground. GFI on your power circuits could also be helpful.</p> <p>There is a potential for severe injury or loss of life if you get it wrong. You might want to consult with a professional rather than relying on random people on the internet.</p>
<p>I own various large stainless steel benches which I'm using to sit heavy equipment (200kg+ per bench). Some of this equipment will need new electronic components i'll have to wire up, such as 120vac motors to various relays and circuit boards. Stainless steel is of course highly conductive so I want to avoid the potential for a live wire to ever make contact with the bench and to also ensure ESD safety working with the circuit boards.</p> <p>I'm relatively new to working with electronics so need some guidance. To solve the first issue I purchased a class 0 insulating mat typically made for floors and placed it on top of the bench, it offers a working voltage of 1000v. It's essentially a single 2mm layer of highly resistant rubber, unlike ESD safe mats, it does not have a conductive under layer, so I'm not sure how to approach grounding the bench and myself, I know wrist straps and a connection to the ESD safe mat bench can be used for grounding, but again this is not an ESD mat, there is no conductive under layer. I don't want to have to purchase a ESD mat to place over this existing high voltage insulating mat, I just want to figure out how to offer ESD safety for the insulating mat I've already purchased, as it was not cheap.</p> <p>Is ESD safety possible in this situation? Again all I have at the moment is a high voltage insulating safety mat placed on top of the stainless steel bench, nothing more.</p>
Balancing high voltage and ESD safety for a work bench
2024-03-07T12:35:25.127
705226
|electromagnetism|emc|emc-filtering|
<p>As Peter Smith says, the harmonics of 16MHz are visible. For peaks that aren’t a harmonic of known clock sources on the board you have to go looking. Things like buck converters tend to radiate up around 100MHz.</p> <p>EMC is a bit of a ‘black art’ - with experience you get to know what might be radiating. There’s also plenty to read on the subject.</p> <p>For horizontal and vertical - this is the polarization of the antenna connected to the spectrum analyser used for the test. You can deduce what might be radiating based on whether the peak is highest in the vertical or horizontal plane. The pcb tracks are horizontal and an inductor or cable might be vertical. Peak and average are what they say. The peak is the highest value measured whereas the average is the value averaged over time. Depending on what standard you are testing to determines which is significant. For CISPR22 it would be quasi peak. Upon looking at the report closer, it notes that the standard used is CISPR16 and the peak is ‘Q peak’ aka quasi peak. Another EMC skill is knowing and understanding the various standards.</p>
<p>I am new to EMC. Our team performed an EMC radiated emission test below is the image of the test result.</p> <p>I am struggling to understand the result. My collegue told me that the 16 MHz clock frequency is easily visible, and the product's radiation seems to cross power lines and pass through several connections from the main PCB. I am not able to see any 16 MHz in the waveform. It is starting from 30 MHz. I have few questions.</p> <p>From where they got 16 MHz?</p> <p>What you mean by peak vertical and peak horizontal?</p> <p>What you mean by average vertical and horizontal?</p> <p>Peak or average value, which one needs to be given high priority?</p> <p><a href="https://i.stack.imgur.com/yzWJd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yzWJd.png" alt="enter image description here" /></a></p>
Interpreting an EMC radiated emission test result
2024-03-07T12:36:55.853
705230
|fpga|simulink|xdc|
<p>There's two ways: look on the board schematic, look in the constraints files of example projects for the board.</p> <p>The schematic is probably easier. You'll have to look for clock sources for the FPGA. If there's only one on-board oscillator module that goes to the FPGA, that's straightforward enough. Otherwise it might be one clock from multiple clock sources, and/or from off-board pins for some module boards.</p> <p>In a Xilinx constraints file (normally .xdc), you'd be looking for the clock name amongst the pin definition constraints.</p> <p>To see a Xilinx Vivado project's constraints files, open the project, got to the Project Manager then select Hierarchy on the Sources window. That will list the project's constraints files, if they exist.</p>
<p>I'm using FPGA-in-Loop function in MATLAB/Simulink and it requires the clock pin number, if I want to choose a board without off-the-shelf support packages. How should I find out the specific pin number of an FPGA?</p> <p>I know there are documents, such as master XDC for Xilinx. But how to get the data for other FPGAs e.g., Altera boards? I don't find them in the datasheet.</p>
How to find out the clock pin number of an FPGA?
2024-03-07T12:53:25.983
705247
|load-cell|hx711|
<p>There should be a specification in the load cell datasheet showing the permissible offset (perhaps as a % of full-scale) under some specified orientation and other conditions.</p> <p>When you measure the voltage with no load it might be positive or negative, and you would normally measure that voltage (directly or after conversion to weight) and subtract it from the reading with the unknown weight applied, similarly to how you would subtract tare weight of an empty container to get the weight of the contents. The offset will vary with temperature, time and so on.</p> <p>It's common for scales to have firmware to perform an auto-zero immediately after power-up- which is why they usually accurately display zero or close to it (there's also sometimes some trickery going on for readings close to zero). If you power it up with a weight on the scale and then remove it after a few seconds it will likely read zero with the weight on, and then off-scale or negative when you remove the weight.</p> <p>In general you'd also want to calibrate the gain to get an accurate reading.</p>
<p>My load cell (and HX711) gives values like these (44~45 g is with an object put on top):</p> <pre><code>I (12955) rust_esp32_hx711: Weight: 0.027999999 g I (13955) rust_esp32_hx711: Weight: -0.0924 g I (14955) rust_esp32_hx711: Weight: -0.0756 g I (15955) rust_esp32_hx711: Weight: -0.0056 g I (16955) rust_esp32_hx711: Weight: 44.814 g I (17955) rust_esp32_hx711: Weight: 44.8364 g I (18955) rust_esp32_hx711: Weight: 44.786 g I (19955) rust_esp32_hx711: Weight: 45.429996 g I (20955) rust_esp32_hx711: Weight: 0 g I (21955) rust_esp32_hx711: Weight: 0.0924 g </code></pre> <p>Is this normal for a 1 or 5 kg <a href="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTU_gfc7mVOVtcyYGzZX4WZObO1pguD621N_Q&amp;usqp=CAU" rel="nofollow noreferrer">beam load cell</a>? If so, what the usual way to solve this issue?</p>
Is it normal for load cells (and HX711) to give negative values when there is no load applied?
2024-03-07T15:59:05.557
705269
|electromagnetism|solenoid|magnetics|
<blockquote> <p><em>What I'm worried about is that this equation doesn't consider the relative permeability of the core, the permeability of the object being lifted, or the magnetic saturation limit of the core. I couldn't find any better equations though.</em></p> </blockquote> <p>Until the object to be attracted actually moves and touches the poles of the electromagnet, the massively biggest factor is the air-gap therefore' the relative permeability of the core and, the permeability of the object being lifted are irrelevant.</p> <p>You might slightly need to be aware of the core saturation limits but in the main, the air-gap is the massive factor that largely prevents core saturation.</p> <blockquote> <p><em>Does anyone know of an equation that includes all the factors already there plus the ones I mentioned?</em></p> </blockquote> <p>There is no need for one.</p>
<p>I'm trying to make an electro-magnet and I want to figure out what core and wire I need using math instead of trial-and-error.</p> <p>I want it to produce ~1.5 newtons of force at ~1.5 inches from the magnet. The best equation I found for it was on <a href="https://calculator.academy/solenoid-force-calculator/" rel="nofollow noreferrer">this</a> website, which is: <span class="math-container">$$ F = n I^2 \mu_0\frac{A}{2d^2} $$</span> where:</p> <ul> <li><span class="math-container">\$F\$</span> is the force in newtons</li> <li><span class="math-container">\$n\$</span> is the number of turns</li> <li><span class="math-container">\$I\$</span> is the current</li> <li><span class="math-container">\$μ_0\$</span> is the permeability of free space</li> <li><span class="math-container">\$A\$</span> is the cross-sectional area of the solenoid</li> <li><span class="math-container">\$d\$</span> is the distance to the object to pull</li> </ul> <p>What I'm worried about is that this equation doesn't consider the relative permeability of the core, the permeability of the object being lifted, or the magnetic saturation limit of the core. I couldn't find any better equations though.</p> <p>Does anyone know of an equation that includes all the factors already there plus the ones I mentioned?</p>
Equation for the force created by a solenoid
2024-03-07T19:10:46.777
705289
|circuit-analysis|capacitor|analog|
<p>Analysis of a capacitive divider where the type of independent generator is not specified and with non-zero initial conditions. You can adapt it to the case of two capacitors:</p> <p><a href="https://i.stack.imgur.com/det9S.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/det9S.png" alt="enter image description here" /></a> <a href="https://i.stack.imgur.com/Kl75f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Kl75f.png" alt="enter image description here" /></a></p>
<p>This may be a stupid question, but it really confuses me. Suppose there are two capacitors connected in series like this (C0=C1=1pF, define Vx=the voltage of the intermediate node):</p> <pre><code> C0 C1 Vin -----||------||------GND </code></pre> <p><span class="math-container">\$\ V_{in} = 1 + sin(\omega t)\$</span>, which is a sin wave with a DC offset. <span class="math-container">\$\ V_x= \frac{1}{2}sin(\omega t)\$</span> according to my simulation result, but what is the explanation of this in the time domain?</p> <p>I read some posts saying that the charge on the two capacitors are the same in this case, and equals to the integral of current. I calculated <span class="math-container">\$ \frac{1}{C} \int i \cdot dt \$</span> in the simulator and found it is exactly the voltage at the intermediate node - this makes sensor for C1 because the voltage difference is <span class="math-container">\$\ V_x-0\$</span>, which is <span class="math-container">\$\ V_x\$</span> itself. However, this doesn't make sense for C0, because the voltage across C0 is <span class="math-container">\$ V_{in}-V_x \$</span>, shouldn't <span class="math-container">\$ \frac{1}{C} \int i \cdot dt = V_{in} - V_x \$</span> (according to the equation <span class="math-container">\$\ Q=C\cdot V\$</span>)?</p>
Understanding of Capacitive Voltage Divider
2024-03-07T23:37:13.893
705302
|identification|vintage|
<p>T3 is the main voltage amplifier for the circuit. The circuit gain is set by R3 and R4 (and the input impedance of T3).</p> <p>D1 is a dual diode, like two 1N914's in series.</p>
<p>This is the PCB from an Elmo Sound Monitor 912, marketed sometime back in the 1970/1980's.</p> <p>The circled component seems to be a diode of some sort. Or, at least the diode mode on a multimeter <strong>measures 0V in one direction and 1.1V in the other</strong>. The two-tone paint also seems to indicate that the polarity of whatever it is matters. And comparing it to the size of the other nearby components, it is quite a bit smaller than most through-hole components.</p> <p><a href="https://i.stack.imgur.com/s0EJ1.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/s0EJ1.jpg" alt="Unknown through-hole component" /></a></p> <p>Can anyone identify more information--like a manufacturer that made this style of component or even the name of the package--that might aid my searching?</p> <p><a href="https://electronics.stackexchange.com/questions/620111/identify-this-type-of-diode-from-the-1970s-1-3v-forward">This question</a> shows a device that appears to be a similar size but has a different paint style. The forward voltage is also in the same ballpark. Would that make this a &quot;stabistor&quot;?</p> <p>Trying to reverse-engineer the board, it's <strong>D1</strong> in this schematic:</p> <p><a href="https://i.stack.imgur.com/wW2Bn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/wW2Bn.png" alt="reverse-engineered schematic diagram of second half of Elmo Sound Monitor 912 PCB" /></a></p> <p>The signal is coming from a magnetic tape head that passes through two fairly standard BJT amplifier stages and a potentiometer voltage divider before entering this schematic through <strong>C4</strong>. It's a little unclear what the role of <strong>D1</strong> or even <strong>T3</strong> is in this situation.</p> <p><strong>EDIT</strong>:</p> <p>Several people asked: the diode forward voltage was measured in-circuit.</p> <p>And here is the complete schematic from the magnetic tape head, including the two BJT pre-amp stages:</p> <p><a href="https://i.stack.imgur.com/Qi6q4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Qi6q4.png" alt="complete reverse-engineered schematic diagram of second half of Elmo Sound Monitor 912 PCB" /></a></p>
What's this vintage diode(?) from the 1970s?
2024-03-08T00:58:34.157
705321
|arduino|can|
<p>The <em>Error Passive</em> state means that the <em>Receive Error Counter</em> (REC) and/or <em>Transmit Error Counter</em> (TEC) have reached a value greater than 127 and TEC is less or equal to 255.</p> <p>Various transmit and receive error events increment these error counters. For more detailed information, see <a href="https://caxapa.ru/thumbs/721101/CAN.pdf#page=6" rel="nofollow noreferrer">An Introduction to CAN</a> (page 6).</p> <p>If the firmware and drivers are implemented correctly, some of the most common causes I have encountered (and the ones I'd recommend checking first) are:</p> <ul> <li>Are exactly two CAN terminating resistors installed to both ends of the bus? Incorrect termination could cause all kinds of bit errors.</li> <li>Double check the bus wiring. For example, if a transmitting node is disconnected from the bus (due to a cable break or the connector not properly connecting), no node can acknowledge the CAN message, causing TEC to rise to the <em>Error Passive</em> threshold.</li> <li>Are all nodes configured to the same baudrate?</li> </ul>
<p>I set up a communication system (J1939) using two MCP2515 modules connected to two Arduino UNO boards. Then, I added a PCAN USB interface to monitor messages using PCAN View Software. Everything was fine until I connected a controller's CAN to the line. Now, I can still read messages from one Arduino in both Serial Monitor and PCAN View, but in addition some lines shows an extra message:</p> <pre><code>322.2675,,Rx,,4,BUSPASSIVE BUSWARNING. </code></pre> <p>What does this warning mean and how I can fix it?</p>
Resolving CAN Communication Issue: Decoding and Fixing 'BUSPASSIVE BUSWARNING'
2024-03-08T05:28:01.813
705330
|batteries|nimh|
<p>Nickel metal hydride batteries have a relatively high self discharge rate. <a href="https://batteryuniversity.com/article/bu-802b-what-does-elevated-self-discharge-do" rel="noreferrer">Battery University</a> says that they lose 10 to 15 percent of charge over the first 24 hours. That loss of charge will result in a lower battery voltage.</p> <p>BU provides this self-discharge rate diagram for nickel based batteries:</p> <p><a href="https://i.stack.imgur.com/tOQnn.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/tOQnn.jpg" alt="enter image description here" /></a></p> <p>Note that the diagram is charge state, not voltage. Voltage is related to charge state, but not in a simple way. About all you can say is that lower charge means lower voltage.</p> <p>In other words:</p> <p>Yes, it is to be expected that the voltage slowly drops with NiMh batteries.</p>
<p>I have a battery pack for a circa 2008 Black &amp; Decker 9.6 V electrical screwdriver. It was not holding a charge so I replaced its batteries. It had eight NiCd 1200 mAh batteries. I replaced them with new NiMh 1500 mAh ones (these were available to me). I charged them with the original charger for 6 hours. I measured the battery pack open circuit voltage at 10.96 V afterwards.</p> <p>Next day I repeated the measurement, and it was 10.75 V. I never used the device and in fact, did not install the battery pack on the device.</p> <ul> <li>Measurement two days after charging: 10.65 V</li> <li>Measurement five days after charging: 10.56 V</li> </ul> <p>Is this normal for the type of batteries used?</p> <p><a href="https://i.stack.imgur.com/aZiOv.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aZiOv.jpg" alt="enter image description here" /></a></p>
Battery pack voltage keeps dropping without use
2024-03-08T08:27:41.727
705338
|connector|soldering|usb-c|mechanical-assembly|
<p>If it was a personal project I would consider adding epoxy all the way around the connector. This also requires a connector that doesn't have any internal holes for the epoxy to leak into, and probably requires a mold to keep the epoxy from flowing away from the connector while it sets. This might also be possible in a commercial project but I would be cautious about the extra assembly steps required.</p>
<p>Many PCB-mounted connectors, in my case a USB-C have no specification regarding mechanical integration. Often, the mechanical durability seemingly relies on through-hole (sometimes even surface mount) pins. This feels very sketchy as both planar and angular mechanical stress from plug and cable will work away at these solder joints. Are there some common praxis or trade secrets to integration of such connectors?</p> <p>It must be a very common consideration considering phones, laptops etc.</p>
Ways of improving USB-C mechanical durability
2024-03-08T10:15:29.007
705350
|operational-amplifier|simulation|multisim|non-inverting|
<blockquote> <p><em>In this simulation, i get around Vout = 11.2, when Vin = 2, and i dont know why the vin and vout is out of phase.</em></p> </blockquote> <p>Your op-amp is fed from a +12 volt and -12 volt supply. This means that the biggest output peak that it can produce is 12 volts and, this is further limited by the output transistors inside the op-amp.</p> <p>In addition, your op-amp is slew-rate limiting and this will cause an unwanted phase shift. This is what you see in your oscilloscope image.</p> <p>The likely reason LTspice delivers an output waveform you anticipated is down to the simplistic op-amp &quot;model&quot; that you used. I'm referring to the mathematical &quot;model&quot; used by the simulator. A lot of models are too simple and you get strange things happening (as per what you saw).</p>
<p>I am doing a simulation in multisim to simulate an non inverting amplifier, but i have gotten values that is not what intended. From what i know, the gain for non inverting amplifier is Va = 1 + Rf/Rin. In this case, Va = 1 + 10k/1k = 11, then the Va = Vout/Vin = 11. I can get Vout = 22. In this simulation, i get around Vout = 11.2, when Vin = 2, and i dont know why the vin and vout is out of phase. Before simulating in multisim, i did the simulation in LTSPICE, and the outcomes are better to my knowledge, as i get the Vout around 22, and the Vout and Vin are in phase. <a href="https://i.stack.imgur.com/JtJ7i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JtJ7i.png" alt="My non-inverting circuit" /></a></p> <p><a href="https://i.stack.imgur.com/ANQHX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ANQHX.png" alt="simulated oscilloscope" /></a> <a href="https://i.stack.imgur.com/nKrU9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nKrU9.png" alt="transient analysis" /></a> <a href="https://i.stack.imgur.com/F0FoW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F0FoW.png" alt="Schematic diagram to be simulated" /></a> <a href="https://i.stack.imgur.com/8uCe1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8uCe1.png" alt="Earlier simulation in LTSPICE" /></a> <a href="https://i.stack.imgur.com/9QNNK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9QNNK.png" alt="Earlier transient analysis in LTSPICE" /></a></p>
Non-inverting amplifier weird Vout values
2024-03-08T13:16:59.703
705363
|pcb-design|switches|ethernet|rj45|rp2040|
<p>At least one difference to the reference schematics is the Wiznet transformer CT connection on pins 2 and 7. It should be connected to 3.3V.</p> <p>The TX pair of a chip usually connects to TX pair on connector. The RTL chip supports Auto-MDIX to swap it, even if the Wiznet doesn't. You have wired them weirdly. Chip TX should be wired to RX of another chip.</p>
<p>I've built a PCB connecting one of the ports of the RTL8363NB-VB-CG to the W5100 mimicking a ethernet cable on board, I used a RP2040 a Wiznet 5100S-L and the Realtek RTL8363NB-VB-CG.The problem that I'm facing it even though I can easily start up the RP2040 and program the W5100, I observe the activity LED and the Link LED of the W5100 constantly on, and no response to ping (with the proper sw tested on a commercial w5100 board) connencting to one of the other available ports on the Realtek side.</p> <p>here the schematics</p> <p><a href="https://i.stack.imgur.com/4cZoj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4cZoj.png" alt="RP2040 SCHEMATICS" /></a></p> <p><a href="https://i.stack.imgur.com/xLm4G.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xLm4G.png" alt="W5100 SCHEMATICS" /></a></p> <p><a href="https://i.stack.imgur.com/UMWQE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UMWQE.png" alt="REALTEK SCHEMATICS" /></a></p> <p>I know that RP2040 and the W5100 are working fine, I can program them and they behave as expected (proven via oscilloscope and leds).</p> <p>EDIT 1: I've used two transformers H1102NLT back to back to simulate the two rj45 connections on the signal path.</p>
Wiznet W5100 and Realtek RTL8363NB-VB-CG board issue
2024-03-08T14:33:45.103
705369
|operational-amplifier|power-electronics|thermistor|
<p>The thermoresistance value at 100°C is correct. The thermistor is a non-linear device, as can also be seen from what TI shows in the relevant manual:</p> <p><a href="https://i.stack.imgur.com/Aa29k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Aa29k.png" alt="enter image description here" /></a> About thermistors from TI see: <a href="https://www.ti.com/lit/an/snoaa12/snoaa12.pdf?ts=1709904262202&amp;ref_url=https%253A%252F%252Fwww.google.ch%252F" rel="nofollow noreferrer">https://www.ti.com/lit/an/snoaa12/snoaa12.pdf?ts=1709904262202&amp;ref_url=https%253A%252F%252Fwww.google.ch%252F</a></p> <p>My calculation of output voltage:</p> <p><a href="https://i.stack.imgur.com/hnDRh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hnDRh.png" alt="enter image description here" /></a></p> <p>By placing the circuit in a feedback loop it is possible to obtain a linear response vs. x.</p>
<p><a href="https://i.stack.imgur.com/eZ1as.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eZ1as.png" alt="circuit" /></a></p> <p>For the circuit shown in Fig. 3, the bridge is balanced when T=100 C. That is R1=R2=R3=R4=10k ohm. The thermistors are matched, and their resistance related to temperature by <code>RT=4130.65+0.15T^2</code> where T is the temperature in Kelvin. Determine Vo for the following temp: (i) T=120 C (ii) T=80 C</p> <p>I'm confused, because when evaluating the RT, using T=100C, it's equal to 25016.79 ohm, am I missing something?</p>
What's the output voltage
2024-03-08T15:46:55.437
705372
|pcb-design|emc|pcb-layers|emi-filtering|stack-up|
<blockquote> <p>Note: I have read several posts on layer stack-ups. They mainly focus on signal crosstalk, SI and EMC. I couldn't see design suggestions for low EMI susceptivity from other nearby devices.</p> </blockquote> <p>As your question regards differences between your concerns and existing posts, I will take this as invitation to explain the differences, or better explain why: why those posts concentrate on these particular subjects, and why you shouldn't be worried about the stackup.</p> <p>Which, to not just hint at, but make explicit; my basic answer is:</p> <p>It doesn't matter, don't worry about it.</p> <p>Now, to explain why.</p> <p>Stackup matters most at high frequencies. Frequencies on the order of trace lengths, board dimensions, components, etc.</p> <p>That is, note that an EM wave flowing through space, or guided by metal or dielectric structures -- a trace is a transmission line is a waveguide, which literally, guides waves, as waves travel largely in the space between conductors, hardly within them at all, so we use this word quite literally -- the wave has some frequency, or harmonics, or rise time, and as it travels at the speed of light [in the local medium], there is necessarily a corresponding distance, a wave<em>length</em>, and there is a corresponding &quot;electrical length&quot; of some given geometry, traces on a board, wires in a harness, etc.</p> <p>When the electrical length of a structure, is comparable to the wavelength of a signal, expect transmission line or wave interactions (implied: heightened EMC concerns).</p> <p>In this high-frequency regime, if we have traces routed on the outside of the board (microstrip transmission line geometry), there is a small but nonzero coupling factor between that trace, and free space: radiation. Which reciprocally means both the potential for emissions from internal signals getting out, and susceptibility to waves from the outside getting in. The coupling factor depends on trace geometry, length, and frequency, and generally increases as frequency goes up.</p> <p>We can reduce the coupling factor of microstrip, by burying it under a shield; a trace surrounded on all sides by metal, is called a stripline geometry.</p> <p>So these are the two alternatives offered. By designing a whole board with ground planes inside or out, you are making a decision to use just microstrip, or just stripline, for the majority of traces on the board.</p> <p>At a glance, you would suppose microstrip is worse, because -- as I just said, it has some coupling factor, whereas the other is shielded. This is true. But it matters, by how much.</p> <p>The kicker is this. You're worried about low frequencies. Quite low as EMI goes, and potentially even below frequencies where the board provides any shielding benefit at all.</p> <p>The difference between microstrip and stripline is important at high frequencies, where signal integrity and crosstalk are also concerns. It's no accident these topics go together; they are all important at the same time. But this is largely a concern in the 10MHz+ range, and the difference for lower frequencies, given a responsibly laid design in either style, is minimal.</p> <p>Hence my answer above: it doesn't matter, don't worry about it.</p> <p>I would even suppose the outer-grounds design is worse, for the following reason: it necessarily has more holes in it, because you cannot avoid holes in the ground plane where components, their holes/pads, and all the vias joining to inner signal layers, lie. It also can't be very much better than microstrip, because while you can save the coupling factor between traces and free space, you cannot do anything about the coupling factor between free space and the components themselves.</p> <p>There is a &quot;secret&quot; 3rd option: pour ground on all layers, stitch them together with liberally placed vias, and route signals where it is most practical to put them. This way, you can have ground fill underneath components, and above long trace routes, and short traces (between adjacent components, say) are... up to you, I guess, but as coupling factor depends on length relative to frequency, a few mm, cm even, routed along the surface won't exactly matter. But by extension, a few 10cm probably won't matter either -- and now that basically encompasses a whole board (asserting some sort of hand-waving average size that may or may not apply here). Which is basically to say, go ahead and microstrip the whole thing, it won't matter.</p> <p>But where things get really nasty are at the low frequencies.</p> <p>As low as a few kHz, there's simply nothing a PCB alone can do about it. At these frequencies, copper foils are reasonably transparent to magnetic fields. The only thing you can do is filter signals where they come in, use differential design and routing techniques if possible, and hope for the best.</p> <p>You can restore shielding effectiveness by using heavier metal. Heavier PCB often isn't practical, but an enclosure made of ~1mm thick aluminum or steel, reflects or absorbs magnetic fields down to quite low frequencies (some kHz; even further in the case of annealed mild steel), is reasonably priced, and has obvious structural benefits (at least, assuming that structure is valuable for the application). If you have shielded cables, and bond them to the enclosure so that induced noise currents are shunted around the signals and electronics within (within both cable and enclosure), you gain the best possible chance of rejecting EMI.</p> <p>Further: since the PCB, enclosure, cable shields, everything really, will be &quot;leaky&quot; to magnetic fields at low frequency, insist upon differential connection for all signals you possibly can; only the lowest bandwidth signals (100s Hz, maybe?) can be single-ended (as interference can simply be filtered out). Using shielded twisted pair cabling, the shields are effective at high frequencies, providing significant rejection of ambient noise (operation at or above 50V conducted or 50V/m radiated should be no problem, with responsibly-joined shields, metallic connectors, etc.), while the twisted pairs reject incident magnetic fields, ground loop, etc. You will likely need special transceiver circuit designs to support this (e.g., diff amps, signal isolators), but a confident and reliable solution can indeed exist.</p> <p>Now, whether any of these are actually motivating, are real requirements, in your application -- we have no idea. You could gather some instruments and measure field strength and spectrum in some example sites. You could measure ground-loop voltage between prospective cabling, or ground-loop current between grounds. You could look up standards typical for the environment, or what standards other (related? competing?) products follow.</p> <p>Most likely, it is not nearly as bad as you imagine it to be -- industrial sites can be brutal, but they still need to work, and it's rare that some VFD is discharging full-peak switching edges directly across your device, the connected sensors, comms cables, whatever. (Granted, there are definitely ways that can happen, whether intermittently as in fault conditions, or due to degradation of shielding (e.g. loose conduit grounding?) or actually-bad (probably, hopefully, illegal) wiring..! But, perhaps your equipment isn't intended to suffer -- let alone survive -- such abuse, either? Sometimes, failure <em>is</em> an option!)</p> <p>But also, that it will probably be worse than you expect, but <em>in certain specific ways</em> that are hard to anticipate, especially when you don't know what to look for. Well, this is simply the nature of the subject; EMC is complex, and considerations are holistic, i.e. you potentially need to take into consideration everything connected, and nearby, to properly assess an EMC environment. Which is further reason (albeit a more heuristic one) why I offer the do-not-care stance: the likely difference is so small, while the level of understanding required to make that decision is so vast, it seems very unlikely that such a difference would prove valuable here, given the effort required.</p> <hr /> <p>Finally, a somewhat more managerial or psychological perspective:</p> <p>Consider your situation, and what you're asking about. You want to make a thing. You want the best for your creation, you hope it works right the first time, or with minimal follow-up work. You hope it doesn't take a dozen revisions to complete. You dread it might. So you want to know the best practices. That's very wise, and understandable.</p> <p>You are also aware that this is a complex topic; electronics, in general, goes deeper than anyone has so far been able to look, I suppose you could say; but even fairly pedestrian technology contains (top to bottom) more than any one person can fit inside their head. Not that you need to know every possible detail to put together a board, it's enough to know the datasheets and some theory; but board-level design, too, takes many years to master (and, I would dare say, anyone who says they've mastered it, definitely hasn't..!). So you can at least get a feeling that, mastery isn't going to be built through rules-of-thumb and (simple) best-practices alone.</p> <p>My warning is this: beware of &quot;bikeshedding&quot;. This is the habit of, committees for example, to sometimes concentrate on relatively trivial details (&quot;what color do we paint the bike shed?&quot; &quot;what siding should it have?&quot; etc.), while the important structure or technical detail (&quot;how big?&quot; &quot;where do we place it?&quot; &quot;how many/what kinds of bike racks does it need inside?&quot;) or other hard work (potentially, controversial topics that no one in the group wants to raise -- &quot;do we need to evict someone from that site to place it there?&quot;) goes neglected. I say committees, but it affects anything from individuals, to groups small and large, and probably other more abstract decision-making systems too.</p> <p>And, mind, not to assert that you aren't working on other things too; just to say, beware of holding up this one step (a PCB layout) over such a decision.</p> <p>Now, much as I might like to, I still won't say to <em>avoid</em> rules of thumb and simple-best-practices; but, just be mindful of them. They aren't hard and fast, they are often wrong, and there are many situations to which they do not apply. Concentrate on the whole picture: you're bringing a design to fruition, not just routing a PCB.</p> <p>And yeah, it's easy to say that, yet oh-so-devilishly-hard to actually do -- but, I think, there are still some things the novice can do to help avoid these traps.</p> <p>The solution -- at least, one I think -- is to <em>embrace failure</em>. Or rather, the potential for it; the unknown. Yes, you want your project to succeed; and perhaps you are under some pressure for it to -- but until you are an expert in the field, there's simply no way to even begin to guarantee that; if your boss expects perfection, your boss is a fool. (I'm making assumptions about circumstances here, of course, which may not be applicable at all; but likely there are some readers out there to whom this applies.)</p> <p>Put another way: yes, there are differences between these layout techniques, but (as should be clear by now) there is no strict ranking. There may be situations to employ one, favorably, over the other -- but until your skills are advanced enough to identify those situations; how would you even know?</p> <p>There is a certain confidence, a sort of nihilistic freedom, in embracing uncertainty: when you simply don't know what to do, when you don't know how to weigh a decision, rather than be stuck in analysis paralysis -- just do it, pick one and see if it works out! At worst, you will have a starting point, a platform to probe and debug on. Even if it turned out a bad idea, you can still say, given your state of knowledge at the time, it was among the best possible decisions you could make.</p> <p>Even if the board ends up trashed, remember it's not wholly wasted effort: you still honed your circuit design and layout skills, and learned at least one way <em>not how to do</em> something -- not that a negative result is very informative, but we can try to draw some more positives from it: for the next run, strategize ways to discover more information, and to make it easier to discover -- add probe points, break down the circuit into manageable building blocks, vary parameters (say it's a power switching stage, test it at low voltage and low current first, then increase each one in steps until you verify the circuit is behaving as expected), etc.</p> <p>As for business related aspects -- managing uncertainty is part of the process, of course. Perhaps you don't have much pull on the project design or management side, I don't know (or, if this is even a work-related question as such!), but to the extent you can inform them of uncertainty, and to the extent they're receptive to better predictions and more lenient budgeting -- that's ultimately a win for everyone. Or, turn it around: if failure is simply not an option, if the timeline is too tight, make it clear that those expectations are unrealistic as-is, and they will need to spend more to meet them; an outside consultant or contractor could be brought in, for example: a subject expert who can identify the environment, the specifications to suit it, and circuit design methods to implement it.</p> <p>And, yes, this assumes one has the freedom to do so; there are the situations where one isn't at liberty to second-guess the higher-ups. There is still, perhaps, a little bit of nihilistic comfort in this -- emphasis on &quot;little&quot;, mind, but consider: if your boss's expectations were wildly beyond your capability to begin with, it's probably inevitable that you were going to get fired by them anyway, and probably for reasons far more trivial than already doing your best. Your best bet in such a situation, might be to lay low, not cause a fuss, and slow-walk the inevitable demise of the project; indeed in that case, bikeshedding might lead to useful yak-shaving; for which &quot;useful&quot; now has a very different target (your success) than where we started (project success), hah.</p> <p>Cheers and good luck!</p>
<p>I plan to design a 4-layer board that will work on an industrial machine. This machine has AC motors driven by commercial AC drives on it. Since the earth ground is very weak at the place, they radiate a lot of noise to the chassis as multiples of 3kHz, which can couple to my PCB. My board will have a 48MHz MCU evaluating 3 ADC signals, some PWM signals for LEDs, I2C, USART. There will be a 1A fuse, a common mode choke, zener regulator, decoupling capacitors at the PCB power connector input, local decoupling capacitors at IC power pins, RC low pass filters on analog signal power throughout the board.</p> <p>At this point I am undecided whether to use the stack-up <strong>GND-PWR/Signal-PWR/Signal-GND with via stitching along the PCB edges (essentially to create a Faraday cage)</strong> or <strong>PWR/Signal-GND-GND-PWR/Signal</strong>. Which one would be best for lowest EMI susceptivity?</p> <p>Note: I have read several posts on layer stack-ups. They mainly focus on signal crosstalk, SI and EMC. I couldn't see design suggestions for low EMI susceptivity from other nearby devices.</p>
What is the best 4-layer stack-up for lowest EMI susceptivity?
2024-03-08T16:12:59.947
705381
|control-system|transfer-function|block-diagram|
<p>It looks like you took what I would consider to be the best (similar) path: -</p> <p><a href="https://i.stack.imgur.com/xzShz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xzShz.png" alt="enter image description here" /></a></p> <p>I'm sure you can double check your answer against mine if you took the final stages yourself. Oh, here's a couple more steps: -</p> <p><a href="https://i.stack.imgur.com/NgtIv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NgtIv.png" alt="enter image description here" /></a></p> <p>Sorry about the error. The next stage is this: -</p> <p><a href="https://i.stack.imgur.com/IO3uw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IO3uw.png" alt="enter image description here" /></a></p> <p>This will produce the same answer that you got.</p>
<p>I have this Block Diagram and I need to simply it. But I'm still confused and this is my progress currently. I don't know is this correct or not. Maybe someone can help me.</p> <p><a href="https://i.stack.imgur.com/P88BM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P88BM.png" alt="Block Diagram" /></a> <a href="https://i.stack.imgur.com/8LZOi.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8LZOi.jpg" alt="Part 1" /></a> <a href="https://i.stack.imgur.com/CTmDX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CTmDX.jpg" alt="Part 2" /></a></p>
Complex Block Diagram Reduction
2024-03-08T17:06:31.427
705389
|pcb|identification|connector|
<p>Try and measure the pad pitch, it can be either 0.5 or 1mm. The vendor is Wurth Elektric, and here is a link to the 30 position, 0.5mm variant: <a href="https://www.digikey.com/en/products/detail/w%C3%BCrth-elektronik/687330124422/2811180?utm_adgroup=FFC%2C%20FPC%20%28Flat%20Flexible%29%20Connectors&amp;utm_source=bing&amp;utm_medium=cpc&amp;utm_campaign=Shopping_Product_Connectors%2C%20Interconnects_NEW&amp;utm_term=&amp;utm_content=FFC%2C%20FPC%20%28Flat%20Flexible%29%20Connectors&amp;utm_id=bi_cmp-420511935_adg-1299623108470404_ad-81226519274362_pla-4584826056668136:aud-813320050_dev-c_ext-_prd-2811180&amp;msclkid=e7af8ff6f03a11d461d0ea1da7cdd446" rel="nofollow noreferrer">https://www.digikey.com/en/products/detail/w%C3%BCrth-elektronik/687330124422/2811180?utm_adgroup=FFC%2C%20FPC%20%28Flat%20Flexible%29%20Connectors&amp;utm_source=bing&amp;utm_medium=cpc&amp;utm_campaign=Shopping_Product_Connectors%2C%20Interconnects_NEW&amp;utm_term=&amp;utm_content=FFC%2C%20FPC%20%28Flat%20Flexible%29%20Connectors&amp;utm_id=bi_cmp-420511935_adg-1299623108470404_ad-81226519274362_pla-4584826056668136:aud-813320050_dev-c_ext-_prd-2811180&amp;msclkid=e7af8ff6f03a11d461d0ea1da7cdd446</a></p>
<p>I had opened my Rotimatic machine for some repairs. I was taking pictures along the way of things that I unplug. While putting it back together, I realized that I am missing the connector the FFC (I think). Can anyone guide me to find the replacement? What kind of a connector I am looking for and where should I buy it from?</p> <p>This is the picture before I took it apart:</p> <p><a href="https://i.stack.imgur.com/ozewH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ozewH.jpg" alt="enter image description here" /></a></p> <p>And this is the picture now:</p> <p><a href="https://i.stack.imgur.com/XQarL.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XQarL.jpg" alt="enter image description here" /></a></p>
Lost my connector
2024-03-08T18:12:18.237
705390
|serial|wiring|transmission-line|rs485|modbus|
<p>There's two wires at each terminal because it made sense to whoever designed the system at a time. It's probably because the nature of the RS-485 standard that you'd want two wires going to each connection.</p> <p>You'd need to show the wiring diagram of the whole system for anyone to be sure, but RS-485 is usually used for multi-drop systems.</p> <p>So a typical system that uses RS-485 to communicate will be hooked up as shown, with any number of devices that are all communicating on one shared pair of wires.</p> <p><img src="https://i.stack.imgur.com/3gaoB.png" alt="schematic" /></p> <p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2f3gaoB.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p> <p>Your pictures with two wires to each RS-485 port indicate that the system wiring is designed to reflect that diagram.</p> <p>Running two wires to each terminal like that is probably done because it makes it easier to wire, and because it makes the wiring easy to inspect.</p> <hr /> <p>Note that there's more that needs to be built on top of this: usually the communications is asynchronous serial, with a protocol built on top of that so that there's only ever one box that's trying to transmit at a time while still insuring that each box gets a chance to communicate when it needs to.</p>
<p>I want to connect the energy meters of our clients to a gateway so that the gateway can communicate with the meters using Modbus. I have visited several electrical rooms that have gateways installed and inspected the wiring in each energy meter. Every energy meter that support RS485 have two wires connected to each A(+) and B(-) terminals of the RS485 port (See images below). The gateway to which these meters are connected though have only one wire connected to each of their RS485 terminal.<br /> My question is why are two wires connected to each terminal of the meters' RS485 port? Isn't one enough?</p> <p><a href="https://i.stack.imgur.com/duAuO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/duAuO.jpg" alt="enter image description here" /></a> <a href="https://i.stack.imgur.com/ITbYs.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ITbYs.jpg" alt="enter image description here" /></a></p>
Why are there two wires connected to each terminal of the RS485 port in energy meters
2024-03-08T18:24:27.807
705392
|voltage|power|capacitor|
<p>Let the voltage and current of capacitor be <span class="math-container">\$v(t)\$</span> and <span class="math-container">\$i(t)\$</span> respectively. The main equations are <span class="math-container">$$p(t) = v(t)i(t) \ \ \text{and} \ \ i(t)=C\frac{dv(t)}{dt}$$</span> We are interested in the case that <span class="math-container">\$p(t) = K \gt 0\$</span>. By substitution we have <span class="math-container">$$K = Cv(t)\frac{dv(t)}{dt} \tag{1}$$</span>Multiplying both sides by <span class="math-container">\$dt\$</span> and integrating yields <span class="math-container">$$Kt =C\frac{v^2(t)}{2} + C_0 \tag{2}$$</span>where <span class="math-container">\$C_0\$</span> is a constant which depends on the initial condition. If we assume <span class="math-container">\$v(0)=0\$</span> then <span class="math-container">\$C_0 = 0\$</span>. So in this case, the solution for <span class="math-container">\$v(t)\$</span> is <span class="math-container">$$v(t) = \pm\sqrt{\frac{2K}{C}t}$$</span> If you are uncomfortable with multiplying by <span class="math-container">\$dt\$</span>, recall that <span class="math-container">\$\frac{d}{dt}(v^2(t)) = 2v(t)\frac{dv(t)}{dt}\$</span> and use it in the equation <span class="math-container">\$(1)\$</span>. The result should be same as <span class="math-container">\$(2)\$</span>.</p>
<p>I know how long it takes to charge a capacitor given constant voltage (that's the first thing everyone learns about capacitors). In my search to answer this question for constant power, I discovered the answer instead for constant current <a href="https://electronics.stackexchange.com/questions/270493/what-is-the-formula-for-charging-a-capacitor-with-constant-current">here</a>.</p> <p>My first thought was <span class="math-container">\$Q=CV\$</span> and <span class="math-container">\$I=C\frac{dv}{dt}\$</span> and <span class="math-container">\$P=IV\$</span>. You can combine all these formulae and cancel the two <span class="math-container">\$V\$</span>'s to get <span class="math-container">\$Q=\frac P{\frac{dv}{dt}}\$</span></p> <p>It was at this point that I realized I had no idea what the heck this equation was supposed to mean. I get what <span class="math-container">\$P\$</span> is, but where do I get <span class="math-container">\$\frac{dv}{dt}\$</span>? So I thought &quot;maybe I should have rearranged it differently&quot;. Perhaps like this: <span class="math-container">\$Q=\frac{CP}{I}\$</span></p> <p>That at least makes sense, because it now depends on the capacitance of the capacitor. But where do I get the current to plug into this equation? I want power to be constant, so voltage and current are going to change.</p> <p>I understand I could get <span class="math-container">\$I\$</span> or <span class="math-container">\$V\$</span>if I chose a specific configuration of battery cells in parallel or series. But will that make a difference in the total time it takes to charge the capacitor? (I could use boosters to up the voltage and lower current or vice versa, so it seems the relevant thing is the power, not the specific battery configuration)</p> <p><strong>motivation:</strong></p> <p>This question came up because I want to charge a capacitor in a very short period of time, so I need to know how large of a battery I need. I can get the power density of LiPO battery's, multiply by the power will give me the weight of the battery.</p> <p>This question also seems apt because in &quot;the real world&quot;, where ever that is, neither voltage nor current are constant. If a battery supplies &quot;a voltage&quot;, but you short it, the voltage between the terminals will drop, because there is some internal resistance, so it's not really supplying that voltage. Similarly, if something supplies &quot;a current&quot; to something like a capacitor, well... the capacitor will act more and more like an open circuit as it charges, until it explodes and literally becomes and open circuit. So while constant current and constant voltage equations are &quot;good enough&quot; for situations when things are <em>almost</em> constant, it will never be accurate when things vary.</p>
How long does it take to charge a capacitor given constant power?
2024-03-08T18:41:59.053
705397
|capacitor|decoupling-capacitor|
<p>The purpose of a decoupling capacitor is to present a low impedance to AC voltage riding on a DC voltage. In this case the DC is the 12 V supply, the AC is any noise or transients on the DC supply.</p> <p>A capacitor will block DC and pass AC, so if you put one across the supply leads it will have no effect on the DC, but it will act like nearly a short circuit for AC depending on the frequency, the lower the frequency the larger the capacitor needs to be. A nanofarad capacitor might be good for RF frequencies, for audio or line frequencies (50/60 Hz) it needs to be microfarads, and these will tend to be polarized, you have to connect them positive to positive, negative to negative.</p> <p>If your capacitor popped there could be several reasons. It could be rated at too low a voltage, but at 12 V it’s unlikely. It could be a bad capacitor, electrolytics have a shelf life, if it was an old one it could fail. More likely it had the polarity reversed, either by connecting it the wrong way around, or by connecting an AC power adapter instead of a DC adapter (you’re using a battery so it’s not an AC adapter, but I just want to add that for completeness).</p>
<p>I'm following a tutorial on how to control a stepper motor, and it instructs me to place a capacitor across a 12V DC power supply, as shown at the top of the diagram. I've seen explanations for how this doesn't create a short circuit and ought to work, but when I built the circuit as suggested by the diagram and instructions, the capacitor just popped, which kinda matches my intuition. In my circuit, I used a 12V DC battery as the power supply.</p> <p>I'm a non-EE student working on a personal project, and I'm struggling to get my head around using capacitors in this way and how to perform the circuit analysis. How is a decoupling capacitor meant to be placed in a circuit like this? Any help is appreciated.</p> <p><a href="https://i.stack.imgur.com/akpLj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/akpLj.png" alt="enter image description here" /></a></p>
How do I implement the decoupling capacitor in this diagram?
2024-03-08T19:09:09.293
705416
|sensor|soldering|temperature|cables|rtd|
<p>There's no problem with soldering to splice the wires. Just avoid adding mismatched length (a few cm won't matter) and match up the colors so the lead resistances are reasonably well matched.</p>
<p>I have a 3 wire RTD sensor (Pt100). The leads coming off of it are not long enough to reach our temperature controller. I bought some RTD extension cable (3 wire) from the same company.</p> <p>Is it okay to use solder to connect the 3 wire RTD extension cable to the 3 leads on the RTD sensor? Or is this poor practice and would it meaningfully affect the temperature measurement accuracy? The other option would be to make sure I place 3 pin RTD connectors on either side of the cables instead of just soldering.</p> <p>For our purposes we only need +-1 C in accuracy (and the RTD's are Class A) so I highly doubt this would make a difference, but thought I would ask and confirm.</p>
Using solder to extend RTD cable?
2024-03-08T22:05:39.533
705424
|arduino|avr|attiny|attiny85|
<p>What you listed (0x62, 0xDF, 0xFF) are the factory settings for fuses. There is no need to program them to that values because that's what they should be set to out the box.</p> <p>Now, assuming that the fuses were for any reason programmed incorrectly, there can be 3 culprits:</p> <ul> <li>The ATtiny85 has a SPIEN fuse bit which disables SPI programming, but the datasheet lists this bit as inaccessible during SPI programming so this is likely not the issue.</li> <li>The more likely possibility - the RSTDISBL bit, which disables the RESET pin. This can be set by standard SPI programming.</li> <li>Lastly, if the CKSEL bits are set to use an external clock, which is not present, the chip will be frozen. If you can verify that any code is running after programming, this can easily be ruled out.</li> </ul> <p>If either of these apply, the only way to program the chip is using high-voltage programming (see section 20.6 in the datasheet)</p> <p>There are also 2 lock bits which can be set by programming, which disable access to the memory. This, however to my knowledge should not disable the programming interface and a chip erase will unlock the chip again.</p> <p>What you can do is try to flash your program without touching the fuses. This can be done using avrdude directly in command line (-U flash:w:&lt;your_hex_file&gt;:i). There's plenty of tutorials and documentation for this so I won't list the details. If this still causes the issue, it's likely that the chips (or perhaps the programmer) you have are either defective or counterfeit.</p>
<p>I am using a tiny AVR programmer to program code specifically this one, <a href="https://rads.stackoverflow.com/amzn/click/com/B00B6KNJRY" rel="nofollow noreferrer" rel="nofollow noreferrer">https://www.amazon.com/dp/B00B6KNJRY?psc=1&amp;ref=ppx_yo2ov_dt_b_product_details</a> , I can successfully upload code onto a blank IC however if I need to make changes or upload a different code to the same IC I get an error avrdude: initialization failed, rc=-1</p> <p>I'm sorry I am new to this I set the internal clock to 1MHz using the Arduino IDE. How would I set up the fuses such that I am able to to reprogram. If you recommend using a different IDE I can use whatever that is as well</p> <p>This is what I found inside the package I am using to program using ArduinoIDE ATtinyX5.menu.clock.internal1.bootloader.low_fuses=0x62 ATtinyX5.menu.clock.internal1.bootloader.high_fuses=0xdf ATtinyX5.menu.clock.internal1.bootloader.extended_fuses=0xff</p>
ATTiny85 won't reprogram
2024-03-09T01:43:15.647
705432
|current|wire|awg|
<p>Well, let's see here...</p> <p>Assume equal temperature rise, long enough wire that heat sunk through the ends doesn't count, and whatever ampacity the nominal size / type corresponds to.</p> <p>Power dissipation depends on surface area, so, tracks with diameter.</p> <p>Ampacity depends on allowed power dissipation and cross-sectional area (and resistivity, which we'll also say is the same in both cases; tubing is usually high-purity copper, e.g. 110 alloy).</p> <p>Tubing must be lower ampacity than wire of the same OD, because there's less material; but higher than wire of the same cross section, because there's more dissipation.</p> <p>The most common, unspecified &quot;copper tubing&quot; will be this product and similar: <br /> <a href="https://www.mcmaster.com/8967K88/" rel="nofollow noreferrer">General Purpose Copper Tubing, 1/4&quot; OD, 0.032&quot; Wall Thickness, 8967K88 | McMaster-Carr</a> <br /> It is widely used for water, compressed air, pressurized fluids, etc., and widely stocked in hardware stores, industrial supplies, etc.</p> <p>which has a cross-section of 14.14 mm<sup>2</sup>. Referring to <a href="https://overheadtransmission.southwire.com/wp-content/uploads/2017/06/XTEInterfaceServlet.pdf" rel="nofollow noreferrer">Bare Copper Wire and Cable | Southwire Company</a>, this is between 5 and 6 AWG (16.76 and 13.3 mm<sup>2</sup> respectively). 2 AWG has an OD of 0.2576 in (close enough), area 33.6 mm<sup>2</sup>, and is rated 225A at 75°C, outdoors/overhead condition.</p> <p>To dissipate the same heat, but with 33.6/14.14 times less area, requires square-root the area ratio, or 146A. Round it to 145A for convenience.</p> <p>In case the alloy differs, C11000 and C12200 copper alloys are typically 85% of annealed high-purity copper, but notice wire isn't usually annealed, but half- to full-hard drawn, which costs it a few points as well; I would expect resistivity within 90% of equivalent wire. Call it 130A if you're feeling cautious. Or lower for a lower operating temperature, poorer air circulation, etc. (Note that the comparable ampacity for plastic-jacketed wire in an installation condition (in walls, conduits, etc.) is more like 75A; see <a href="https://en.wikipedia.org/wiki/American_wire_gauge#Tables_of_AWG_wire_sizes" rel="nofollow noreferrer">American wire gauge | Wikipedia</a>.)</p> <p>Interestingly, the ampacity rating given for 5 AWG is also 145A. The reference given on the Wikipedia page ([9] &quot;Table 11: Recommended Current Ratings (Continuous Duty) for electronic equipment and chassis wiring&quot;. Reference Data for Engineers: Radio, Electronics, Computer and Communications (7th ed.). pp. 49–16) might very well assume constant current density, or the difference including convection happens to be down in the rounding error so we don't really see much effect here. Similar assumptions or effects may underlie the Southwire reference.</p> <p>You would have to research these references, and other supporting information, to see where exactly it comes from; up to and including committee discussions that led to major industry/regulatory standards, such as the National Electric Code (NEC).</p> <p>Real ampacity in an application, of course depends on other factors as well -- voltage drop for example. For fairly ordinary wiring applications, it seems conductor cross section dominates over dissipation area, so the ampacity of tubing is not much more than its equivalent area.</p>
<p>Out of curiosity, what is the equivalent AWG of 1/4 inch copper tubing?</p> <p>The tubing would be mostly hollow; how much current would it be rated for?</p>
What is the equivalent AWG of 1/4 inch soft copper tubing?
2024-03-09T04:23:56.360
705457
|hall-effect|plc|
<blockquote> <p><em>The problem is that I cannot find an appropriate SSR or optoisolator that could activate at 12V and deactivate at 8V.</em></p> </blockquote> <p>You say that you can find an SSR or opto-isolation device that can run from an input of 5 volts so, why not use a Zener diode of maybe 7.5 volts, to drop the 8 to 12 volt signal to 0.5 to 4.5 volts. If using a regular opto-isolator you might need to add a series resistor as well: -</p> <p><a href="https://i.stack.imgur.com/Yx5L8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Yx5L8.png" alt="enter image description here" /></a></p> <p>If you don't need an isolation barrier why not use a PLC input that is 5 volt compatible instead?</p>
<p>I would need help with my application for counting impulses sent from a Hall sensor. Below is the description of the application.</p> <p>In the project, I have a 2-pin Hall sensor powered by +13VDC. Depending on whether the sensor is &quot;on&quot; or &quot;off&quot;, it sends voltage pulses of approximately 12V or 8V. I need to count the number of pulses in my PLC controller. I have a card that counts voltage pulses of +24VDC. I have considered using an SSR relay or an optoisolator to create pulses of +24VDC based on the voltages from the Hall sensor. The problem is that I cannot find an appropriate SSR or optoisolator that could activate at 12V and deactivate at 8V. I have considered using a voltage divider, but I couldn't configure it to work for these voltages and appropriately activate and deactivate the SSR. I have considered SSR/optoisolators for 0-5V (PXC.2964270) and 0-10V (MURR.6652500).</p> <p>Below are the device specifications: Hall sensor: Power supply: 13V Resistance: 182 OHM Low-state voltage: 7.7V - 8.8V High-state voltage: 11.3V - 12.7V</p> <p>PLC measurement card: 6ES7138-6AA01-0BA0</p> <p>I would greatly appreciate help in finding a solution. <a href="https://i.stack.imgur.com/R8577.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R8577.png" alt="enter image description here" /></a></p>
Transmission of the signal from the Hall sensor to the PLC
2024-03-09T11:18:40.233
705458
|verilog|simulation|vivado|sequential-logic|
<p>Although people tend to generalize by saying use nonblocking assignments for sequential logic and blocking assignments for combinational logic, the more precise rule is:</p> <blockquote> <p>Use nonblocking assignments when one process writes to a variable, and another process reads the same variable, and both processes are synchronized to the same clock edge to prevent race conditions. This guarantees the reading process always uses the <em>old</em> value of the variable.</p> </blockquote> <p>In your example it might be the ordering of the way you have written your 3 <code>always</code> blocks that determines whether the assignment to <code>enable1</code> sees old or updated values of <code>go_high_r1</code> and <code>go_low_r1</code>.</p> <p>Synthesizable, combinational logic should always be written with blocking assignments. There are certain exceptions for modeling transport delays where you can use nonblocking assignments.</p> <p>Within an edge triggered block, variables that are read before written within the same process will always become sequential logic regardless of which kind of assignment is used. Any variable written in one edge triggered process and read outside that process becomes sequential logic. That precise rule above still applies.</p>
<p>Please refer to the following Verilog module:</p> <pre><code>module counter( input wire clk, input wire rstn ); reg [4:0] counter; // Powered by non-blocking assignments reg enable1; reg enable2; reg enable3; // Powered by blocking assignments reg go_high_r1; reg go_low_r1; // Powered by non-blocking assignments reg go_high_r2; reg go_low_r2; // Powered by continuous assignments wire go_high_3; wire go_low_3; assign go_high_3 = (counter == 'd17); assign go_low_3 = (counter == 'd28); always @ (posedge clk or negedge rstn) begin if (!rstn) begin counter &lt;= 'd0; end else begin // let it overflow counter &lt;= counter + 'd1; end end // interaction b/w these signals below and enable1 signal is NOT clear always @ (posedge clk or negedge rstn) begin if (!rstn) begin go_high_r1 = 'd0; go_low_r1 = 'd0; end else begin go_high_r1 = (counter == 'd17); go_low_r1 = (counter == 'd28); end end always @ (posedge clk or negedge rstn) begin if (!rstn) begin go_high_r2 &lt;= 'd0; go_low_r2 &lt;= 'd0; end else begin go_high_r2 &lt;= (counter == 'd16); go_low_r2 &lt;= (counter == 'd27); end end always @ (posedge clk or negedge rstn) begin if (!rstn) begin enable1 &lt;= 'd0; enable2 &lt;= 'd0; enable3 &lt;= 'd0; end else begin enable1 &lt;= (go_high_r1) ? 'd1 : (go_low_r1) ? 'd0 : enable1; enable2 &lt;= (go_high_r2) ? 'd1 : (go_low_r2) ? 'd0 : enable2; enable3 &lt;= (go_high_3) ? 'd1 : (go_low_3) ? 'd0 : enable3; end end endmodule </code></pre> <p>Waveform:</p> <p><a href="https://i.stack.imgur.com/EIsQ5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EIsQ5.png" alt="wave" /></a></p> <p>I am able to understand the interaction between <code>enable_2</code> and <code>enable_3</code> and corresponding control signals.</p> <p>What I am not able to understand is that how <code>enable1</code> gets its value <em>without a single clock cycle delay</em> (source: <a href="https://electronics.stackexchange.com/a/173050/260943">ans1</a>, <a href="https://electronics.stackexchange.com/a/123654/260943">ans2</a>) from the point of time when either <code>go_high_r1</code> or <code>go_low_r1</code> gets its value from the procedural block.</p>
Interaction between multiple blocking assignment and non-blocking assignment running in separate procedural blocks in Verilog
2024-03-09T11:22:30.133
705459
|circuit-analysis|differential|dynamic|
<p>One way to find the free response of that system, with no use of Laplace Transform, is assuming a possible response (the exponential function is a good candidate due to its properties, like the derivative being similar to the function itself).</p> <p>Applying the KVL in <span class="math-container">\$t = 0_+\$</span> (immediately after the switch is closed):</p> <p><span class="math-container">$$-R_2i_L(t)-L\frac{di_L(t)}{dt}-v_C(t)=0 \qquad (1)$$</span></p> <p>Deriving wrt to time:</p> <p><span class="math-container">$$L\frac{d^2i_L(t)}{dt^2}+R_2\frac{di_L(t)}{dt}+\frac{dv_C(t)}{dt}=0$$</span></p> <p>Replacing <span class="math-container">\$\frac{dv_C(t)}{dt}=\frac{i_L(t)}{C}\$</span></p> <p><span class="math-container">$$\frac{d^2i_L(t)}{dt^2}+\frac{R_2}{L}\frac{di_L(t)}{dt}+\frac{i_L(t)}{LC}=0$$</span></p> <p>Replacing component values:</p> <p><span class="math-container">$$\frac{d^2i_L(t)}{dt^2}+750\frac{di_L(t)}{dt}+10^6i_L(t)=0 \qquad (2)$$</span></p> <p>Assuming a possible solution as: <span class="math-container">\$i_L(t)=Ae^{st}\$</span> in <span class="math-container">\$(2)\$</span>:</p> <p><span class="math-container">$$s^2Ae^{st}+750sAe^{st}+10^6Ae^{st}=0$$</span></p> <p><span class="math-container">$$Ae^{st}\left(s^2 +750s+10^6 \right )=0$$</span></p> <p>Therefore, the characteristic equation is:</p> <p><span class="math-container">$$s^2 +750s+10^6=0$$</span></p> <p>With complex conjugate roots:</p> <p><span class="math-container">$$ \begin{cases} s_1=\underbrace{-375}_{-\alpha}+j\underbrace{927.025}_{\omega_d=\sqrt{\omega_0^2-\alpha^2}}\\ \\ s_2=-375-j927.025 \end{cases} $$</span></p> <p>Where:</p> <p><span class="math-container">$$ \begin{cases} \alpha=\frac{R_2}{2L}= 375 \space Np/s \\ \omega_0=\frac{1}{\sqrt{LC}}=1000 \space Hz \\ \omega_d=927.025 \space Hz \end{cases} $$</span></p> <p>As <span class="math-container">\$\omega_0&gt;\alpha\$</span>, the system is <strong>underdamped</strong> (the roots already indicated that).</p> <p>For an underdamped RLC series circuit without source (drived only by the initial conditions), the response has the form:</p> <p><span class="math-container">$$i_L(t)={e^{-\alpha t}[ K_1\cos(\omega_d t)+ K_2\sin(\omega_d t)]}u(t) \qquad (3)$$</span></p> <p>where <span class="math-container">\$u(t)\$</span> is the unit step function.</p> <p>The initial conditions are:</p> <p><span class="math-container">$$ \begin{cases} i_L(0_+)=i_L(0_-)=0 \space A \\ v_C(0_+)=v_C(0_-)=15 \space V \\ \end{cases} $$</span></p> <p>Doing <span class="math-container">\$t=0_+\$</span> in <span class="math-container">\$(3)\$</span>:</p> <p><span class="math-container">$$K_1=i_L(0_+)=0$$</span></p> <p>Doing <span class="math-container">\$t=0_+\$</span> in <span class="math-container">\$(1)\$</span>:</p> <p><span class="math-container">$$-R_2i_L(0_+)-L\frac{di_L(0_+)}{dt}-v_C(0_+)=0$$</span></p> <p>Resulting in:</p> <p><span class="math-container">$$\frac{di_L(0_+)}{dt}=-18.75 \space A/s$$</span></p> <p>Deriving <span class="math-container">\$(3)\$</span> wrt time:</p> <p><span class="math-container">$$ \frac{di_L(t)}{dt}=-\alpha e^{-\alpha t}[K_1\cos(\omega_d t)+K_2\sin(\omega_d t)]+e^{-\alpha t}[-K_1\omega_d\sin(\omega_d t)+K_2\omega_d\cos(\omega_d t)] $$</span></p> <p>In <span class="math-container">\$t=0_+\$</span>:</p> <p><span class="math-container">$$\frac{di_L(0_+)}{dt}=-\alpha K_1+K_2\omega_d=-18.75\qquad A/s$$</span></p> <p>With:</p> <p><span class="math-container">$$K_2=-0.0202$$</span></p> <p>So, from <span class="math-container">\$(3)\$</span>, the total response is:</p> <p><span class="math-container">$$\boxed{i_L(t)=[-0.0202e^{-375t}\sin(927.025t)]u(t)}$$</span></p> <p>With plot:</p> <p><a href="https://i.stack.imgur.com/He9GJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/He9GJ.png" alt="enter image description here" /></a></p>
<p>For the past few weeks I have been trying to solve this dynamic circuit with no lock in solving the whole equation. I have difficulty in finding the contants at the end of the equation when coming up with the general solution for the circuit. Here is the question: <a href="https://i.stack.imgur.com/ChxrZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ChxrZ.png" alt="enter image description here" /></a></p> <p>This is my note trying to solve it:</p> <p><a href="https://i.stack.imgur.com/KLCjy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KLCjy.png" alt="enter image description here" /></a> <a href="https://i.stack.imgur.com/9HG57.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9HG57.png" alt="enter image description here" /></a></p> <p>Correct me if my understanding of the way I have analyzed the circuit is incorrect. Thanks!</p>
Dynamic circuit using second-order differential equation
2024-03-09T11:26:52.737
705462
|passive-networks|
<p>You have a sign error where you calculated</p> <p><span class="math-container">$$I_x= \frac{1}{2} \cdot I_1 - \frac{1}{6} \cdot I_2 $$</span></p> <p>So in order to make this answer useful not only for finding these specific error but for general use:</p> <p>When you want to verify a result: Compute it by a different method (as not to make the same error twice).</p> <p>E.g: In this case what you could use is the method of <strong>superposition</strong>:</p> <p>You set <span class="math-container">$$ I_1 = 0$$</span> And then only calculate the voltages that are generated by the current I2.</p> <p>And then you do the same thing the other way around.</p> <p>(In your case: since your solution only differs by the influence of I2 then you would have found the error right there).</p> <p>And with this method you can directly read off your matrix elements.</p>
<p>This is the schematic from <a href="https://youtu.be/Aa1A8zLAvbw" rel="nofollow noreferrer">youtube link</a>.</p> <p><a href="https://i.stack.imgur.com/XXDVg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XXDVg.png" alt="enter image description here" /></a></p> <p>Here is how I analyse this circuit.</p> <p><a href="https://i.stack.imgur.com/SE98l.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SE98l.png" alt="enter image description here" /></a></p> <p><span class="math-container">$$I_1 + 6 (I_1 - I_x) = V_1 \tag{1}$$</span> <span class="math-container">$$2 (I_2 + I_x) = V_2 \tag{2}$$</span></p> <p>And to calculate <span class="math-container">\$I_x\$</span>, we have</p> <p><span class="math-container">$$6 (I_1 - I_x) = 4 I_x + 2 (I_2 + I_x) $$</span> <span class="math-container">$$\Rightarrow I_x = \frac{3 I_1 + I_2} {6} $$</span></p> <p>Substitute <span class="math-container">\$ \mbox{$\Large \frac{3 I_1 + I_2} {6} $}\$</span> for <span class="math-container">\$I_x \$</span> in equations (1) and (2).</p> <p><span class="math-container">$$\Rightarrow 4 I_1 - I_2 = V_1 $$</span> <span class="math-container">$$\Rightarrow I_1 + \frac{7} {3} I_2 = V_2 $$</span></p> <p><span class="math-container">$$ \begin{bmatrix} 4 &amp; -1 \\ 1 &amp; \frac{7} {3} \end{bmatrix} $$</span></p> <p>However, this youtuber give the following</p> <p><span class="math-container">$$ \begin{bmatrix} 4 &amp; 1 \\ 1 &amp; 1.6 \end{bmatrix} $$</span></p> <p>Who is correct?</p>
How to calculate this two port network impedance of this circuit?
2024-03-09T11:45:43.533
705487
|transformer|identification|
<p>From the thickness of laminations, US domestic manufacture and resistance of the black winding it's plausible that it is a 115VAC/60Hz mains transformer with the black winding as the primary. Possibly junky cheap laminations that will run hot, but that remains to be seen.</p> <p>If you have a variac you can apply a voltage starting from 0VAC and slowly increase it, monitoring for sudden increases in magnetizing current.</p> <p>If you don't you could slap it across the mains with something like a 10 or 20W incandescent bulb from the dollar store in series and see what happens. If the bulb doesn't light up it's probably okay.</p> <p>Then measure the output voltage on the yellow winding. You can estimate the output VA capability by comparing mass with similar commercial transformers. Rated voltage is typically under load so it may measure 15~20% or so higher than rated in the unloaded condition.</p> <p>This kind of construction tends to have less leakage inductance than the split-bobbin construction (and hence better regulation) but poorer isolation, so keep that in mind from a design and safety pov.</p>
<p>NOS transformer from a defunct radio shop, closed in 80s, military colors (green.) I contacted the manufacturer with no response. Is it identifiable, and its use known? It has 22 plates (windings?) and reads 3.0 ohms yellow to yellow, 69.0 ohms black to black. Paper weight or file 13?</p> <p><a href="https://i.stack.imgur.com/qto27.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qto27.jpg" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/mlvpD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mlvpD.jpg" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/68N2H.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/68N2H.jpg" alt="enter image description here" /></a></p>
How do I identify this transformer and it use
2024-03-09T16:43:56.207
705488
|capacitor|
<blockquote> <p>...an LR circuit..</p> </blockquote> <p>I suspect that a CR circuit is what is intended.</p> <blockquote> <p>Why isn't <strong>[charging and discharging at the same time]</strong> taken into account?</p> </blockquote> <p>(The bold text is my interpretation.)</p> <p>To answer this question, a complete circuit is required, so I expect that the circuit in Figure 1 is the one containing the capacitor on the question. The equation in the OP is incomplete and the terms not all defined so I will present using my notation.</p> <p><img src="https://i.stack.imgur.com/sXNlW.png" alt="schematic" /></p> <p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fsXNlW.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p> <p>Kirchhoff's voltage law will present a differential equation that results in the following solution for the capacitor voltage <span class="math-container">\$v_{C}(t)\$</span> including initial conditions. <span class="math-container">$$ v_{C}(t)=V_{A}\left(1-e^\frac{-t}{\tau}\right)+V_{0}e^\frac{-t}{\tau}\tag{equ 1} $$</span></p> <p>The term <span class="math-container">\$V_{A}\left(1-e^\frac{-t}{\tau}\right)\$</span> represents a charging of the capacitor, while the term <span class="math-container">\$V_{0}e^\frac{-t}{\tau}\$</span> represents a discharging of the capacitor.</p> <p>It seems like the capacitor is both charging and discharging at the same time. It is an interesting way to understand the operation.</p> <p>Actually the capacitor is charging if <span class="math-container">\$V_{A}&gt;V_{0}\$</span> and discharging if <span class="math-container">\$V_{A}&lt;V_{0}\$</span>. Both charging an discharging are not happening at the same time, but the result is the same if it is viewed that way in the equation.</p> <p>The equation can be manipulated into the form that most resembles the OP: <span class="math-container">$$ v_{C}(t)=V_{A}+\left(V_{0}-V_{A}\right)e^{\frac{-t}{\tau}}\tag{equ 2} $$</span></p> <p><span class="math-container">$$ v_{C}(t)C=V_{A}C\left[1+\frac{\left(V_{0}C-V_{A}C\right)}{V_{A}C}e^{\frac{-t}{\tau}}\right] $$</span></p> <p><span class="math-container">$$ q(t)=v_{C}(t)C=V_{A}C\left[1+\frac{\left(Q_{0}-V_{A}C\right)}{V_{A}C}e^{\frac{-t}{\tau}}\right]\tag{equ 3} $$</span></p> <hr /> <p>A comment about notation: In the first equation (missing a closing bracket) the letter <span class="math-container">\$E\$</span> is not defined. The letter <span class="math-container">\$V\$</span> looks to be intended as the amplitude of the input step. Comparing with my solution (equ 3), V and E mean the same thing the amplitude of the input step, <span class="math-container">\$V_{A}\$</span>.</p> <p>Reusing <span class="math-container">\$V\$</span> in the second equation in the question as the voltage the capacitor is sourcing is incorrect. The voltage across the capacitor is always <span class="math-container">\$v_{C}(t)\$</span> (equ 1). So the second equation has no meaning.</p> <p>Clarity of notation leads to clarity of the solution. It also allows answers to be meaningful. After looking at equ 1, the source of charging and discharging at the same time can lead to an interesting viewpoint, but the circuit diagram and correct, complete analysis allows good discussion leading to the correct interpretation based on <span class="math-container">\$\left(V_{0}-V_{A}\right)\$</span>, (equ 2), being positive or negative as to whether the capacitor is charging or discharging</p>
<p>The equation describing the charging of a capacitor from a non-zero initial charge (connected in an LR circuit with a constant voltage source) is</p> <p><span class="math-container">$$q=VC[1-\frac{(EC-q_0)}{EC}e^{\frac{-t}{\tau}}$$</span></p> <p>However, the capacitor itself behaves as a fluctuating voltage source <span class="math-container">$$V=\frac{q(t)}{C}$$</span> which is discharging and being charged at the same time.</p> <p>Why isn't that taken into account?</p>
A question about the equation describing the charging of a capacitor having a non-zero initial charge
2024-03-09T17:18:38.013
705492
|switch-mode-power-supply|emc|earth|
<p>When using a AC/DC SMPS, the input <strong>should and must be grounded</strong>, as the unit you are using has a metal case. The earth ground on the input is required to stop you getting shocked if and when you come into contact with its casing. Consumer PSUs like computer chargers and other appliances only have two prongs as they have no metal parts that can be contacted, however your SMPS has a metal case hence protective earth must be used.</p> <p>For Mean Well supplies, it does not matter whether the V- terminal is connected to PE or left floating. In your case, it is completely fine to connect the V- terminal to mains earth.</p>
<p>I'm going to use a switching mode power supply in a product. When I use no earth connection in the input, the metallic body of the PSU gives a little electric shock. (it has ~70V AC with reference from my fingers.) But whenever I connect the earth connection to the input this residual voltage disappears but I still have some residual AC voltage on the DC negative output because the earth connection and DC ground are isolated in the SMPS for some reason I'm trying to understand.</p> <p><strong>So the question is: Is it okay to connect the DC negative in the output of the SMPS directly to the AC earth on the input with a small jumper wire to get rid of the residual voltage on the DC negative rail?</strong></p> <p><strong>Edit:</strong> By &quot;OK&quot; I mean passing the safety standards and not tripping the fuse on the consumer side. The product is a walkthrough metal detector and the body is completely floated.</p> <p><a href="https://i.stack.imgur.com/2Iaui.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2Iaui.png" alt="MeanWell LRS-100-24 SMPS" /></a></p> <p>Block diagram reference: <a href="https://www.meanwell-web.com/content/files/pdfs/productPdfs/MW/LRS-100/LRS-100-spec.pdf" rel="nofollow noreferrer">MeanWell LRS-100-24 datasheet</a></p> <p>According to the datasheet of my SMPS, there is a capacitor from DC negative to earth. I guess the purpose of that cap is to not allow any DC current to flow down to the earth but on the other hand, the DC negative still has some residual voltage even when the earth wire is connected to the input. (~30V AC)</p>
Is it safe to connect AC earth to DC negative?
2024-03-09T18:46:16.417
705493
|stm32|uart|serial|python|stm32cubeide|
<p>As someone said, &quot;You're using it wrong&quot;!</p> <p><a href="https://www.disca.upv.es/aperles/arm_cortex_m3/llibre/st/STM32F439xx_User_Manual/group__uart__exported__functions__group2.html#gab868edc590e3b827a14528a25c999e2f" rel="nofollow noreferrer">HAL_UART_Receive_IT()</a> is a non-blocking function meant to prepare for receiving data. You pass your buffer address and length to the HAL, and then later, when some characters arrive on the UART, they will be written to the buffer. It has a return code, which you do not check.</p> <p>This function does not block and does not receive any data, therefore your code looks into the buffer immediately afterwards and finds no data.</p> <p>So the while() keeps looping until the first character, which is 'M' is written to the buffer, after which <code>UART2_rxBuffer[0] == 'M'</code></p> <p>When it sees the 'M' it enters the if(). At this point, the buffer contains only 'M' followed by zeros because the rest of the line hasn't arrived yet.</p> <p>The scanf() therefore fails, but you don't check the return code.</p> <p>Then it echoes the contents of the receive buffer with HAL_UART_Transmit(), giving the expected result, 'M' followed by zeros.</p> <p>When the buffer is full and the transfer is complete, the HAL would call HAL_UART_RxCpltCallback() so you can handle the data, but the code in HAL_UART_RxCpltCallback() doesn't do anything with the received data. It is probably never called anyway, because after the first character is received, HAL_UART_Receive_IT() is called again which reinitializes the transfer.</p> <hr /> <p>You're using a line-based protocol, so you need to parse lines, which means knowing where your lines end, which means: read characters into a buffer until...</p> <ul> <li><p>An end-of-line character arrives: you have a complete line, which you can parse with sscanf() or via other means, then either acknowledge and execute the command, or throw an error if the line contains an invalid command.</p> </li> <li><p>Or the buffer is full. So you keep skipping characters until the end of line, then ignore the whole line, and reply with a &quot;line too long&quot; error.</p> </li> </ul> <p>This does not fit the HAL_UART_Receive_IT() API because it expects fixed-length messages, and the length has to be known beforehand. If you use a line-oriented protocol, you pretty much have to read character by character, until an end of line character is found.</p> <p>What API to use depends on what you want to do with the robot.</p> <p>The simple and dumb approach is to use a blocking read. For example you can use <a href="https://www.disca.upv.es/aperles/arm_cortex_m3/llibre/st/STM32F439xx_User_Manual/group__uart__exported__functions__group2.html#gab868edc590e3b827a14528a25c999e2f" rel="nofollow noreferrer">HAL_UART_Receive()</a> to grab one character. Then you build your line in a buffer and when an end of line arrive, you can parse it and execute it.</p> <p>Drawback: the UART on these chips doesn't have a FIFO (it has DMA instead) so if data comes in while HAL_UART_Receive() is not waiting for it, it will be dropped. This means your robot is either listening to a new command with HAL_UART_Receive, or executing a command, but not both at the same time.</p> <p>So this approach requires the robot to send Ready messages when it is ready to accept a new command. The python code should wait for Ready before sending a new one. Note I'm using &quot;Ready&quot; but you can use any message you want as long as both sides agree on what it means.</p> <p>Ready's aren't a problem because you'd need them anyway: even if you use a smarter UART mode (DMA) which can receive while the MCU is doing something else, the RAM is still tiny on this chip, so you can't send the whole list of commands for the whole drawing in one go. The python code will always have to stream commands at the same speed as the robot is drawing, to avoid overflows.</p> <hr /> <p>To streamline things a little bit, a smarter version: you may want to send a bunch of commands without waiting for Ready every time in order to pipeline it. A way to do this is to send the first N commands without waiting for Ready (assuming the N commands do fit inside the UART receive buffer), then wait for Ready for all the subsequent commands. This way there are N commands pipelined. This needs a ring buffer on the mcu and using the UART in DMA mode (or in interrupt-per-character mode, but that's slower and not simpler).</p>
<p>I need some help communicating between python's pyserial and an STM32f030R8 microcontroller. This is for a 2 DOF robot which has a python base GUI. The GUI will send, via serial communication, the coordinates for the robot and some other commands to engage or disengage the toolhead. On the python side, the relevant code snippets are the following:</p> <pre><code>def GoToCoords(X, Y): Msg = &quot;M,&quot; + &quot;{0:0=4d}&quot;.format(int(X)) + &quot;,&quot; + &quot;{0:0=4d}&quot;.format(int(Y)) #Msg = &quot;{0:0=4d}&quot;.format(int(X)) print(Msg) ser.write(bytes(Msg, 'UTF-8')) def DeployMarker(): Msg = &quot;E,0000,0000&quot; print(Msg) ser.write(bytes(Msg, 'UTF-8')) def StowMarker(): Msg = &quot;D,0000,0000&quot; print(Msg) ser.write(bytes(Msg, 'UTF-8')) # set up serial comms print(&quot;Serial coms connecting...&quot;) ser = serial.Serial('com4', 9600, timeout=10) # create Serial Object, baud = 9600, read times out after 10s time.sleep(3) # delay 3 seconds to allow serial com to get established print(&quot;Serial com connected&quot;) ... some code which builds the GUI and calls the above functions... </code></pre> <p>You can see the code is attempting to send the command type and the relevant data in the format M,####,####. The first character dictates what kind of command is being sent (M = move, E = engage toolhead, D = disengage toolhead).</p> <p>Onto the hardware, the computer is connected to a HiLetgo FT232RL Mini USB to TTL Serial Converter Adapter Module (<a href="https://rads.stackoverflow.com/amzn/click/com/B00IJXZQ7C" rel="nofollow noreferrer" rel="nofollow noreferrer">https://www.amazon.com/dp/B00IJXZQ7C?psc=1&amp;ref=ppx_yo2ov_dt_b_product_details</a>).</p> <p>Next on the STM32 side we have the following code:</p> <p>main.c:</p> <pre><code>#include &quot;main.h&quot; #include &quot;WhiteBoardRobotFuncts.h&quot; #include &lt;stdbool.h&gt; #include &lt;stdlib.h&gt; #include &lt;stdio.h&gt; #include &lt;string.h&gt; const uint8_t MsgLength = 11; char UART2_rxBuffer[11]; TIM_HandleTypeDef htim3; TIM_HandleTypeDef htim6; TIM_HandleTypeDef htim15; UART_HandleTypeDef huart2; void SystemClock_Config(void); static void MX_GPIO_Init(void); static void MX_TIM3_Init(void); static void MX_TIM6_Init(void); static void MX_USART2_UART_Init(void); static void MX_TIM15_Init(void); ////---------[ UART Data Reception Completion CallBackFunc. ]--------- void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) { HAL_UART_Receive_IT(&amp;huart2, (uint8_t*) UART2_rxBuffer, MsgLength); //You need to toggle a breakpoint on this line! } int main(void) { int x_msg = 0; int y_msg = 0; HAL_Init(); SystemClock_Config(); MX_GPIO_Init(); MX_TIM3_Init(); MX_TIM6_Init(); MX_USART2_UART_Init(); MX_TIM15_Init(); HAL_TIM_Base_Start(&amp;htim3); //start timer HAL_TIM_Base_Start(&amp;htim6); //start timer HAL_TIM_PWM_Start(&amp;htim15, TIM_CHANNEL_1); StepperStartup(); SetSpeed(50); HAL_UART_Receive_IT(&amp;huart2, (uint8_t*) UART2_rxBuffer, MsgLength); while (1) { if (UART2_rxBuffer[0] == 'D') { DisengagePen(); HAL_UART_Receive_IT(&amp;huart2, (uint8_t*) UART2_rxBuffer, MsgLength); //clear buffer for (int i = 0; i &lt; MsgLength; i++) UART2_rxBuffer[i] = 0; } if (UART2_rxBuffer[0] == 'E') { EngagePen(); HAL_UART_Receive_IT(&amp;huart2, (uint8_t*) UART2_rxBuffer, MsgLength); //clear buffer for (int i = 0; i &lt; MsgLength; i++) UART2_rxBuffer[i] = 0; } if (UART2_rxBuffer[0] == 'M') { sscanf (UART2_rxBuffer,&quot;M,%d,%d&quot;,&amp;x_msg, &amp;y_msg); LinearMove(x_msg, y_msg); HAL_UART_Receive_IT(&amp;huart2, (uint8_t*)UART2_rxBuffer, MsgLength); //clear buffer for (int i = 0; i &lt; MsgLength; i++) UART2_rxBuffer[i] = 0; } } /* USER CODE END 3 */ } /** * @brief System Clock Configuration * @retval None */ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = { 0 }; RCC_ClkInitTypeDef RCC_ClkInitStruct = { 0 }; /** Initializes the RCC Oscillators according to the specified parameters * in the RCC_OscInitTypeDef structure. */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; if (HAL_RCC_OscConfig(&amp;RCC_OscInitStruct) != HAL_OK) { Error_Handler(); } /** Initializes the CPU, AHB and APB buses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; if (HAL_RCC_ClockConfig(&amp;RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK) { Error_Handler(); } } /** * @brief TIM3 Initialization Function * @param None * @retval None */ static void MX_TIM3_Init(void) { /* USER CODE BEGIN TIM3_Init 0 */ /* USER CODE END TIM3_Init 0 */ TIM_ClockConfigTypeDef sClockSourceConfig = { 0 }; TIM_MasterConfigTypeDef sMasterConfig = { 0 }; /* USER CODE BEGIN TIM3_Init 1 */ /* USER CODE END TIM3_Init 1 */ htim3.Instance = TIM3; htim3.Init.Prescaler = 8; htim3.Init.CounterMode = TIM_COUNTERMODE_UP; htim3.Init.Period = 65535; htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; if (HAL_TIM_Base_Init(&amp;htim3) != HAL_OK) { Error_Handler(); } sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; if (HAL_TIM_ConfigClockSource(&amp;htim3, &amp;sClockSourceConfig) != HAL_OK) { Error_Handler(); } sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; if (HAL_TIMEx_MasterConfigSynchronization(&amp;htim3, &amp;sMasterConfig) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN TIM3_Init 2 */ /* USER CODE END TIM3_Init 2 */ } /** * @brief TIM6 Initialization Function * @param None * @retval None */ static void MX_TIM6_Init(void) { /* USER CODE BEGIN TIM6_Init 0 */ /* USER CODE END TIM6_Init 0 */ /* USER CODE BEGIN TIM6_Init 1 */ /* USER CODE END TIM6_Init 1 */ htim6.Instance = TIM6; htim6.Init.Prescaler = 8; htim6.Init.CounterMode = TIM_COUNTERMODE_UP; htim6.Init.Period = 65535; htim6.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; if (HAL_TIM_Base_Init(&amp;htim6) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN TIM6_Init 2 */ /* USER CODE END TIM6_Init 2 */ } /** * @brief TIM15 Initialization Function * @param None * @retval None */ static void MX_TIM15_Init(void) { /* USER CODE BEGIN TIM15_Init 0 */ /* USER CODE END TIM15_Init 0 */ TIM_ClockConfigTypeDef sClockSourceConfig = { 0 }; TIM_MasterConfigTypeDef sMasterConfig = { 0 }; TIM_OC_InitTypeDef sConfigOC = { 0 }; TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = { 0 }; /* USER CODE BEGIN TIM15_Init 1 */ /* USER CODE END TIM15_Init 1 */ htim15.Instance = TIM15; htim15.Init.Prescaler = 0; htim15.Init.CounterMode = TIM_COUNTERMODE_UP; htim15.Init.Period = 65535; htim15.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim15.Init.RepetitionCounter = 0; htim15.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; if (HAL_TIM_Base_Init(&amp;htim15) != HAL_OK) { Error_Handler(); } sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; if (HAL_TIM_ConfigClockSource(&amp;htim15, &amp;sClockSourceConfig) != HAL_OK) { Error_Handler(); } if (HAL_TIM_PWM_Init(&amp;htim15) != HAL_OK) { Error_Handler(); } sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; if (HAL_TIMEx_MasterConfigSynchronization(&amp;htim15, &amp;sMasterConfig) != HAL_OK) { Error_Handler(); } sConfigOC.OCMode = TIM_OCMODE_PWM1; sConfigOC.Pulse = 0; sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH; sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET; sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET; if (HAL_TIM_PWM_ConfigChannel(&amp;htim15, &amp;sConfigOC, TIM_CHANNEL_1) != HAL_OK) { Error_Handler(); } __HAL_TIM_DISABLE_OCxPRELOAD(&amp;htim15, TIM_CHANNEL_1); sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE; sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE; sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF; sBreakDeadTimeConfig.DeadTime = 0; sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE; sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH; sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE; if (HAL_TIMEx_ConfigBreakDeadTime(&amp;htim15, &amp;sBreakDeadTimeConfig) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN TIM15_Init 2 */ /* USER CODE END TIM15_Init 2 */ HAL_TIM_MspPostInit(&amp;htim15); } /** * @brief USART2 Initialization Function * @param None * @retval None */ static void MX_USART2_UART_Init(void) { /* USER CODE BEGIN USART2_Init 0 */ /* USER CODE END USART2_Init 0 */ /* USER CODE BEGIN USART2_Init 1 */ /* USER CODE END USART2_Init 1 */ huart2.Instance = USART2; huart2.Init.BaudRate = 9600; huart2.Init.WordLength = UART_WORDLENGTH_8B; huart2.Init.StopBits = UART_STOPBITS_1; huart2.Init.Parity = UART_PARITY_NONE; huart2.Init.Mode = UART_MODE_TX_RX; huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE; huart2.Init.OverSampling = UART_OVERSAMPLING_16; huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; if (HAL_UART_Init(&amp;huart2) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN USART2_Init 2 */ /* USER CODE END USART2_Init 2 */ } /** * @brief GPIO Initialization Function * @param None * @retval None */ static void MX_GPIO_Init(void) { /* USER CODE BEGIN MX_GPIO_Init_1 */ /* USER CODE END MX_GPIO_Init_1 */ /* GPIO Ports Clock Enable */ __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); /* USER CODE BEGIN MX_GPIO_Init_2 */ /* USER CODE END MX_GPIO_Init_2 */ } /* USER CODE BEGIN 4 */ /* USER CODE END 4 */ /** * @brief This function is executed in case of error occurrence. * @retval None */ void Error_Handler(void) { /* USER CODE BEGIN Error_Handler_Debug */ /* User can add his own implementation to report the HAL error return state */ __disable_irq(); while (1) { } /* USER CODE END Error_Handler_Debug */ } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t *file, uint32_t line) { /* USER CODE BEGIN 6 */ /* User can add his own implementation to report the file name and line number, ex: printf(&quot;Wrong parameters value: file %s on line %d\r\n&quot;, file, line) */ /* USER CODE END 6 */ } #endif /* USE_FULL_ASSERT */ </code></pre> <p>The WhiteBoardRobotFuncts.c is as follows:</p> <pre><code>/* * WhiteBoardRobotFuncts.c * * Created on: Jan 13, 2024 * Author: Ericw */ #include &quot;main.h&quot; #include &lt;math.h&gt; #include &quot;WhiteBoardRobotFuncts.h&quot; //#include &quot;PWMFunctions.h&quot; #include &quot;stm32f0xx.h&quot; float MoveVelocity = 50; float CurrentLl = 0; float CurrentLr = 0; float CurrentX = X_init; float CurrentY = Y_init; float CurrentStepl = 0; float CurrentStepr = 0; void setPortAndPinForOutput(GPIO_TypeDef *portOnMCU, int pinNumber) { //ENABLE PORTS if (portOnMCU == GPIOA) { RCC-&gt;AHBENR |= RCC_AHBENR_GPIOAEN; } if (portOnMCU == GPIOB) { RCC-&gt;AHBENR |= RCC_AHBENR_GPIOBEN; } if (portOnMCU == GPIOC) { RCC-&gt;AHBENR |= RCC_AHBENR_GPIOCEN; } if (portOnMCU == GPIOD) { RCC-&gt;AHBENR |= RCC_AHBENR_GPIODEN; } if (portOnMCU == GPIOF) { RCC-&gt;AHBENR |= RCC_AHBENR_GPIOFEN; } //SET PIN TO OUTPUT, HIGH SPEED, PP, NO PUPD portOnMCU-&gt;MODER |= 1 &lt;&lt; (2 * pinNumber); portOnMCU-&gt;MODER &amp;= ~(1 &lt;&lt; (2 * pinNumber + 1)); portOnMCU-&gt;OSPEEDR |= (1 &lt;&lt; (2 * pinNumber)) | (1 &lt;&lt; (2 * pinNumber + 1)); portOnMCU-&gt;OTYPER &amp;= ~(1 &lt;&lt; (pinNumber)); portOnMCU-&gt;PUPDR &amp;= ~(1 &lt;&lt; (pinNumber)); } void Delay_uS(uint16_t us) { TIM3-&gt;PSC = 8; TIM3-&gt;ARR = 65535; TIM3-&gt;CNT = 0x00000000; // set the counter value a 0 while (TIM3-&gt;CNT &lt; us) { } // wait for the counter to reach the us input in the parameter } void Delay_mS(uint16_t ms) { for (int i = 0; i &lt; ms; i++) { Delay_uS(1000); } } void StepperStartup() { //setup Servo PWM //PWMSetup_CH4(); //SETUP RIGHT STEPPER setPortAndPinForOutput(dirPortR, dirPinR); setPortAndPinForOutput(StepPortR, StepPinR); setPortAndPinForOutput(EnablePortR, EnablePinR); EnablePortR-&gt;BSRR |= (1 &lt;&lt; EnablePinR); //disable stepper //SETUP LEFT STEPPER setPortAndPinForOutput(dirPortL, dirPinL); setPortAndPinForOutput(StepPortL, StepPinL); setPortAndPinForOutput(EnablePortL, EnablePinL); EnablePortL-&gt;BSRR |= (1 &lt;&lt; EnablePinL); //disable stepper , CurrentLl = sqrt(pow(X_init, 2) + pow(Y_init, 2)); CurrentLr = sqrt(pow(X_init - Ls, 2) + pow(Y_init, 2)); // //temporary trouble shooting pin // setPortAndPinForOutput(GPIOB, 13); // GPIOB-&gt;BRR |= (1 &lt;&lt; 13); //TURN ON LED } void SetSpeed(float speedInput) { MoveVelocity = speedInput; //StepDelay [us/step] = [min/rev][s/min][us/s][rev/deg][deg/step] //StepDelay = floor((1 / speedInput) * 60. * 1000000. * (1. / 360.) * (1.8 / NumMicrosteps)); //StepDelay = floor((300000 / (speedInput * NumMicrosteps))); } void LinearMove(float x, float y) { //convert (x,y) coords to steps-------------------------------------------------- float TargetLl = sqrt(pow(x, 2) + pow(y, 2)); float TargetLr = sqrt(pow(Ls - x, 2) + pow(y, 2)); int StepsToTakeL = floor( StepsPerRad * ((TargetLl - CurrentLl) / SpoolRadius)); int StepsToTakeR = floor( StepsPerRad * ((TargetLr - CurrentLr) / SpoolRadius)); int TargetStepL = StepsToTakeL + CurrentStepl; int TargetStepR = StepsToTakeR + CurrentStepr; float incrementerL = 0; float incrementerR = 0; //determine Move distance --&gt; find move time (given move speed) --&gt; find delays for each stepper float MoveLinearTime = sqrt(pow(x - CurrentX, 2) + pow(y - CurrentY, 2)) / MoveVelocity; //Find Left and right stepper delays int StepperDelay_L = ceil(1000000 * MoveLinearTime / abs(StepsToTakeL * 2)); //us / step int StepperDelay_R = ceil(1000000 * MoveLinearTime / abs(StepsToTakeR * 2)); //us / step //Determine Directions for both steppers if (StepsToTakeL &lt; 0) { dirPortL-&gt;BRR |= (1 &lt;&lt; dirPinL); incrementerL = -0.5; } else { dirPortL-&gt;BSRR |= (1 &lt;&lt; dirPinL); incrementerL = 0.5; } if (StepsToTakeR &lt; 0) { dirPortR-&gt;BSRR |= (1 &lt;&lt; dirPinR); incrementerR = -0.5; } else { dirPortR-&gt;BRR |= (1 &lt;&lt; dirPinR); incrementerR = 0.5; } //enable steppers EnablePortR-&gt;BRR |= (1 &lt;&lt; EnablePinR); EnablePortL-&gt;BRR |= (1 &lt;&lt; EnablePinL); //start each clk at zero TIM3-&gt;CNT = 0x00000000; // set the counter value a 0 TIM6-&gt;CNT = 0x00000000; // set the counter value a 0 //WHILE EITHER STEPPER ISNT AT ITS TARGER while ((CurrentStepl != TargetStepL) | (CurrentStepr != TargetStepR)) { if ((CurrentStepl != TargetStepL) &amp; (TIM3-&gt;CNT &gt;= StepperDelay_L)) { TIM3-&gt;CNT = 0x00000000; // clear counter StepPortL-&gt;ODR ^= (1 &lt;&lt; StepPinL); //flip pin value with xor CurrentStepl += incrementerL; //note half a step has been taken } if ((CurrentStepr != TargetStepR) &amp; (TIM6-&gt;CNT &gt;= StepperDelay_R)) { TIM6-&gt;CNT = 0x00000000; // clear counter StepPortR-&gt;ODR ^= (1 &lt;&lt; StepPinR); CurrentStepr += incrementerR; } } //after move is complete update Ll and Lr CurrentLl = TargetLl; CurrentLr = TargetLr; CurrentX = x; CurrentY = y; //disable steppers EnablePortR-&gt;BSRR |= (1 &lt;&lt; EnablePinR); EnablePortL-&gt;BSRR |= (1 &lt;&lt; EnablePinL); } void EngagePen() { WriteServoAngle(0); } void DisengagePen() { WriteServoAngle(179); } void PWMSetPulseAndPeriod_inPulse(int PeriodInMS, int PeriodInPulses, int PulseWidth){ int prescaler; int NewPeriodInPulses; if (PeriodInMS&gt;0){ prescaler = floor(((HSI_VALUE/1000) * PeriodInMS)/65536); NewPeriodInPulses= floor(((HSI_VALUE/(prescaler+1)) / 1000) * PeriodInMS); }else if(PeriodInPulses&gt;0){ prescaler = floor(PeriodInPulses/65536); NewPeriodInPulses= floor(PeriodInPulses/(prescaler+1)); } //SET ARR AND PRESCALER TIM15-&gt;PSC = prescaler; TIM15-&gt;ARR = NewPeriodInPulses; int newPulseWidth = floor(PulseWidth/(prescaler+1)); //set pulse width TIM15-&gt;CCR1 = newPulseWidth; } void PWMSetPulseAndPeriod_inDutyCycle(int PeriodInMS, int PeriodInPulses, int dutyCycle){ int prescaler; int NewPeriodInPulses; if (PeriodInMS&gt;0){ prescaler = floor(((HSI_VALUE/1000) * PeriodInMS)/65536); NewPeriodInPulses= floor(((HSI_VALUE/(prescaler+1)) / 1000) * PeriodInMS); }else if(PeriodInPulses&gt;0){ prescaler = floor(PeriodInPulses/65536); NewPeriodInPulses= floor(PeriodInPulses/(prescaler+1)); } //SET ARR AND PRESCALER TIM15-&gt;PSC = prescaler; TIM15-&gt;ARR = NewPeriodInPulses; int newPulseWidth = floor(NewPeriodInPulses*dutyCycle/100); //set pulse width TIM15-&gt;CCR1 = newPulseWidth; } void WriteServoAngle(float angle){ int widthPulses = floor(4000. + angle*800./9.); PWMSetPulseAndPeriod_inPulse(20,0,widthPulses); } </code></pre> <p>So what is my problem:</p> <p>When I send a move command from my python GUI, on the first command the robot always moves to the same incorrect point on the board, regardless of my commanded coordinates. Then when I attempt to send additional move commands, the robot does not move (meaning the passed x, y coordinates are the same as in the previous calls of the function). My DeployMarker() and StowMarker() commands work and I have no issues controlling those via the python GUI. Additionally, the LinearMove command works flawlessly when I am not trying to feed it coordinates received via serial communication. Therefore, I have concluded that the issue must be in the way I am sending/receiving/parsing the x and y coordinates. So my question, in short, is what should I be doing differently to send/receive/parse a message in the format of &quot;M,%d,%d&quot; ?</p> <p>As an aside, it is probably pretty obvious that my knowledge of Serial and Uart communication is pretty limited, so I am all ears if anyone has any recommended resources for me to learn more!</p> <p>Update: I commanded x=100 and y= 130 in my python GUI and had the STM reply with the exact same message, as shown in the following code:</p> <p>STM:</p> <pre><code>while (1) { if (UART2_rxBuffer[0] == 'D') { DisengagePen(); HAL_UART_Receive_IT(&amp;huart2, (uint8_t*) UART2_rxBuffer, MsgLength); //clear buffer for (int i = 0; i &lt; MsgLength; i++) UART2_rxBuffer[i] = 0; } if (UART2_rxBuffer[0] == 'E') { EngagePen(); HAL_UART_Receive_IT(&amp;huart2, (uint8_t*) UART2_rxBuffer, MsgLength); //clear buffer for (int i = 0; i &lt; MsgLength; i++) UART2_rxBuffer[i] = 0; } if (UART2_rxBuffer[0] == 'M') { sscanf (UART2_rxBuffer,&quot;M,%d,%d&quot;,&amp;x_msg, &amp;y_msg); //LinearMove(x_msg, y_msg); HAL_UART_Transmit(&amp;huart2, UART2_rxBuffer, sizeof(UART2_rxBuffer), 100); Delay_mS(100); HAL_UART_Receive_IT(&amp;huart2, (uint8_t*)UART2_rxBuffer, MsgLength); //clear buffer for (int i = 0; i &lt; MsgLength; i++) UART2_rxBuffer[i] = 0; } } /* USER CODE END 3 */ } </code></pre> <p>python:</p> <pre><code>def GoToCoords(X, Y): Msg = &quot;M,&quot; + &quot;{0:0=4d}&quot;.format(int(X)) + &quot;,&quot; + &quot;{0:0=4d}&quot;.format(int(Y)) print(Msg) ser.write(bytes(Msg, 'UTF-8')) while (True): if ser.in_waiting: print(ser.readline()) break </code></pre> <p>This gives the following from in python:</p> <blockquote> <p>M,0100,0130</p> </blockquote> <blockquote> <p>b'M\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'</p> </blockquote> <p>Likewise, just returning just x_msg gives:</p> <blockquote> <p>M,0100,0130</p> </blockquote> <blockquote> <p>b'\x00\x00\x00\x00'</p> </blockquote>
STM32 Help receiving serial data sent from python's pyserial
2024-03-09T18:54:44.510
705502
|mosfet|circuit-analysis|
<p>The diode is a flyback diode. The fan motor is an inductive load, which means that it will generate a voltage across itself opposite to the motor current flow when turned off abruptly. The diode provides a path for current to flow and sink the flyback voltage, protecting the MOSFET from a potentially high voltage spike that can be induced by the stopping motor.</p> <p>R24 is likely a simple pulldown resistor which makes sure the MOSFET is off during startup. R42 is a gate resistor which slows down the switching of the MOSFET and reduces transient currents, which can generate EM interference if too high (such as a case with a power MOSFET with a high gate capacitance)</p>
<p>I'm looking <a href="https://github.com/Duet3D/Duet-2-Hardware" rel="nofollow noreferrer">at the schematic</a> for the Duet 2, a 3D printer mainboard.</p> <p>This particular block controls a small DC fan for part cooling (same block also used for the extruder cooling).</p> <p><code>V_FAN</code> is selectable, can be 5V or 12V based on a jumper set elsewhere.</p> <p>I assume <code>FAN0-</code> is the ground pin for FAN 0.</p> <p><code>FAN0</code> comes from the MCU and is a line-level pin, presumably 3.3V or 5V.</p> <p>I don't understand the diode circled in 1 nor the resistors in 2. The specific question is: What is the purpose for those components?</p> <p>My leading theory on 1) is that it allows current flowing in the wrong direction (say the fan is spun backwards) to somehow dissipate or one way or another ensure that the ground wire between the fan and MOSFET isn't building up a charge. Unclear on this and would appreciate a better breakdown if correct.</p> <p>On 2), maybe a voltage divider to drive the MOSFET at a lower voltage? It's confusing because I thought that the point of a FET was to not sink current to ground but maybe I have that wrong. The 10K resistor I believe exists to drive the pin from floating to ground when it is disconnected ensuring that the MOSFET drains. That part makes sense.</p> <p><a href="https://i.stack.imgur.com/ILxgT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ILxgT.png" alt="enter image description here" /></a></p>
DC Fan circuit with MOSFET control of ground
2024-03-09T20:39:57.790
705513
|i2c|embedded|c++|mbed|expander|
<p>You are sending ACK after receiving a byte that is last when reading a register.</p> <p>It should be a NAK or the expander tries to send first bit of the next byte, and if it is a zero, you can't send stop.</p> <p>It should be quite visible in the logic analyzer captures.</p> <p>Which means you have no error checking on e.g. read and stop functions if they fail.</p>
<p>I'm using an LPC1768 microcontroller (mbed) and 4 GPIO expanders (MCP23017). I am trying to write to the expanders to enable the pull up resistors and some other functions, but am getting strange behavior when reading from or writing to the registers over I2C.</p> <p>My code has a read and write function, as well as a busInit() function where I write to a few config registers on the MCP23017s. Main just runs the busInit and then loops printing values of registers of interest on the first MCP23017 (using my read function). I think it must be my write or read functions that are causing this. Relevant snippets:</p> <pre><code>/* Takes device address, register to read, buffer to store value in. Reads from a given GPIO expander register for all slaves. Returns 0 on success, -n on ACK fail, where nth sent byte was NACK by slave. */ int readReg(uint8_t addr, uint8_t reg, uint8_t *buf) { uint8_t opcode = (addr &lt;&lt; 1) | 0x40; //format opcode as 0100AAA0, last bit writes bus.start(); if (bus.write(opcode) == 1) { //if control byte ack by slave, send reg byte (2 on timeout, 0 on nack) if (bus.write(reg) == 1) { //if register address ack, restart and send next control byte bus.start(); if (bus.write(opcode | 1) == 1) {//send second control byte (opcode with read bit high) *buf = bus.read(1); //read reg into buf and send ack bus.stop(); return 0; } else {bus.stop(); return -3;} } else {bus.stop(); return -2;} } else {bus.stop(); return -1;} } /* Takes device address, register to write to, write data buffer. Writes to a given GPIO expander register for all slaves. Returns 0 on success, -n on ACK fail, where nth sent byte was NACK by slave. */ int writeReg(uint8_t addr, uint8_t reg, uint8_t *buf) { uint8_t opcode = (addr &lt;&lt; 1) | 0x40; //format opcode as 0100AAA0, last bit writes bus.start(); if (bus.write(opcode) == 1) { //if control byte ack by slave, send reg byte (2 on timeout, 0 on nack) if (bus.write(reg) == 1) { //if register address ack, send write data if (bus.write(*buf) == 1) { bus.stop(); return 0; } else {bus.stop(); return -3;} } else {bus.stop(); return -2;} } else {bus.stop(); return -1;} } /* Init I2C network. Configures: -All pins as inputs (except GPA7/GPB7, in datasheet errata they are output only on MCP23017, bidirectional on MCP23S17!) -Pin logic state to match input -All pins enabled for interrupt on change (except GPA7/GPB7) -Interrupt comparison to previous value, not DEFVAL -Non-banked addressing -Internally linked interrupt pins -Automatic pointer incrementation disabled -INT as active driver output -Interrupts as active LOW -100k pull up resistors enabled on all pins (except GPA7/GPB7) Returns 0 on success, -n on write fail. n = 1 for IOCON, 2 for IODIR, 3 for GPINTEN, 4 for GPPU. */ int busInit() { bus.frequency(400000); uint8_t IOCON_cfg = 0x40; uint8_t IODIR_cfg = 0x7F; uint8_t GPINTEN_cfg = 0x7F; uint8_t GPPU_cfg = 0x7F; for (uint8_t addr = 0; addr &lt; 4; addr++) { //write config to each I2C slave debug((&quot;Writing config to slave %i\n&quot;, addr)); if (writeReg(addr, 0x0A, &amp;IOCON_cfg)) { //IOCON reg debug((&quot;IOCON write failed!\n&quot;)); return -1; } else if (writeReg(addr, 0x00, &amp;IODIR_cfg) || writeReg(addr, 0x01, &amp;IODIR_cfg)) { //IODIR A/B debug((&quot;IODIR write failed!\n&quot;)); return -2; } else if (writeReg(addr, 0x04, &amp;GPINTEN_cfg) || writeReg(addr, 0x05, &amp;GPINTEN_cfg)) { //GPINTEN A/B debug((&quot;GPINTEN write failed!\n&quot;)); return -3; } else if (writeReg(addr, 0x0C, &amp;GPPU_cfg) || writeReg(addr, 0x0D, &amp;GPPU_cfg)) { //GPPU A/B debug((&quot;GPPU write failed!\n&quot;)); return -4; } } return 0; } </code></pre> <p>Output (INCORRECT, NOT the values that I set these to in busInit() and they are changing each time I read them for some reason):</p> <pre><code>========MAIN======== Writing config to slave 0 Writing config to slave 1 Writing config to slave 2 Writing config to slave 3 I2C bus init success! IOCON=40 | IODIRA=40 | IODIRB=7f | GPINTENA=7f | GPINTENB=7f | INTCONA=7f | INTCONB=7f | GPPUA=7f | GPPUB=7f | GPIOA=7f | GPIOB=0 | INT LOW IOCON=0 | IODIRA=7f | IODIRB=7f | GPINTENA=7f | GPINTENB=7f | INTCONA=0 | INTCONB=0 | GPPUA=0 | GPPUB=0 | GPIOA=1 | GPIOB=1 | INT LOW IOCON=7f | IODIRA=7f | IODIRB=7b | GPINTENA=7b | GPINTENB=7b | INTCONA=7b | INTCONB=0 | GPPUA=0 | GPPUB=0 | GPIOA=0 | GPIOB=8 | INT LOW IOCON=0 | IODIRA=c | IODIRB=c | GPINTENA=4 | GPINTENB=4 | INTCONA=13 | INTCONB=13 | GPPUA=7b | GPPUB=7b | GPIOA=5 | GPIOB=5 | INT LOW IOCON=0 | IODIRA=0 | IODIRB=0 | GPINTENA=0 | GPINTENB=8 | INTCONA=8 | INTCONB=c | GPPUA=c | GPPUB=c | GPIOA=c | GPIOB=0 | INT LOW IOCON=0 | IODIRA=7b | IODIRB=7b | GPINTENA=5 | GPINTENB=5 | INTCONA=1 | INTCONB=1 | GPPUA=5 | GPPUB=5 | GPIOA=0 | GPIOB=0 | INT LOW </code></pre> <p>Main:</p> <pre><code>int main() { debug((&quot;========MAIN========\n&quot;)); if (busInit()) { debug((&quot;I2C bus init failed!\n&quot;)); } else { debug((&quot;I2C bus init success!\n&quot;)); } while (true) { uint8_t rbuf; readReg(0x01, 0x0A, &amp;rbuf); debug((&quot;IOCON=%x | &quot;, rbuf)); readReg(0x01, 0x00, &amp;rbuf); debug((&quot;IODIRA=%x | &quot;, rbuf)); readReg(0x01, 0x01, &amp;rbuf); debug((&quot;IODIRB=%x | &quot;, rbuf)); readReg(0x01, 0x04, &amp;rbuf); debug((&quot;GPINTENA=%x | &quot;, rbuf)); readReg(0x01, 0x05, &amp;rbuf); debug((&quot;GPINTENB=%x | &quot;, rbuf)); readReg(0x01, 0x08, &amp;rbuf); debug((&quot;INTCONA=%x | &quot;, rbuf)); readReg(0x01, 0x09, &amp;rbuf); debug((&quot;INTCONB=%x | &quot;, rbuf)); readReg(0x01, 0x0C, &amp;rbuf); debug((&quot;GPPUA=%x | &quot;, rbuf)); readReg(0x01, 0x0D, &amp;rbuf); debug((&quot;GPPUB=%x | &quot;, rbuf)); readReg(0x01, 0x12, &amp;rbuf); debug((&quot;GPIOA=%x | &quot;, rbuf)); readReg(0x01, 0x13, &amp;rbuf); debug((&quot;GPIOB=%x | &quot;, rbuf)); if (INT_0) { debug((&quot;INT HIGH\n&quot;)); } else { debug((&quot;INT LOW\n&quot;)); } } </code></pre> <p><a href="https://www.mouser.com/datasheet/2/268/MCP23017_Data_Sheet_DS20001952-2998473.pdf" rel="nofollow noreferrer">MCP23017 datasheet!</a></p> <p>I have tried:</p> <p>-Verifying my read/write functions by writing to a register and reading it back.</p> <p>-Rewiring the physical ICs and disconnecting anything from the GPIO expander inputs. The circuit seems OK and the soldering looks good.</p> <p>-Waiting a period between reads/writes.</p> <p>-Examining the I2C lines using a logic analyzer.</p> <p>-Creating a reproducible example.</p> <p>-Writing/reading registers in various orders.</p> <p>-Writing a different config.</p>
Why are GPIO Expander Registers Being Rewritten?
2024-03-09T22:53:44.903
705514
|diodes|power-electronics|
<p>The voltage across the resistor is zero with ideal diodes for any input voltage.</p> <p>Maybe help the simulator out a bit by grounding the right hand side of the resistor- generally you need to ground at least one point for simulators to be happy.</p> <p>With real diode models there will be a small voltage across the 1kΩ resistor due to diode reverse leakage. 1nA leakage will result in 1<span class="math-container">\$\mu\$</span>V. The voltage will be more-or-less fixed for voltages greater than a few hundred mV, and will smoothly cross zero and change polarity as the input voltage changes polarity.</p>
<p><a href="https://i.stack.imgur.com/7Yjok.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7Yjok.png" alt="List item" /></a></p> <p>I find a small problem when I tried to illustrate the voltage graph of this circuit, I used multisim to help me but the result was confusing, sometime the graph is the same of the input voltage and sometime give me NULL voltage, I see the last result is more logical because D2 is blocked in positive alternance so no current goes in resistor and the same for negative alternance D1 is blocked. please could you confirm my point?</p>
what is the voltage graph of the resistor that found in between two reversed ideal diodes in series?
2024-03-09T22:56:53.493
705536
|current-measurement|esp32|
<p>The INA219 has sensitivity of +-40mV at highest gain. Therefore you will need a 40-Ohm shunt to measure your 1mA current with full 12-bit resolution. If you are fine with 10-bit readout, the shunt can be 10 Ohms, and so on. Will the 10-Ohm in-series resistor break your &quot;analog gauge&quot;, I don't know.</p>
<p>I have an analogue gauge that works off a 0 to 1mA input. The gauge is for a fuel tank on a ship.</p> <p>Given the input current is 1 mA at the most, what can I do to make this readable on an esp32?</p> <p>I tried connecting a resistor in series with the gauge to output a voltage, this worked, but it conflicted with the gauge causing it to be inaccurate. Whatever solution I find, I still need the gauge to retain its accuracy.</p> <p>I might consider something like INA 219, but don't know if it would work with such small current.</p> <p>I do not need super high accuracy, the gauge is for a fuel tank on a small ship, and as you can imagine, in any swell, the level is all over the place.</p> <p>Many thanks in advance.</p>
measuring microamps Arduino/esp32
2024-03-10T04:01:45.537
705543
|mosfet|led|pwm|dimming|
<p>Could the software controlling the LEDs be changed to start and keep the PWM outputs out of phase with each other? The more strips you add, the more the phase would need to adjust. Two strips can be 180 degrees out of phase, and three strips 120 degrees, following the formula 360 / N, where N is the number of strips you are driving. This could smooth out the surges in the power supply.</p>
<p>I am a rookie with electronics and have an issue that is beyond me. To set the scene: I have a number of custom-made circuit boards, all performing different tasks as a part of some automation I am doing. Each circuit board has its own ESP32 microcontroller that interfaces with whatever circuit is on the board. All the circuit boards are powered via a single 24 V power supply (<a href="https://www.meanwell-web.com/en-gb/ac-dc-single-output-led-driver-mix-mode-cv-cc-with-hlg--600h--24a" rel="nofollow noreferrer">Mean Well HLG-600H-24A</a>) and I use a buck converter on each board to step down to 5 V for the microcontroller.</p> <p>I am still setting it all up but for the most part it all works pretty well... that is, except this one thing. I have one board that switches and dims 24 V LED strips. The board has ten channels that look like this: <a href="https://i.stack.imgur.com/5DhRL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5DhRL.png" alt="enter image description here" /></a></p> <p>Each channel is controlled by sending a PWM signal to the TLP351 optocoupler. The frequency is 1000 Hz and the resolution is 16 bits. I set the brightness of the light by setting the duty cycle.</p> <p>Now for the fun part. When I dim my all my lights, say all to 75%, strange things start happening. Low-voltage logic devices (on different boards and microcontrollers but same PSU) stop working. For instance, I have a DS18B20 temperature sensor connected via 5 m of cable and it stops working. I have some rotary encoders (3V3 logic) that jump all over the place when I try to use them.</p> <p>It appears to stop if I put the duty cycle to 0% or 100%. It also seems to stop if I put the lights at different duty cycles (rotary encoders untested on that one).</p> <p>How do I stop this happening? Is it something to do with the fast switching of the MOSFETs all at the same frequency? Do I put a power line capacitor in to smooth out the fast on/off from the MOSFET? How do I size it? Different frequency? I really appreciate your wisdom on this one.</p> <p>Also, I tried reading the voltage using a Pockit meter oscilloscope and this is what I got (I am inexperienced with oscilloscopes)...</p> <p>When the lights are off: <a href="https://i.stack.imgur.com/YJZPu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YJZPu.jpg" alt="enter image description here" /></a></p> <p>When the lights are set to 75%: <a href="https://i.stack.imgur.com/gaJ1H.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gaJ1H.jpg" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/eOrON.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eOrON.jpg" alt="enter image description here" /></a></p>
Dimming LEDs with MOSFET circuit causes low voltage devices to fail
2024-03-10T06:42:21.743
705575
|surge-protection|over-voltage-protection|
<ol start="0"> <li>It's just the wrong part for the job -- don't use it. Pick something with 36V at the absolute minimum, preferably 40V or higher rating. This gives enough range that transient clamping is feasible, for instance; as-is, you have simply zero headroom.</li> </ol> <p>If the load is small, you might consider an LDO in front of the switching regulator -- including crude solutions such as a zener shunt regulator into a depletion-mode NMOS source follower. This is most practical for transient limiting, such as automotive load dump, and doesn't seem important or worthwhile here.</p> <p>Also, mind your current consumption. If all you need is 1A -- if even that -- choose a smaller regulator. The 3A rating of this device means 3A of partial-fault current is available, making liabilities downstream.</p> <p>Regarding [context added in comments, at time of writing], you might consider wired-OR-ing 3.3V from an LDO from USB5V, instead of 28V. Then you don't need a switching regulator with low dropout. Note that USB sources aren't generally capable of 1A (or without negotiation).</p> <ol> <li><p>See <a href="https://electronics.stackexchange.com/questions/704381/why-did-my-dc-dc-buck-circuit-fail">Why did my DC/DC Buck Circuit fail?</a> for the most recent run-down on this topic.</p> </li> <li><p>An electrolytic capacitor, probably; a TVS might also be welcome.</p> </li> </ol> <p>Filtering for EMC purposes is undefined, as you've given no information to go on. We would need to know at least: where the battery is placed relative to everything else, if the cables are exposed, or hugging or inside metal members, if anything else connects to the battery, power supply, etc., what test levels are, etc. etc. Preferably, complete schematics and assembly diagrams for the system would be provided, as well as a guide to where and what connector(s) are mated and to what.</p> <ol start="3"> <li>No, only the cross-sectional geometry; the transmission line impedance. Typical twin-lead is in the ballpark of 100Ω, giving ca. 0.5 µH/m inductance per length.</li> </ol>
<p>I'm planning a CAN network based on the <a href="https://docs.longan-labs.cc/1030018/" rel="nofollow noreferrer">CANbed RP2040</a> where the boards will be connected via fairly long cables (1 to 5 metres) to a LiFePo4 battery as shown below:</p> <p><img src="https://i.stack.imgur.com/7snKy.png" alt="schematic" /></p> <p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2f7snKy.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p> <p>The battery has a peak, end-of-charge voltage of about 29.2V, which I have currently adjusted down to 28.4V in the charger settings. Normal float voltage is about 27 V. All circuits must remain operational during charging.</p> <p>The <a href="https://www.semiee.com/file/DIOO/DIOO-DIO54302.pdf" rel="nofollow noreferrer">DIO54302</a> regulator specifies an absolute max rating of 32V and recommended operating conditions up to 28V. The input diode D1 (ORing diode with aux power input from USB, not shown) is a <a href="https://www.vishay.com/docs/88751/ss32.pdf" rel="nofollow noreferrer">SS32</a> with typical Vf of 0.1 V to 0.5 V.</p> <p>Questions:</p> <ol> <li>is there a risk of inductive spikes exceeding the maximum voltage rating when SW1 is closed? (looking at you, ceramic input capacitor)</li> <li>what sort of input filtering can I add (at the location marked '?') to protect the device and avoid having to lower the battery charge voltage any further?</li> <li>I can select the power cable to have a cross-section between 0.75 mm2 and 2.5 mm2, does this choice affect the potential for inductive spikes?</li> </ol> <p>[EDIT] After reading Tim Willams and Spehro Pefhany, I ran some simulations on LTspice. The power-on spike reached more than 60 V.</p> <p><a href="https://i.stack.imgur.com/cdX1C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cdX1C.png" alt="schematic, initial" /></a> <a href="https://i.stack.imgur.com/FMYMK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FMYMK.png" alt="simulation, initial" /></a></p> <p>Adding a 470uF electrolytic eliminated the spike, but given Spehro's comments on the diode breakdown voltage I will also reduce the input voltage to 12 V for this section. The electrolytic is still needed to prevent a ~30 V spike in that case.</p> <p><a href="https://i.stack.imgur.com/j6BSN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j6BSN.png" alt="schematic, final" /></a> <a href="https://i.stack.imgur.com/uNjEk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uNjEk.png" alt="simulation, final" /></a></p>
Input protection close to maximum voltage
2024-03-10T15:59:11.413
705583
|control|control-system|matlab|pole-zeroplot|
<p>This is the code I created and it solves that problem.</p> <pre><code> clc clear % Declaration of Omega_n Value wn = 3; % Zeta Values for Each Variation z1 = 1; z2 = 2; z3 = 0.1; z4 = 0.5; z5 = 0; % Numerator and Denominator Values for Each Variation num1 = wn^2; den1 = [1 2*z1*wn wn^2]; num2 = wn^2; den2 = [1 2*z2*wn wn^2]; num3 = wn^2; den3 = [1 2*z3*wn wn^2]; num4 = wn^2; den4 = [1 2*z4*wn wn^2]; num5 = wn^2; den5 = [1 2*z5*wn wn^2]; figure; % When Zeta = 1 sys_tf1 = tf(num1, den1); % Pole Zero Map subplot(2,5,1) pzmap(sys_tf1); title(['Pole Zero Map (Zeta = ', num2str(z1), ')']) % Step Response subplot(2,5,6) step(sys_tf1); title(['Step Response (Zeta = ', num2str(z1), ')']) % When Zeta = 2 sys_tf2 = tf(num2, den2); % Pole Zero Map subplot(2,5,2) pzmap(sys_tf2); title(['Pole Zero Map (Zeta = ', num2str(z2), ')']) % Step Response subplot(2,5,7) step(sys_tf2); title(['Step Response (Zeta = ', num2str(z2), ')']) % When Zeta = 0.1 sys_tf3 = tf(num3, den3); % Pole Zero Map subplot(2,5,3) pzmap(sys_tf3); title(['Pole Zero Map (Zeta = ', num2str(z3), ')']) % Step Response subplot(2,5,8) step(sys_tf3); title(['Step Response (Zeta = ', num2str(z3), ')']) % When Zeta = 0.5 sys_tf4 = tf(num4, den4); % Pole Zero Map subplot(2,5,4) pzmap(sys_tf4); title(['Pole Zero Map (Zeta = ', num2str(z4), ')']) % Step Response subplot(2,5,9) step(sys_tf4); title(['Step Response (Zeta = ', num2str(z4), ')']) % When Zeta = 0 sys_tf5 = tf(num5, den5); % Pole Zero Map subplot(2,5,5) pzmap(sys_tf5); title(['Pole Zero Map (Zeta = ', num2str(z5), ')']) % Step Response subplot(2,5,10) step(sys_tf5,5); title(['Step Response (Zeta = ', num2str(z5), ')']) % Displaying damping mode information and time domain specifications for z = [z1, z2, z3, z4, z5] if z == 0 disp(['Mode of damping for Zeta = ', num2str(z), ': Undamped']); elseif 0 &lt; z &amp;&amp; z &lt; 1 % Displaying damping mode information disp(['Mode of damping for Zeta = ', num2str(z), ': Underdamped']); % Calculating and displaying time domain specifications % Rise Time tr = pi / (wn * sqrt(1 - z^2)); disp(['Rise Time: ', num2str(tr)]); % Settling Time ts = 4 / (z * wn); disp(['Settling Time: ', num2str(ts)]); % Natural Frequency of Oscillation fn = wn * sqrt(1 - z^2); disp(['Natural Frequency of Oscillation: ', num2str(fn)]); elseif z == 1 disp(['Mode of damping for Zeta = ', num2str(z), ': Critically Damped']); elseif z &gt; 1 disp(['Mode of damping for Zeta = ', num2str(z), ': Overdamped']); end disp(' '); % Empty line break end </code></pre>
<blockquote> <p><span class="math-container">$$\frac{C(s)}{R(s)}=\frac{\omega_n^2}{s^2+2\zeta \omega_n s+\omega_n^2}$$</span></p> <p>Obtain the pole zero map and step response of the 2nd order system and determine the mode of damping in the system. If the system is underdamped obtain the time domain specifications. On the pole zero map show that corresponding damping ratio and natural undamped frequency of the poles.</p> </blockquote> <p><span class="math-container">\$\omega_n = 3 r/s\$</span> and <span class="math-container">\$\zeta =1\$</span></p> <p>The problem is that I am still confused about how to calculate it using MATLAB. All I know is how to calculate it manually. Maybe someone knows how to calculate it in MATLAB.</p>
How to obtain the pole zero map and step response of the 2nd order system and determine the mode of damping in the system using MATLAB?
2024-03-10T17:16:44.723
705586
|transistors|high-voltage|pcb-assembly|
<p>Several considerations:</p> <ul> <li><p>Creepage and clearance aren't functionally required. They are required in many cases -- but actual electrical breakdown in clean conditions can be quite high, and FUNCTIONAL type insulation is acceptable in specific cases.</p> </li> <li><p>Package material is (or... can be? I'm not too clear on it myself, but asking the manufacturer would be prudent) higher CTI (comparative tracking index) than ordinary plastics and resins, so doesn't need as much distance as you might expect. Typical molding compounds are mostly (like 80%+?) silica, so they don't char as much, or as thoroughly, as you'd expect from other materials. This also gives higher strength and lower expansion rate, critical for operating temperature and longevity.</p> </li> <li><p>You aren't required to use the package pin spacing; pins can be formed by hand, with a tool, or ordered with spread or staggered pins. This greatly increases the pad-pad spacing.</p> </li> <li><p>You can also rout slots in the board, at least when pad spacings are sufficient to do so. You often see this on stagger-legged TO-220s for SMPS application, for example.</p> </li> </ul>
<p>I'm looking to build a high voltage (but low current) current source and I see transistors rated at 500V in a TO-92 package. The leads aren't even bent so spaced 50mils/1.27mm apart, and when measuring the corresponding footprint pad spacing in KiCAD it is below the safe distance for an external pcb trace at that voltage:</p> <p><a href="https://i.stack.imgur.com/ex6d4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ex6d4.png" alt="to-92 footprint" /></a></p> <p>According to KiCAD electrical spacing calculator, for voltages over 500V, uncoated pads and lead terminations should be no less than 1.805mm apart, so even the leads of the package itself are too close according to this (about 0.85mm free space between the leads).</p> <p>I must be missing something, if they make HV parts in this package there must be a way to safely implement them but I can't find guidelines or best practices on this even on the manufacturers' sites. I'm still searching but would appreciate pointers and/or links to documents.</p> <p>Example of such a HV TO-92 part: <a href="https://www.diodes.com/assets/Datasheets/ZTX560.pdf" rel="nofollow noreferrer">ZTX560 datasheet</a>.</p> <p><strong>Edit</strong> From the answers and comments, I switched to using the TO-92 &quot;wide&quot; footprint from kiCAD for voltages over 15 volts. For straight pin TO-92 parts this involves some fancy lead twisting for the outer pins to reach their holes but this will make for safer designs. Conformal coatings might still be needed on the pins for very high voltages over 400V.</p> <p><a href="https://i.stack.imgur.com/qWbxM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qWbxM.png" alt="TO-92 wide footprint example usage" /></a></p>
Using TO-92 package for high voltage applications
2024-03-10T17:48:37.833
705597
|circuit-analysis|small-signal|
<p>Why is <span class="math-container">\$Z_L\$</span> in parallel with the VCVS <span class="math-container">\$g_mv_i\$</span>? Shouldn't it be in series?</p> <ul> <li>It's not a VCVS</li> <li>It's a voltage controlled <strong>current</strong> source (VCCS).</li> <li>Secondly, with current sources, the impedance is put in parallel.</li> </ul> <p>Various dependent sources: -</p> <p><a href="https://i.stack.imgur.com/DgYnF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DgYnF.png" alt="enter image description here" /></a></p> <p>Image from <a href="https://www.pinterest.com/pin/dependent-sources-in-electrical-networks--554787247849909234/" rel="nofollow noreferrer">here</a></p>
<p>I have a book that contains the solutions to certain problems that states that the small signal model for this circuit:</p> <p><a href="https://i.stack.imgur.com/QJb6o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QJb6o.png" alt="enter image description here" /></a></p> <p>is this:</p> <p><a href="https://i.stack.imgur.com/DUwqb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DUwqb.png" alt="enter image description here" /></a></p> <p>I don't understand it. Why is <span class="math-container">\$Z_L\$</span> in parallel with the VCVS <span class="math-container">\$g_mv_i\$</span>? Shouldn't it be in series?</p>
I don't understand the small signal model of this circuit
2024-03-10T21:33:26.843
705619
|pcb|diodes|identification|surface-mount|camera|
<p>It's a <a href="https://datasheet.lcsc.com/lcsc/2304140030_Littelfuse-SMBJ43CA_C224021.pdf" rel="noreferrer">Littelfuse SMBJ43CA</a> bi-directional TVS diode.</p> <p><a href="https://i.stack.imgur.com/gcoMg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gcoMg.png" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/yOzSx.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yOzSx.png" alt="enter image description here" /></a></p> <p>(Source: <a href="https://www.lcsc.com/product-detail/Electrostatic-and-Surge-Protection-TVS-ESD_Littelfuse-SMBJ43CA_C224021.html" rel="noreferrer">lcsc.com</a>)</p>
<p>I have a faulty power supply circuit of a PELCO PTZ camera. It has a burnt diode with the marking CT 6DZRS. I can't find the exact specs or type of the diode. The image is attached</p> <p>Help will be much appreciated.</p> <p><a href="https://i.stack.imgur.com/PtfDY.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PtfDY.jpg" alt="Diode " /></a></p>
Help me identify an SMD diode
2024-03-11T06:38:25.590
705622
|stm32|uart|st-link|
<p>You have initialized the pin as open drain pin and without pull-up.</p> <p>There is no reason to expect the pin ever to go high by itself, if there is no internal pull-up enabled or no external pull-up resistor connected.</p> <p>Connecting it to ST-Link provides it a pull-up, either the ST-Link MCU enables an internal pull-up or has a physical resistor to pull the line up.</p>
<p>I'm using an ST-Link broken off from a NUCLEO board to program a custom board with an STM32G4A1 on it. The issue is that UART transmission only seems to work while the ST-Link is connected (verified with an oscilloscope). This is especially confusing since the LED blinks in the while loop are still working, indicating that the program is actually running.</p> <p>I've used this ST-Link with several custom boards at this point, and never had an issue like this. Any idea as to what might be causing this?</p> <h2>Additional Details</h2> <p>The USART1_TX on the board connects to nothing apart from the RX pin on the ST-Link. The ST-Link SWD pins and UART pins are connected to the board using a Wurth SKEDD connector - when disconnecting, this is the connector that is removed.</p> <p>When the ST-Link is connected, I can read data from UART_TX using the serial monitor and see the UART activity on the pin using the scope. When I disconnect the ST-Link, the serial monitor stops (obviously expected) and there is no more UART activity on the pin (not expected).</p> <p>Power comes from a benchtop power supply set to 9V (there's an LDO on the board giving 3V3). The scope is an Analog Discovery 2, with the positive input connected to USART1_TX and the negative connected to the power supply negative.</p> <h3>Code</h3> <p>The <code>main.c</code> code is as follows:</p> <pre class="lang-c prettyprint-override"><code>/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file : main.c * @brief : Main program body ****************************************************************************** * @attention * * Copyright (c) 2024 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include &quot;main.h&quot; /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include &quot;stdlib.h&quot; #include &quot;string.h&quot; /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN PTD */ /* USER CODE END PTD */ /* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN PD */ //#define RX /* USER CODE END PD */ /* Private macro -------------------------------------------------------------*/ /* USER CODE BEGIN PM */ /* USER CODE END PM */ /* Private variables ---------------------------------------------------------*/ TIM_HandleTypeDef htim2; UART_HandleTypeDef huart1; /* USER CODE BEGIN PV */ char msg[100] = {0}; /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MX_GPIO_Init(void); static void MX_USART1_UART_Init(void); static void MX_TIM2_Init(void); /* USER CODE BEGIN PFP */ /* USER CODE END PFP */ /* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ /** * @brief The application entry point. * @retval int */ int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration--------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_USART1_UART_Init(); MX_TIM2_Init(); /* USER CODE BEGIN 2 */ /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ sprintf(msg, &quot;test\r\n&quot;); while (1) { HAL_GPIO_TogglePin(LD1_GPIO_Port, LD1_Pin); HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin); HAL_UART_Transmit(&amp;huart1, msg, strlen(msg), 1000); /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ } /** * @brief System Clock Configuration * @retval None */ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; /** Configure the main internal regulator output voltage */ HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1); /** Initializes the RCC Oscillators according to the specified parameters * in the RCC_OscInitTypeDef structure. */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; if (HAL_RCC_OscConfig(&amp;RCC_OscInitStruct) != HAL_OK) { Error_Handler(); } /** Initializes the CPU, AHB and APB buses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; if (HAL_RCC_ClockConfig(&amp;RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK) { Error_Handler(); } } /** * @brief TIM2 Initialization Function * @param None * @retval None */ static void MX_TIM2_Init(void) { /* USER CODE BEGIN TIM2_Init 0 */ /* USER CODE END TIM2_Init 0 */ TIM_ClockConfigTypeDef sClockSourceConfig = {0}; TIM_MasterConfigTypeDef sMasterConfig = {0}; /* USER CODE BEGIN TIM2_Init 1 */ /* USER CODE END TIM2_Init 1 */ htim2.Instance = TIM2; htim2.Init.Prescaler = 25; htim2.Init.CounterMode = TIM_COUNTERMODE_UP; htim2.Init.Period = 9; htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; if (HAL_TIM_Base_Init(&amp;htim2) != HAL_OK) { Error_Handler(); } sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; if (HAL_TIM_ConfigClockSource(&amp;htim2, &amp;sClockSourceConfig) != HAL_OK) { Error_Handler(); } sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; if (HAL_TIMEx_MasterConfigSynchronization(&amp;htim2, &amp;sMasterConfig) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN TIM2_Init 2 */ /* USER CODE END TIM2_Init 2 */ } /** * @brief USART1 Initialization Function * @param None * @retval None */ static void MX_USART1_UART_Init(void) { /* USER CODE BEGIN USART1_Init 0 */ /* USER CODE END USART1_Init 0 */ /* USER CODE BEGIN USART1_Init 1 */ /* USER CODE END USART1_Init 1 */ huart1.Instance = USART1; huart1.Init.BaudRate = 19200; huart1.Init.WordLength = UART_WORDLENGTH_8B; huart1.Init.StopBits = UART_STOPBITS_1; huart1.Init.Parity = UART_PARITY_NONE; huart1.Init.Mode = UART_MODE_TX_RX; huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; huart1.Init.OverSampling = UART_OVERSAMPLING_16; huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; huart1.Init.ClockPrescaler = UART_PRESCALER_DIV1; huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; if (HAL_HalfDuplex_Init(&amp;huart1) != HAL_OK) { Error_Handler(); } if (HAL_UARTEx_SetTxFifoThreshold(&amp;huart1, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK) { Error_Handler(); } if (HAL_UARTEx_SetRxFifoThreshold(&amp;huart1, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) { Error_Handler(); } if (HAL_UARTEx_DisableFifoMode(&amp;huart1) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN USART1_Init 2 */ /* USER CODE END USART1_Init 2 */ } /** * @brief GPIO Initialization Function * @param None * @retval None */ static void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct = {0}; /* USER CODE BEGIN MX_GPIO_Init_1 */ /* USER CODE END MX_GPIO_Init_1 */ /* GPIO Ports Clock Enable */ __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOA, LD2_Pin|LD1_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(DUMMY_SIG_GPIO_Port, DUMMY_SIG_Pin, GPIO_PIN_RESET); /*Configure GPIO pins : LD2_Pin LD1_Pin */ GPIO_InitStruct.Pin = LD2_Pin|LD1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOA, &amp;GPIO_InitStruct); /*Configure GPIO pin : LINE_SIG_Pin */ GPIO_InitStruct.Pin = LINE_SIG_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(LINE_SIG_GPIO_Port, &amp;GPIO_InitStruct); /*Configure GPIO pin : DUMMY_SIG_Pin */ GPIO_InitStruct.Pin = DUMMY_SIG_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(DUMMY_SIG_GPIO_Port, &amp;GPIO_InitStruct); /* USER CODE BEGIN MX_GPIO_Init_2 */ /* USER CODE END MX_GPIO_Init_2 */ } /* USER CODE BEGIN 4 */ /* USER CODE END 4 */ /** * @brief This function is executed in case of error occurrence. * @retval None */ void Error_Handler(void) { /* USER CODE BEGIN Error_Handler_Debug */ /* User can add his own implementation to report the HAL error return state */ __disable_irq(); while (1) { } /* USER CODE END Error_Handler_Debug */ } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t *file, uint32_t line) { /* USER CODE BEGIN 6 */ /* User can add his own implementation to report the file name and line number, ex: printf(&quot;Wrong parameters value: file %s on line %d\r\n&quot;, file, line) */ /* USER CODE END 6 */ } #endif /* USE_FULL_ASSERT */ </code></pre> <p>Please note that there's a couple of callbacks that have been disabled while testing.</p> <p><code>stm32g4xx_hal_msp.c</code>:</p> <pre class="lang-c prettyprint-override"><code>/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file stm32g4xx_hal_msp.c * @brief This file provides code for the MSP Initialization * and de-Initialization codes. ****************************************************************************** * @attention * * Copyright (c) 2024 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include &quot;main.h&quot; /* USER CODE BEGIN Includes */ /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN TD */ /* USER CODE END TD */ /* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN Define */ /* USER CODE END Define */ /* Private macro -------------------------------------------------------------*/ /* USER CODE BEGIN Macro */ /* USER CODE END Macro */ /* Private variables ---------------------------------------------------------*/ /* USER CODE BEGIN PV */ /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ /* USER CODE BEGIN PFP */ /* USER CODE END PFP */ /* External functions --------------------------------------------------------*/ /* USER CODE BEGIN ExternalFunctions */ /* USER CODE END ExternalFunctions */ /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ /** * Initializes the Global MSP. */ void HAL_MspInit(void) { /* USER CODE BEGIN MspInit 0 */ /* USER CODE END MspInit 0 */ __HAL_RCC_SYSCFG_CLK_ENABLE(); __HAL_RCC_PWR_CLK_ENABLE(); /* System interrupt init*/ /** Disable the internal Pull-Up in Dead Battery pins of UCPD peripheral */ HAL_PWREx_DisableUCPDDeadBattery(); /* USER CODE BEGIN MspInit 1 */ /* USER CODE END MspInit 1 */ } /** * @brief TIM_Base MSP Initialization * This function configures the hardware resources used in this example * @param htim_base: TIM_Base handle pointer * @retval None */ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) { if(htim_base-&gt;Instance==TIM2) { /* USER CODE BEGIN TIM2_MspInit 0 */ /* USER CODE END TIM2_MspInit 0 */ /* Peripheral clock enable */ __HAL_RCC_TIM2_CLK_ENABLE(); /* TIM2 interrupt Init */ HAL_NVIC_SetPriority(TIM2_IRQn, 0, 0); HAL_NVIC_EnableIRQ(TIM2_IRQn); /* USER CODE BEGIN TIM2_MspInit 1 */ /* USER CODE END TIM2_MspInit 1 */ } } /** * @brief TIM_Base MSP De-Initialization * This function freeze the hardware resources used in this example * @param htim_base: TIM_Base handle pointer * @retval None */ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) { if(htim_base-&gt;Instance==TIM2) { /* USER CODE BEGIN TIM2_MspDeInit 0 */ /* USER CODE END TIM2_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_TIM2_CLK_DISABLE(); /* TIM2 interrupt DeInit */ HAL_NVIC_DisableIRQ(TIM2_IRQn); /* USER CODE BEGIN TIM2_MspDeInit 1 */ /* USER CODE END TIM2_MspDeInit 1 */ } } /** * @brief UART MSP Initialization * This function configures the hardware resources used in this example * @param huart: UART handle pointer * @retval None */ void HAL_UART_MspInit(UART_HandleTypeDef* huart) { GPIO_InitTypeDef GPIO_InitStruct = {0}; RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; if(huart-&gt;Instance==USART1) { /* USER CODE BEGIN USART1_MspInit 0 */ /* USER CODE END USART1_MspInit 0 */ /** Initializes the peripherals clocks */ PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1; PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2; if (HAL_RCCEx_PeriphCLKConfig(&amp;PeriphClkInit) != HAL_OK) { Error_Handler(); } /* Peripheral clock enable */ __HAL_RCC_USART1_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); /**USART1 GPIO Configuration PA9 ------&gt; USART1_TX */ GPIO_InitStruct.Pin = USART1_TX_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF7_USART1; HAL_GPIO_Init(USART1_TX_GPIO_Port, &amp;GPIO_InitStruct); /* USART1 interrupt Init */ HAL_NVIC_SetPriority(USART1_IRQn, 0, 0); HAL_NVIC_EnableIRQ(USART1_IRQn); /* USER CODE BEGIN USART1_MspInit 1 */ /* USER CODE END USART1_MspInit 1 */ } } /** * @brief UART MSP De-Initialization * This function freeze the hardware resources used in this example * @param huart: UART handle pointer * @retval None */ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) { if(huart-&gt;Instance==USART1) { /* USER CODE BEGIN USART1_MspDeInit 0 */ /* USER CODE END USART1_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_USART1_CLK_DISABLE(); /**USART1 GPIO Configuration PA9 ------&gt; USART1_TX */ HAL_GPIO_DeInit(USART1_TX_GPIO_Port, USART1_TX_Pin); /* USART1 interrupt DeInit */ HAL_NVIC_DisableIRQ(USART1_IRQn); /* USER CODE BEGIN USART1_MspDeInit 1 */ /* USER CODE END USART1_MspDeInit 1 */ } } /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ </code></pre> <h3>Scope output</h3> <p>ST-Link connected: <a href="https://i.stack.imgur.com/dS81e.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dS81e.png" alt="Scope output with ST-link connected" /></a></p> <p>ST-Link disconnected: <a href="https://i.stack.imgur.com/LbB3l.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LbB3l.png" alt="Scope output without ST-link connected" /></a></p> <h3>Schematic</h3> <p>I'm not sure if I can share the schematic since it's not mine - I'll ask if it's okay to share if it turns out to be necessary.</p>
STM32 UART only works while ST-Link is connected
2024-03-11T07:34:49.793
705623
|microcontroller|analog|adc|filter|
<p>A thermistor's response is relatively slower, yes, but if the environment is noisy (e.g. if the traces are routed close to relatively noisy nets such as a switching node) then the noise may lead to false measurements, so a filter will be useful.</p> <p>If you really want to get rid of the filter (e.g. you may want to gain some space) then you can remove R3 and place C1 across R2. Since the NTC and R2 form a voltage divider the Thevenin equivalent of the circuit will still be an RC filter. The only downside here is that the cut-off frequency will change with temperature:</p> <p><img src="https://i.stack.imgur.com/Xnxo4.png" alt="schematic" /></p> <p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fXnxo4.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p> <p>But it's always good to follow what is recommended by the manufacturer.</p>
<p>I am interfacing an <a href="https://www.digikey.in/en/products/detail/panasonic-electronic-components/ERT-J0EG103FA/526528?s=N4IgTCBcDaIKICUAqBaAUgBjgcQIwYGYAxAQRAF0BfIA" rel="nofollow noreferrer">NTC</a> with an ADC present in <a href="https://www.nxp.com/part/FS32K146HAT0MLLT?_gl=1*xvgc51*_ga*NjI2MzExMzUxLjE3MTAxNDIwODk.*_ga_WM5LE0KMSH*MTcxMDE0MjA4OS4xLjEuMTcxMDE0MjExOC4wLjAuMA..#/" rel="nofollow noreferrer">FS32K146HAT0MLLT</a> .The circuit is given below.I was told to follow the same circuit.</p> <p>This is an automotive environment.</p> <p><a href="https://i.stack.imgur.com/9xmzk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9xmzk.png" alt="enter image description here" /></a></p> <p>I think filter is not required because this is a slow analog system.A thermistor gradually responds to changes in temperature, so is a low pass filter is not really necessary.</p> <p>May I know your thoughts</p>
NTC interfacing with ADC Do we need a LPF after NTC
2024-03-11T07:43:19.750
705630
|voltage|batteries|dc-motor|
<p>Here is a <a href="https://www.sytatek.com/uploads/soft/%E6%AD%A5%E8%BF%9B%E7%94%B5%E6%9C%BA%E9%A9%B1%E5%8A%A8/SA8302-Brief-V1.3.pdf" rel="nofollow noreferrer">SA8302 datasheet</a> (Chinese only). On your board you might be able to cut some traces and provide a higher voltage only to the SA8302 motor driver chip. The datasheet shows that the VDD pins can take from 2 to 7 V. You definitely don't want to get the higher voltage into the smaller CPU chip.</p> <p>The best method would be to carefully draw out a schematic of the complete board (by following the wiring and traces) so that you can see all the component connections. That will also show you the best way to keep the high and low voltage sections separated. There may also be some additional control that Q1 is being used for. If you can include a schematic of the board you may even receive some better design ideas.</p> <p>A slightly more complex redesign may be to supply the board with 6 V (using 4 batteries) then use a simple Zener diode circuit or a 5 V low-dropout regulator to supply the CPU section with 5 V.</p> <p>Note that the SA8302 motor driver is sort of a simplified version of a MX1508 motor driver.<br /> .<br /> .</p>
<p>I have a small RC system, which is having trouble moving. I think it has to do with the motors not getting enough voltage.</p> <p>The motors support up to 9 V but this is how my current situation is (3B is the battery source and it consists of three 1.5 V batteries, for a total of 4.5 V):</p> <p><a href="https://i.stack.imgur.com/hHZy2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hHZy2.jpg" alt="Current Setup" /></a></p> <p>Each corner has a DC motor I think but they have 2 cables to them, one positive and a negative, so i think each motor is getting 4.5 V.</p> <p>I want to increase the voltage to the motors but I’m not sure how because I don’t want to damage the receiver on the car that is also attached to the batteries in the middle (more pictures down below). I would appreciate any help.</p> <p><a href="https://i.stack.imgur.com/fmg9l.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fmg9l.jpg" alt="All" /></a></p> <p><a href="https://i.stack.imgur.com/qMtbs.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qMtbs.jpg" alt="Pcb" /></a></p> <p><a href="https://i.stack.imgur.com/jlxUw.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jlxUw.jpg" alt="Pcb" /></a></p>
Redesign circuit to increase voltage to small motor
2024-03-11T08:20:50.227
705631
|jfet|saturation|
<p><a href="https://medium.com/@bhimsenbgs2000/jfet-and-its-working-75bb5d625e0" rel="nofollow noreferrer">This graph</a> shows where the saturation region is for an N-channel JFET: -</p> <p><a href="https://i.stack.imgur.com/5Khug.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5Khug.png" alt="enter image description here" /></a></p> <p><span class="math-container">\$V_P\$</span> is the vertical dotted line representing the pinch-off voltage when <span class="math-container">\$V_{GS} = 0\text{ volts}\$</span>. To the right of <span class="math-container">\$V_P\$</span> the device is deemed to be in the saturation region. If you choose a more negative value of <span class="math-container">\$V_{GS}\$</span> the pinch-off point reduces and follows the locus indicated.</p> <p>The 2nd link in your question is not for a JFET; it's for a depletion mode MOSFET.</p> <blockquote> <p><em>Vthreshold is the voltage that JFET starts conducting current.</em></p> </blockquote> <p>No, the JFET (N-channel) will conduct current when <span class="math-container">\$V_{GS}\$</span> is 0 volts and will only stop taking current when <span class="math-container">\$V_{GS}\$</span> becomes significantly negative in value.</p>
<p>the operating condition of JFET in saturation is stated below from <a href="https://www.allaboutcircuits.com/textbook/semiconductors/chpt-5/simulating-jfet-circuits-using-ltspice/" rel="nofollow noreferrer">this website</a>.</p> <p><a href="https://i.stack.imgur.com/SzgPI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SzgPI.png" alt="enter image description here" /></a></p> <p>Vp stands for pinch-off voltage in the article.</p> <p>But after reading <a href="https://electronics.stackexchange.com/questions/643566/threshold-and-pinch-off-voltages-for-n-channel-depletion-mosfet">this post</a> shouldn't Vp change to Vthreshold in Vds condition? <a href="https://i.stack.imgur.com/GfoR0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GfoR0.png" alt="enter image description here" /></a></p> <p>or like this, since Vp = Vgs - Vthreshold <a href="https://i.stack.imgur.com/m96Ik.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m96Ik.png" alt="enter image description here" /></a> Vthreshold is the voltage that JFET starts conducting current.</p> <p>Am I correct?</p>
JFET Pinch-off voltage or threshold voltage
2024-03-11T08:50:10.377
705635
|amperage|ac-dc|
<p>You're misunderstanding what the AC adapter is actually doing. In your mind, you think it is taking in some amount of current, and then has to &quot;push&quot; that same current back out. That's not really what's happening.</p> <p>The AC adapter fundamentally is taking in energy. It takes in that energy at a certain rate, for example 1 J of energy per second, which we call power with units of J/s.</p> <p>So the correct way to think about it is that it can't &quot;push out&quot; any more energy than it is taking in. So if it's taking in 120 V AC rms at 2 A, then it is taking in up to 240 W of power (P=IV) if it's running at it's max (this simplifies it a bit because there is apparent vs real power, but ignore that for the moment). So we know that it can't output more than 240 W of power. However, the form of the output power can be any combination of current I and voltage V as long as the product of them (P=IV) is not more that 240 W of power. So it is totally acceptable to output 12 A at 20 V if the output power is exactly the same as the input power (again simplifying here because there are inefficiencies).</p> <p>The AC adapter is really converting energy into a different format. There is no rule that input current must match output current for there to be energy conservation.</p> <p>The specific mechanism through which the input power is converted to an output power with higher current (but lower voltage) is a transformer.</p>
<p>I have a laptop adapter that takes in 120V AC and converts it to 20V DC. The adapter is rated for 230W (11.5A 20V.) Knowing conservation of energy and such, this means that the adapter takes in 120V at 1.92A from the wall.</p> <p>That confuses me. How can it provide more amperes than it takes in? Clearly, it would be insane inefficiency for it to draw in 120V 11.5A and then provide 20V 11.5A (230W vs 1380W).</p> <p>What is the mechanism? Is there a current booster?</p>
How can an AC adapter push 11A but only suck 2A?
2024-03-11T09:20:51.423
705650
|diodes|battery-charging|short-circuit|mobile-robot|
<p>You can use a 3 poles connector. In the robot frame, connect one pole to negative of battery, one for the coil of a relay (pin 3), and positive of battery through a contact of this relay (and your fuse). The other terminal of the coil of relay should be connected to positive of battery. In the plug for the charger, make a jumper from pin 3 to negative, so when your connect this plug, will activate the relay. Withour inserting the plug you only get negative from battery and the coil of the realy, no positive is available.</p> <p><img src="https://i.stack.imgur.com/z7zJI.png" alt="schematic" /></p> <p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fz7zJI.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p> <p>For some 3 phase motor plugs, I also used 5 poles connector, 3 phases+ground, and one of the male contacts was used to close a limit switch in the box to enable starter. That way the operator can plug without power in the socket.</p>
<p>I built a mobile robot which uses 24Vdc 200Ah battery pack to power 2 DC motors.<br /> The circuit used to power the system is pretty robust, I used a relay to switch the motor controllers on and off, and there are fuses for each circuit branch.</p> <p>The problem is related to the charging circuit: I placed a panel connector on the robot frame and this connector is directly connected to the battery terminals. I connect the battery charger to this connector when I need to charge them.<br /> Everything works fine, but the wires are always connected to the battery even when the robot is powered off. Is there any way to avoid short circuits on these wires? If something comes in contact with the connector, a short circuit could happen.<br /> I placed a fuse on the positive wire between the battery and the connector, but I would like to find a correct solution to avoid sparks or shorts.</p> <p>What are the solutions uses in this case?</p> <p>Thank you</p>
How to avoid short circuit on battery wires on a charging circuit
2024-03-11T11:38:48.827
705654
|attenuator|balun|
<blockquote> <p><em>Is it OK to use balanced attenuator for impedance matching instead of balun? I need an attenuator anyway, so why use both?</em></p> </blockquote> <p><sub>A balun is a word composite. The first three letter (Bal) mean balanced. The last two letters (un) mean unbalanced so, when we use a balun we are converting a balanced signal to an unbalanced signal (or vice versa).</sub></p> <p>Given that you are probably using the term incorrectly (I'd call it a transformer), you are quite right that if you need attenuation then you can use a resistive impedance matching network without the transformer.</p>
<p>Is it OK to use balanced attenuator for impedance matching instead of balun? I need an attenuator anyway, so why use both?</p> <p>Original schematic:</p> <p><img src="https://i.stack.imgur.com/Ws6z5.png" alt="schematic" /></p> <p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fWs6z5.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p> <p>New design: skip 4:1 balun, recalculate attenuator resistors considering input impedance 200 Ohm</p> <p><img src="https://i.stack.imgur.com/nSdqJ.png" alt="schematic" /></p> <p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fnSdqJ.png">simulate this circuit</a></sup></p>
Balanced attenuator instead of balun
2024-03-11T13:21:58.180
705667
|connector|raspberry-pi|
<p>There are a whole bunch of 0.5mm pitch bottom-contact connectors that will fit this footprint, but you'd have to match the actual manufacturer (or a clone) pretty closely to get the clip to fit. I don't share Davide's pessimism on the swapping the clip out. I would suggest going through his list and seeing if any photos seem to match (I did not do that).</p> <p>From a quick look, it appears to be very close to <a href="https://www.digikey.ee/en/products/detail/molex/0527460671/2074148" rel="noreferrer">this</a> Molex part<br /> 0527460671 (image from Digikey linked): <a href="https://i.stack.imgur.com/6TzDL.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/6TzDL.jpg" alt="enter image description here" /></a></p> <p>I would suggest</p> <ol> <li><p>go through Davide's list and see if there are any closer matches.</p> </li> <li><p>buy a few (shipping charges will dominate anyway) and try to get the clip out and put it in the existing connector. Chances are it was designed to snap in since they're obviously different parts assembled later. You may have to cut the white plastic since the snap appears to be <a href="https://datasheet.lcsc.com/lcsc/2401301209_MOLEX-0527460671_C5464715.pdf?_gl=1*1voe3hf*_ga*MTU3OTE3NjkxLjE2OTIyMzg3MjU.*_ga_98M84MKSZH*MTcxMDE3MTc0NC4yNi4xLjE3MTAxNzMxMDYuNjAuMC4w" rel="noreferrer">chamfered</a> for entrance only (one-time assembly assumed).</p> </li> <li><p>If you fail, quit while you still have one or two left and attempt desoldering and replacing the part using hot air or whatever fine SMT techniques you have available to you (or take it to some mobile phone repair technician who should be able to do that with their eyes closed).</p> </li> </ol> <p><a href="https://i.stack.imgur.com/QYZAE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/QYZAE.png" alt="enter image description here" /></a></p>
<p>I bought a Raspberry Pi Display v1.1 but the clip where panel 1 connects is missing (a brown clip, on a white connector). What is the name and size of this clip / connector?</p> <p>See here <a href="https://raspberrypi.stackexchange.com/questions/93003/where-to-buy-the-raspberry-pi-7-touchscreen-display-board-separately">Someone with the clip</a></p> <p>Missing clip:</p> <p><a href="https://i.stack.imgur.com/k0BRK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k0BRK.png" alt="Missing clip and the connector of interest" /></a></p>
What is the name of the clip on the Raspberry Pi display connector?
2024-03-11T15:24:51.120
705675
|electromagnetism|current-rating|
<p>Note: Outside of relatively narrow regulatory contexts, wires don't really have current &quot;ratings&quot; because the maximum permissible current is dependent on so many other factors.</p> <p>Fusing current for AWG24 copper wire is approximately 29A. But most 'magnet wire' insulations will not withstand molten copper temperatures.</p> <p>So it's mostly the insulation you'll be worried about. You need to have a specification for the maximum operating temperature of the insulation. Polyimide (eg. Kapton) insulation may be good for well over 200°C. Some types of PU insulation, as low as 90°C.</p> <p>If you're starting off at (say) 75°C maximum, that's around an order of magnitude different <span class="math-container">\$\Delta T\$</span>, depending on the insulation type, so <strong>not</strong> small.</p> <p><a href="https://essexfurukawa.com/wp-content/uploads/2019/09/Essex-Wire-White-Paper-Thermal-Class-EN.pdf" rel="nofollow noreferrer">Here</a> is some detailed information on various insulation types and reliability impact of the temperature range (and some discussion of momentary overloads). For example (emphasis added):</p> <blockquote> <p>Polyimide film is very resistant to high temperatures, and is the product of choice where the magnet wire may be subjected to continuously high operating temperatures or <em>subject to intermittent severe overloads</em>.</p> <p>Some typical uses include:</p> <ul> <li>Fractional and integral horsepower motors</li> <li>High temperature continuous duty coils and relays</li> <li>Hermetic and sealed units</li> </ul> </blockquote> <p>I suggest using the delta-resistance method to get some idea of the average temperature of the wire, keeping in mind that the hottest point will be hotter than the average (how much depends on a lot of factors). If you think the inner part of the coil is going to be the peak part it's pretty easy to embed a bead or ribbon thermocouple in the coil (but may not be feasible if the voltages are high).</p>
<p>If I have a chart like <a href="https://www.remingtonindustries.com/content/Remington%20Copper%20and%20Magnet%20Wire%20Data%20Chart.pdf" rel="nofollow noreferrer">this</a> that shows the current limit for different gauges of wound magnet wire, how much could I push the current over the limit for a short amount of time? I'm assuming these ratings would be for keeping current going through the wire indefinitely, so if I would only have it on for 15 or so seconds before turning it off and letting it fully cool down, how much more would I be able to go past the rating? Take 24 AWG wire for example, the chart rates it at 577 mA, if I only ran it for 15 seconds, could I push it to a full amp? Maybe even two? Keep in mind the wire is coiled, so it shares heat between itself, and it is also around a ferrite core, which can act as a heat sink. If it matters the core is rectangular and the part I'm wrapping around is 18mm * 28mm * 14mm.</p>
How much more can I push current past the rating in a magnet wire?
2024-03-11T17:06:39.057
705676
|current|inductor|datasheet|inductance|physics|
<p>The clue is in your statement - &quot;current aligns some of the magnetic domains in the core material&quot;. When you run out of domains to align in the core the core is saturated and the inductor behaves more like an air-core inductor. There will be a B-H curve for the core material so you can pick a flux density that suits your purposes if you are designing an inductor or transformer. The curves will also show you other non-ideal behaviours- temperature dependence of permeability and hysteresis to mention a couple important ones.</p> <p>An analogous electrostatic mechanism is responsible for the drop of capacitance in some MLCC capacitors as the voltage increases due to drop in dielectric constant of the dielectric. Class II dielectrics have enormous dielectric constants compared to air or plastic film, but that, like the magnet core material, comes with limitations.</p> <p>If there is substantial DC current you may be able to bias the core (for example with a permanent magnet) so that the inductance is maximum at the expected DC current. Or you can use an electromagnet carrying current in the opposite direction (which is what a common-mode choke does, essentially). It does not seem to be very common in practice but <a href="https://odr.chalmers.se/server/api/core/bitstreams/580a7ffc-3628-4f96-b434-92248734edb1/content" rel="noreferrer">this person</a> got a Masters thesis out of it, for example.</p>
<p>I am struggling to understand what seems like a fundamental behavior of an inductor. I am looking at a chip mount <a href="https://www.murata.com/en-us/products/productdetail?partno=LQM18PN2R2MFR%23" rel="noreferrer">LQM18PN2R2MFR</a> inductor. One of the diagrams on the manufacturer's website shows a graph that describes the relationship between inductance and current. I assume this refers to DC current through the inductor.</p> <p><a href="https://i.stack.imgur.com/citrE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/citrE.png" alt="enter image description here" /></a></p> <p>Since there is a ferrite core in the inductor, the DC current aligns some of the magnetic domains in the core material. Is this the reason the inductance drops? If so, if I had a signal with a DC current component of 400mA, then the AC component would see an inductance of 0.8uH?</p>
Why does an inductor's inductance decrease with current?
2024-03-11T17:24:31.910
705686
|operational-amplifier|filter|transimpedance|transimpedance-amplifier|
<p>You got the right hunch.</p> <p>The upper amplifier is a fast but not very DC-accurate amplifier. The bottom amplifier is a classic DC servo integrator with negative gain. It nulls out the DC offset of the top amplifier.</p> <blockquote> <p>How does it null the offset?</p> </blockquote> <p>DC on pin 2 is measured relative to pin 3, integrated inverted, and fed to (top:+). Any long-term DC offset on pin 2 will be thus compensated by appropriately driving (top:+) so that pin 2 is at the same potential as pin 3. The compensation path of course goes through pin 6, external Rf, and back to pin 2. That's how the voltage on pin 2 can be controlled.</p> <p>The idea is that the photodiode is connected to a virtual ground, and the current into that virtual ground is measured by driving the opposite current from pin 6 into Rf.</p> <blockquote> <p>Doesn't it also remove some current from the already tiny photodiode current?</p> </blockquote> <p>The 1MΩ resistor at DC is open circuit since it connects to the high-impedance input of lower op-amp, which is also open-circuit at DC. At AC, 1MOhm is between two virtual grounds, so it won't do much either. Recall that the voltage at pin 2 of the chip is same as on pin 3, and typically is ground.</p>
<p>I am confused by the equivalent circuit of the <a href="https://www.ti.com/lit/ds/symlink/opa380.pdf?ts=1710051264930&amp;ref_url=https%253A%252F%252Fwww.mouser.bg%252F" rel="noreferrer">OPA380</a>, a precision Transimpedance Amplifier from Texas Instruments. The internals of the amplifier are pictured below:</p> <p><a href="https://i.stack.imgur.com/zdSbc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/zdSbc.png" alt="enter image description here" /></a></p> <p>I assume the integrator and the RC filter at its output are there in some filtering capacity, perhaps to remove any DC offset?</p> <p>I would think the second op-amp with its RC components would act as an integrator, or some kind of low-pass filter, and attenuate only high frequencies, thereby leaving the dc offset/component of the signal intact. So, why have it there in the first place?</p> <p><strong>How does the op-amp integrator enhance the performance of the whole circuit?</strong></p>
How does this Precision, High-Speed Transimpedance Amplifier work?
2024-03-11T18:27:10.177
705698
|logic-gates|boolean-algebra|truth-table|
<p>In the interest of not reinventing the wheel, thanks to @periblepsis I was able to find the following python module which does kind of what I am interested in. Here it is for anyone who goes down the same path:</p> <p>package is called pyeda. Searching this function should give you info you need to run. If you still have questions let me know I can possibly help.</p> <pre><code>&gt;&gt;&gt; from pyeda.boolalg.espresso import espresso &gt;&gt;&gt; espresso(ninputs, noutputs, cover, intype) {((2, 3, 3), (1,)), ((3, 2, 2), (1,))} </code></pre> <p>in my case the values are:</p> <pre><code>ninputs = 3 noutputs = 1 # format is ((input), (output)) # input has 1 added for god knows what reason. 0 = 1 and 1 = 2 cover = {((1, 1, 1), (0,)), ((1, 1, 2), (0,)), ((1, 2, 1), (0,)), ((1, 2, 2), (1,)), ((2, 1, 1), (1,)), ((2, 1, 2), (1,)), ((2, 2, 1), (1,)), ((2, 2, 2), (1,))} intype = 5 </code></pre> <p>This will only return the inputs which result in output = 1. 3 means don't care.</p> <p>To get the inputs that result in 0 I can invert the output values in cover and rerun.</p> <p>Cheers</p>
<p>I searched quite a bit about this but it seems not many people have a similar interest as mine regarding don't cares. Most don't care topics I found revolve around simplifying the function at hand. I am, however, not interested in changing the function, but interested to understand which inputs are inconsequential at any particular state.</p> <p>Problem:</p> <p>I have a circuit with an known arbitrary function, for example:</p> <pre><code>z = a|(b&amp;c) </code></pre> <p>which will yield a truth table as follows:</p> <pre><code>a b c | z ______|__ 0 0 0 | 0 0 0 1 | 0 0 1 0 | 0 0 1 1 | 1 1 0 0 | 1 1 0 1 | 1 1 1 0 | 1 1 1 1 | 1 </code></pre> <p>I would like to further reduce this table with don't cares, as in the following table:</p> <pre><code>a b c | z ______|__ 0 0 x | 0 0 x 0 | 0 x 1 1 | 1 1 x x | 1 </code></pre> <p>I would like to be able to generate a reduced truth table from a full truth table (or from the original function) programmatically for many logic functions with mostly 2-6 inputs. I am at a loss of how to come up with an algorithm myself. I am wondering if there are known algorithms out there that I can leverage. Planning to implement in Python if that is of any help.</p> <p>I am particularly interested in knowing which inputs are inconsequential given the value of other inputs. i.e if I know that &quot;a&quot; is 1 for a particular time window, I would like to know what &quot;b&quot; and &quot;c&quot; values don't matter within that time window (ignoring glitches and delays).</p> <p>I feel I may not be using the right keywords in my research (truth table, don't care, reduce). Any pointers will be helpful.</p> <p>Thank you.</p>
Reducing a given truth table with don't cares at inputs
2024-03-11T21:53:19.670
705701
|modulation|fsk|bpsk|
<p>Here are are two sinusoids, with slightly different frequencies, 1kHz (A, blue) and 1.2kHz (B, orange):</p> <p><a href="https://i.stack.imgur.com/TN0Cs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TN0Cs.png" alt="enter image description here" /></a></p> <p>Even though I have not introduced any phase shift, at any time, to either, clearly the phase relationship between them changes over time. The left green marker show B slightly leading A, and the right marker shows B trailing.</p> <p>Without having a reference signal, perfectly sychronised with the transmitter (which would require transmitting <em>two</em> signals), the receiver will be unable to distinguish between a phase shift, and a frequency change.</p> <p>You can't combine PSK and FSK in the same encoding scheme. Either you keep frequency fixed, and you modulate phase, or you keep phase fixed, and modulate frequency. Not both.</p>
<p>I am beginner and I want to modulate the digital signal: 101101 based on the combination: frequency/phase (2 frequencies/2 phases). For that, I set the 4 possible combinations: <code>f1ph1</code>, <code>f1ph2</code>, <code>f2ph1</code>, and <code>f2ph2</code> where: <code>f1</code> represents 1 cycle, <code>f2</code> represents two cycles, <code>ph1</code> represents 180, and <code>ph2</code> represents 0. Now, I wonder how to link between the four combinations and <code>00</code>, <code>01</code>, <code>10</code>, and <code>11</code> in order to be able to graphically represent the digital signal.</p>
Modulate a digital message using FSK/PSK combination
2024-03-11T22:44:19.773
705712
|circuit-analysis|amplifier|radio|amplitude-modulation|
<p>For this kind of radio, you need a <strong>BIG antenna</strong>**, try for 100 feet of wire as high as you can get it, perpendicular to power lines if possible. Also, you need a good ground. <strong>Multiple earth ground rods</strong> at least 3 feet apart will do a good job. The antenna will serve you well when you graduate to shortwave, get a ham license, and start transmitting.</p> <p>I built a similar radio in the 7th grade in about 1952. Mom and dad never suspected that I was listening to late night radio. In those days the diode was a little lead sulfide crystal that you had to poke with the whisker of a cat.</p> <p>** Take appropriate lightning protection measures with the antenna and position it to avoid possible contact with utility power.</p>
<p>I have been trying to make an AM radio over the last couple days and am very confused as to why this circuit is not working. I found the circuit on <a href="https://www.researchgate.net/figure/AM-radio-receiver-circuit-showing-the-main-electronic-components-to-be-optimized-by-the_fig4_3419023" rel="nofollow noreferrer">this website</a> and I saw <a href="https://www.youtube.com/watch?v=MQPrYXybiP4&amp;list=PLbYxo8MYzjIeNlGG5-_Nx9voRGMWZN9pH&amp;index=4&amp;t=304s" rel="nofollow noreferrer">this video</a> on this design. I have tried to copy it but it is not working. I have the output leads connected to a Sony speaker. It is a Sony VGF-WA1. <a href="https://i.stack.imgur.com/tHtB1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tHtB1.png" alt="enter image description here" /></a></p> <p>Is the circuit diagram correct?</p> <p>Is there a better AM radio circuit diagram that you know works?</p> <p><img src="https://i.stack.imgur.com/tEeC2.png" alt="schematic" /></p> <p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2ftEeC2.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p>
Why does this AM radio circuit not work?
2024-03-12T01:05:25.147
705715
|transformer|electromagnetism|magnetics|
<p>In your previous questions (<a href="https://electronics.stackexchange.com/questions/639569/how-does-a-magnetic-material-confine-a-magnetic-field">How does a magnetic material &quot;confine&quot; a magnetic field?</a>) the answer was not completely accurate, in my opinion. The presence of the core does influence the magnetic field behavior.</p> <p>The best way to analyze such conditions is converting it to equivalent circuits (well described in another answer). To illustrate even further, this picture may help you: <a href="https://i.stack.imgur.com/W8HC7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W8HC7.png" alt="enter image description here" /></a></p> <p>There you can see that the magnetomotive force (sources) will drive some magnetic flux to circulate, however, the magnetic flux does depend on the reluctances (defined by the medium [core, air, oil, whatever]). Thus, the presence of the core is not only magnifying the <span class="math-container">\$B\$</span>, but conducing it and preventing it to be shared with parallel reluctances (as the air duct between coil and core). At the end, some very small flux will flow through the air duct, but it will be smaller than if the core wasn't there.</p> <p>If you want to check further, a method to solve this circuit is described <a href="https://tede.ufsc.br/teses/PEEL1836-D.pdf" rel="nofollow noreferrer">here</a>, from page 77 to 80.</p> <p>By the way, just to mention: in practice, this transformer with non-concentric coils doesn't work properly when some load is applied to the secondary due to the very high dispersion (too high impedance).</p>
<p>I had a follow up question to this: <a href="https://electronics.stackexchange.com/questions/639569/how-does-a-magnetic-material-confine-a-magnetic-field">How does a magnetic material &quot;confine&quot; a magnetic field?</a></p> <p>In the above question, it asks how the magnetic flux is &quot;confined&quot; by the core. The answer is that the actual H field produced by the primary side is constant regardless of the presence of the core, but the high permeability causes a lot of magnetic flux density to occur in the core (as opposed to outside of the core, where the lower permeability causes less flux density in response to the H field.)</p> <p>How can you assume (for most transformers) that most of the flux going through the primary also goes through the secondary? Yes, I know that there is some leakage flux, but for the most part, transformers are said to be very good at having most flux thread through both the primary and secondary.</p> <p>As is the case for most coils (as I understand it,) the H field created by the primary side would be strongest in its centre, and weaker and points further away, so the H field would also be weaker in the centre of the secondary. Since the permeability of the core is constant, the H field is magnified by a constant amount in the primary and in the secondary, the degree by which the H field is stronger in the primary than secondary is the same degree by which the B field is stronger in the primary than secondary.</p> <p>If that is the case, then how is it said that most of the flux density in the primary is also shared with the secondary?</p> <p><a href="https://i.stack.imgur.com/efzDt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/efzDt.png" alt="enter image description here" /></a></p>
How does all (well most of) the flux in the primary side get into the secondary side in a transformer?
2024-03-12T01:34:49.250
705751
|relay|solar-cell|solid-state-relay|
<p>Hybrid relays are a very old concept. The relay only has to switch a volt or two so contact wear is minimized. There was a Motorola App note where they even suggested using a &quot;well made&quot; 5A relay at 50A (some relays were rather overdesigned in those days- most of the ones today are a bit iffy at full rated current).</p> <p>The SSR will tend to fail 'on' so if that is an issue consider it. If the relay fails to close, the SSR soon will fail too (probably fail to open) unless it is adequately rated and has an appropriate heatsink.</p> <p>15,000 operations per year is not a whole lot. I would also consider a beefy mechanical relay/contactor. It should not be too hard to get a predictable 10 years life by derating a bit. The hybrid might last 50 years or it might fail tomorrow in a thunderstorm.</p>
<p>I'm wanting to switch my hot water cylinder element based on the amount of solar i'm generating. The element is 3kw @ 230v = 13A. I need to switch the element ON for a short time every 15 minutes. This is equal to 4 times per hour. Solar would generate abort 10 hours per day at a guess. So the relay needs to switch 14,600 times per year. It my understanding relays are more likely to wear out and fail if switched at peak load. I'm wanting to make the system reliable and also reduce heat dissipation. So i'm thinking I switch a SSR first then a few ms later switch the mechanical relay. The mechanical relay will then take the load so the SSR effectively wont need to dissipate any power. I will then turn off the mechanical relay before turning off the SSR. I'm hoping that when the mechanical relay switches ON/OFF with this setup the load across it is effectively nothing so it will be able to handle ideally over 100,000 cycles before failure.</p> <p>I could try to detect the zero cross and switch the relay. But this seems more simple.</p> <p>Does this sound like a solution that will work?</p> <p>TLDR; Where I live the export price for solar is very low. So you want to use it rather than export if possible. The power company calculates import/export as a net amount over a 15 minute interval. The plan is to export the power at the start of the 15 minute billing cycle. Tally up how much is exported and as the billing period draws to an end import the exported amount back to the hot water cylinder.</p> <p>I know its common for this system to work off effectively a dimmer on the element and a PID. Although the dimmer gets really hot and I was thinking the on/off might be a better approach.</p>
Solid state relay in parallel with mechanical relay
2024-03-12T07:30:34.283
705766
|high-frequency|modulation|jfet|small-signal|analog-switch|
<p>I think you're going to have to go with a series/shunt switch configuration if you want much on/off ratio or at least reduce the 1M to more like 50Ω (more than 4 orders of magnitude!). Calculate how much the capacitive reactance is of your 'off' FET if you want to do hand calculations.</p> <p>50MHz is a relatively high frequency. You might be able to get away with something like a DG419 SPST analog switch.</p> <p>There are much higher performance (GHz) RF switch ICs available but they typically have issues with DC and are designed for lower voltage systems.</p>
<p>The task is to derive sinewave (of higher frequency) chopped by step-function (also periodic but of lower frequency, i.e. several periods of sine wave are placed in that pulse). So I have a sinewave generator with frequencies up to 50 MHz, I have 3.2-3.3V logic levels from my STM32 with the desired duty cycle and I need to deliver 0.5 V amplitude sine wave with 1 V DC offset for my 50 Ohm load connected to the ground (i.e. cannot be placed above the drain). I hardly imagine how to deliver that sine pulse directly, so suppose we have a voltage buffer (with lil amplification) for the output. Also, it looks to me simpler to use JFET among other FETs because it's symmetric in drain and source. So far I only considered depletion mode P-channels, since it looked as winning solution having in general 0V Vgs as fully open and 3V Vgs as pinched-off. I've looked through a lot of models and analysis textbooks but yet cannot find the answer to the problem of having this 1 DC offset which appears on the drain as soon as the channel is fully open, i.e. can it burn the JFET and will it affect it's closing time and efficiency? If I added 1V DC bias to the gate terminal, would it be a solution or do I need some feedback from the drain? I don't see a case when it closes and opens completely. Please have a look at the figures below. I indicated Vgs of established ON and OFF states, however, I suppose transient process should be taken as well, especially time constants of formed RC-circuits, but I have no complete understanding of what MUST be calculated and what's the priority.</p> <p><a href="https://i.stack.imgur.com/0WMN2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0WMN2.jpg" alt="Test circuit and desired output diagram" /></a></p> <p>Currently, I can not manage even with this part, however, high-frequency effects should be included into the problem solution and if you have a piece of advice for that as well, you'd be helpful and I'd be enormously grateful.</p>
Switching circuit with logic 3.3V control on p-channel JFET
2024-03-12T12:14:54.610
705777
|microwave|
<p>The best thing to use will be a <a href="https://nvlpubs.nist.gov/nistpubs/Legacy/crpl/crpl-9-2.pdf" rel="noreferrer">'waveguide beyond cutoff' attenuator</a>. This absolutely guarrantees a minimum level of screening, easily calculated, and easily increased to any value in a simple structure and compact size.</p> <p>It is a tube of diameter much less than the wavelength of the radiation. An evanescent wave goes along the tube, being attenuated by 27 dB for every tube diameter. The attenuation provided by a tube 3 times as long as its diameter will be coupling_in_loss + 81 dB + coupling_out_loss. With a small hole in mesh, the only attenuation you get is the coupling_in_loss + coupling_out_loss.</p> <p>Do bear in mind that, as you suggested, you must use something insulating like quartz for the fibre. Any attempt to use a conductive wire will result in you having built a coaxial cable through the wall, whether the wire passes through a hole or a tube.</p> <p>This type of isolator was extensively used in a company I worked for, building low noise signal generators, which passed high speed data into a screened enclosure, using a LED, and tube soldered through the wall, and a photodiode at the far end.</p>
<p>We have a microbalance that has a &quot;hangdown wire&quot; supporting a sample pan in a steel chamber. We need to heat this with microwaves, most probably at the common 2.4GHz of microwave ovens.</p> <p>This wire will probably be a quartz fiber. However, it has to enter the chamber through a hole and must not touch the sides of the hole. External to the chamber there are some expensive and sensitive electronics, not to mention people.</p> <p>For a given diameter of hole, what attenuation of the signal can I expect?</p> <p>Is there any way of blocking the microwaves entirely given the mechanical constraints? eg multiple baffles.</p> <p>Naturally we will be starting at very low power levels of a few Watts before pumping in kW pulses.</p>
Microwaves going through a hole - attenuation?
2024-03-12T13:46:11.267