Sunday, October 30, 2022

Reducing I2C Bus Noise

 Hello,

 In my experience I2C is very reliable protocol which you can use to communicate between one or multiple devices. However sometimes due to external circuits there can be noise on the line which makes communication not reliable. In order to reduce noise, I have compiled some of the methods here:

 Some basic rules of I2C Bus Line:

1.  I2C bus cannot have more than 400 pF (include all devices on the bus!)

 

Some Interesting facts regading Electrical Engineering design

  1.  X- Capacitors are put between Mains and Y capacitors are grounded from Live.

Friday, August 12, 2022

Use of Macros

I am listing some unique macros:

1. Following macros used for incrementing/decrementing any numer(integer preferred) x. This usually can be used when you are having Menu layout using pushbuttons. For each pushbutton, menu index value x can be increased/decreased by any value inc/dec and can be set to a limit max/min

#define INC(x,max,inc) x = (x<=(max - inc))?(x+inc):max
#define DEC(x,min,dec) x = (x>=(min + dec))?(x-dec):min


2. When using RTOS you have periodic tasks that may loop in every 10ms or 50ms etc. Usually while development, we want to constantly change this loop time and test functions out. But while changing this many variables that are dependent on the task time need to be varied. Following macros can be used appropriately adjust the values depending on task time.

#define TASK2_REPEAT_MS        20
#define COUNT_1SEC_TASK2    (1000/TASK2_REPEAT_MS)


example usage

Lets say you have task that repeats every 20ms. and there is a variable that checks for 1sec loop.

 

your caode can be written using above macros:

task2(){

 uint8_t var_u81secCounter;

 var_u81secCounter++;

if(var_u81secCounter > COUNT_1SEC_TASK2    ) {

/* do things whatever you want to do every 1second

}



THis way if you change task periodicity to 50ms, all you need to update is macro TASK2_REPEAT_MS       50. Nothing else






Thursday, August 4, 2022

ESP32 Development

1. In the field of IoT ESP32 is major player. There are many Arduino versions are available, however they are only limited to small projects and hobby projects. If you want to develop a professional application, then you need to learn about ESP-IDF. This is the framework specially developed for ESP32 using which we can quickly drive various peripherals.

2. In addition ESP Also provides eclipse based IDE to make things even easier for developers:

3. Find the ESP-IDE here : https://dl.espressif.com/dl/esp-idf/


 

4. Select 2nd option as offline installer gives you reference that you have v2.5.0 version of IDE & ESP-IDF Version v4.4.

 5.  Git link - https://github.com/espressif/idf-installer

6

 

Thursday, July 21, 2022

Mice Puzzle

 I saw this on a forum. Solution is amazing:


Here is the problem:

Problem. You have mice, and bottles, exactly one of which is poisoned. Each mouse can taste any combination of bottles at once, and if it is poisoned it will die after exactly one minute. Once a mouse is dead, it can't taste any more bottles. How many minutes do you need to determine exactly which bottle is poisoned?