Hello friends, I hope you are doing well. Today we will convert a MATLAB M-file into a P-file so another MATLAB user can run our function without receiving its readable implementation. We will start with one small calculation, create its P-code version, and then organize a distribution folder that includes everything needed to use it. The basic command is short, but a reliable delivery requires a few additional decisions. Where will MATLAB write the output? Which copy of the function will run? Does the recipient have a compatible MATLAB release and the required toolboxes? We will answer these questions as we work through the example. An M-file is a readable MATLAB program saved with the.m extension. It can contain a script, a function or a class definition. A P-file is a content-obscured executable representation of MATLAB source, saved with the.p extension. MATLAB executes it, but the MATLAB Editor does not expose its original source text. According to the MathWorks pcode reference, the command accepts individual M-files or folders. Ordinary output goes to the current folder; use '-inplace' when you specifically want output alongside the input files. The source files remain available for future development. P-code helps when you want to share an algorithm's behavior while withholding the editable implementation. For example, you might supply a calculation routine to a project team with a documented interface while keeping its internal design in your development repository. ...
Hello friends, I hope you are doing well. In this tutorial, we will compare alternating current and direct current, calculate power in both systems and explain why modern electrical networks use each form. AC and DC describe the direction and time variation of voltage and current. Power is the rate at which electrical energy is transferred. The phrase “AC power” therefore means power carried by alternating voltage and current, while “DC power” means power carried by quantities with fixed polarity. Direct current flows with one reference direction. Its magnitude may be constant, may contain ripple or may change with load, but it does not reverse direction during normal operation. A battery discharging into a resistor is the simplest example. For an ideal constant DC load: P = V × I A 12 V device drawing 2 A consumes: P = 12 V × 2 A = 24 W Energy consumed over time is: E = P × t Running that load for three hours requires 72 Wh in the ideal case. Battery capacity, converter efficiency, voltage variation and allowable depth of discharge must be included in a real design. Alternating current reverses direction periodically, and alternating voltage reverses polarity. Utility power is approximately sinusoidal. An ideal sine voltage is: v(t) = Vpeak × sin(2πft) At 50 Hz, one cycle lasts: T = 1/f = 1/50 = 20 ms For a sine wave: Vrms = Vpeak / √2 A 230 V RMS supply has a peak magnitude of approximately 325 V. RMS is useful because a 230 V RMS sine wave produces the same average heating ...
Hello everyone, I hope you are doing well. In this tutorial, we will compare DC and AC motors from their operating principles to their speed control, maintenance and applications. Both convert electrical energy into mechanical energy through electromagnetic force, but those broad labels contain several different motor families. The first important correction is that an AC motor is not simply a DC motor with continuous slip rings. Most industrial AC motors create a rotating stator field and use either induction or synchronous interaction to produce rotor torque. We will therefore compare common brushed DC motors, brushless DC motors, induction motors and synchronous AC motors. A current-carrying conductor in a magnetic field experiences force. For a straight active conductor: F = B × I × L × sin(theta) B is flux density, I is conductor current, L is active conductor length, and theta is the angle between current and the field. A motor arranges many conductors around a rotor so their forces create torque. Mechanical output power is: Pmechanical = torque × angular speed With torque in newton-metres and speed in revolutions per minute: Pmechanical = T × 2πn / 60 A motor producing 5 N·m at 1500 rpm delivers approximately 785 W of mechanical power. A simple permanent-magnet brushed DC motor has a stationary magnetic field and rotor windings connected through a commutator and brushes. Current in the rotor conductors produces torque. As the rotor turns, the commutator reverses coil ...
Hello friends, I hope you are doing well. Welcome to our Difference Between engineering series. In this series, we compare two related technologies side by side so you can understand where they are similar, where they differ and when each one should be selected. A useful comparison goes beyond short definitions. We will begin with the physical principle, compare construction and operating behavior, add equations or ratings where they clarify the subject, and finish with practical selection guidance. This format is useful for students preparing for examinations and interviews, but it is equally useful when an engineer must choose between two real design options. We will expand this index as additional comparisons are published. Each linked article stands on its own, so you can begin with the topic that matches your course, project or interview preparation. Related engineering terms are easy to confuse because they often share a purpose. AC and DC motors both convert electrical energy into mechanical output. AC and DC power both transfer energy. Their common purpose does not mean their sources, waveforms, construction, control or limitations are the same. A comparison creates fixed reference points. Instead of memorizing two isolated descriptions, you can ask the same questions about both subjects: This approach turns a list of facts into a decision framework. It also reveals when a popular one-line distinction is incomplete. Read the definitions first and identify the common ...
Hello friends, I hope you are doing well. In this tutorial, we will publish a Visual Basic or C# Windows Forms application from Visual Studio 2010 by using ClickOnce. This is useful when you have completed a desktop program, such as the serial terminal from our Serial Port in VB 2010 tutorial, and want to install it on another Windows computer. Visual Studio 2010 is a legacy environment whose Microsoft support ended in July 2020. We are keeping it here because the original project and screenshots use that version. For a new application, use a supported Visual Studio and.NET release and follow the current deployment workflow. The phrases EXE file and setup file are often used as if they mean the same thing. They describe different deployment artifacts: The Publish tab shown in this tutorial creates a ClickOnce deployment. It does not create a traditional MSI package. Microsoft explains that ClickOnce uses application and deployment manifests to describe the files, version, permissions and update location. Publishing does not include your Visual Studio project files or original source files, so users do not receive the project in its editable form. However, a compiled.NET assembly contains intermediate language and metadata that can often be inspected or decompiled. An EXE is therefore a deployment format, not a guarantee that program logic or embedded secrets cannot be recovered. Never embed database passwords, API secrets or private keys in a desktop application. Code signing ...
Hello friends, I hope you are doing well. In this tutorial, we will design the timing logic for a modified sine-wave inverter and study the original CD4047B and CD4017B approach. We will also develop an equivalent microcontroller timing example so you can see exactly how the positive, zero and negative intervals are produced. This article follows our tutorials on the basics of inverter topologies, the major inverter components and the pure sine-wave inverter. A modified waveform is simpler than filtered SPWM, but its harmonic content limits the loads that should use it. A modified sine wave is a stepped bipolar waveform. During each cycle, the inverter applies a positive voltage, remains at zero, applies a negative voltage and returns to zero. It is also called a modified square wave or quasi-square wave. The stepped output is not a sine wave with small imperfections. It is a different waveform with a strong harmonic spectrum. The zero intervals let us adjust RMS voltage and can reduce selected harmonics compared with a continuous square wave, but they do not provide the broad compatibility of a low-distortion sine source. Let the output magnitude be Vpk during the positive and negative plateaus. Let the two plateaus occupy a combined fraction D of the full period. The output is zero during the remaining fraction. Its RMS voltage is: Vrms = Vpk × √D If a transformer secondary produces plateaus of 325 V and we want 230 V RMS: D = (Vrms / Vpk)² = (230 / 325)² = 0.501 The ...
Hello friends, I hope you are doing well. In the previous tutorials, we studied the basics of inverter topologies and the major components of an inverter. We will now connect those ideas and study how an AVR controller can create a sine reference for a pulse-width-modulated inverter. This tutorial explains the signal chain, frequency calculations, H-bridge states, LC filter and transformer. The AVR code is an educational SPWM reference generator for an ATmega16 running at 8 MHz. It is useful for simulation and low-energy waveform testing, but it must not be connected directly to power MOSFET gates. A physical inverter needs proper high-side and low-side gate drivers, hardware dead time, current limiting, voltage feedback, thermal protection and a safe PCB layout. The original project package is still available here: Pure Sine Wave Inverter Design, Code and Report You can also study the related pure sine-wave inverter simulation in Proteus before working with physical power hardware. A low-frequency transformer design can be divided into five blocks: The exact order of filter and transformer depends on the topology. A filter placed on the low-voltage, high-current side requires a large-current inductor. A high-voltage-side filter carries less current but needs components rated for hazardous voltage. The feedback sensing point must match the voltage that the controller is expected to regulate. Before calculating PWM, define the input range, output voltage, output frequency, ...
Hello friends, I hope you are doing well. In the previous tutorial, we studied the basic inverter topologies. We will now examine the components that turn a topology into a working power converter. An inverter is a system rather than a single H-bridge. The controller creates switching commands, gate drivers translate those commands into high-current gate pulses, power semiconductors process energy, capacitors and magnetics store and filter it, sensors close the feedback loop, and protection circuits stop unsafe operation. The thermal design, PCB layout and enclosure are also functional parts of the converter. We will follow the energy path from the DC input to the AC output and add the control and protection blocks around it. The exact parts depend on voltage, power, isolation, switching frequency, waveform and applicable safety standards. The DC source determines the current level seen by the input stage. A 1 kW inverter operating from 12 V at 90% efficiency requires approximately: Iin = Pout / (efficiency × Vdc) Iin = 1000 W / (0.90 × 12 V) = 92.6 A This current is before surge allowance and before battery voltage falls under load. The fuse, disconnect, cable, connector, PCB copper and current sensor must carry the worst continuous and transient current. Place the primary fuse close to the battery or source so an upstream cable fault is also protected. A soft-start or precharge circuit limits the current that charges an empty DC-link capacitor. Without it, connecting a ...
Hello friends, I hope you are doing well. This is the first tutorial in our inverter series. We will begin with the purpose of an inverter, study the common output waveforms and then compare the power-stage topologies used to produce AC from a DC source. An inverter looks simple in a block diagram, but a useful design must control voltage, frequency, waveform quality, current, temperature and fault energy at the same time. A circuit that produces an alternating voltage on an oscilloscope is not automatically a safe or well-regulated AC power source. Our goal here is to understand the engineering decisions before selecting components or writing control code. An inverter is a power electronic converter that changes direct-current electrical power into alternating-current electrical power. The DC source may be a battery, photovoltaic array, fuel cell, rectified mains bus or another converter. The AC output may supply a stand-alone load, drive a motor or exchange power with an electrical grid through the required control and protection system. The word inverter describes the conversion function, not one fixed circuit. A 12 V battery inverter that supplies 230 V, 50 Hz is one example. A variable-frequency motor drive that converts a DC link into three-phase AC is another. A solar string inverter may begin with hundreds of DC volts and feed a synchronized grid current without using a 50 Hz step-up transformer. A practical stand-alone inverter normally contains several functional ...
Hello friends, I hope you are doing well. In the previous tutorial, we studied the working principle of a relay. Today, we will connect a 12 V relay to a PIC18F4550 microcontroller through a ULN2003A driver. A relay coil needs more voltage and current than a microcontroller pin should provide. It is also an inductive load, so it produces a voltage transient when switched off. The ULN2003A solves these interface problems by providing seven low-side Darlington drivers and seven internal clamp diodes in one package. The key point is that the ULN2003A does not convert a 5 V logic signal into a 12 V output. The 12 V energy comes from a separate 12 V supply. A logic high merely turns on one internal driver, which connects the low side of the relay coil to ground. We will examine that current path, calculate the important values, build the circuit and write a small test program. Suppose the relay has a 12 V coil rated at 400 mW. Its approximate current is: Icoil = Pcoil / Vcoil = 0.400 W / 12 V = 0.0333 A = 33.3 mA The approximate coil resistance is: Rcoil = Vcoil / Icoil = 12 V / 0.0333 A = 360 ohms A PIC18F4550 output operates from its logic supply and is not a 12 V power output. Microchip's PIC18F2455/2550/4455/4550 datasheet lists 25 mA per pin under absolute maximum ratings, but an absolute maximum is a damage boundary rather than a recommended operating point. Output-voltage specifications, total port current and device power dissipation impose additional restrictions. A 33.3 ...