Saturday, October 24, 2020

KiBoard 3, again an Arduino Clone

The year 2020 is almost over now. Unfortunately, my job is very busy during the COVID19 pandemic. Today (October 2020) I have a real vacation for the first time this year. I used the time and developed 2 boards. Not really anything new. It's Arduino compatible boards with Atmega328 again. They contain a buck regulator, 3.3V LDO regulator, EEPROM, buzzer and an RTC (DS 1307 or DS3231). These boards are designed to be mounted with spacers on the back of a 1602 LCD display, which contains an I2C adapter. I decided again for an I2C display and deliberately did not choose a parallel connection because it "eats up" too many pins.
A UART header is available to connect a USB converter.


I ordered only the boards for the DS3231 version from JLCPCB.
I did not order the version with the DS1307 and will test it at a later date.



Today I got the PCBs from JLCPCB. I then assembled and tested 3 boards of the DS3231 version. It all looks very good. The board fits perfectly on the back of my 16x2 LCD display and everything seems to be working.
Fortunately, it contains protection against reverse polarity of the operating voltage (7 - 24V). Otherwise I would probably have grilled one of the circuit boards :-) ...






My KiCAD project files can be downloaded from my Google Drive:
Google Drive

There is another archive in the ZIP files. This can be uploaded directly to a board manufacturer (I use Seedstudio or JLCPCB) to order professional PCBs in your desired color.

My project is free for private use. It is aimed at experienced people. I take no guarantee! Duplication is at your own risk and responsibility!
You are welcome to customize or modify my project and publish it. However, you always have to refer to the origin!
 
Update 2/2021
I have finished my device. I added two p-channel power MOSFETs. Now it controls the lighting in my aquarium. The special thing is that I can now control the colors blue and white of my lighting separately. Now my fish have a blue night light and daylight that is accurate to the minute. And all of this is softly dimmed without stress.


 

Monday, October 12, 2020

Rotary encoder secret decoded ...

There are many pages that deal with rotary encoders in connection with Arduino. Numerous diagrams with square-wave signals are published and reports on a shift in the signals depending on the direction of rotation. All of this is correct. But I was often missing a small but important piece of information.

What exactly happens when the encoder is only rotated one stop point further?

Unfortunately, this is not understandable for me from the many technical descriptions.
I couldn't explain it clearly to myself, so I just hooked up my own oscillograph. An example from the ardino accessories was used as an encoder. Pull-up resistors are already built in here.


 

I operated this with 5v and tapped the signals at CLK (yellow) and DT (blue). And now it looks very simple:

This is the information that I have always lacked in order to understand it:

The (my own) rotary encoder generates a complete single pulse on the CLK and DT, while the rotation continues by one detent point. In the idle state, both connections are at HIGH level. 

Depending on the direction of rotation, there is a time lag between the two signals. The trigger point would be the edge from HIGH (logic 1) to LOW (logic 0) at the CLK connection (or alternatively the rising edge). In order to determine the direction of rotation, you only have to determine the level at which the 2nd output is at this point in time. Exactly at this moment the level at the DT connection is always LOW when turning in one direction or always HIGH when turning in the other direction. I have framed this point in time in red in the screenshots of my oscilloscope.