Friday, April 2, 2021

TB6612FNG AVR motor driver


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.

IN1 IN2 PWM OUT1 OUT2 Mode
H H H/L L L Short brake
L H H L H CCW
L H L L L Short brake
H L H H L CW
H L L L L Short brake
L L H OFF OFF Stop

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




Tuesday, March 2, 2021

ESP8266 ESC/POS Smart Thermal Printer


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

Sunday, February 7, 2021

A script to download all the repositories from a Bitbucket account


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

Saturday, January 2, 2021

MiniHTMLTextBox - .NET WinForm HTML TextBox component

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