Mechatronics geek blog

المواضيع الرئيسيه للميكاترونكس

Physical System Modeling , Sensors and Actuators ,Signals and Systems , Computers and Logic Systems AND Software and Data Acquisition

Sunday, May 5, 2019

Data Structure

Data Structure main topics: ---------------------------------- Linked List Stack Queue Tree -------------------------------------------------------------------------------------------------------- Array: is the best data structure in terms of accessing time as the time complexity of it is O(1) the time required to access any element of it is constant. Problem: Memory usage! Linked List:  is the best data structure in terms of memory management but in terms of accessing time is O(N). Problem: Accessing time- Time complexity is O(N)! Types:  ...

Saturday, April 27, 2019

Sorting Algorithms

Sorting Algorithms: --------------------------- 1- Selection Sort 2- Bubble Sort 3- Merge Sort ============================================================ 1- Selection Sort:  - Time Complexity : O(N^2) --------------------------------------- void swap(int*ele1,int*ele2) { int temp; temp=*ele1; *ele1=*ele2; *ele2=temp; } /* in this code: the use of mini variable is to determine the index of the smallest number in the array first then we swap after the inner loop finishes. Without the mini variable, we have to move the swap function...

Searching Algorithm

Searching Algorithms: --------------------------- 1-Sequential Search 2- Binary Search ---------------------------------------------------------- 1- Sequential Search:     -Searching in an array of N.     -Time complexity: O(N) int sequentialSearch (int * arr, int size, int data) {        int index= -1;        int i;        for(i=0;i<size;i++)        {           if(arr[i] == data)           {  ...

Matrices (mathematics)

Matrices Addition and Subtraction:- ============================= ************************************************************************ Rule: You can only Add or subtract two matrices only and only if they have the same number of rows and columns and the result will have the same number of rows and columns. *************************************************************************** Addition or subtraction is performed between the two elements that have the same location. Ex: [ 5      4           ...

Pointers Questions

1- Print an array after removing duplicating numbers in it? Solution: https://github.com/AmrHRAbdeen/C-Programming/blob/master/RemoveDuplicatedValues.c =================================================================== 2- Find 2 Elements in the Array such that the difference between them is the Largest? Solution: https://github.com/AmrHRAbdeen/C-Programming/blob/master/MaxDiffInArray.c =================================================================== 3- Find the One repeated number in an Array and print number of repetition? Solution: https://github.com/AmrHRAbdeen/C-Programming/blob/master/findOneRepeatedValue.c =================================================================== 4-...

Monday, April 15, 2019

Building Process and Critical Sections || Part(2)

Building process (Part 2): -------------------------------- in case the variable is used repeatedly in the code and its value is not changing during the code, The compiler optimizer has the option to store it in a General purpose register (GPR) or cache it in a cache memory if exists to reduce execution time. Ex: var =40; while(var==40) { .. .. .. } Here, the compiler will solve this line while(var==40) to 1- Read Var from its Virtual Memory Address (or from a GPR if cached in a GPR or cache memory) 2- Compare Var to 40 3- Jump if Equal. is...

Tuesday, April 9, 2019

Analog to Digital Converter (ADC)

Analog to Digital Converter (ADC): ----------------------------------------------- used to convert Analog signals to digital value. Types of ADC: ============== 1- Ramp Counter ADC:- -------------------------------- The idea behind this type of ADCs is that: The Counter is Enabled by Zero (Active LOW). When the desired signal (Vin) > DAC output(which is a voltage too) the comparator output is Zero (0) Enabling the timer to continue to count. ...

Watchdog Timer

Watchdog Timer:- ----------------------- -is a countdown timer used to reset the microcontroller after a specific timeout. The microcontroller should kick the Watchdog timer by resetting its value preventing it from reaching Zero. - One should adjust the watchdog timer to guarantee that a specific code will be executed is a specific time period less than the watchdog period. At the end of that piece of code, one should disable the...

Monday, April 8, 2019

Embedded C From 12 to 2 - Episode 1

Embedded C From 12 to 2 - Episode 1 ...

Saturday, April 6, 2019

IOT_Notes

Found in iTi_First_Sketch (Bac...

Tuesday, April 2, 2019

Memory Sections

Memory Sections (Common Sections) ----------------------------------------------- RAM: 1- .Stack section 2- .Heap section 3- .BSS section (Block Started by Symbol) 4- .Data ROM: 1- .ISR Vector or .Vectors or .intVVector or .IVT 2- .rodata (Read Only data) 3- .romdata or .data 4- .text ============================================== Example: ------------ uint32 x ; /*Uninitialized Global Variable stored in .bss section in RAM  and initialized with ZERO "According C Standard"*/ uint32 y=7; /*Initialized Global Variable stored in .data section...

Monday, April 1, 2019

Generate Sine Wave using ATmega32

Sine wave Equation: y=sin(x) ; where x is  the angle in radian. in a whole circle there are 2*PI radians . This means x varies from 0 to 2*3.14(PI) [0,6.28] => Half circle [0,+3.14] Other half [0,-3.14] As sin may be negative we need to handle this situation by shifting the 0 to 127 ( 127 is our new ZERO line) anything above 127 would be +ve and anything below 127 would be -ve. One more thing, The output of sine is from -1 to +1 so we need to scale it up by multiplying it with 127 So the Final Equation is:        ...