Sunday, December 6, 2020

OpenWrt main and Guest network AP using VLAN with unmanaged switch

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

Monday, November 2, 2020

ESP8266 Smart Wind Speed Meter


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



Sunday, October 4, 2020

ATmega BLDC motor driver dev board


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



Friday, September 4, 2020

BLDC motor driver v02 speed test


In my last video about the new BLDC driver I've written you can find here http://davidegironi.blogspot.com/2019/12/an-atmega-brushless-sensorless-motor.html, I was talking about testing other motors.

Here you can find a sample speed test I've run over a Brushless motor Mistery D2025-5000.

To test the speed I've used a cheap Laser Tachometer DT-2234C+.
I've put tape around the motor and mark just one side of the motor tape with a black marker.

Results are pretty good, the motor spins at almost 11000rpm  running at 12V, with a current consumption of 0.9A.
Don't forget that this driver is not made for performance, this driver was built to be fairly simple and easly modify in order to be easly embedded in any project. If you are looking at performance, you should take a look at the SimonK firmware (https://github.com/sim-/tgy).

Testing the the same motor running at almost the same speed 11000rpm with SimonK firmware, results in a current consumption of 0.8A. However with SimonK i was able to run this motor at 30000rpm, 

This means that even if my driver is not build with performance in mind, it still runs pretty well.

I've tested the driver over other BLDC motor I've around here, all the motor spins without much problems. Startup sequence is good.

However, if you want to trick up performance, you can still make changes to the bldcsetupmotor.h file. In that file you can find various parameters used during the ramp startup time as long as the running time, like the ZC error setting and PWM timer counter settings, that will set the speed.

One last word about this BLDC driver that makes me happy, an article has been published on the italian Elettronica In (http://www.elettronicain.it/) magazine.


Notes
  • read risk disclaimer
  • excuse my bad english

Monday, August 3, 2020

Homemade PCB Cutting Machine


Here i present you my homemade PCB Cutting Machine.
It's a simple DIY project to build, there are just a few key points to watch out for.

This Cutting Machine it's based on a drill 12V DC motor. I've a broken electric drill, that's the donor of the motor. My motor is a ZG-RS550S-12V.



Then the inkjet printer sliding mechanism, once again something broken you can find without problem.
The sliding mechanism need to be prepared to make the motor fit on the ink sled.

I've buy the motor bracket and the motor adaptor, and of course the circular blade.
As for the circular blade mine it's a 50mm diamond plated steel disc used for Dremel. I've found that this kind of blade works better on PCB than saw blade with teeth like the ones for wood.


Then we need the piece of wood that will be base of our machine. We need to saw away the line where the cutting blade will slide in.

The key point now is to assembly all the pieces in such a way that is all perpendicular, that will affect the 90 degrees cutting that we want on our PCB. As you notice on my Cutting machine I've used big screw to mount the sliding mechanism, the hole that I've drill on the mechanism it's a bit larger then the screw, this way i can arrange the mechanism horizontally and vertically.



I've tried it with PCB up to 2mm without problem.

The PWM board it's a 6..90V, 15A.
A switch is attached in order to enable the PWM board, or to skip it and give the motor the full speed.

Notes
  • read risk disclaimer
  • excuse my bad english

Sunday, July 5, 2020

My Score Keeper: a simple app to track score of your games


My Score Keeper is a simple app that allows your track score of your games.
You can add multiple Games, each games may have many Match and each match many Rounds. You can add as much Players as you need. Points are recorded so you can take a look at the full historical points list.


A Dice tool and the Countedown Timer are also included. Just tap on the dice to generate a random number, or use the Countdown Timer to time your Round. The free Backup and Restore cloud agent allows your data to be upload on a temporary cloud space you can use to restore to another device just in case. My Score Keeper is Open Source, and it's built using React Native.
You can find the app on the Google Play Store. It's not published yet on the Apple Store, but it works with iOS too.
The app reley on the Realm database.
The first app screen is the Game one, all the Games are listed here. User can create a new math or select one listed. Long tapping on the game enters the edit/delete mode.
Inside the Game screen, user can add Match. When a Match is selected, Players needs to be added. Players of course can be removed or added whenever the user wants. When a new Round is added the user can select which are the Players that play that round.


During the Round points can be added or substracted to each Players.
A couple of tools can be enabled on the Round screen.
A Dice, that select a random number between an interval and a Countdown Timer.
Database can be backupped on a cloud service that is hosted free on Firebase. The web folder contains the code of the backup server.
Backup are rotated, this way the server space does not fill up.


Code

Notes
  • read risk disclaimer
  • excuse my bad english


Monday, June 1, 2020

AppDressBook: Address Book app that synchronizes contacts using a custom API server


AppDressBook is an Address Book app that synchronizes contacts using a custom API server.
It is useful for companies or associations that's want to share contacts using a unique application.
They just have to build their own server that provides the contact list and eventually an authentication method, then the server url can be shared with people engaged and used in this app.


AppDressBook is Open Source and it's built using React Native.
It works both on Android and iOS. Although it's not yet published on Apple Store. You can find the Android app here at the Google Play Store.
The backend server itself it's pretty simple, in the Docs folder you can find all the json schemas for the routes you have to serve.
Ther's a simple test server written in node.js published with the application code, you can find it in the appdressbookapisample folder. I've implemented a C# server for my company. Building the API server is really a simple job. Contacts can be secured by username and password validation. Contacts can of course be synced according to the logged in user. You can even chose to deploy your contacts without authentication.



When the application is executed for the first time, the API server must be filled. Then that server is beeing asked for settings. If authentication is required user has to authenticate, if not contacts can be synced instantly.
Contacts list is cheked against the server each 10 minutes, using the hash of the list, this is to prevent bandwith consumption.
The application itself is simple, and customizable for your needs.


Code

Notes
  • read risk disclaimer
  • excuse my bad english


Saturday, May 2, 2020

NRI G-13.mft parallel coin acceptor to Serial adapter


The NRI G-13.mft by Crane (https://www.cranepi.com/) is a versatile and high secure coin validator.
It can be programmed using the propretary WinEMP software and PC interface, or event it has some DIP Switch that can be used to program the device.
Unluckily it does not come with a UART interface. But it features a "machine tester" I/O interface we can use to track the inserted coins.


On page 50/51 of the Technical Documentation for NRI G-13.mft G-13.mft parallel Standard, Casino and AMU Models (from Version /4) 05.05 Hns/WP/ds Edition 1.2 BA.G13MFTPAR4-GB, we find the specification for the interface we could use.



For the G-13.mft standard/Casino model – vending machine 10pin interface, we notice that
PIN 1 is the GND while PIN 2 the VCC, we can use those pin to power the device on.
Moreover, if we scope on the PIN3,4,7,8,9,10 we may notice that as the datasheet said, the signal is active low when a coin is inserted on the specific line.


Because those PIN also inhibit a signal line we can even instruct the coin acceptor to disable a specific coin line. This will not be the case we are investigating here, I'm only interested in getting the coin signal.
For this reason I just connect the output of the Coin signal line, with a pullup resistor to our microcontroller.
That's easy, now it's just a pin reading matter, with a bit of debounching.


The schematics itself is simple. The main microcontroller is an ATmega8. The UART to USB adapter chip is the Silab CP2102, attached to a microUsb port.


For this project I've also design the PCB, which i prototype using a chinese PCBA service. We are able to build the final board after 3 prototype, that's because I'm not a pro in the PCB design, but I've to start somewhere. Then the company I work request 100 boards production from the chinese company. It was the first time that I try the PCBA service of a company, think this was a good experience, to start with a small and simple board like this one.



Code, Schematics and PCB

Notes
  • read risk disclaimer
  • excuse my bad english


Friday, April 3, 2020

3 kind of Ruby Amp: Standard, Bassman and Hiwatt with distortion mod


I've introduced you the Ruby Amp here http://davidegironi.blogspot.com/2019/08/my-ruby-amp-bassman-mod-small-bass.html when I was talking about my bass amplifier 1W amp.
The Ruby Amp is a small guitar amplifier built around the LM386 IC.

This time i present you 3 kind of Ruby Amps from my collection.


Then the first one, it's a standard one, straight like the one of the runoffgroove.com site http://www.runoffgroove.com/ruby.html with a gain control.



Second one is a Bassman mod one, with a distortion switch that pump up the LM386 gain to it's limit. It was built on a PC speaker case.



Last one, the third, like the previous, was built on a PC speaker case, but this time it's an Hiwatt mod, again it cames with distortion switch.



All those you see above, I've built using a PCB board I've design.

Then some bonus pictures of the first one I've built. It's a standard one without gain pot. It was built on a prototyping board, it was 2010.



Most of them runs on a 9v supply voltage, some on 12v.
A personal note on the supply, if you are using a high to low voltage transformer and a rectifier to get your supply voltage, use big caps or even better a voltage regulator like the LM7809 if you want to avoid noise from your power line.

As you can see, I've always use salvaged parts, even that, they sound pretty well to my ears.
I've built others, always using recovered case and parts.
Although I've never use those amps in a record they sounds good, are simple to build and portable, so if you need one small amp at your friend house or during a BBQ, those are the amps.

Notes
  • read risk disclaimer
  • excuse my bad english

Monday, March 2, 2020

D03: the "LESA Boogie" guitar amplifier


I've built this guitar amplifier from a 50's turntable with speakers.
This turntable was built by LESA (Laboratori Elettrotecnici Società Anonima), which sounds like Electrotechnical Laboratories of an Anonymous Company.


It happens that this turntable was left in an house with water leaks, the water was running just over the turntable, luckly speakers was intacts.
Because i like the turntable front and the speakers case, i decide to build a small guitar amplifier our of that piece.


As a side note to this project, the main PCB of this turntable contains some germanium transistor that I've use to build this Germanium Fuzz guitar pedal: http://davidegironi.blogspot.com/2019/02/bad-ragaz-fuzz-germanium-fuzz-pedal.html
Stage one was the building of the case.


I've glued and screwed two speakers, a hole between the two speakers was drilled for the cables.
Then on top of the speaker I drill some holes for potentiometers and panel devices.
On the back panel I put the power plug with fuse and power button.
Once I was sure that the case was correctly built it was time for the interesting stage, the electronic.
I've a +-13V 80VA transformer that I salvage from an old HiFi system, so I can build something with dual rail supply.


The design reference I use are the schematics of the following amplifiers:
  • Marshall MG10
  • Fender Frontmain 10g
  • Vox Pathfinder 10
The power stage is pretty simple, just a bridge rectifier, capacitors, two resistors used for voltage reduction, and two zener diode for the +V and -V of the opamps.
The preamplifier uses a TL072 opamp, the input stage rectify the guitar high impedance and gain the signal of 8.9.


The second stage is the overdrive channel, which is also TL072 based. This channel is enabled by the bypass selector, that is simply a DPDT switch.
The gain of the overdriver in my construction is fixed, cause I do not want to drill an hole for a gain potentiometer, instead I want to use one button of the original amplifier.
So in my design I can switch between a crunch/soft gain overdrive to an overdrive/high gain.
It would be easy to mod this amp adding the gain potentiometer for a more accurate setting.
You could simply add a 1M pot instead of the gain fixed resistors.


The tone stack it's based on the Fender 6G5 circuit with some little mods.
The signal then goes to a PT2399 based reverb. It's rectified by the TL072 that fits the signal for the amplifier board.


The reverb board has two trimmers, one for the feedback signal, the other for the delay time. Adjusting the trim the reverb sounds change. The two trimmer are in parallel with two resistors, a switch on the amplifier select which resistor is enabled, this way I can select between two different reverb styles.


The amplifier is based on the TDA2030A IC. It's basically the datasheet sample with some fleavours and signal filtering additions.


Speakers are obviously old. They comes with a woofer and a tweeter, joined togeter using a single capacitor filter. The original speaker impedance was 3.2ohm. In order to connect the amplifier board to the speaker I've wire the two speaker using a single filtering capacitor.


The amplifier sounds and looks pretty good to my hear and eyes.
Furthermore it's a LESA and I have an apartment in Lesa (https://it.wikipedia.org/wiki/Lesa), a town on the Major Lake. Guess where this amplifier is built for?





Notes
  • read risk disclaimer
  • excuse my bad english

Monday, February 3, 2020

AVR Brushless motor driver PWM scheme samples


A three-phase brushless motor it is usually drive by six-state commutation step sequence.
The commutation sequence drive the motor coils in order to make it spin.
The picture above represent a standard commutation scheme, each line is the motor coil status.


Given a 360 degree commution space, each commuation happens takes a 60 degree space.
A coil it is usually driven by mosfet bridge.
The coil can be drive on or off, but we can also drive it in PWM.
The PWM scheme is the way the power gates bridge is controlled in order to drive each motor coil.

In the AVR bldc driver here:
http://davidegironi.blogspot.com/2020/01/an-atmega-brushless-sensored-motor.html

I've implemented 4 PWM scheme.

H PWM L ON: PWM is performed on the ON channel


H ON L PWW: PWM is performed on the OFF channel


H PWM ON: PWM is performed on UWV channels every 60degrees, starting from U ON-ON


H ON PWM: PWM is performed on UWV channels every 60degrees, starting from V OFF-NULL



See above the signal sample recordered using a CD-ROM motor.

H PWM L ON sample


H ON L PWW sample


H PWM ON sample


H ON PWM sample



Notes
  • read risk disclaimer
  • excuse my bad english