All posts by Per Magnusson

Making VLC automatically reload the favorite playlist

I sometimes use VLC as an mp3 player and it would be nice if it did automatically load my default playlist when it starts. It is not apparent from the settings within VLC how to accomplish this, but some googling brought up an old blog post from 2007 that explained how to do it. Sort of. The information was outdated, but the remaining piece of the puzzle was provided in one of the comments.

This is how to make VLC automatically load a specific playlist:

  • Select the menu Tools->Settings.
  • Click to show all settings and not just the simple ones.
  • Click on playlist.
  • Fill out the path to the playlist in the field “Standard stream”: file:///C:/audio_files/playlist.m3u
  • Click Save.

Note that there shall be three slashes after file: and that the slashes shall be forward (/), not backward (\) as is usually the case in file paths on Windows.

 

Changing to mbed firmware on FRDM-KL25Z using Windows 10

I have a couple of projects where I want to use the ARM mbed platform on the inexpensive  FRDM-KL25Z board, which features the Freescale Kinetis KL25Z ARM Cortex-M0+ processor. This requires a firmware update on the board and I have done this previously without trouble while I was still running Windows 7. Now however, I have moved to Windows 10 and this caused a bit of trouble.

This post describes the problems I ran into and how I solved them. In essence, I was forced to use a computer running Windows 7 to do the actual update.

Failed attempt

The firmware upgrade process is described on this page. While there are some hints on that page that the upgrade might not work if the host computer runs Windows 8 or Windows 10, this is not entirely clear, so I tried it anyway. This is what I did and what happened:

  • Download the 20140530_k20dx128_kl25z_if_opensda firmware file (a zipped .s19 file) and unzip it.
  • Hold down the reset button on the FRDM-KL25Z board while plugging in the USB cable in the right (SDA) USB connector.
  • The board now appears as a disk called BOOTLOADER.
  • Drag the .s19 file to the BOOTLOADER disk.
  • Unplug and replug the FRDM-KL25Z.
  • If everything had worked as it should, the board would now have shown up as a disk called MBED. What instead happened was that the computer did not at all react to the board. No disk showed up.

Reading a bit more on the firmware upgrade page and in the discussions at the bottom of the page, it seemed like there was no way forward using only a Windows 10 computer.

Successful attempt

The reason it did not work with Windows 10 seems to be that my FRDM-KL25Z board had too old bootloader firmware. It has to be 1.11 or higher to work on Windows 10 (or Linux and Mac it seems). To check the bootloader version, one can hold down the reset button while plugging in the USB cable into the SDA port. This makes the board show up as a BOOTLOADER disk where there is a file called SDA_INFO.HTM. Double clicking on this file brings up a web page that says among other things what the bootloader version is. In my case it was 1.09.

To remedy this, the following steps are required:

  • Get hold of a computer running Windows 7 or Windows  XP.
  • Hold down the reset button on the FRDM-KL25Z board while plugging in the USB cable in the right (SDA) USB connector.
  • The board now appears as a disk called BOOTLOADER.
  • Download a new OpenSDA bootloader firmware from PE Micro. This requires some form of registration and giving out an email address, but is otherwise free.
  • Unzip the downloaded file.
  • Unzip the OpenSDA_Bootloader_Update_App_v111_2013_12_11.zip (or similar) file from inside the big zip file.
  • Drag and drop the resulting BOOTUPDATEAPP_Pemicro_v111.SDA (or later version) file to the root directory of the BOOTLOADER disk.
  • Unplug and replug the board to initiate the bootloader update. This typically takes just a few seconds.
  • Once the update is complete the board will automatically reappear as a disk called BOOTLOADER.
  • Double click on the SDA_INFO.HTM file in the root directory of the BOOTLOADER disk to see that the bootloader version now is 1.11 (or higher).
  • Drag the 20140530_k20dx128_kl25z_if_opensda.s19 (or whatever the latest version of the mbed firmware is) to the BOOTLOADER disk.
  • Unplug and replug the board. It should now show up as a disk called MBED.

After this, the board showed up as a disk called MBED and worked on Windows 10.

To upload and run a .bin-file (the output of the mbed online compiler) to the board one drags the .bin file to the MBED drive and then presses reset on the KL25Z board.

 

AC Current Sensor

This post describes a circuit that can detect a mains frequency AC current and translate it into a voltage that is proportional to the current. It does this while being electrically isolated from the AC current.

One way of measuring the current to a single phase AC load, like a motor or a heater, is to use a current sense transformer around a wire that conducts the current. One kind of current sense transformer is the Rogowski coil, which is basically an air-core toroidal coil where one of the leads is routed back inside the coil to end up on the same side as the other lead. The absence of an iron/ferrite core makes the Rogowski coil immune to saturation, so it can handle large currents while still being linear.

The output voltage of the coil is proportional to the rate of change of the current to be measured, so in order to get a voltage proportional to the current itself, one has to use an integrator. If the current is known to be a sinusoid of a fixed frequency, it is not necessary to integrate the voltage as a simple factor determines the relationship between the current and the coil voltage, but such a design would make the circuit very sensitive to high-frequency overtones. The circuit discussed here contains an integrator so that it gives accurate outputs for a wide range of frequencies.

Below is a schematic of the integrator circuit I came up with.

Rogowski-based AC sense amplifier.
Rogowski-based AC sense amplifier.

The components in the box to the left is a simulation model of the Rogowski coil PA3208NL. This device has an internal resistance of 37.6 ohm (R1) and gives an output voltage of 383 µV for a 1 A 50 Hz current. I1/L1 provides a voltage that is proportional to frequency and reaches 1 V RMS at 50 Hz, which is converted to 383 µV at 50 Hz by E1.

C1 provides some high-frequency (EMI) attenuation while R2 makes sure the input of the amplifier circuit is biased to GND even if the coil is not connected. These components have little effect on the simulations.

R3/C3 is partly another EMI low-pass filter, but the values are also chosen so that it takes over the integrating function from the amplifier around 15 kHz. C2 AC-couples the GND-referred signal at the input to the half-supply point used by the amplifier.

R4/R5 biases the amplifier input at half supply to maximize the available signal swing.

U1 approximates an integrator over the frequencies of interest. In this range C4 acts as a short and R7 has much higher impedance than C5. The frequency response is thus determined by C5/R6 and the gain is (1 + 1/(s*R6*C5)). The 1/(sR6C5) becomes shrinks to become equal to the 1-term at about 15 kHz, so well below this frequency the response is close to that of an integrator, which would be 1/(s*R6*C5). As mentioned above, R3/C3 are chosen so that they take over the integrating business (low-pass filtering) at this point, so the total circuit response is close to that of an integrator to frequencies quite a bit above 15 kHz, to around 100 kHz or so.

For low frequencies, R7 starts dominating over C5 around 3.3 Hz. The same cutoff frequency has been chosen for C4/R6, so 10 times this frequency (33 Hz) is approximately the lower point at which the circuit behaves as an integrator.

For very low frequencies, well below 3 Hz, C4 and C5 acts as open circuits and R7 provides DC feedback to establish the operating point. This takes care of a problem that ideal integrators have, namely infinite gain at DC, which would sooner or later rail the output of U1. By having C4 in series with R6 and R7 in parallel with C5, the gain at DC becomes 1 and since the input is AC-coupled (through C2), the only DC term at the output is one times the amplifier input offset.

Below is a frequency response plot of the most interesting nodes in the circuit.

Frequency response at some of the nodes.
Frequency response at some of the nodes.

The green curve shows the voltage linac inside the Rogowski model. Note that it reaches 1 V at 50 Hz and increases linearly with frequency.

The blue curve is the green curve scaled so that it has a value of 383 µV at 50 Hz.

The red curve is the input of the amplifier. It follows the blue curve up to just below 10 kHz, where the low-pass action of R3/C3 kicks in and flattens the curve. As mentioned above, this knee is chosen to coincide with the opposite knee of the amplifier caused by R7/C5 so that the total response, the grayish-green curve, is flat from 30 Hz to 100 kHz. The gain is just above 0.1 V/A, which makes this design suitable for applications with up to at least 10 A of maximum current.

One caveat when testing or using this circuit is that it takes a pretty long time for the 100 µF capacitor to charge up via the 2.2 megohm resistor after power up. The time constant here is more than three minutes (220 seconds), which means it will take a long time from power up until the circuit is operational. If this is a problem in any given application, one could consider  placing a CMOS switch (like 4066) across the 2.2 megohm resistor and let it be closed for a short period after power up.

The 10 µF capacitor at the input of the amplifier will also take some time to charge. Here the time constant is 5 seconds, so this is less of a problem than the 100 µF cap. This can be improved by reducing the 1 megohm bias resistors to 330k, which will have little effect on the overall response. Even 100k might be acceptable, although this will cause some unevenness in the response above 10 kHz.

In the schematic, the amplifier LTC6088 is present. I chose this as it was a suitable opamp available in the default LTSpice library. There are however many other amplifiers that would do well in this position. Important characteristics are:

  • Operation at 5 V
  • Preferably rail-to-rail output
  • Reasonably low input bias current, preferably below 50 nA or so
  • Enough gain-bandwidth for the application, at least a few MHz