Close
0%
0%

Xling

A pocket demon named Exy.
Luci? Haven't heard about him.

dsldsl
Public Chat
Similar projects worth following
This is a pocket demon I've created for my wife. I used to think that this is how a modern Tamagotchi could look like initially. However, it can also be used as a battery-powered DIY platform to experiment with FreeRTOS and graphics.

Specifications

  • 35x47mm board
  • Monochrome OLED 128x64px
  • Low energy consumption (~20mA @ active, 0.75mA @ sleep)
  • Hand-soldering friendly (TQFP-44 0.8mm pitch, smallest is 0603)
  • 3D-printable case
  • Open Source Hardware/Firmware

Hardware

  • ATmega1284P 8-bit AVR MCU with 128 KiB flash and 16 KiB SRAM
  • SH1106G display controller
  • MCP73831 charge controller
  • AP3401 DC-DC buck converter
  • 400mAh 3.7V Li-Po battery (~26h @ active, ~30 days @ sleep)
  • Load-sharing circuit (can be powered by USB or battery, like a smartphone)
  • KiCad 5.1.0 project for schematic and board designs
  • Released under CERN-OHL-W v2 (Rev. 4) and CC-BY-SA (before Rev. 4)

Software

Please, note that the software part of the project isn't finished yet! Xlingtool (a plugin for GIMP) can be used to create complex animated scenes for Xling.

  • Programmed in C99 using the FreeRTOS kernel modified for ATmega1284P
  • There are four tasks: to update display, to handle keyboard input, to monitor battery, to monitor device activity for sleep mode transition
  • Released under GNU GPLv3+

Xling_v3.2_gerber_U2Pi_artwork.zip

Xling v.3.2 PCB gerber files with an artwork by U2Pi on silkscreen (doesn't usually render well by gerber viewers, but can be produced by PCB houses easily). Artist: https://www.deviantart.com/u2pi

Zip Archive - 533.63 kB - 03/24/2020 at 17:06

Download

Xling_v3.2_bom.csv

Xling v3.2 Bill of Materials (Text CSV)

Comma-Separated Values - 2.40 kB - 03/22/2020 at 13:01

Download

Xling_v3.2_bom.ods

Xling v3.2 Bill of Materials (Open Document Spreadsheet)

spreadsheet - 16.47 kB - 03/22/2020 at 13:01

Download

Xling_v3.2_schematic.pdf

Schematic for Xling v3.2

Adobe Portable Document Format - 151.11 kB - 03/22/2020 at 12:46

Preview
Download

  • Love it? Support it!

    dsl02/22/2023 at 20:38 0 comments

    I've just opened a page on Patreon: www.patreon.com/salychev.

    No updates for the project have been published for a long time. Some fuel might help to kick it again!

  • A static scene with parallax effect

    dsl01/21/2021 at 17:33 2 comments

  • Xling v4.0 - a plugin for GIMP, improved graphic functions and updated PCB

    dsl01/13/2021 at 14:04 0 comments

    Introduction

    It's been quiet here for a while and it might be a good moment to provide an update describing what's been done during previous months.

    I've been working on Xlingtool, a plugin for GIMP based on LCD Image Converter and a new way to draw and export scenes for Xling, which is essential to finish firmware part of the project. There are several improvements in the graphic functions which allow to draw a visible part of an image on the canvas when it's top-left corner has negative coordinates. PCB itself has received several updates including new switches with ground terminals (hopefully, more robust) and a battery socket to prevent a short of its wires during soldering.

    Xlingtool

    GIMP has an attractive user interface and allows to modify an image with many layers. It supports plugins which can be written in C or Python and usually used to implement various raster effects and filters. Plugins have an access to the whole image including its layers and raw data. This can be used together with the image converter to prepare and export a whole scene composed of several static images and animations directly into C code.

    Xlingtool does exactly this. Moreover, it uses SHA-1 hash as a name of the exported file which is calculated based on the image data. This feature allows to use layers with duplicated images in a scene construction process, but prevents a scarce flash memory of ATmega1284P to be occupied by duplicated image data.

    Once scene is ready, it can be exported into a set of C header files by pressing Filters > Tools > xlingtool... Scene in the example above contains 100 layers, but only visible ones and layers without !ignore() tag will be exported. You'll find similar files generated by Xlingtool in the repository. Let's take a closer look at the scenes.h:

    The most important part here is XG_SCNL_smoking_02, an array of scene layers which will be used by the graphic functions to draw a whole scene on a canvas which will be transferred to the display memory once the scene painting process is finished.

    Order of the layers in scenes.h is the same as in GIMP, i.e. layer with the smallest index will be placed on top of the others.

    There's a special !kbd() tag which tells the plugin to generate a prototype of the keyboard callback function. For example, scene on the picture above contains a dedicated layer with the tag used as a name which forces the plugin to add XG_SCNKBD_smoking_02(XG_ButtonState_e, void *) to the scenes header file. Obviously, there should be an implementation of the function provided. This keyboard function is called right before the next iteration of the scene drawing loop in the display task.

    Two types of the layer objects are available at the moment: images and animations with XG_IMG and XG_ANM prefixes accordingly. Xlingtool also generates an anim.h file where each scene animations are defined:

    Each animation has its own array of frames defined with XG_ANMF prefix, and each animation frame has a chance to select an alternative frame to be drawn next instead of the frame which goes right after the current one, i.e. XG_ANMF_RightEye[0] has a 98% chance for XG_ANMF_RightEye[8] to be drawn next instead of XG_ANMF_RightEye[1].

    This mechanism helps to create non-linear, complex and interesting animations.

    The plugin may produce a lot of files with SHA-1 hashes in their names depending on a number of layers in a particular scene and only two human-readable files described above. Scene itself can be drawn on a canvas using a simple function from xling/graphics.h which is designed to be called in a loop in order to update animation frames:

    Improved graphic functions

    I've already had a function to draw images on a canvas at the non-negative coordinates. It worked quite well when only a part of the image was visible due to its placement and size. However, it was impossible to use negative coordinates there.

    I'm talking about XG_Draw_PF() function which uses a new CALC_AUX_POINT()...

    Read more »

  • Exy’s waiting to be animated more

    dsl09/29/2020 at 19:16 0 comments

  • Xling v3.2 - updated board, PCBWay review and firmware bugs fixed

    dsl03/21/2020 at 19:06 0 comments

    Introduction

    I'm going to include a review for PCBWay service as a part of this update because they supported me with the current iteration of Xling v3.2 and manufactured black PCBs for free.

    However, I'd like to keep it as fair as possible because everyone should benefit in this case. On one hand, everyone who's reading it will be able to understand what PCBWay is capable of. On the other hand, PCBWay will be able to see what they might improve in their service.

    Personally, I'd like to thank DI HALT and his blog, easyelectronics.ru. I read it from time to time with pleasure. Besides, an article about PCBWay helped me a lot.

    Let me show you how Xling looks like in its current iteration fully assembled and in a 3D-printed case.
    Just as I imagined!

    How to configure PCB

    There are many parameters to tweak in order to quote a PCB production, and some of them might not be obvious enough. I'll try to describe them briefly and spend more time for obscure ones.

    Board type parameter means a way to prepare PCBs. You'll receive boards in single pieces in case of the first option which is suitable for prototypes or a small batch production. The second and third options which start with Panel by... might be useful in case of an automatic assembling and a mass production and allow you to select your own size of a panel (Panel by Customer) and let PCBWay populate it with your boards, or let PCBWay to do all of these steps (Panel by PCBWay).

    Please, note that in case of a single board it's necessary to select Size of a single board only, but in case of a panel, these are dimensions of the whole panel which might contain several boards. The same rules are applicable for Quantity which means a number of single boards or a number of panels accordingly.

    Generally speaking, it's not obvious why somebody would let PCBWay to decide how to panel her boards because dimensions of a panel depend on a specific assembly equipment. However, PCBWay offers an assembly service also and the third option is useful in this specific case.

    There are several ways how boards will be connected within a panel. In case of V-Scoring PCB material will be cut for a half of its height to simplify a break off. In case of Tab Route boards will be attached to a panel and among each other by narrow bridges.

    It might also be necessary to include different designs into a single panel, but it'll increase its price.

    Another option called X-out Allowance in Panel gives an incredible ability to reduce an overall cost of the panel by about 30%. It's useful if you can tolerate a PCB in the panel to fail electrical testing. It'll be marked by a cross in this case.

    You shouldn't usually worry about number of Layers because it can be obtained automatically from Gerber files provided within an archive.

    Material is what PCB is manufactured from, where FR-4 is epoxy glass cloth (the most widely used material for PCB, probably) and the rest.

    Personally, I'd like to mention FR4-TG which stands for a glass transition temperature and defines some thermal and chemical properties of the material. One of the most important things which is affected by this temperature is board geometry which is critical in case of really narrow routes and precision PCBs. The higher the temperature, the better PCBs can be manufactured, but overall cost will be increased also.

    Another important option is HDI (Buried/blind vias) which stands for High Density Interconnect PCBs. In this case RCC (Resin Coated Copper) is applied to epoxy glass cloth which leads to fine circuits.

    These are limits for tracks/spaces and size of the holes. Please, be careful and select them according to your design.

    It's interesting how minimal these options are. For example, you cannot select a limit for annular ring, but a diameter only. Personally, I'd recommend to read about PCBWay capabilities first in order to stay within limits and reduce amount of money to be spent on PCB production.

    There...

    Read more »

  • Xling v3.1 - an animation demo, more checkpoints, 4-wire SPI and FreeRTOS

    dsl11/17/2019 at 19:45 0 comments

    Almost a month and a half passed since the previous update (not so much comparing to v0.3, eh?) and I'm here to share some details regarding the overall progress.

    First of all, I've finally got rid of the leading zero in the Xling PCB version because there are no chances that I'll be brave enough to change it in future. So, v0.3.1 became v3.1 and it means that the most recent changes of the Xling PCB will find their way into current/3.0 branch of the repository.

    Note that it has nothing in common with the firmware version of Xling. The most recent changes in code find their way into current/0.4 branch of the Xling-firmware repository

    Animation demo

    Anyway, I'd like to show you a walking animation demo at 24 FPS. There are only 4 images of the animation where each one stays on a screen during two frames.

    However, a driver for SH1106-based displays I've been working on can do its best and produce the same animation at full speed:

    You're probably interested in the technical information on the screen. Here it is:

    1. BAT_LVL - a raw ADC value of the battery voltage (voltage divider, ADC3, 10-bit, Vref = 1.1 V).
    2. BAT_STAT - a single bit, which is grabbed directly from the MCP73831 STAT pin (1 - when the battery current, Ibat, is below a selected threshold, Iterm, 0 - otherwise).
    3. Number of frames to re-draw before calculating a delay.
    4. Time spent to re-draw the frames.
    5. Current FPS (according to 3 and 4).

    More PCB checkpoints and 4-wire SPI


    Spending time debugging and optimizing the OLED driver, I've realised that it would be convinient to have additional test points on top of the PCB. It's now possible to solder wires and attach the oscilloscope probes easily, without turning the bottom part of the PCB into a mess.

    Another change is 4-wire SPI which is used to connect the display in v3.1. I've decided to give up with the 3-wire SPI support in the driver entierly because of the 8-bit SPI shift register available in ATmega1284P only.

    There is no room for the 9th bit required by the display controller to distinct between data for graphics RAM and command register. Moreover, there is no easy way to stop transmitting bits from the shift register to "hack" the protocol.

    FreeRTOS-based firmware

    This is probably the most interesting update of mine.

    I've got a demo project (FreeRTOS/Demo/AVR_ATMega323_WinAVR) of FreeRTOS v10.2.1, copied several files (including list.c, queue.c, tasks.c, croutine.c and port.c + headers) to the Xling-firmware project and adjusted CMake configuration file according to the makefile from the demo project.

    Another modification is the port.c file which has been re-programmed a bit in order to use a 16-bit Timer/Counter 1 of the ATmega1284P to generate ticks for the FreeRTOS scheduler.

    So, it means that I can do something like that from now on :)

    Other updates

    Personally, I'd like to thank the community of r/PrintedCircuitBoard and u/charliebruce123 in particular because they pointed me to the issues with the previous version of the PCB. I've tried to fix them all in v3.1.

    Xling v3.1 isn't the first PCB version which has been attached to the battery in order to check how load-sharing circuit works, but it is the first one which allowed me to measure a battery voltage obtained from ADC via a voltage divider, a direct battery voltage, an output voltage at +3.3V and a battery status pin.

    All of the information should be enough to program a task which monitors the battery status correctly and prevents overcharges and deep discharges.

    Anyway, if you have any questions and ideas on your mind, feel free to tell me then.

    Have a good time!


  • Xling v0.3 - an artistic PCB, ATmega1284P and white OLED with SPI

    dsl10/05/2019 at 18:45 2 comments

    The whole summer has passed and I've finally finished the next version of the toy according to my plan. There are several significant changes which you've probably noticed:


    The first one doesn't carry any technical function, but provides a unique look and feel of the PCB (many thanks to SierraSaura for this picture).


    The second change is a new ATmega1284P MCU which replaces the previous ATmega328P one.

    It is the most important improvement over the previous versions because of the 32 KiB -> 128 KiB flash memory (the only memory on the board to carry a lot of the graphic sprites, for example). An amount of RAM has also been increased from 2 KiB on ATmega328P to 16 KiB on ATmega1284P.


    The third change is almost the same OLED display which color is white now instead of the yellow on the previous prototypes and connected using SPI.

    All of the previous displays with SH1106 controller were connected via two-wire interface (TWI, another name for I2C) which is relatively slow comparing to the SPI.

    However, a driver for the SH1106-based displays I'm working on doesn't support SPI yet. This is the next step on my way and this new Xling v0.3 will help me testing it.


    Anyway, if you have any questions and ideas on your mind, feel free to tell me then.

    Have a good time!

  • Actual size (height)

    dsl05/24/2019 at 18:45 0 comments

  • Actual size (width)

    dsl05/24/2019 at 18:38 0 comments

View all 9 project logs

Enjoy this project?

Share

Discussions

That One Bitch wrote 07/06/2022 at 13:36 point

Hey!  Do you have any updates? how is this little guy doing? 

  Are you sure? yes | no

jasonwmayjr wrote 05/05/2022 at 22:52 point

hey! I love your project but I was wondering, do you have any instructions on the latest model of the "pocket demon". thanks!

  Are you sure? yes | no

meeshee wrote 05/31/2021 at 03:20 point

love this project so much!! I really love the disenchantment aspect of it and can’t wait to see it completed. 

  Are you sure? yes | no

dsl wrote 06/18/2021 at 12:30 point

Thanks :) I've several scenes under construction at the moment and improved firmware and Xlingtool, but no time to show any results unfortunately.

  Are you sure? yes | no

Danielle wrote 04/06/2021 at 23:16 point

This project is absolutely wonderful, and ever-so cute. I wish you had a Youtube channel so I could keep up with your progress. I dont really browse Hackaday much. What kind of features do you intend on implementing? I can't find a function list, although I will continue to look once I have posted this comment.

  Are you sure? yes | no

dsl wrote 04/07/2021 at 07:02 point

Hi Danielle! Thanks for an interest :) I thought about a Youtube channel, but I barely have time to work on the project. It's just less time-consuming to post updates here as articles.

If we're talking about software part of the project, I'm going to implement a complete tamagotchi-like game with Exy as a demon and a main character in a "fairy tale" setting. You'll be able to control him, wonder here and there, face challenges (trick people, steal stuff, etc.), lose karma and build your own pub at the end (or earn your karma by helping someone accidentally, lose the game and start again).

Hardware isn't that complex as you can see and I don't have plans to change it significantly.

  Are you sure? yes | no

Victorio Berra wrote 03/28/2021 at 16:48 point

What is the easiest way to order one of these boards?

  Are you sure? yes | no

dsl wrote 04/02/2021 at 14:10 point

Hi Victorio. The easiest way is to stay tuned here, at Hackaday.io, or follow my github project and wait till one will appear somewhere like Tindie :) I'm still working on a software part of the project.

If you want to get your hands dirty, I could send you a prototype though.

  Are you sure? yes | no

Jacob MacLeod wrote 10/13/2019 at 20:55 point

Nice project!

  Are you sure? yes | no

dsl wrote 10/14/2019 at 06:00 point

Thanks :)

  Are you sure? yes | no

Tom Nardi wrote 10/11/2019 at 03:07 point

Love the Disenchantment reference, very impressive project.

  Are you sure? yes | no

dsl wrote 10/11/2019 at 07:53 point

Ah, you've noticed it! Thanks :)

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates