App note: Linear and rotary encoders are evolving to meet demands

an_ttelectronics_rotary_encoders

Application notes from TT Electronics on optical encoders versatile sensing. Link here (PDF)

Linear and rotary encoders have come in a wide variety of design styles over the years, the most common being rotary switches, potentiometers, capacitive, magnetic, and optical types. The optical encoder has become the most popular of these encoding methods due to its long life, simplicity of construction, versatility, high accuracy and high resolution. This application bulletin will briefly define an optical encoder, and bring the designer up to date on encoder terminology, design techniques and limitations.

Yellowstone: Cloning the Apple II Liron

yellowstone-in-600

Steve writes:

FPGA-based disk control for Apple II is finally working! Six months ago, I began designing a universal disk controller card for the Apple II family. Apple made a bewildering number of different disk controller cards in the 1970s and 80s, and my hope was to replace the IWM chip (Integrated Wozniak Machine) and other assorted ICs typically found on the cards, and substitute a modern FPGA. With a little luck, that would make it possible to clone any vintage disk controller card – some of which are now rare and expensive. It would also enable a single card to function as many different disk controllers, simply by modifying the FPGA configuration. With the successful cloning of a Liron disk controller, the first major step towards those goals has been made.

More details at Big Mess o Wires site.

Check out the video after the break.

STM32F103 vs GD32F103 round 1: Solderability

stm32vsgd32_boards-1080x675-600

Sjaak writes:

I locked myself into the basement with a couple of PCBs, chips and fresh flux for a couple of days. For the STM32F103 vs GD32F103 challenge I needed to have two identical boards with a different microcontroller. As far as I could judge both chips are legit and not counterfeits as we bought both chips from (different) reputable sellers. The used chips are GD32F103CBT6 and STm32F103CBT7. The STM32F103CBT7 is the industrial rated part of the STM32F103CBT6 and is identical except for the temperature range.

More details at smdprutser.nl.

Multicolor signal light with beeper

ljuc3-600

Multicolor signal light with beeper for ROS by Gal Pavlin

When debugging algorithms in an autonomous vehicle a light that can show algorithm state in real time was proven to be effective for easier debugging and additional insight to what is going on in the code.
Because all existing signal light were either to bulky or too expensive we decided to build our own. It was actually quite simple with few key elements:

  • 3x RGB LED strip
  • STM32F0 microcontroller with native USB support
  • Beeper

Via Mare & Gal Electronics.

Check out the video after the break.

Troubleshooting tips: Failed debugging with GDB

problem-occured-version

Erich Styger writes:

Three years ago I published “Debugging Failure: Check List and Hints” and unfortunately this article is one of the most popular ones: obviously debugging problems are very common. Debugging with GDB works usually fine, but if things are failing, then it can be hard to find the cause for it. Recently I have been asked to check some failures, so here are two more hints about what could go wrong…

More details at MCU on Eclipse blog.

 

ESP32 (30) – HTTP server in SoftAP mode

One of the most frequent questions I receive from my website’s contact form or from my Facebook page is whether it’s possible to publish an HTTP server when the esp32 chip is working in SoftAP mode, that is when it publishes its own wifi network.

In previous tutorials (18 – Access Point and 20 – Webserver) I’ve already blogged about the two subjects separately, today I’ll explain how to combine them.

Access Point

Let’s start defining the parameters of the TCP/IP network will be published by the esp32 chip. You have to choose an addressing plan, that is which IP addresses will belong to the network. You can use some of the IP addresses IANA assigned to private networks (RFC1918):

  • 10.0.0.0/8
  • 172.16.0.0/12
  • 192.168.0.0/16

The numbers /8/12/16 are, in short form, the network mask. For example/8 means that the network 10.0.0.0/8 contains all the addresses from 10.0.0.1 to 10.255.255.254, a total of 16.777.216 different addresses. Thanks to the subnetting you can slice a network in smaller subnetworks.

In this example I’m going to use the network 192.168.1.0 with netmask 255.255.255.0 (/24), that is a network with 254 usable addresses (192.168.1.1 – 192.168.1.254). You have to statically assign to the esp32 chip an address that belongs to that network; to make things easy I chose the first one (192.168.1.1):

tcpip_adapter_ip_info_t info;
memset(&info, 0, sizeof(info));
IP4_ADDR(&info.ip, 192, 168, 1, 1);
IP4_ADDR(&info.gw, 192, 168, 1, 1);
IP4_ADDR(&info.netmask, 255, 255, 255, 0);
ESP_ERROR_CHECK(tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_AP, &info));

The other devices which will connect to the network will dynamically configure their IP address, thanks to the DHCP service. To use the DHCP server in your program, first you have to stop it before configuring the network settings and then start it:

ESP_ERROR_CHECK(tcpip_adapter_dhcps_stop(TCPIP_ADAPTER_IF_AP));
[...]
ESP_ERROR_CHECK(tcpip_adapter_dhcps_start(TCPIP_ADAPTER_IF_AP));

After having configured the TCP/IP network and the related services, you can set up the wifi interface of the esp32 chip and activate the SoftAP mode:

wifi_init_config_t wifi_init_config = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&wifi_init_config));
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));

You have to prepare a wifi_config_t struct that contains all the parameters for the wifi network (SSID, authentication…) and pass it to the method:

ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &ap_config));

You can hardcode the parameters in the program, or make them configurable via menuconfig (as in this example) or Possiamo decidere di inserire i parametri hardcoded nel programma, di renderli configurabili tramite menuconfig (come nell’esempio) or even read them from a config file or from NVS variables.

Finally start the wifi interface with:

ESP_ERROR_CHECK(esp_wifi_start());

HTTP server

Now you can use the Netconn API of the lwip library to bind your program to the TCP/80 port (it’s the standard port used by the HTTP protocol) and to listen for incoming connections:

struct netconn *conn;
conn = netconn_new(NETCONN_TCP);
netconn_bind(conn, NULL, 80);
netconn_listen(conn);

The accept() method blocks the program until a new connection is accepted:

struct netconn *newconn;
netconn_accept(conn, &newconn);

After having established the connection, your program must speak the same language (protocol) of the client; in this case the HTTP protocol used by web browsers.

To keep the example simple, it will publish a static website, whose content is stored in an SPIFFS partition (see the ESP32lights project for more information). Therefore, the program will answer requests in the form GET <resource> looking for the resource in the SPIFFS partition and, if found, sending its content using the netconn_write() method:

http-ap-001

Bonus, mDNS

To be able to connect to the HTTP server published by the esp32 chip, a client must know the IP address (192.168.1.1) assigned to the chip.

We can leverage the mDNS service (as explained here) to allow the client to connect using an alias (for example esp32web):

mdns_server_t* mDNS = NULL;
ESP_ERROR_CHECK(mdns_init(TCPIP_ADAPTER_IF_AP, &mDNS));
ESP_ERROR_CHECK(mdns_set_hostname(mDNS, "esp32web"));
ESP_ERROR_CHECK(mdns_set_instance(mDNS, "esp32 webserver"));

If the device you’re using supports the mDNS service, it will be possible to connect to the website using the address esp32web.local:

http-ap-002

Demo

The complete program is available in my Github repository. After having loaded it on your devboard, a new wifi network will be available:

http-ap-003

if you connect to that network, your device will be assigned an IP addess on the 192.168.1.0/24 network:

http-ap-004

and you’ll be able to point the browser to http://esp32web.local (or http://192.168.1.1) and display the website:

http-ap-005

App note: Measuring inrush current

an_aimtec_inrush

Inrush current evaluation from Aimtec. Link here

In AC/DC power converters beyond a few watts, during the initial application of power an excessive inrush current will flow when the input capacitors are suddenly charged. If unhindered the inrush current can easily exceed 50 A at the peak of the AC cycle and severely stress the converter’s fuse and input rectifiers, thereby significantly reducing the reliability and life expectancy of the modules. Universal power supplies (supplies which accept a wide range of input voltages) are particularly susceptible to high inrush current since their input capacitors must be large enough to handle line voltages as low as 110 VAC, as well as voltages as high as 305 VAC at start-up. In these environments, a power-supply failure or a tripped circuit breaker can be inconvenient at best, and expensive or dangerous at worst.