Sunday, February 26, 2023

Creating a Ramp Generator

Have you ever wondered how to use the fact that a capacitor charges in a straight line to build a useful circuit? One simple and effective way is to turn it into a ramp generator. In this post, we'll take a closer look at how this can be achieved with a circuit that produces an output waveform that ramps up and down in a controlled manner.


The circuit consists of three main blocks: a capacitor (C1), a constant current source based on a PnP transistor, and a discharge circuit based on a FET. Let's take a closer look at how each of these components works together to create the ramp generator.

Discharge Circuit

Starting from the left side of the circuit, we have some kind of square wave oscillator producing a 1KHz pulse. The square waveform is then fed into a differentiator, which removes any DC offset and produces an output proportional to the rate of change of the signal. This means we only get an output of the rising and falling edges.

However, to ensure the circuit works correctly, we need to remove the negative side of the pulses. This can be achieved using a diode clamp, which is then fed into the gate of a FET. The FET effectively places a low resistance across the capacitor every 1ms, quickly discharging the capacitor.


Constant Current Source

A capacitor will create a linear voltage if charged from a constant current source. The circuit we're using here creates a constant current source by using a PnP transistor. For more details on how the constant current source works, please see a previous blog post on Building a Constant Current Source for Linear Charging.

By combining the discharge circuit and the constant current source, we can create a ramp generator that produces an output waveform that ramps up and down in a controlled manner. The ramp can be adjusted by changing the values of the capacitor or the constant current source.

In conclusion, by using the fact that a capacitor charges in a straight line, we can create a simple and effective ramp generator. This circuit can be useful in a variety of applications, such as in audio circuits, waveform generators, and more.













Building a Constant Current Source for Linear Charging

In a previous post (Charging a capacitor exponentially), we explored a simple circuit for charging a capacitor over a period of 1 millisecond. As we saw, the voltage against time characteristics of this circuit were exponential in nature. However, what if you want to charge the capacitor in a straight or linear line? Thankfully, you can achieve this by switching from a constant voltage source to a constant current source.

If you supply a constant current to a capacitor, you can calculate the time it will take to charge using the formula Vc = (I x t) / C, where Vc is the voltage across the capacitor, I is the current supplied, t is the charging time, and C is the capacitance of the capacitor.

 To achieve a linear charge, we can use the following circuit:

In this circuit, the capacitor C is charged through a constant current source, which ensures that the current flowing into the capacitor remains constant. As a result, the voltage across the capacitor increases linearly with time.

If you want to charge a capacitor with a constant current, you can use a constant current source. One way to build a constant current source is to use a PNP transistor.


The circuit shown above can produce a constant current of 1mA through R4. To calculate the value of the constant current, we need to determine the base voltage, Vb, which is set by the potential divider R1 and R2. Once we know the base voltage, we can easily calculate the constant current using the formula (V1 - Vb - 0.7) / R3, where V1 is the voltage supplied to the circuit, and 0.7V is the voltage drop across the emitter of the transistor.

In conclusion, a PNP transistor-based constant current source is a simple and effective way to generate a constant current for charging capacitors or driving LEDs. With some basic knowledge of transistor operation and circuit theory, you can easily design and build a constant current source that meets your requirements.





Thursday, February 23, 2023

Charging a capacitor exponentially

Are you interested in creating your own RC charging circuit? With just a few simple components and a little bit of knowledge, you can easily make it happen! By connecting a resistor and capacitor in series and applying a voltage, you can create a circuit that charges the capacitor over time. But how long will it take? The answer is simple: it's 5 times the resistance (R1) multiplied by the capacitance (C1). That means you can control the charging time by choosing the right components. For example, if you want the capacitor to charge in just 1 millisecond, all you need is a 500 ohm resistor and a 400 nanofarad capacitor.

To make things even easier, I've included some helpful diagrams below to guide you through the process. And if you're interested in the nitty-gritty details, I've even included some Python code to help you calculate the charging time.

---
KHZ = 1e3
OHMS = 1
FARAD = 1


f = 1.0*KHZ

t = 1/f
print(f'Time constant {t*1e3:.2f}ms or {t*1e6:.2f}us')

R =500*OHMS
C = (t/(5 * R))*FARAD
print(f'Resistor:{R*1e-3:.2f}K, Capacitor:{C*1e9:.2f}nF'
---

Mastering the Art of Deep Work: Insights from Cal Newport's "Deep Work”

  Introduction: The Power of Deep Work In a world dominated by constant connectivity and digital distractions, Cal Newport's Deep Work...