obblab

MCP2221/MCP2221A USB Converter Open Source HID Library

This is an open-source library that aims to provide a multi-platform interface solution for interacting with Microchip’s MCP2221/MCP2221A USB-to-UART and I2C/SMBus serial converters. The library supports access to various functions of the converter, including 4 GPIO pins, 3 10-bit ADCs, and 1 5-bit DAC. Unlike Microchip’s proprietary DLL library, this project aims to provide an open-source, cross-platform alternative.

This library also makes use of HIDAPI.

Supported features:

FeatureStatus
ADCSupported
DACSupported
GPIOSupported
Interrupt inputSupported
Clock reference outputSupported
USB Descriptors
(Manufacturer, product, serial, VID, PID)
Supported
I2C/SMBLimited support, WIP
Flash password protectionNot yet implemented
C++ and C# wrappersNot yet implemented

Download from GitHub
Documentation

Bits of info about the MCP2221

  • Doesn’t use a crystal, only requires 1 small capacitor when powered with 3.3V or 2 capacitors when powered with 5V.
  • Available in a hacker friendly DIP package.
  • Has a remote wake function which when used in conjunction with the interrupt input can be used to wakeup the USB host (usually a PC), just

USB RGB LED Controller Based on AVR Microcontroller

Why not upgrade the CPU usage LED project to a general-purpose RGB LED controller? The current CPU usage LED controller uses a value between 0 and 255 to calculate the color it should be and then fades to that color. This is indeed quite limited; changing the color and fading method requires firmware updates. In contrast, a general-purpose RGB LED controller can let the host software handle all the work, and the controller only needs to be told what brightness the red, green, and blue LEDs should be, providing greater flexibility and scalability.

To simplify interactions with the controller, I developed a library that wraps all LibUSB content. With this library, you can achieve basic functionality with just a few lines of code (only 10 lines).


#include <rgbledctrl.h> int main() { rgbledctrl_init(); rgbledctrl_find(); s_rgbled_device* rgbLed = rgbledctrl_open(); rgbledctrl_setR(rgbLed, 200); // Set red value to 200 rgbledctrl_close(rgbLed); return 0; }

The library also has support for reading and writing to the EEPROM of the controller. Class wrappers for C++ and C# .NET are also provided.

Download from GitHub
Documentation

Bluetooth Smart Monitoring System V2.0

This article only provides a sneak peek into the new features of the network monitor.I’d recommend having a look at the original post first.

  • New PCB design
    The new PCB is now an almost single board design, just a separate board for the USB connector. The old monitor had a small main board which connected to the LCD and Bluetooth modules. This new board has everything soldered straight on.
  • Revamped microcontroller code
    Refactored a lot of the microcontroller code, reduced RAM usage and improved performance a little bit.
  • New router program
    The router program is now completely written in C! Uses much less CPU time than the old shell script.
  • New host program
    Written in C# .NET and uses LibUsbDotNet. It’s still in early development, but at the moment allows uploading images (takes around 2.5 – 3 seconds to upload), drawing stuff (mouse click and drag) and controlling the display brightness.
  • Other new features
    New efficient binary protocol instead of a text protocol.
    Added a temperature sensor since there was a lot of room left on the PCB, however this turned out to be a bit useless for measuring the room temperature because of the heat dissipated by nearby parts, mainly

Low-Power Microcontroller Applications in Smartwatches

Introduction

The main motivation behind this project was to see how much hardware and software I could cram into a small, watch-like device. I chose an OLED display because it’s only 1.5mm thick, doesn’t require a backlight, and each pixel emits its own light, making it look really cool. Initially, I planned to use a 0.96-inch display, but it turned out to be too small to fit all the components I wanted. Increasing the size to 1.3 inches proved to be the perfect solution.

https://youtube.com/watch?v=KrUJlZK1ct0

Hardware

The hardware components of this watch include an Atmel ATmega328P microcontroller, a 2.5V voltage regulator, a Maxim DS3231M RTC, a 1.3-inch 128×64 monochrome OLED, 2 LEDs (red and green), a buzzer, a 3-route navigation switch, powered by a 150mAh LiPo battery, and charged via USB and 2 PCBs.

The microcontroller ATmega328P uses its internal 8MHz oscillator and runs at 2.5V. It consumes approximately 1.5mA in active mode and 100nA in sleep mode.

The DS3231M RTC is a high-precision clock chip with a small 8-pin package, including a built-in temperature-compensated MEMS resonator, with an accuracy of ±5ppm (±2 minutes 40 seconds per year). …

Intelligent Lithium Battery Charging Management System


In project development, we may encounter issues where the circuit fails to turn on and the battery fails to charge, even with an LED. To address this problem, this article will introduce a design for a battery charger with load sharing functionality to ensure correct battery charging and normal operation of the main circuit.
We will utilize Microchip’s popular charging IC, MCP73831/2, suitable for single-cell lithium polymer and lithium-ion batteries, with a maximum charging current of 500mA. Additionally, we will reference Microchip’s application note AN1149 for load sharing design to ensure the charger’s stability and reliability.

Charging Issues without Load Sharing

During the pre-charge and constant current charging stages, the charging IC’s current limit may cause insufficient battery charging. If the load’s current demand exceeds the charging IC’s limit, the battery will be forced to discharge instead of charging. For example, if the charging IC’s current limit is 40mA and the load requires 50mA, the battery will discharge by 10mA.

During the constant voltage charging stage, the charger typically waits until…

Free Chip Sample Acquisition Sharing

Everyone loves free stuff! I’m thrilled to share my experience of recently getting some free chip samples.

Atmel
3 day delivery from US to UK via DHL WW Express

Maxim
5 day delivery from UK via Royal Mail.

Microchip
2 week delivery from Thailand

I also ordered STD75N3LLH6 x4 and STD155N3LH6 x4 (MOSFETs) from ST, but they declined my request, I think I ordered too many, 3 of each part is usually the maximum.
So in total, these samples are worth around £45! (ex. VAT) The DS3231 RTC ICs being the bulk of it, at £5-£7 each.
Stay tuned for upcoming projects using these parts!

Update – 23 May 2013
Atmel
3 day delivery from US to UK via DHL WW Express

Ti
2 day delivery from US

ST
1 week delivery from US

From Scratch to Smart: Creating a Custom Lock with EaseLock

Create a custom smart lock device for your existing door that integrates an Atmega328 microcontroller, HC-05 Bluetooth module, and relay module, enabling remote operation from any paired Android device.

In this project, We will show you how to build a comprehensive prototype of smart lock step by step with minimal cost.

The initial intent with this tutorial was to show you that you can make build this project even if you have little experience with all of the various parts (AVR chips, Bluetooth, Android). We still believe you can if you follow the steps in this tutorial.

Getting Started

Hardware Tutorial

Create a custom smart lock device for your existing door that integrates an Atmega328 microcontroller, HC-05 Bluetooth module, and relay module, enabling remote operation from any paired Android device.

In this project, I will show you how to build a comprehensive prototype of smart lock step by step with minimal cost.

Introduction

Developing a product that goes beyond software requires mastering multiple technologies, which can be a daunting task. However, this diversity can also be the most fascinating aspect of the project.

Below is a rough diagram that provides a comprehensive…

AVRDUDE Studio – A Microcontroller Programming Tool Based on AVRDUDE

AVRDUDESS is a graphical interface for AVRDUDE, designed to simplify the programming process of Atmel microcontrollers. It provides a user-friendly interface that allows users to easily upload code, read and write to the microcontroller’s flash, EEPROM, and other configurations.

Some key features:

  • Supports all programmers and MCUs that AVRDUDE supports
  • Supports presets, allowing you to change between devices and configurations quickly and easily
  • Drag and drop files for easy uploading
  • Automatically lists available COM ports
  • Cross-platform with the use of Mono for Linux & macOS

DOWNLOAD HERE

High-Precision Timing Library for AVR

This lightweight library is specifically designed for millisecond-level time tracking. It supports the “unsigned long long” data type, allowing it to accurately track up to 584.9 million years! Additionally, it can adapt to clock frequencies of up to 20MHz, with most common frequencies having no timing errors.

Compared to Arduino’s built-in millis() timer, this library is especially useful when running at clock frequencies of 8MHz or below or when tracking time for more than 50 days.

Download from GitHub

Brief comparison against the Arduino millis()

Arduino millis()

  • Microsecond support
  • Doesn’t loose or gain time at any clock frequency
  • Loss of resolution at lower frequencies

This library

  • Faster execution
  • Less RAM used
  • Always updates millisecond count every millisecond
  • Support for ‘unsigned long long’ data type, 64 bit integer allows tracking time for up to 584.9 million years, Arduino millis() uses ‘unsigned long’ which goes up to 49.71 days
  • Uses CTC mode for the timer, which might make it a little bit more difficult to use the timer for multiple things

Accuracy at commonly used clock frequencies

ClockThis library (TIMER0)This library (TIMER1)