Programming and Simulation of AVR with HC-05: PART II

The final build of my work with HC-05 involves using AVR ATmega32 microcontroller which is a powerful micro controller. The Controller is programmed in AVR GCC.

For HC-05 (or any other serial communication system), the USART needs to be set on the ATmega32 through programming.
Here is a snippet of code being used for UART in my build:

Setting up UART


The Primary task of responding to various commands is done by a switch statement which is way easier to modify and work on instead of  IF-ELSE statements.Since Each character has a unique ASCII Code, we have a lot of commands which can be given to the micro controller.For example ,there are 26 lower case + 26 upper case + 10 digits + about 32 symbols which equal about 94 unique commands.
Snippet of code for Switch:

Decision Task by Switch Statement

The character 'ch' is set to receive value from registers whenever the receive interrupt is triggered by the HC-05.The ISR (Interrupt Service Routine) is defined as follows:

Interrupt Service Routine

Simulation of code is done in Proteus 8.4 using all the peripherals included. Input here is given from a virtual terminal however HC-05 would have served the same objective.

Simulation in Proteus

A video accompanying the simulation conveys that the code works fine and can be implemented into the hardware.Here's the vid :


Used:
Proteus 8.4
Atmel Studio 7.0

A Simple Edge Detection Algorithm

In tasks of image processing, finding edges in an image occasionally serves as the basis for the evaluations.

However, imaging functions usually take up a lot of memory and computation power due to the complexity of  the equations which limit their usage on low memory devices like microcontrollers and single chip boards.

In such case a Linear equation can serve our purpose with a low computation complexity, efficient memory utilisation and faster execution time.

Loading image to find edges :

Self advertisement at its best ;)
Reading and displaying image to process


Edge finding algorithm with intuitive coefficient representation:

Edge Finder 

Edges obtained by the difference equation:

Processed image overlayed on original image

Here is the Edgefinder function, Lines 8-10 are what we are supposed to be looking at :


1:  function out=Edgefinder(I)  
2:    I1=rgb2gray(I);      % conversion to grayscale  
3:    I2=imbinarize(I1);   % conversion to binary image,using Otsu's method  
4:    [m,n]=size(I2);      % size of the image  
5:    out=zeros(size(I2)); % preallocating memory  
6:    for i=2:m-1  
7:      for j=2:n-1  
8:         out(i,j)=  (0.25*I2(i+1,j+1))-   I2(i+1,j) + (0.25*I2(i+1,j-1)) ...  
9:                        - I2(i,j+1)   + 3*I2(i,j)   -       I2(i,j-1) ...  
10:                  +(0.25*I2(i-1,j+1))-   I2(i-1,j) + (0.25*I2(i-1,j-1));  
11:      end  
12:    end  
13:  out=imoverlay(I,out,'red');  %  'I' was preserved for image overlay,not really necessary  
14:  imshow(out);  
15:  end 

Take a look at the coefficients of the difference equation:



Observe the oscillatory nature of the coefficients: A characteristics of a high pass filter.
Also you may observe that the sum of all coefficients is equal to Zero,
quite intuitive.

It is also evident that this algorithm can find edges at all inclinations so simplicity and efficiency are the key factors here.

Peace out.

Used:
MATLAB 2016a

Starting up with HC-05 Bluetooth Module : PART I

Recent aspiration of mine has been to develop on both AVR and Android a full fledged package for Bluetooth communication

For Prototyping I chose this: 


Setup on this:


With these: 


Looking Something Like this: 


Configured using this:


And Running This:


SO FAR SO GOOD :)