# Gas station without pumps

## 2016 October 25

### Solar power annual cycle

Filed under: Uncategorized — gasstationwithoutpumps @ 16:25
Tags: ,

I’ve been running my solar panels for almost 15 months now, and I decided to plot the daily energy production:

The sinusoidal fits are to all the data (the lower curve), and to the data after cleaning up the bad-weather drops in energy.

When I first looked at the data, I realized that a sinusoidal fit to the data would be heavily affected by the cloudy days, which drop power production substantially, so I wrote a script to delete any day whose power was less than the day on either side. Doing three passes of that resulted in most of the really low values being gone, so I fitted a sinusoid to that subset of the data—what I would have gotten if there were no bad-weather days.

When using all the data, I averaged about 7.1 kWh a day, with a ±3.4 kWh annual fluctuation. With just the good-weather data, I averaged about 8.1 kWh a day, with a ±3.5kWh annual fluctuation. That means that I’m losing about 1/8 of the potential solar capacity to cloudy weather. The max and min are within one day of the solstices, so the fitting is doing a pretty good job of finding the phase.

The fluctuation is not perfectly fit by a sine wave, though, as the summer peak is a bit broader than the winter valley. If I were ambitious, I would try seeing how well the data fits with the equation of time or the sunrise equation, instead of a simple sinusoid. I don’t think that would actually help the fit much, as I think that the biggest part of the error is due to shadowing by trees or buildings in the early morning and late afternoon, and this shadowing is more pronounced with the low sun angles of winter.

## 2016 October 24

### Bike seat fixed

Filed under: Uncategorized — gasstationwithoutpumps @ 18:47
Tags: , , , ,

This past weekend, I fixed my bike seat (see Broken bike seat and Flexible adhesives).

The idea of the fix was simple: to insert at 15mm diameter aluminum rod (6061 alloy, tempered to T6) that spans the break and the high-stress point on the other side of the clamp, which is also scored and likely to fracture, and glue it in place.

I found the rod I need at McMaster-Carr, with specifications of 15±0.23 mm diameter.  I thought it was slightly undersized at 14.7mm, measuring with my calipers, but my calipers are not so precise that I can be sure of that measurement.  Measuring with my micrometer gave 14.82±0.01mm, which is within spec.  I could have gotten a more precisely specified aluminum rod for an extra $10, but I did not think that it was worth the extra price—I may come to regret that, as the aluminum rod fits loosely, not snugly inside the tubing. I cut the rod to length with a hacksaw (using oil to lubricate the blade) and ground the sharp edges down with a wet wheel, then sanded the rod both to round the ends and to remove most of the oxide coating and provide a rough surface for the epoxy. The rounded ends are to reduce the stress raisers at the ends of the rods, as that is now where the tubing should flex the most. Aluminum rod: cut, ground, and sanded. The mark indicates where the break in the tubing should be. The rod extends about 15mm past either end of where the clamp holds the tubing. I would have extended it further, but I was worried about bending the aluminum tubing too far to open up the bike seat frame enough to get over the end of the tubing. I sanded the inside of the tubing on the broken bike seat and the fractured ends to promote adhesion, and I cleaned both the rod and the tubing with rubbing alcohol. In the comments on Broken bike seat, gflint suggested a silicone adhesive, but I ended up using a flexible epoxy, TotalBoat FlexEpox, that is designed for repairing boats. It is supposed to adhere well to aluminum, have high tensile and flexural strength, and a very slow set time, plus it is fairly cheap at$18 for about 30 times more epoxy than I needed.

I mixed up tiny amounts of the epoxy in old cough-syrup measuring cups:

The cough-syrup cups did not make precision measurement of the resin and hardener easy, as both were quite viscous—I hope I got close to equal quantities. I suppose I should have gotten out the centigram scale and mixed by weight—that would probably have given a more precise ratio.

For the first gluing on Saturday, I coated both the inside of the tubing and the rod with the epoxy and inserted it to the desired depth. I wiped off excess (there was a lot that oozed out) with a paper towel wet with rubbing alcohol, and clamped the rod in place simple by letting the other part of the tubing press against the rod sideways. I used a little scrap of paper towel between the rod and the outside of the tubing to keep them from getting glued together:

The rod glued and clamped in place, with paper towel to keep the rod from sticking to the outside of the other part of the tubing.

On Sunday, I mixed more epoxy and coated the inside of the other piece of tubing and the piece of the aluminum rod sticking out, then lined up the tubing and let it close back together:

Excess glue squeezed out of the joint.

I clamped the joint together by wrapping bungee cords around the frame of the seat, and wiped off the excess glue with a paper towel moistened with rubbing alcohol:

The bungee cords provided a fairly large clamping force, but no more glue oozed out when it was added, so the springiness of the frame alone may have been sufficient.

On Monday, I worked on the clamp on the bike.

I rounded the edges of the clamp to reduce the stress raising that had led to the first failure—the edges had been quite sharp.

In addition to rounding the edges to reduce the stress raising, I also offset the seat by a few millimeters from where it had been, so that the glued joint is now slightly inside the clamp.

Before replacing the seat, I noticed that there was a bad rust spot behind the clamp, so I took the clamp apart to look at the frame:

The frame was quite rusty behind and inside the clamp.

I was going to sand the rust spots, prime with metal primer, and repaint the spots, but my metal primer was no longer any good, so I just did some light sanding and coated all the rusty spots with oil. I will have to buy some more metal primer and repaint in a couple of weeks when I next have time to work on the bike.

I put the bike seat back in the clamp and replaced the mesh seat, which had been washed to remove the road grime.

I plan to let the epoxy cure for another day before riding the bike (they claim a 7–10-hour cure time, 24 hours for high load, but I’ll go a little longer, as it is going to rain tomorrow anyway).

I’m hopeful that this fix, which cost under $50, will let the bike seat be usable for the next 15 years. ## 2016 October 23 ### UCSC athletics “town hall” A year and a half ago, I wrote a post, I’m proud of UCSC undergrads, in which I praised UCSC undergrads for rejecting a fee to subsidize the approximately 250 Division III athletes on campus, and last Spring I wrote Not so proud of UCSC undergrads this year, when they voted 63% in favor of being asked if they would support a new fee of$270 a year to support the NCAA athletes (about $4.3 million for 16,000 students, or$14,000/athlete for the 300 NCAA athletes).

Last Spring, the Faculty Senate put together an ad hoc committee to report on athletics, but only those who strongly supported athletics volunteered to serve on it, so it came out with a very strongly pro-athletics report that I don’t believe honestly reflects faculty opinion. I particularly object to the claim

Perhaps more importantly, as faculty, we have great concern that the termination of UCSC student athletics, a program that distinguishes itself in the classroom and in competition, would signal to the world that we cannot maintain a first-class university.

That is BS of the highest order—being a first-class university has nothing to do with athletics, certainly not in the world outside the USA.  And even in the USA, a few Division III teams has nothing to do with the perception of the university.

Quite frankly, I find it shameful that the administration is spending $1million a year of unrestricted funds on NCAA athletics—that amount of money would hire instructors for about 100 more classes, helping about 3500 students, rather than 300. The big advantage of sports on a campus comes from student participation, not being spectators, so funding models that provide facilities for intramurals and club sports that any student can participate in make much more sense than dedicating funding for a tiny number of privileged athletes. Last Wednesday the Faculty Senate athletics committee had a “town-hall meeting”, ostensibly to get comments from students, but the audience consisted almost entirely of the NCAA athletes and their coaches, so turned into a “how can we get this passed?” rather than having students discussing whether it was a good idea. The few students there who were not NCAA athletes were probably too intimidated by being surrounded by athletes to raise any objections—though one student did bravely ask what fraction of the students benefited from the student fee (a bit less than 2%). There were some very strange ideas being passed around—like that students who weren’t athletes were getting sweetheart funding that the athletes should be getting instead (or perhaps as well). The question was brought up of where engineering students got their funding from (which was not answered). That one struck me as particularly strange, as engineering students generally end up either self-funding, crowd-funding, or getting funding from grants that faculty have spent years trying to get—they aren’t getting any handouts from the rest of the students! A case in point: the iGEM project team needed about$25,000 for the 20-member team for the equipment, reagents, and travel to the iGEM conference. They raised this money through a crowd-funding campaign (which means that most of it came from family and friends).  The instructor’s salary was paid out of summer-school tuition (again, paid for by the team members, as there is no general-fund subsidy for summer school).  Rather than getting a $14,000 subsidy per team member like the athletes are asking for, they were paying out thousands of their own money to attend summer school to be on the team, and doing crowd-funding for the rest. I have no objection to the NCAA teams running crowd-funding campaigns. There is some industrial sponsorship for a few senior engineering capstone projects (maybe a quarter of all the capstone projects in the Baskin School of Engineering). That sponsorship comes as a result of many years of hard work by faculty and administrators making contacts in industry and begging for support for student projects (and those projects come with several strings attached, sometimes including ownership of the students’ work by the sponsoring company, I believe). Funding for student projects in engineering is much more like club sports than like NCAA athletics—essentially everything is paid for by the students involved, either directly or through fund-raising. The same is largely true of other student groups on campus (theater groups, dance groups, artists, … ). All the groups can apply for tiny amounts of money from student fees through the student government—only the NCAA athletes seem to feel that they deserve much, much more than that. Theater and dance groups often need instructors, the same way that athletes need coaches, but there is no built-in funding for these instructors. For the most part, they are paid for teaching courses, as OPERS coaches are—why should one group of instructors have a dedicated student fee, when others do not? The NCAA athletes at UCSC are not dumb jocks—they have a higher GPA and graduation rate than the campus as a whole, so they must be aware that they are asking for very special privileges that are not given to other students. Why do they or their coaches deserve special treatment? ## 2016 October 16 ### Lagrangian mechanics for linear electronics Filed under: Uncategorized — gasstationwithoutpumps @ 13:27 Tags: , , This post is a continuation of Having trouble learning Lagrangian mechanics, looking at electronic systems rather than mechanical ones. Again, this is not intended as a tutorial but a dump of my understanding, to clarify it in my own head, and to get corrections or suggestions from my readers, many of whom are far better at physics than me. For electronics, I’ll use charge $q$ as my coordinate, with current$i = \dot q\$ as its derivative with respect to time.  In all but the simplest circuits, there will be multiple charges or currents involved, which I’ll distinguish with subscripts.

Some notation:

• $\mathcal{L}$ is the difference between kinetic and potential energy of the system.  The potential energy will be the energy stored in capacitors, $\frac{q^2}{2C}$, and the kinetic energy the energy in the inductors, $L\dot q^2/2$.  (Note: that is only self-inductance.  If we have mutual inductance $L_{12}$ between two inductors, we need to use $L_{12}\dot q_1\dot q_2 /2$ for the kinetic energy—I’m a bit confused by that, as we could have negative kinetic energy.  I rarely use inductors or transformers in my electronics, so I’ve not had to work out my confusion yet.)
• $\mathcal{P}$ is the power dissipated by the resistors in the system: $R{\dot q}^2/2$.
• $\mathcal{F}$ is the vector input to the system needed to make the energy balance work out.  By using charge for each coordinate, the units here will be volts.

With this notation, the basic formula is

$\frac{d}{dt}\frac{\partial \mathcal{L}}{\partial \dot q} - \frac{\partial \mathcal{L}}{\partial q} + \frac{\partial \mathcal{P}}{\partial \dot q} = F_{q}~.$

Let’s check the units:

• Potential energy: $\frac{\partial}{\partial q} \left(\frac{q^2}{2C}\right)= \frac{q}{C}$, which is indeed volts.
• Kinetic energy: $\frac{d}{dt}\frac{\partial L\dot q^2/2}{\partial \dot q} = L\ddot q$, which is also volts.
• Dissipated power:$\frac{\partial R{\dot q}^2/2}{\partial \dot q} = R \dot q$, which is again volts (Ohm’s Law).

Now all we need to do is to figure out which $q_i$ or $\dot q_i$ has to be associated with each component of the system, and what voltages the $\mathcal{F}_i$ correspond to.  I think that will be easiest if I have some specific circuits to work with.  Let’s start with a very simple one:

Simple RLC series circuit with a voltage source.

We can use a single coordinate, the charge on the capacitor, $q_1$, so that the current flow $\dot q_1$ is clockwise in the schematic. We get the Lagrangian $\mathcal{L} = L_1{\dot q_1}^2/2 - \frac{{q_1}^2}{2C_1}~.$ The power dissipation is $\mathcal{P}=R_1{\dot q_1}^2/2$, and taking the derivatives gives us $\mathcal{F}_1 = L_1 \ddot q_1 + R_1 \dot q_1 + q_1/C$, which is the voltage for the voltage source.

For electronics modeling, we often want to look at the ratio of two different voltages in a system, for example, the output of a filter relative to the input to a filter. How do we set that up? Let’s look at a very simple low-pass RC filter:

The upper schematic shows the normal way to represent the low-pass filter. The lower schematic shows it with a voltage source and a voltmeter, with two loops (one of which has no current).

The potential energy is just $\frac{(q_1+q_2)^2}{2C}$, there is no kinetic energy (no inductors), and the dissipation is $R{\dot q_1}^2/2$. Taking the derivatives of the Lagrangian gives us
$\mathcal{F}_1 = \frac{q_1 + q_2}{C} + R \dot q_1$ and
$\mathcal{F}_2 = \frac{q_1 + q_2}{C}$.
In other words, we get the voltage at the voltage source and the voltage at the voltmeter. If we want to do anything with these equations, we need to recognize that the $q_2$ and $\dot q_2$ terms are 0 (modeling the voltmeter as a perfect infinite impedance), giving us the usual formulas for the input and output voltage, in terms of the charge on the capacitor: $v_{in} = \frac{q_1}{C} + R \dot q_1$ and $v_{out} = \frac{q_1}{C}$.

If we take Laplace transforms, we get $V_{in} = Q_1/C + RsQ_1$ and $V_{out}= Q_1/C$, which gives us the transfer function $\frac{V_{out}}{V_{in}} = \frac{1}{RCs + 1}$, as expected.  (Plug in $s=j\omega$ to get the usual format in terms of angular frequency.)

I could do another, more complicated example, but I think that the idea is clear (to me):

• Make a charge (and current) coordinate for each current loop in the circuit—including a dummy loop with current 0 wherever you want to measure the voltage.
• Set up the Lagrangian by adding terms for each inductor (kinetic energy) and subtracting terms for each capacitor (potential energy), and set up the power-dissipation functions by adding terms for each resistor.
• Take the appropriate derivatives to get the voltages.
• If needed, eliminate charge terms by using more easily measured voltage terms.

I don’t find this process any simpler than using complex impedances and the usual Kirchhoff laws, but it isn’t much more complicated.  It may be easier to use the Lagrangian formulation than setting up the equations directly when there are mutual inductances to deal with—I’ll have to think about that some more.

Of course, the big advantage I’ve been told about for Lagrangian mechanics is in electromechanical systems, where you model the mechanical part as in Having trouble learning Lagrangian mechanics and the electronic part as in this post, with only a conservative coupling network added to combine the two. It is in setting up the coupling network that I get confused when trying to model electromechanical systems, and I’ll leave that confusion for a later post.

## 2016 October 15

### Having trouble learning Lagrangian mechanics

Filed under: Uncategorized — gasstationwithoutpumps @ 22:51
Tags: , ,

For the past few days, I’ve been trying to teach myself enough Lagrangian mechanics that I can derive systems of ordinary differential equations for the sorts of simple systems that come up in control-theory classes.

I think I’ve kind of got it for mechanical systems, and maybe for electronic ones, but I can’t seem to wrap my head around electromechanical systems.  I’m going to dump out a little of my understanding here, to clarify it in my own head, and to get corrections or suggestions from my readers, many of whom are far better at physics than me, having actually taken it in college. My son and I studied simple physics using the textbook Matter and Interactions a few years ago, but the book doesn’t get into Lagrangian mechanics, and I don’t think I really understand magnetic fields intuitively well enough to keep the mathematical abstractions straight.

Part of my problem in reading introductions to Lagrangian mechanics (like the Wikipedia one) is that they use almost impenetrable abstract notation and immediately jump to very general cases, leaving me with no intuition about what they are doing.

As I understand it, Lagrangian mechanics starts with the idea of a conserved scalar quantity (like energy), and provides a way of setting up equations of motion by taking partial derivatives with respect to generalized coordinates, which are in turn functions of time.

For mechanical systems the generalized coordinates are generally positions of point masses or angles of joints (velocity and angular velocity are time derivatives of the coordinates).  For electronic systems, the generalized coordinates are either charges or voltages and currents, depending whose formulation you read.  The charge-based formulation has made a bit more sense to me, as currents are the time-based derivatives of charge.  We look at the charge on capacitors and current through inductors to compute energy in the system.

One problem with a lot of the descriptions of Lagrangian mechanics is that they do everything with purely conservative systems, then tack in dissipation as an afterthought, but all real systems that need control have dissipation of energy as a fundamental part of the modeling process.  I’ll try to include the dissipation terms in the basic formulation, rather than adding them  at the end.

Some notation:

• $\mathcal{L}$ is the difference between kinetic and potential energy of the system.  In a conservative system, it would always be 0, with energy sloshing back and forth between kinetic and potential forms, but never increasing or decreasing.Correction based on comments: I screwed up here—it is the sum of kinetic and potential energy (the Hamiltonian) not the difference (the Lagrangian) that is constant in a conservative system.
• $\mathcal{P}$ is the power dissipated by the system.
• $\mathcal{F}$ is the vector input to the system needed to make the energy balance work out.   The units for this vector depend on what the generalized coordinates are.  For mechanical systems, Cartesian coordinates will need forces, and angles will need torques.  For electronic systems using charges as coordinates, the units are volts.

With this notation, the basic formula is

$\frac{d}{dt}\frac{\partial \mathcal{L}}{\partial \dot x} - \frac{\partial \mathcal{L}}{\partial x} + \frac{\partial \mathcal{P}}{\partial \dot x} = F_{x}~.$

I may be missing some critical conditions on when this can be applied, but I did manage to work out the equations of motion for an inverted pendulum on a cart from it.

So here is the inverted-pendulum example:

We have two coordinates: the horizontal position of the cart $x$, and the angle of the inverted pendulum (clockwise from upright) $\theta$.  The cart has mass $m_{c}$ and the pendulum $m_p$, with a distance from the pivot on the cart to the center of  mass for the pendulum $l$.  Furthermore, the pendulum has moment of inertia $J$, and there is viscous drag on the cart with a force $-b\dot x$.  The pivot is assumed to be frictionless.

Let’s use $p$ to designate the location of the center of mass of the pendulum: $p= \left(x+l\sin(\theta), l\cos(\theta) \right)$.

The potential energy in the system is just due to the height of the pendulum mass: $m_{p}g l \cos(\theta)$.  The kinetic energy is $m_{c} \dot x^2/2 + m_p \dot p^2/2 + J \dot\theta^2/2$. Combining these gives us

$\mathcal{L} = m_{c} \dot x^2/2 + m_p \dot p^2/2 + J \dot\theta^2/2 - m_{p}g l \cos(\theta)~.$

The power dissipated due to friction is $\mathcal{P} = b \dot x^2/2$.

It would be good to get rid of the extra variable $p$, using just $x$ and $\theta$.  The derivative is $\dot p=\left(\dot x +l \cos(\theta)\dot\theta, -l \sin(\theta)\dot\theta\right)$, and its square is $\dot p^2 = \dot x^2 + 2l\cos(\theta) \dot x \dot \theta + l^2\dot \theta^2$.  Substituting that into our previous formula gives us the Lagrangian in terms of just the generalized coordinates and their time derivatives:

$\mathcal{L} = (m_{c} +m_p) \dot x^2/2 + m_p l \cos(\theta)\dot x\dot \theta + (J +m_{p}l^2)\dot\theta^2/2 - m_{p}g l \cos(\theta)~.$

Applying the basic formula gives us

$F_x = \frac{d \left((m_c+m_p)\dot x +m_p l \cos(\theta)\dot \theta\right)}{dt} + b \dot x$

$F_x = (m_c+m_p)\ddot x + m_p l \cos(\theta)\ddot\theta -m_p l \sin(\theta) {\dot\theta}^2+ b \dot x$

$F_\theta =\frac{d \left(\left(m_p l \cos(\theta) \dot x + (J+m_pl^2)\dot\theta\right)\right)}{dt} +m_p l \sin(\theta)\dot x{\dot\theta}^2+ g m_p l \sin(\theta)$

$F_\theta = m_p l \cos(\theta) \ddot x - m_p l \sin(\theta)\dot x\dot\theta + (J+m_pl^2)\ddot\theta+m_p l \sin(\theta)\dot x{\dot\theta}^2+ g m_p l \sin(\theta)$

We can linearize this around $\theta=0$ (the inverted pendulum straight up), by setting $\cos(\theta)\approx 1$ and $\sin(\theta)\approx 0$, except for the gravitational term, where we use $\sin(\theta)\approx\theta$:

$F_x = (m_c+m_p)\ddot x + m_p l \ddot\theta+ b \dot x$

$F_\theta = m_p l \ddot x + (J+m_pl^2)\ddot\theta+ g m_p l \theta$

These equations of motion can be used to design a controller for the cart and inverted-pendulum system, as long as you don’t let the pendulum get too far from the vertical.  I think that the linearized equations are ok, but I may have made some calculus errors in the nonlinear equations I simplified them from.

I’ll stop here, but try to do another (electronic) example in a later blog post.

Next Page »

Blog at WordPress.com.