Fuyang's Blog

On the way to achieve minimalism and essentialism

Category: Uncategorized

First impression on Python

Just started learning Python for a couple of days, found it seem to be a elegant and powerful language.

For example, there’s a problem set of the MIT online course, to let you use for loop output a sequence of number like this:

10, 8, 6, 4, 2,

I know it is easy with basic programming handling method. But I was asking myself, since range(1,5) can give you:

1, 2, 3, 4,

then what is the shortest code to output an array like this:

4, 3, 2, 1,

So how? Tried something like range(5,1) or range (1, 5,-1) it didn’t work. (Later I found actually “range(4,0,-1)” will do)

Then I turned to google and found one can actually do this:


give output

4, 3, 2, 1

My impression on this was like:


This is brilliant and elegant, also perhaps very efficient. However, after looking more discussion on the stackoverflow page, I found an interesting thing for example:

import numpy as np

a = np.array(range(1,11))

b = a[:]

c = a[::-1]

print c

a[1] = 100

b[2] = 101

print c

and the output of it is:

[10 9 8 7 6 5 4 3 2 1]
[ 10 9 8 7 6 5 4 101 100 1]

which means c changes by not doing direct change on itself.

This is because “when you create c you are creating a view into the original array. You can then change the original array, and the view will update to reflect the changes,” as stated by someone on that stackoverflow page. This could be extremely useful, and it feels python give me back the freedom of easily using index or pointer-like functionalities, which could mean that one can probably write very elegant code to do efficient and memory saving operations, easily. It seems to have the potential.

Also, as someone from this stackoverflow post said:

I commonly work with >10GB 3D arrays of uint8’s, so I worry about this a lot… Numpy (seems to be a python math package) can be very efficient at memory management if you keep a few things in mind.

And he also mentioned other ways to save time and space such as how to avoid making a copy of an array and so on. I will need to go back to this post again sometime later, to get a better understanding of the language.

And so far my first impression on Python is like this:


Berkeley Electronic Interfaces Course – Robot Module 3.3 – Amplifier (Speaker Driver & Choosing Amp)

In the previous chapter, we made the robot can hear us. And now we try to let the robot be able to make some noise. Thus we will try to connect a speaker to it.

Suppose we have a small 8 ohm speaker needed to put on the robot. Apparently there are several ways to simply do that, we will start trying some simple ones and see if it works.

Method 1 – Direct drive by the MSP430


As discussed in the course that while doing a setup like this, due to the low impedance of the speaker, with 3.3V voltage supply from the board, it will theoretically drain around 412.5mA. That’s a huge a mount of current. However if we look at the MSP430 datasheet it says there’s only a 48mA maximum output on all the output pins. So when driving the speaker directly with MSP430, not only it will not be very loud, also it will make MSP won’t able to do anything else on any of the output pins due to the speaker is sucking up all the current.


  • Simple setup


  • Drain too much power or current from MSP430 board
  • Might not be able to drive the speak loud enough (48mA limit due to MSP430 spec)

One way to solve this is to use an amp and let the amp provide the power to the speaker. And here is a way to do it.

Method 2 – Non-Inverting Amplifier Drive (OPA2344)


By looking at the circuit we could calculate by using the 3 golden rules, we could know theoretically the output of the amp should be with a gain of 2, which is around 6.6V, and hopefully driving the speaker with 825mA. That should sound very loud. However when you test it, as they did in the course video, you will see that the speaker sounds no much difference. The reason is that for some low power amplifiers, they have a relatively large output impedance, or in other words, they have a relatively low short current – a current at output when you short the output to the ground. And this short current is the maximum current this amp can deliver to the load on output. On the OPA2344 datasheet it notes the short-circuit current is around 15mA. No more than our previous direct drive method.


  • Low power consumption (high impedance between inputs and low quiescent current 150uA)
  • No power drain from MSP430


  • Low short-current (15mA), output power low
  • Consume a little power at the grounded R1

So an easy way to solve some of the low output issue above is by using a type of amps especially designed to dive speakers, an amp with low output impedance and high short current.

Method 3 – Audio Amplifier Drive (LM380 Drive)


For example if we can use LM380-8 amp as a comparator to drive the speaker, shown above. This for sure can drive the speaker very loud with a short current of 1.3A. However there are some draw backs of this amp in our application due to it’s power consumption of the battery could be really high. This is due to the relatively low input impedance comparing with the previous OPA2344 amp. The quiescent current is 7mA for this amp and only 150uA for OPA2344. (As long as I remember the quiescent current is the current that flows between the non-inverting and inverting inputs, or it could be also described as the current an amp is “naturally” drawing without and load connected. The higher the input impedance, the lower of the quiescent current, thus lower power consumption.)


  • High short current 1.3A, powerful output
  • No power drain from MSP430


  • High power comsumption – Quiescent current typical 7mA

So what we do? Well practically we don’t need to make the speaker sound extremely loud in our robot case, so method 2 will more or less do the job. However by noticing the power drain on the R1, we then could just change the circuit without using feedback resisters, but using a direct feedback to so make a voltage follower.

Method 4 – Voltage Follower Drive


In this way the output voltage has no gain and we still can output 15mA mostly to the speaker and this sounds quite alright. Also in this way the power consumption is extremely low among other methods shown here.


  • Ultra low power consumption
  • No power drain from MSP430


  • Low output power, but for our case it is acceptable

I believer there are more methods out there and could be discussed to improve the design. But since the learning level of this course is not aiming at those advanced topics and the method 4 will just do fine for our robot, we just decide to go on with it now 🙂

Berkeley Electronic Interfaces Course – Robot Module 2 – Wheatstone Bridge


This second module on the EE40LX course is about using a Wheatstone bridge: any resistive sensor could be used in the bridge. The final robot we build in the course has two photocell “eyes.”

One key note on Wheatstone bridge is that, if one would like the swing of V_{out} to include both positive and negative voltages, one will have to make sure the choices of R1, R2, R4 to have a value between the lower and upper limit of R3, which is a photocell (VT90N1) in this case.


Photocell used here is EXCELITAS TECH VT90N1 LDR, 200KOHM, 80MW, VT900 Series.

Changing CSS to customize your Wordpress theme (Manifest)

With quite a bit of effort, I finally could relax and enjoy my blog’s nice and neat looking theme. Shortly speaking, there are not so many those “very minimal” type of theme on WordPress, after comparing around, I found these two theme very good but each has something that is not perfect in my opinion:

  • Penscratch – Good looking but font and line-space too big for me. The font color seems a bit too light. Also the setup of the background color causing the Latex equation to have a dark color background by default 😦
  • Manifest – Good looking as well, but the main content width is too narrow. It also cannot change the width based on your browser condition or your screen size of your device. As a modern website it should be self-adapted. Another thing is this theme doesn’t have a side bar where you can show some links such as categories or archives.

In order to make my blog looks better, I started to look into the customize CSS option that WordPress provides. Firstly I tried on Penscrath theme but in the end couldn’t solve the Latex color problem. Then I switched to Manifest, downloaded it’s CSS from the link above, search key word “width” inside, found many things like this:

#site-wrapper {
margin: 0 auto;
padding-top: 15px;
width: 500px;
text-align: center;
position: relative;

Which means that the “site-wrapper” is set exactly to 500px. No matter how wide your screen is. Thus by changing all the constant defined width in the original CSS to something like “50%”, then the webpage will show up in a nicer way, especially in my case that I use a very wide screen.

After I did those changes, weather it looks good or not, you should be easily see if you are viewing this post. (Suppose I am still using Manifest as the theme).

If you want to try these changes for yourself, try copy paste the following code to the WordPress CSS editor:

#site-wrapper {
 width: 51.8%;
#site-description {
 width: 60%;
#main-nav ul {
 width: 100%;
#main-nav ul ul {
 width: 100%;
#core-content {
 width: 100%;

h1 {
 text-transform: uppercase; /* Your Blog Title*/
h2 {
 text-transform: none;

.commentContent {
 float: left;
 width: 51.8%;
 margin-left: 22px;
#comments h3 {
 font-size: 1.4em;
#comments h3,
legend span {
 width: 51.8%;

#footer {
 width: 51.8%;
.footer-content {
 width: 100%;

With the code above your Manifest Theme should look the same as mine which you are looking at right now. And it’s nice that Latex by default can show up in a very nice way 🙂

e^{i\pi} + 1 = 0

Special thanks to my friend Jean Popescu for providing help and suggestions on this.

An idea before sleeping

Making some small but daily repeating habits can be very beneficial, I guess.

Have heard about this idea somewhere before and today saw it again in the book essentialism, its called “Create new triggers” in the book.

Perhaps I could try to read some book before sleep and record down some interesting ideas I had for the day. Since I used to browse Facebook and reading some news on web before sleep, this new “trigger” should be easily added 🙂

It’s late, good night, hope we all can sleep well 🙂


Tesla unveiled the D version – dual motor version – a few days ago. Feel so excited and would like to try the car some day. And hopefully in 2017 the Tesla Model 3 will come, then I will probably think about getting one for myself 😛

First Post

Just see if would like to keep a blog…