Quantcast
Channel: Davide Gironi blog
Viewing all 196 articles
Browse latest View live

ATmega BLDC motor driver dev board

$
0
0

This board is the PCB version of the development board I've used to build the BLDC driver implemented here:
http://davidegironi.blogspot.com/2019/12/an-atmega-brushless-sensorless-motor.html
http://davidegironi.blogspot.com/2020/01/an-atmega-brushless-sensored-motor.html


The board max input voltage is 45V, that is the maximum supply voltage of step-down voltage regulator LM2596-12V.
This step-down regulator provides the power voltage for the IR2101 high and low side attached to the main power mosfets of the bridge motor driver. In this design i use IRF640 mosfets, but one can also use other kind of mosfets.
A 5V regulator provides the supply voltage of the main microcontroller.

The board works both for sensored and sensorless motors.

For sensorless motor EMF signal is catched by the voltage divider network attached to pin PD6, PC0, PC1 and PC2. The PD6 pin is used in the voltage comparer configuration.
For sensorled motors digital hall sensor inputs are read by the PB0, PB1 abd PB2 pins.

A 16Mhz crystal is attached to the main ATmega8 micro, even if I've tested this board and the driver at 8Mhz using the internal ATmega oscillator circuit.

A direction switch is used to select the spinning direction of the motor.
The UART RXD and TXD pins can be used for debug or driving purpose, as example one can easly implement a protocol that control the motor driver.

Least but not last, the RC Input pin can be used to read the input of a RC servo signal.



Schematics and Board - EagleCad
Notes
  • read risk disclaimer
  • excuse my bad english




ESP8266 Smart Wind Speed Meter

$
0
0

This project is a Smart Wind Speed Meter that uses the ESP8266 to read value from a sensor, then posts results to ThingSpeak.

ThingSpeak in an application to store data from IoT devices. We are going to use the https://thingspeak.com/ website.
Once we have created our account and we need to make a new channel, and collect the Channel ID and the Write API Key for that channel, we will then set those parameters in our meter configuration.


The sensor I'm going to use is a DNA701 from LSI http://www.lsi-lastem.it/. It's a wind speed sensor supplied with 24V AC, and industrial current output 4..20mA. A friend give this away to me, and so I would like to use in some way.

LSI sends me the datasheet for this sensor, it turned out that current to wind speed m/s is a linear function, so simple.

So, I just have to measure current with my ESP8266. In order to have an accurate measurement i prefer to use a linear current to voltage converter, then read the voltage using an ADC.


As for the current to voltage converter I go for a cheap board, it is supplied with 12V DC, and it gives you 0 to 5V output depending on the 4 to 20mA input.

Then, i read the voltage output from this sensor using an ADS1115 ADC board.
I supply the ADS1115 with 5V.
Software side I'm using the Adafruit ADS1X15 library. I initialize the sensor setting the gain to 2/3. By datasheet setting the 2/3 gain means the sensor can read +/-6.144V in 16bit. This means 6.144V in 15bit, which is 187.5uV per bit. So if we get a raw value of 32768 from the ADC, the voltage we are reading is 32768*187.5uV, which is 5V.
I prefer to add a Exponential Moving Average filter to the ADC raw value that I read, this can smooth wrong readings if there are any.

Now that we know how to read the voltage, we just have to transform back to current, that's a simple linear interpolation. For this we can use the map function.

Now that we get the current we just substitute this in the LSI conversion formula, and we so have wind speed expressed m/s.

To be more usable I've add an 8 digit seven segment display which displays the wind speed in real/time, updated each second. To be honest a 4 digit display could be enough but the simplest thing is to connect a 8 digit board you simply buy.
Then, every 60 seconds, the wind speed is sent to out ThingSpeak channel.


As on other device based on ESP8266 I've built, the WiFi AP to use can be setup using the WiFiManager integrated library. This time the device tries to connect to the AP, if any was configured, if it's not able to connect to the AP you have 3 minutes to connect to the "forced AP" of the ESP8266 and configure a WiFi, otherwise it will go on and work just like a meter with the seven segment display.

Other parameters, like the ThingSpeak Channel ID and Write API Key, can be changed in the configuration web page generated from the device itselft.

Code
Notes
  • read risk disclaimer
  • excuse my bad english



OpenWrt main and Guest network AP using VLAN with unmanaged switch

$
0
0
I've already talked about the building of a small network infrastructure with a Guest lan that runs on a specific VLAN using unmanaged switch.
You can find the link here: http://davidegironi.blogspot.com/2017/10/openwrt-guest-routed-ap-using-vlan-with.html
The good things about the network I described was the capabilities to run that VLAN using unmanaged switch.
This time I would like to refine the whole structure adding AP that could act as main network AP and Guest network AP.
The APs used needs to be VLAN managed and dual SSID compatible, it means that the WiFi chip must be able to manage multiple SSID simultaneously.
One again for those AP I will use OpenWrt (https://openwrt.org/)

At first we have to install our main router.

Let's suppose we are serving our main network on 192.168.1.0/24 ip ranges, and out guest network, isolated from the 192.168.1.0/24 one, on the 192.168.11.0/24 ip range.
Our router ip will be 192.168.1.1 on main network and 192.168.11.1 on the guest network.



We will use 
  • VLAN 1 as our main untagged network
  • VLAN 2 for the WAN connectivity
  • VLAN 11 for the guest network
Let's suppose we have a router with LAN 1, LAN 2, LAN 3, LAN 4, CPU, and WAN interface.

On the router side, let's start with the Switch settings.
  • the CPU port will be tagged on all VLAN
  • on VLAN 1, we mark all LAN ports as untagged, and we disable the WAN port
  • on VLAN 2, we disable all LAN ports, and we mark WAN as untagged
  • on VLAN 11, we disable all LAN ports except one (as example the number 4) that has to be tagged, and we disable the WAN port
The port with VLAN 11 tagged, and VLAN 1 untagged is the one we have to connect to our main unmanaged switch network.
Then we have to set the LAN interface as "static address" with ip 192.168.1.1 and DHCP enabled.
We can of course customize DHCP settings for both interfaces.
Same settings for the GUEST interface, which however we have to add, setted as static address with ip 192.168.11.1 and DHCP enabled.

On the firewall side we have to add GUEST firewall zone for GUEST interface.
This zone has to accept input, accept output, reject forward and "Allow forward to destination zones" -> WAN, this way all the traffic will be forwarded to the WAN interface.

If we want to enable the WiFi capabilities, we just have to add two wifi. The main one bridged with the LAN network, the GUEST one with the GUEST network.

Of course we have to set the WAN interface, that could be PPPoE, PPPoATM or any other protocol. This interface will be the one that grant the Internet connection.

For completeness, here you can find a sample configuration for the router.

/etc/config/network
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'

config globals 'globals'
option ula_prefix 'fd00:0000:0001::/48'

config interface 'lan'
option type 'bridge'
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
option ip6assign '60'
option _orig_ifname 'eth0.1 wlan0'
option _orig_bridge 'true'
option ifname 'eth0.1'

config device 'lan_dev'
option name 'eth0.1'
option macaddr '00:00:00:00:00:01'

config interface 'wan'
option _orig_ifname 'eth0.2'
option _orig_bridge 'false'
option proto 'pppoe'
option username 'pppoeusername'
option password 'pppoepassword'
option ipv6 'auto'
option ifname 'eth0.2'

config device 'wan_dev'
option name 'eth0.2'
option macaddr '00:00:00:00:00:11'

config interface 'wan6'
option _orig_ifname 'eth0.2'
option _orig_bridge 'false'
option ifname 'eth0.2'
option proto 'none'

config switch
option name 'switch0'
option reset '1'
option enable_vlan '1'

config switch_vlan
option device 'switch0'
option vlan '1'
option vid '1'
option ports '0 1 2 3 6t'

config switch_vlan
option device 'switch0'
option vlan '2'
option vid '2'
option ports '4 6t'

config switch_vlan
option device 'switch0'
option vlan '3'
option vid '11'
option ports '3t 6t'

config interface 'guest'
option proto 'static'
option ipaddr '192.168.11.1'
option netmask '255.255.255.0'
option type 'bridge'
option _orig_ifname 'eth0 wlan0-1'
option _orig_bridge 'true'
option ifname 'eth0.11'

/etc/config/firewall
config defaults
option syn_flood '1'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'REJECT'

config zone
option name 'lan'
option input 'ACCEPT'
option output 'ACCEPT'
option network 'lan'
option forward 'REJECT'

config zone
option name 'wan'
option output 'ACCEPT'
option masq '1'
option mtu_fix '1'
option input 'REJECT'
option forward 'REJECT'
option network 'wan wan6'

config rule
option name 'Allow-DHCP-Renew'
option src 'wan'
option proto 'udp'
option dest_port '68'
option target 'ACCEPT'
option family 'ipv4'

config rule
option name 'Allow-Ping'
option src 'wan'
option proto 'icmp'
option icmp_type 'echo-request'
option family 'ipv4'
option target 'ACCEPT'

config rule
option name 'Allow-IGMP'
option src 'wan'
option proto 'igmp'
option family 'ipv4'
option target 'ACCEPT'

config rule
option name 'Allow-DHCPv6'
option src 'wan'
option proto 'udp'
option src_ip 'fc00::/6'
option dest_ip 'fc00::/6'
option dest_port '546'
option family 'ipv6'
option target 'ACCEPT'

config rule
option name 'Allow-MLD'
option src 'wan'
option proto 'icmp'
option src_ip 'fe80::/10'
list icmp_type '130/0'
list icmp_type '131/0'
list icmp_type '132/0'
list icmp_type '143/0'
option family 'ipv6'
option target 'ACCEPT'

config rule
option name 'Allow-ICMPv6-Input'
option src 'wan'
option proto 'icmp'
list icmp_type 'echo-request'
list icmp_type 'echo-reply'
list icmp_type 'destination-unreachable'
list icmp_type 'packet-too-big'
list icmp_type 'time-exceeded'
list icmp_type 'bad-header'
list icmp_type 'unknown-header-type'
list icmp_type 'router-solicitation'
list icmp_type 'neighbour-solicitation'
list icmp_type 'router-advertisement'
list icmp_type 'neighbour-advertisement'
option limit '1000/sec'
option family 'ipv6'
option target 'ACCEPT'

config rule
option name 'Allow-ICMPv6-Forward'
option src 'wan'
option dest '*'
option proto 'icmp'
list icmp_type 'echo-request'
list icmp_type 'echo-reply'
list icmp_type 'destination-unreachable'
list icmp_type 'packet-too-big'
list icmp_type 'time-exceeded'
list icmp_type 'bad-header'
list icmp_type 'unknown-header-type'
option limit '1000/sec'
option family 'ipv6'
option target 'ACCEPT'

config rule
option name 'Allow-IPSec-ESP'
option src 'wan'
option dest 'lan'
option proto 'esp'
option target 'ACCEPT'

config rule
option name 'Allow-ISAKMP'
option src 'wan'
option dest 'lan'
option dest_port '500'
option proto 'udp'
option target 'ACCEPT'

config include
option path '/etc/firewall.user'

config zone
option name 'guest'
option input 'ACCEPT'
option output 'ACCEPT'
option network 'guest'
option forward 'REJECT'

config forwarding
option dest 'wan'
option src 'guest'

config forwarding
option dest 'wan'
option src 'lan'

/etc/config/dhcp
config dnsmasq
option domainneeded '1'
option boguspriv '1'
option localise_queries '1'
option rebind_protection '1'
option rebind_localhost '1'
option expandhosts '1'
option authoritative '1'
option readethers '1'
option leasefile '/tmp/dhcp.leases'
option resolvfile '/tmp/resolv.conf.auto'
option localservice '1'
option local '/lan/lab.local/'
option domain 'lab.local'
list server '8.8.8.8'
list server '208.67.222.222'
option nonwildcard '0'

config dhcp 'lan'
option interface 'lan'
option start '100'
option leasetime '12h'
option force '1'
option limit '49'

config dhcp 'wan'
option interface 'wan'
option ignore '1'

config odhcpd 'odhcpd'
option maindhcp '0'
option leasefile '/tmp/hosts/odhcpd'
option leasetrigger '/usr/sbin/odhcpd-update'

config dhcp 'guest'
option interface 'guest'
option start '100'
option leasetime '12h'
option force '1'
option limit '49'

/etc/config/wireless
config wifi-device 'radio0'
option type 'mac80211'
option channel '11'
option hwmode '11g'
option path 'platform/10180000.wmac'
option htmode 'HT20'
option country 'US'
option txpower '20'

config wifi-iface 'default_radio0'
option device 'radio0'
option mode 'ap'
option ssid 'myssid'
option encryption 'psk-mixed'
option key 'wifipassword'
option network 'lan'

config wifi-iface
option device 'radio0'
option mode 'ap'
option ssid 'myssid-guest'
option encryption 'psk-mixed'
option key 'wifipasswordguest'
option network 'guest'

Now we have to config the Access Point.
This AP will be able to distribute both the main WiFi and guest WiFi.
Let's start again with the switch settings, that will be the same of the main router, the point here is having the VLAN 11 with just one LAN port tagged, and the others disabled. Note that the cable from the unmanaged switch as to be connected to this port, as for the main router, the one with VLAN 11 tagged and VLAN 1 untagged.
We now have to set the LAN and GUEST interface with a "static address", let's suppose 192.168.1.5 for main network on 192.168.11.5 in this example, of course we have to set our main router addresses as Gateway, that will be 192.168.1.1 for the main network and 192.168.11.1 for the GUEST network. Both those interfaces can be set as "DHCP client" protocol if we don't want to reserve a satic address, but setting those as static would be simpler if we want to browse the AP.
On the firewall side, we don't need a GUEST zone, cause the guest traffic is firewalled by the main GUEST router firewall zone, note that we are free to add a specific firewall zone if we want.
Then we have of course to enable the WiFi capabilities, we just have to add two wifi. The main one bridged with the LAN network, the GUEST one with the GUEST network.
That's all.
This router will also act as an unmanaged switch for main VLAN. Inverting the untagged/off settings for the VLAN 1 and 11 will make that specific port unmanaged for the main or GUEST network.
If our device does not support multiple SSID, we can still add just one WiFi and use the AP for the GUEST or main network.

Again find below a sample configuration for the AP.

/etc/config/network
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'

config globals 'globals'
option ula_prefix 'fd00:0000:0005::/48'

config interface 'lan'
option type 'bridge'
option ifname 'eth0.1'
option proto 'static'
option netmask '255.255.255.0'
option ip6assign '60'
option ipaddr '192.168.1.5'
option gateway '192.168.1.1'
option dns '192.168.1.1'

config device 'lan_dev'
option name 'eth0.1'
option macaddr '00:00:00:00:00:05'

config interface 'wan'
option ifname 'eth0.2'
option proto 'dhcp'

config device 'wan_dev'
option name 'eth0.2'
option macaddr '00:00:00:00:00:15'

config interface 'wan6'
option ifname 'eth0.2'
option proto 'dhcpv6'

config switch
option name 'switch0'
option reset '1'
option enable_vlan '1'

config switch_vlan
option device 'switch0'
option vlan '1'
option ports '0 1 2 3 6t'
option vid '1'

config switch_vlan
option device 'switch0'
option vlan '2'
option ports '4 6t'
option vid '2'

config switch_vlan
option device 'switch0'
option vlan '3'
option ports '3t 6t'
option vid '11'

config interface 'guest'
option type 'bridge'
option proto 'static'
option ifname 'eth0.11'
option ipaddr '192.168.11.5'
option netmask '255.255.255.0'
option gateway '192.168.11.1'
option dns '192.168.11.1'

/etc/config/firewall
config defaults
option syn_flood '1'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'REJECT'

config zone
option name 'lan'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
option network 'lan'

config zone
option name 'wan'
option input 'REJECT'
option output 'ACCEPT'
option forward 'REJECT'
option masq '1'
option mtu_fix '1'
option network 'wan wan6'

config forwarding
option src 'lan'
option dest 'wan'

config rule
option name 'Allow-DHCP-Renew'
option src 'wan'
option proto 'udp'
option dest_port '68'
option target 'ACCEPT'
option family 'ipv4'

config rule
option name 'Allow-Ping'
option src 'wan'
option proto 'icmp'
option icmp_type 'echo-request'
option family 'ipv4'
option target 'ACCEPT'

config rule
option name 'Allow-IGMP'
option src 'wan'
option proto 'igmp'
option family 'ipv4'
option target 'ACCEPT'

config rule
option name 'Allow-DHCPv6'
option src 'wan'
option proto 'udp'
option src_ip 'fc00::/6'
option dest_ip 'fc00::/6'
option dest_port '546'
option family 'ipv6'
option target 'ACCEPT'

config rule
option name 'Allow-MLD'
option src 'wan'
option proto 'icmp'
option src_ip 'fe80::/10'
list icmp_type '130/0'
list icmp_type '131/0'
list icmp_type '132/0'
list icmp_type '143/0'
option family 'ipv6'
option target 'ACCEPT'

config rule
option name 'Allow-ICMPv6-Input'
option src 'wan'
option proto 'icmp'
list icmp_type 'echo-request'
list icmp_type 'echo-reply'
list icmp_type 'destination-unreachable'
list icmp_type 'packet-too-big'
list icmp_type 'time-exceeded'
list icmp_type 'bad-header'
list icmp_type 'unknown-header-type'
list icmp_type 'router-solicitation'
list icmp_type 'neighbour-solicitation'
list icmp_type 'router-advertisement'
list icmp_type 'neighbour-advertisement'
option limit '1000/sec'
option family 'ipv6'
option target 'ACCEPT'

config rule
option name 'Allow-ICMPv6-Forward'
option src 'wan'
option dest '*'
option proto 'icmp'
list icmp_type 'echo-request'
list icmp_type 'echo-reply'
list icmp_type 'destination-unreachable'
list icmp_type 'packet-too-big'
list icmp_type 'time-exceeded'
list icmp_type 'bad-header'
list icmp_type 'unknown-header-type'
option limit '1000/sec'
option family 'ipv6'
option target 'ACCEPT'

config rule
option name 'Allow-IPSec-ESP'
option src 'wan'
option dest 'lan'
option proto 'esp'
option target 'ACCEPT'

config rule
option name 'Allow-ISAKMP'
option src 'wan'
option dest 'lan'
option dest_port '500'
option proto 'udp'
option target 'ACCEPT'

config include
option path '/etc/firewall.user'

/etc/config/wireless
config wifi-device 'radio0'
option type 'mac80211'
option hwmode '11g'
option path 'platform/10180000.wmac'
option htmode 'HT20'
option channel '6'
option country 'US'
option legacy_rates '1'
option txpower '20'

config wifi-iface 'default_radio0'
option device 'radio0'
option network 'lan'
option mode 'ap'
option ssid 'myssid'
option encryption 'psk-mixed'
option key 'wifipassword'

config wifi-iface
option device 'radio0'
option mode 'ap'
option ssid 'myssid-guest'
option network 'guest'
option encryption 'psk-mixed'
option key 'wifipasswordguest'

Many other changes can be done to this sample settings, you can use this as a starting point.


Notes
  • read risk disclaimer
  • excuse my bad english

MiniHTMLTextBox - .NET WinForm HTML TextBox component

$
0
0

MiniHTMLTextBox is Minimal .NET WinForms HTML Editor control based on the TextBox component.

I was building a simple C# desktop application that needs a simple HTML editor. I haven't find any good and free HTML editor, so I decide to build one my one.

It has minimal features, like bold, italic, underline, font name and size selection, text can be aligned, it also ships a ordered and buillet list. Source text can be view like formatted HTML or html raw format.

For the HTML rendering it use a WebBrowser component, that triggers the change in the text and render it to the UI.

In Text mode a simple TextBox is used.

This component is very simple, but it can be expanded it one needs. Both the WebBrowser and TextBox component are exposed as public, so that one can play with the internal components without having to compile a new one.


Downloads


Notes
  • read risk disclaimer
  • excuse my bad english

A script to download all the repositories from a Bitbucket account

$
0
0

A few days ago I've to download all the git repositories from my company Bitbucket account.

I wasn't able to find any script to perform this task, so I write down this one you find in the gist linked above.

This bash script will download and eventually pull all changes from all the repositories of an account.

You can use your Bitbucket account, or better you should create a read/only account with access to all the repositories you want to download.

Set your Bitbucket account username and password in the "run_bitbucketgitdownloader.sh" file, than run the file.

$./run_bitbucketgitdownloader.sh

You also could enable the git credential helper, to prevent git always requesting you the password. This is done using the command:

$git config --global credential.helper store

If you need you could also add the file to a crontab job.


Code

Notes
  • read risk disclaimer
  • excuse my bad english

ESP8266 ESC/POS Smart Thermal Printer

$
0
0

The gear introduced here is a device that use a ESP8266 to print text that comes from a RESTful API or from an internal database to an ESC/POS thermal printer.


ESC/P (Epson Standard Code for Printers) is a printer control language developed by Epson to control computer printers. The ESC/POS is a variant for controlling receipt printers as commonly used at the point of sale (POS).


The clue here is to build a device that call a RESTful API, and print the text the API returns to a thermal printer, and eventually fits a thermal printer.

I want the printer to be capable of printing:
  • when a button is pressed
  • once in a day at a specific day time
  • many times after minutes have passed
To build this thing I decided to use a ESP8266.

At startup the ESP8266 try to connect to a WiFi network, if it does not reach the last network used, or no network was imposed before, the device comes to a "forced AP mode", that way one can connect to the device WiFi and set the main WiFi AP to be used for the internet connection. The WiFiManager (https://github.com/tzapu/WiFiManager) library it's used for this purpose.


Whenever the IP address is released at the device by the DHCP of the main AP, or even if a static address is imposed, the device address is printed on the thermal printer.
This address is useful to access the settings page.

All the settings for this device are accessible by the web page embedded in it, like custom header, footer, ESC/POS commands, cut paper and print logo enabler, day/time printing period, the text database and other.


If the device is connected to the internet, and the RESTful API uri is inserted, then the device call the API and print out the text returned, otherwise a random string is selected from an internal text database.

There's also a pretty pulsing light output can be connected to a led strip to make the device look more attractive.

The board is quite simple, it features a fixed voltage DC-DC Step Down regulator, the ESP8266 in the ESP-12 package, the strip led power stage, and a voltage converter that can be populated if the printer UART voltage is not the same of the ESP8266 UART voltage (3.3v).



I've build the first gear using a prototype board, it's the one you find in the video and pictures above, but also I've embedded the PCB board in a few printer I gifted to friends.


Code

Notes
  • read risk disclaimer
  • excuse my bad english

TB6612FNG AVR motor driver

$
0
0

The + is an H-Bridge driver IC that can drive up to 2 motors.
This IC as a maximum power supply voltage of 15V, with an output current of 1.2A average and 3.2A peak.





It's pretty simple to drive this chip. For each motor it has 3 input, 2 digital ones used to select the direction, the other is the PWM input.

Find below the control table for this IC, IN1 and IN2 are the two digital input that defines the direction and in conjuction with the PWM one, the Mode of operation of the OUT1 and OUT2 pin, that are connected to the motor.

IN1IN2PWMOUT1OUT2Mode
HHH/LLLShort brake
LHHLHCCW
LHLLLShort brake
HLHHLCW
HLLLLShort brake
LLHOFFOFFStop

This driver is based on my DC Motor PWM driver you can find it here http://davidegironi.blogspot.com/2015/02/driving-dc-motor-using-pwm-with-avr.html

It use the PWM output pins of the microcontroller, it means that no software resources are used to generate the PWM needed to drive the motors in speed.

This driver is built to control one IC, it means 2 motors independently in speed and direction.

This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 8MHz but can easly be ported to other microcontroller.



All the parameters can be changed in the dcmotortb6612.h.
The drive can even run on a single motor output, we just need to change the macro DCMOTORTB6612_SINGLEMOTOR.

Code

Notes
  • read risk disclaimer
  • excuse my bad english




docker-mysql-backup-restore-s3 Docker backup and restore using S3 AWS

$
0
0

docker-mysql-backup-restore-s3 is Docker app that can be used to backup and restore a MySQL using AWS S3 as storage.



I want to run a mysql backup and restore script on my devices that use S3 AWS as storage for the dump. The best way to do this in a multi-enviroment to me is to pack this script in to a Docker image.

You can find it on Docker Hub here: https://hub.docker.com/repository/docker/davidegironi/docker-mysql-backup-restore-s3

To perform a backup simply run the following docker command, selecting the right parameter for your AWS and MySQL server

docker run -e ACTION=backup -e S3_ACCESSKEYID=awskey -e S3_SECRETACCESSKEY=awssecret -e S3_BUCKET=s3bucket -e S3_PREFIX=backup -e S3_REGION=awsregion -e MYSQL_USER=user -e MYSQL_PASSWORD=password -e MYSQL_HOST=localhost -e S3_FILENAME=latestbackup -e MULTI_FILES=yes davidegironi/docker-mysql-backup-restore-s3
To restore, the command is almost the same
docker run -e ACTION=restore -e MYSQLDUMP_DATABASE=test -e MYSQLDUMP_TODATABASE=newtest -e S3_ACCESSKEYID=awskey -e S3_SECRETACCESSKEY=awssecret -e S3_BUCKET=s3bucket -e S3_REGION=awsregion -e S3_PREFIX=backup -e MYSQL_USER=user -e MYSQL_PASSWORD=password -e MYSQL_HOST=localhost -e S3_FILENAME=latestbackup -e MULTI_FILES=yes -davidegironi/docker-mysql-backup-restore-s3
Find the latest usage option and code in the github page of this small project here: https://github.com/davidegironi/docker-mysql-backup-restore-s3 

I'm using this on Fargate to backup and restore a managed MariaDB (RDS) without poblems.


Notes
  • read risk disclaimer
  • excuse my bad english

AVR BTS7960 43A DC Motor Driver

$
0
0
The BTS7960 is a fully integrated high current H bridge module for motor drive applications.


This library can drive up to two BTS7960, it means two motors independently in speed, direction and acceleration.

The library I'm going to use here it's the TB6612FNG one, you can find in the blog link below.
Indeed the BTS7960 works almost like the TB6612FNG IC.
We just need to change the wiring and all the things will works.

This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 8MHz but can easly be ported to other microcontroller.



For further information take a look at the TB6612FNG post here: https://davidegironi.blogspot.com/2020/03/tb6612fng-avr-motor-driver.html

Notes
  • read risk disclaimer
  • excuse my bad english


ESP Temperature to ThingSpeak smart meter

$
0
0

ESP/Temperature To ThingSpeak is a smart temperature meter that sends temperature to the ThingSpeak service.


It's based on the ESP8266 board and uses the ADS1115 analog to digital converter in order to read the resistance value of up to 4 NTC sensors and convert it to the temperature value. The NTC to temperature convertion is performed using the library you can find here http://davidegironi.blogspot.com/2018/01/esp8266arduino-ntc-library.html

The code is written using the Arduino ESP8266 framework.

The WiFiManager library it is used to simplify the settings of the AP the board has to connect to. If the ESP8266 can not find the last network used, or no network is set, the ESP8266 enters the "forced AP mode", now the user can connect to the device WiFi and set the main WiFi AP to be used for the internet connection.

When it's connected WiFi AP the IP address given by the main AP DHCP server, the default web page is accesible at the ip address of the device or at the address http://esptemperaturetothingspeak001

Through the web interface one can also set the unit of temperature and the ThingSpeak API Key and Channel ID.


A ThingSpeak channel has to be setup, it must have 1 to 4 Fields, depending on the NTC sensor added. Then the Write API Key and the Channel ID should be filled up in the web interface of this mini device in order to allow the temperature to be sent to ThingSpeak.


Each seconds the device read the raw value from the ADC, convert itt to resistance, and then use the resistance value to get the temperature.

Each minute temperatures where sent to ThingSpeak.

The code is really simple and can be modified according to your needs. Just download it, compile and use it.

Code

Notes
  • read risk disclaimer
  • excuse my bad english

ESP8266 seven segment counter

$
0
0
ref 2018

 

The ESP8266 seven segment counter is a WiFi enabled device that updates one ore more 7 segment led display by loading data from a RESTful API.

The device is based on a ESP8266 chip. It uses the WiFiManager (https://github.com/tzapu/WiFiManager) library to simplify the settings of the AP the board has to connect to. If the ESP8266 can not find the last network used, or no network is set, the ESP8266 enters the "forced AP mode", now the user can connect to the device WiFi and set the main WiFi AP to be used for the internet connection.
When it's connected WiFi AP the IP address given by the main AP DHCP server, or the static IP of the device is shown on the first seven segment dispaly.


The user can change the API uri used to get the data, and the interval of the data routine from the settings web page.

Whenever the interval time, which is by the way expressed in seconds, is passed by, the ESP8266 performs a GET requests on the API uri, then try to parse the results. The result must be plain text format: each line must be a numeric value that will be shown on the display. Of course it's just a matter of changing a little bit of code to customize the parsing function to fit the desidered API uri.

If errors happened, nothing is display till a threshold number is reached, then the last error is displayed.



The schematics and the board for this project is as simple as the code.

The power comes from the 5V port, a mini USB is used, then a linear regulator reduce the voltage to 3.3V used by the ESP8266 board, that is a ESP-12F pinout compatibile one.

The seven segment display driver is the MAX7219.



Even the numer of 8 bit seven segment display is pretty simple to customize by changing a few lines of code.
The one proposed here has 2 seven segment 8 digits display, one display for each driver, but with just a few changes it will be easy to add or reduce the number of digits to use.

Code
Notes
  • read risk disclaimer
  • excuse my bad english







Sony Playstation 3 Fat YLOD repair

$
0
0

The Sony Playstation 3 Fat, the first version Sony build, suffers for the well know problem of the Yellow Led Of Death (YLOD), that cause the PS3 not to boot.

It happens that I've found a PS3 Fat in the dumpster. It works for a while, than It turns off due to thermal overload.

First thing I've try, was to reflow the two main processing unit.

I take my hot air soldering station, set it to 200 Celsius degree and move for 2 minutes on the first then on the second unit. I keep moving around while reflowing. Second step was done at 250 Celsius degree and 2 minutes.

After the reflow, I've changed the thermal paste, and the PS3 has started working again.

I'm not a big player, so I'ven't use the console for a while. After a couple of month I wanted to play again, but the PS3 does not boot anymore. This time it suffers of the YLOD, it try to boot, then after 1 ore 2 seconds the red led flashes three times and PS3 won't start.

Searching on the web I've found this may due to the NEC/TOKIN capacitors used by Sony in this console version. There are 8, 4 on one side, 4 on the others. They suffer for thermal overload, and eventually loose their capacity.

The fix this time was to remove those caps, and replace with new ones. You can even replace just a couple of those caps, so I decide to replace 4 caps, the bottom side one.

I've used 470uF Tantalum capacitors, model 2R5TPE470M9. 4 for each of the NEC/TOKIN removed.

The difficult part here is to remove the old caps, I've try with air flow solder, without luck, finally I was able to remove those with some brutal force and a chisel. You have to pay attention removing caps cause you may damage your PS3 PCB, and it can be your Game Over.

Anyway, once caps have been removed, you have to clean the PCB trace. There's a big gound plane, so you have to use a solder with some energy. I've used a 100W solder with a big tip (1cm) with a strong thermal mass.

Even to solder the new caps, you have to use a solder with a pretty big thermal mass. I've try with my KSGER T12 soldering station, but even at 450 Celsius degree it was difficult to solder the caps. So I've used a 60W solder with a 3mm tip, the 100W I've used before has a really big tip.

Remember to select low profile caps and solder them next to the PCB, try to stay low, cause once you assembly the console again, just over your caps there will be the mouting shield.

Here you can find a really good guide: https://www.psx-place.com/threads/research-experimental-nec-tokin-capacitors-replacement-ylod.25260/

Once I've replaced the caps, my PS3 has started working. Again I'm not a big gamer, It was more about reparing this console than playing on it... but it has been in the same fashing funny.

Bontempi HP 544.20 keyboard repair

$
0
0

The HP 544.20 is a middle 80's keyboard from Bontempi (https://www.bontempi.com/).

Bontempi is an Italian musical instrument manufacturer that build low-priced instruments. This model is an electric organ that offers a Solo section with a few instruments presets and a Rhythm section.

I found this keyboard years ago on the edge of the road. It was full of ants.

First thing first I power it on, to my surprise after a couple of tries it works. So I decide to clean it.

The only problem this keyboard has is that most of the time, you have to move it, or try a few times to power it on after it works.

The keys are not so bad, they don't feels like a toy instruments. Even if the sound is not that good I decide to give a second change to this keyboard.

I've noticed that it was something on the power/amplifier board that didn't work, cause moving cables and connector on the main boards made this works.

Power stage seems good. Visual inspection seems ok. So my first try was to clean the connectors. All seems to work for a while... then after a couple of days the power on issue started again.

So I decide to scope around the board.

I've found that there's aren't problem on the audio signal coming out from the generator board to the amplifier board. So it should be something on the amplifier board.

The thing is that I've to wait for the problem to arise to check where the signal fade away. After a couple of tries I've found that the signal seems to vanish where it should not. I though it was something related to a component, but then I realize the signal is interrupted on a PCB trace.

I repeat the visual inspection, this time i focessed on the indicted PCB trace under my microscope and there i found the problem.

There's a little crack in this PCB that sometimes stops the signal. Moving PCB connectors helped cause the PCB slighlty moves and the trace conduct again.

So I simply scrape a little bit of the trace next to the crack, and solder this again.

The keyboard now is fully working.

For this reason I decided to build also a sheet music holder, that was missing. Now it's complete and ready to play.

Notes

  • read risk disclaimer
  • excuse my bad english

Sony PS3 capacitors remove and replace - YLOD repair

$
0
0

I've already talked about this topic on the this post here: https://davidegironi.blogspot.com/2021/09/sony-playstation-3-fat-ylod-repair.html

Summarizing Sony Playstation 3 Fat use a kind of capacitor, namely the NEC/TOKIN, that dies after a while due to thermal stress. The result of this damage is the Yellow Led Of Dead (YOLD), in other word your PS3 will not boot.

The "uneasy" part on replacing those caps is the removal. For this reason I want to share with you the method I've used.

Keep in mind that this procedure may damage your PS3, so do this repair at your own risk, i am not responsible if your PlayStation 3 will not work anymore.

The trick I've use to remove those caps is to use a chisel. You can find it in the linked video. You just have to pay attention not to use to much force.

Once removed you have just to clean the trace with a soldering iron. I've used one with a big thermal mass, this helps cause there's a pretty big ground plane to heat.

Last step you have to install new capacitors, doing this keep in mind you have to stay "low" cause over the new caps there will be the metal frame of the PS3. By the way like I've said in the linked post I've used 470uF Tantalum capacitors, model 2R5TPE470M9. 4 for each of the NEC/TOKIN removed.

Removing the original caps you will lose the VCC join between the caps head, so you have to replace this with a piece of wire.

If you have done a good job, and the damage was just on capacitors, you are good to go, your Playstation 3 will boot again.

Notes

  • read risk disclaimer
  • excuse my bad english

JBL Creature II speakers repair and power supply mod

$
0
0

The JBL Creature II is a 2.1 speaker system.

They came out in middle 2000, and they look futuristic.

The Creature II are equiped with a 27 watts 4.5 inch subwoofer and 2 small 4. 5 inch 9 watt sattelites. On the subwoofer is located the treble and bass adjustment, on one of the sattelite the touch volume control.

A friend of mine give me those speaker, they were without the power supply and the two satellites speaker were broken.

The speaker ring foam ring decay it's a common fault for this kind of spekaer. I've buy a couple of 40mm 4Ohm 5W full range speaker from AIYIMA and replaced the original ones, like the one you see below.

I did not want to buy a new supply for this speaker system. I had a 220V to 19V 1A transformer, I know the original supply it's 3.5A, but I've take measurements, my system use 1A almost at high volume, so I've used the one I've.

My first try was to 3D print an holder and put the transfomer inside the subwoofer case. The holder works but I had not thinked about the inducted noise of the transformer coil. So I moved the transformer outside the case, but leaving a 220V switch in the case, this way the transfomer is fully powered off when the switch is off.

This system sounds pretty good. I think that due to his 2000/futuristic look I'm going to use this with a synthetizer, built in the 2000. They are a good pair.

Notes

  • read risk disclaimer
  • excuse my bad english



Extended button debounce library

$
0
0

I've previously introduced my debounce library here: http://davidegironi.blogspot.com/2018/10/switch-debounce-library.html

This post is about an expansion to that library.

In brief, this library try to solve the contact bounce issue (ref. https://en.wikipedia.org/wiki/Switch#Contact_bounce), implenting the Jack Ganssle's article "A Guide to Debouncing" idea. As my previous library, this too is based upon the Trent Cleghorn work, you can find here https://github.com/tcleg/Button_Debouncer

This version of the library implements the long press and other function too, let's list it all:

  • currentpressed: check if button is currently pressed
  • pressed: check if a buttons were immediately pressed
  • pressedchange: check if a button were pressed since the last request
  • released: check if a buttons were immediately released
  • releasedchange: check if a button were released since the last request
  • continuouspressed: checks if a button were continuous pressed
  • longpressedchange: check if a button were long pressed since the last request
  • longreleasedchange: check if a button were long released since the last request

Those functions covers most of the requirements you may have handling buttons.

The buttondebouncer.h file contains all the parameters such as the constant value that defines how many step the debouncer will take to get a long pressed button state.

The library has been developed on a ATmega running @ 1Mhz, but it can easly ported to other microcontroller.


Code

Notes
  • read risk disclaimer
  • excuse my bad english

AVR Industrial Weight Checker - Model t02

$
0
0

This weight checker is device that constantly check the weight under test and possibly trigger an alert action. The alert is triggered in the form a relay.

This device is built on top of an ATmega8 running @ 8Mhz. It has 3 button to setup all the parameters and an 2x16 LCD to monitor the working status. As weight sensor a HX711 board is used.

Configuration parameter are stored inside the ATmega EEPROM. Whenever the weight raise the minimum or maximum threshold an error is triggered. Use can set the number of errors system has to raise before the alert action happens. Whenever an alert is triggered, a relay is opened or closed, depending on the wiring desired for the external equipment.

User can set a few parameters inside the LCD, like:

  • Weight sensor calibration: here we can set the gain, the offset and the tare.
  • Interval between weights
  • Number of errors to wait for an alert to be triggered
  • Max and Min Weight error: thresholds for an alert to be triggered
This is just a simple device one can customize depending on personal needs.



Below the load cells used for test. On the industrial application this device has been attached to industrial cells.


Code


Notes
  • read risk disclaimer
  • excuse my bad english

D04: vintage 18W guitar amplifier

$
0
0

The D04 is a guitar amplifier built using an old turntable by Perpetuum Ebner (https://de.wikipedia.org/wiki/Perpetuum-Ebner).


The model I've used it's a vintage 70's PE 3015 turntable. When I was a boy friends give away this turntable to me, cause it's not working. I've used this turntable years ago as a standard amplifier, taking advantages of it's aux input, then I've decided to turn this in a guitar amplifier.

Like the D03 amplifier that you can find here http://davidegironi.blogspot.com/2020/03/d03-lesa-boogie-guitar-amplifier.html, this one also is built using a dismissed and not working turntable.


Building technique of the case was almost the same. The speaker were glued together and an hole was drilled in order to makes cables run one side to the other.
I've worked then on the turntable panel to make it fit the top of the speakers.
As on the D03, I've used all the original potentiometer knobs as the panel holes.
The power switch is on the top of the panel.
Then a channel selector is installed.
This amplifier has 2 channels
  • clean
  • overdrive/distortion
The selector switch from the clean to the overdrive/distortion channel. Also the switch act as a voltage divider selector for the overdrive/distortion section. The selected transformer, this time is a 24V single rail, think it's a 40VA. Single rail are cheaper and easier to find than dual rail, so I would like to build something with a single rail.


The preamplifier it's a JFET preamplifier based on the J. Donald Tillman design found in the article "A Discrete FET Guitar Preamphttp://www.till.com/articles/GuitarPreamp/. It use a single J201 JFET and just a few components. It really sounds good. This kind of preamplifier is the same you can find in many other amplifier.

Then the tone stack is a dual tone, as i tell you I would like to keep the original panel untouched, it means to use the two treble and bass selector.
The tone is based on the Fender 6G5 amplifier, it's simple to build and sounds good.


Least but not last, the speakers. Original turntable speakers are used, but they need to be wired in such a mono way.

Then another JFET is used as a Booster to restore the signal due to the tone loss. It's just like the ElectroSmash1Wamp Electric Guitar Amplifier found here https://www.electrosmash.com/1wamp.

Here comes the overdrive/distortion stage. That's based on Clock of Tone 50 and The Ursa Minor pedal with a few mods. It's basically a single transistor, the 2N5088, based distortion. The selector gives this transistor even more distortion adding a diode clipping stage.
At the end of this stage we need to add a voltage divider in order to makes the distortion volume almost equals to the clean stage.

The signal then goes to the reverb stage. The reverb it's based on the Valve WizardSmallTime pedal with a few changes. The main IC used in this reverb is the PT2399, a TL072 op amp is then used to restore the signal before and after the reverb.
Two trimpot can be used to trick the reverb sounds.

The amplifier itself is build around a TDA2030 IC. This chip is a class-AB amplifier monolithic integrated circuit. The design used is a based on the main datasheet single rail voltage test circuit.

The power stage is as simple as you can imagine, it's just a rectified AC voltage, with a 9V and 5V output from two separate linear voltage regulators.



Now, how does it sounds?
Really good to me, even if the amplifier is supplied in a single rail way, as the only opamp of this circuit, the sounds of the JFET preamp and the overdrive/distortion stage, makes this amplifiers sounds warm, but when the distortion is pumped up, the sound can be very "sharp".

Find the schematics below.










Notes
  • read risk disclaimer
  • excuse my bad english

Garrard 60B by Philarmonic Elettronica turntable repair

$
0
0

I've found a 70's turntable. Of course it was not working, so I decide to repair this piece of gear, mostly because I do not have a turntable, even if I have a few vinyl, and cause I would like to learn how a turntable works.

Mine it's a Philarmonic Elettronica turntable, based on the Garrard 60b mechanism. The core of the player is indeed the Garrard gear. Garrard Engineering and Manufacturing Company was British company that sold turntable and also mechanism used for other companies.

The Garrard 60B is a 3 speed auto-player with single play facility, it can runs at 33, 45 and 78 rpm.

My disc spins, but really slowly even at 45rpm. It needs to be cleaned. Also the auto-player mechanism does not works, and the stylus is completely broken.

The wood is in pretty good condition, I just remove the Garrard mechanism and clean it apart.

To clean the mechanism I use water and degreaser. Then I clean it all with water and let it dry. Once dried I disassemble the plate, it turns out that the gear in charge of the auto-player mechanism has a decent amount of grease that dried out during years, this lock the gear not allowing it to spin. I clean it all.

Then I use oil (5W 30 motor oil) and grease (lithium grease) to lubricate gears. I use grease, just a little, on just a few points, for the most of the parts I use oil, just a few drops.

Once assembled again, all work smooth.

Now it's time to fix the style. Original one as said was fully broken, the repair cartridge costs more than 15Eur, so I decided to look for a cheaper one. I've found a couple of cheap stylus for 3Eur shipped.
I've just to draw and print in PLA an adapter. Once done the stylus is mounted and worked well.

Now, I have also a spare old transformer around, so I decide to buy a phone preamplifier. Unluckily I've to change values for two resistore of the input voltage divider of this preamplifier, cause the new cartdridge has high output, and this leads to distortion if the gain is not reduced. I must admit that my AIWA amplifier phono preamplifier sounds better that the integrated board I've used, but that will be enough if I've to use with an amplifier without phono preamp. 

Then I wired all using a 4PDT switch with two position:

  • position 1, preamplifier detached: L/R channel from stylus output goes straight on the output
  • position 2, preamplifier attached: L/R channel from the stylus to the input of the preamplifier, then output of the preamplifier connected to the output cables

This way I can use the turntable even with an amplifier without phono input.

Also I've add a couple of led, on the bottom of the plate.

Last thing that I've build is the top enclosure, I didn't want to use plexiglass for the cover, so I've used wood. Then I've glued on top of the fabric, using vinylic glue, to stay in the same context :)

The result it's a fully working, vintage style turntable, equipped with new era cheap stylus and a phono preamplifier.

Notes

  • read risk disclaimer
  • excuse my bad english

Seven segment smart counter PCB and 3D printed box

$
0
0

I've introduced you my seven segment RESTful counter here: http://davidegironi.blogspot.com/2020/04/esp8266-seven-segment-counter.html
It's based on the ESP8266, and it may drive one or more 8 digits seven segment MAX7219 displays.

In this post here I would like to share with you a double line 8 digits seven segment PCB board. Ready to be printed and builded.


Also, I attache here the CAD files that you can use to print you own box for this counter.

The board was built using Eagle.
The seven segments module that i use are the HS420361K-32, which is a common cathode module with the following wiring.

  pin 01: E
  pin 02: D
  pin 03: dp
  pin 04: C
  pin 05: G
  pin 06: dig4
  pin 07: B
  pin 08: dig3
  pin 09: dig2
  pin 10: F
  pin 11: A
  pin 12 dig1


Please find the connection diagram below. Of course the wiring of 4 bit seven segment modules changes by the model you use, so pay attention to your wiring scheme.


The box was designed using Autodesk Fusion 360 and printed using a Creality3D Ender-3 Pro on PLA.

Code
Notes
  • read risk disclaimer
  • excuse my bad english


Viewing all 196 articles
Browse latest View live