My weekend exercise.

For the past several weekends I’ve been hiking up this canyon. It’s a little over 3.5 miles with 2.5 miles of gentle slope and one grueling high slope mile. It’s had some pleasing health benefits, and the view’s not so bad.

Ideal Zener

Zener diodes are handy devices which can be inserted into a circuit in reverse to clamp voltages to desired levels. But like all circuit components, Zener diodes do nor exhibit ideal behavior in all circumstances. The zener voltage varies significantly based upon temperature and through current, for instance. Thus, if one wants to use a zener diode to protect a low voltage, sensitive chip from over voltage on VDD, there are some important considerations. Assuming we have a 3.3V VDD and we select a 3.3Vz Zener diode. The diode Vz will increase with through current, but will decrease with increasing temperature. It is easy and wise to eliminate the current variability by using overcurrent protection devices like PPTC fuses, sized such that current through the zener diode does not exceed the power dissipation limit of the component nor cause the Vz to rise above the voltage maximim of the chip to be protected, whichever of those occurs first as current rises.

A more difficult to handle concern is the tendency of the zener voltage to decrease with temperature. If the curcuit is designed to operate in a wide range of temperatures, then the actual zener voltage has to assessed for all of those temperatures, most crucially to insure that the reduced zener voltage does not fall below the minimum voltage required by the chip, and that there are no other negative effects from reduced VDD (such as how it affects adc reference or digital output voltage).

In extreme cases, where zener protection is needed, but zener voltage variance is undesired, it becomes necessary to use a feedback controlled mosfet with a voltage reference that is temperature stable within the desired operating range, rather than a normal zener. The source of the n-channel mosfet is connected to ground, and the drain is connected to the VDD to be protected. The output of an opamp is connected to the mosfet gate, and the mosfet drain is connected to the + input of the opamp. The temperature stable voltage reference is connected to the negative input if the opamp. Thus if VDD falls below Vref, then the gate voltage will be brought low, making the mosfet high impedance. And if VDD rises above VRef the gate voltage will increase until it sets the mosfet impedance at the exact level required to reduce VDD to match Vref.

Amusingly, a temperature stable voltage reference can itself be made with a temperature feedback controlled current source through a zener diode.

Ardbox PLC

The Ardbox PLC is a din rail compact industrial controller built around an arduino Leonardo by Industrial Shields. This type of device provides a convenient bridge between the free to use and open source arduino development capability and 24V industrial controls. It’s similar to what I hope to achieve with my esp32 PLC, though I think I’ve come up and will come up more interesting additional capabilities.

The price of this solution is hard to beat for its range of capability. As a connected device, the Ardbox is quite limited (though by no means useless), but as an independent single machine controller, it excels, and it doesn’t require expensive proprietary development software. Don’t get me wrong, that proprietary software can be extremely useful for developing large machines which rely upon network attached sensors and other controllers. But for a simple, pantry sized machine with hardwired sensors and drivers, the Ardbox provides a good cheap way to get it done, which is always highly desirable.

One drawback of the Ardbox is a lack of programming security. It’s ease of development and programming translates to a need for physical security of the device to insure preservation of the program as is where such is critical for safe operation of a machine.

Computer Day

I spent the day researching and evaluating open source database solutions, and decided to upgrade from debian 9 to 10 again.

The biggest ooen source database communities are mysql and postgresql. I started out with mysql, and I chose the guaranteed free and open source mariadb variant. Mysql has a few good looking php generator tools to generate interfaces to gather and show the data to the users and has an admin tool called mysql workbench. I verified from the mariadb documentation that mariadb databases can be administered with mysql workbench and proceeded to install a mariadb server and mysql workbench. I set up a test database and got mysql workbench to connect to it, but there were many warnings. I went to set up a table in the database with mysql workbench and it kept throwing syntax errors in the autogenerated sql code. I couldn’t get it to stop without going in and editing the autogenerated code. That’s not what I’m looking for in a good database tool, and after I imagined having to do the same editing with every auto generated php interface file, I decided to give postgre a try. I suspect the issue has to do with mariadb and mysql compatibility, but I’d want to use mariadb rather than straight mysql.

Postgre is free and open source, and there is a free and opensource admin program called pgadmin. There are also php generator tools on the market to build interfaces, just as with mysql. So I purged all traces of mysql from my system and set up postgresql and pgadmin4. There was a problem with setting up the postgresql server, though an understandable one. Postgre doesn’t allow a user named “user.” I, of course, happened to be running a system in which the only non-root user is named “user.” And it happens that pgadmin has to be run in a browser, and for security reasons, firefox doesn’t permit being run as root. So I set up a new user with an actual name, migrated everything over, and finally deleted “user.” After setting up the new user, I get postgresql working and pgadmin4 working as well. I set up a test database, and used the admin tool to create test tables and there were no syntax problems. Easy. At least, it would have been if not for my ironic choice of user names.

Having replaced my user profile, and having noticed during software research that debian buster had been released as stable, I decided to go ahead and run the dist-upgrade. I’d actually had buster installed earlier in the year but I had reverted to stretch in an ultimately futile attempt to get monodevelop installed (a problem eventually solved with a windows virtual machine). It was a smooth upgrade with minimal complications. I mostly just had to go through the apt sources.list and sources.list.d and replace stretch with buster and 9 with 10, the one complication was having to replace a 9.0 with just a 10 rather than a 10.0.

Supercap Buck Converter

There are some obvious advantages to using supercaps in buck converter designs including low output voltage impedance and high output currents. But those same advantages also effect the circuit design.

Ideally, with a supercap, the charging happens on a time scale such that it would be possible to just connect the input voltage to the cap, monitor the cap voltage, and then disconnect the input voltage at the desired cap voltage. However, in practice, this method draws high currents from the input requiring an expensive high watt power supply and beefy cabling or traces. So, putting an inductor and a transistor switch in series with the input is desired, just as they would be used in a standard buck converter. But in the case of a supercap buck, the inductor is there just to limit the input current to levels that are tolerable for all of the components. The power throughput of the buck, then, is dominated by the inductor selection.

One should choose a current rating for the transistor switch and shunt reverse diode to be greater than the input power supply current rating, and the current rating of the inductor should be greater than twice the input power supply rating, then select an inductance and PWM switching frequency such that at a 50% duty cycle, the integral for the first half (when the switch is “on”) of a PWM period of the inductor current divided by a whole PWM period reaches 80% of the power supply max continuous current (more current will flow through the inductor after the transistor is switched off, but that current will come from the reverse diode rather than the input power). This process often requires a few iterations as both the available PWM frequencies and available inductances are often restricted. When calculating inductor current it is safest to assume that the cap voltage is always set to zero to account for the possibility of a very low impedance load on the secondary. The PWM output to the transistor switch gate is, of course, enabled/disabled by voltage feedback to the controller, which will limit the cap voltage to the desired level.

For the capacitor, I suggest the use of Licap 350F or 3000F cells to insure maximum power delivery to your coil gun, I mean… to your safe and beneficial application.

Depletion MOSFET Current Limiter

N-channel depletion MOSFETS can be used for more than just low power current limiting.  The following is an example of an approximately 10A bidirectional current limiter suitable for use in 24V circuits.  One thing to note, of course, is that this circuit is large, with a 12W resistor and two transistors requiring heat sinks, and expensive.

Depletion MOSFET Current Limiter.png

Low Power Circuit Protection

Low power circuit protection devices are important for making durable and long lasting electronic circuits.  Resettable fuses, also called PPTC devices, are made of special PTC materials that maintain a low resistance up to a certain through current.  Once that current level is reached, the PPTC begins to heat up and the resistance jumps to very high levels, stopping current flow and interrupting the circuit.  The fuse then starts to cool and if the fault has been removed the circuit goes back to operating normally, but if the fault remains the PPTC settles at some high resistance that permits just enough current to heat the fuse and maintain the tripped state.

PPTC’s are handy for enclosed or sealed electronics where fuse replacement is too labor intensive or impossible. However, there is another option. N-channel depletion mosfets limit their drain to source current when the gate voltage drops to a certain level below the source voltage. Thus, by connecting the gate of a depletion mosfet to the other side of a source resistor, the transistor becomes increasingly more current limiting as the current from drain to source increases. Thus, the transistor permits current to flow freely until it reaches a trip level and then it clamps the current at the trip level. With their built in source to drain diode action, this transistor only permits current limitation in one direction. However by attaching the source of another n channel depletion mosfet on the other side of the resistor such that the current flows drain to source to resistor to source to drain, and the gates of the transistors are connected to the drains of the other transistor, a bidirectional automatic current limiting device can be created. Using this type of circuit protection requires special attention to how much power is being lost to heat in the transistors, which is a function of the voltage across the device. As such, voltage limiting circuitry may also be required for effective, reusable circuit protection.

Xilinx zynq-7000 and iCE40

Looking through what’s new on Mouser, I came across an advert for the Xilinx zynq-7000 SoC.  These systems on a chip combine a processor with a massive FPGA.  FPGA’s are useful for performing complex logic operations at the highest speeds.  Processors can do the same logic operations as FPGA’s, but they have to break them into multiple simpler operations which use memory and require hundreds to millions of clock cycles.  FPGA’s, on the other hand, can do the same operation in just a few clock cycles.

By combining an FPGA with a processor, as in these zynq-7000’s one is able to effectively use the FPGA to give the processor the ability to perform extremely complex logic operations at FPGA speeds.  Furthermore, as the FPGA’s are programmable, it is possible to “retool” the FPGA in between blocks of high quantities of similar complex logic operations.  This “retooling” takes some time, but there is the potential for a massive time savings overall.  One of the best applications for this SoC, in my opinion, is for applications involving a lot of data stream processing such as feature identification and tracking in video or audio streams.

The Lattice iCE40 series of FPGA’s are not SoC’s and are much smaller FPGA’s in terms of LUT’s as compared to the FPGA’s built into the zynq-7000’s.  But, the iCE40 FPGA’s are considerably cheaper.  Nevertheless, one can use the iCE40’s in combination with an spi flash chip and cheap microcontroller to build a cheap module with a very modest fraction of the zynq-7000’s capabilities.

 

A New Project

I’ve been planning on making a custom arduino based industrial I/O module for a while. Something that, with the arduino IDE, would in effect be a structured text PLC. However, an arduino uno or nano would make for a limited system in terms of program size and built-in functionality. An alternative would be to make a custom chipset that programs like an arduino, but, chipsets like that have already been developed. One such chipset module is the esp32 wrover-b. I’ve wanted to begin developing with the esp32, and this project to make a PLC seems to me a perfect place to start.

My tentative specifications are:

1. Exploit all available wrover-b I/O pins to have industrially hardy, 24VDC, opto-isolated programmable DI/DO and AI/AO where feasible.

2. Wire esp32 wrover-b communication pins to expansion ports to connect with I/O expandion boards. It is acceptable to use an interposing uC as necessary to support addition communication protocols. Optoisolate or otherwise protect all communications ports as much as can be done without harming speed or signal strength.

3. Include a programming port for the wrover-b, preferably supporting micro usb.

4. Program the esp32 to accept wifi connections for output overrides or reading of inputs, serving an html page to facillitate this and also responding to certain get requests with just the requested data for data polling. All with as much security as I can give it.