Showing posts with label Proteus ISIS. Show all posts
Showing posts with label Proteus ISIS. Show all posts

Thursday, April 30, 2015

Arduino Serial communication and Proteus ISIS simulation

 

The serial communication on most devices is a transmission of data between the microcontroller to a computer or even to another microcontroller.

The Arduino serial port (also known as a UART or USART) that stands for Universal Synchronous/Asynchronous Receiver/Transmitter and provides the interface necessary for communication with modems and other serial devices.

For this type of communication you’ll need three cables (TX, RX, GND) and they stand for:

TX: Transmit pin

RX: Receive pin

Take into account that it is different with I2C and SPI where the labels and the pins are connected with each other, in serial communication the pins should be inverted and connected that way.

Devices

In the following picture you can see the schematic of the exercise.

Schematics

The components used in this exercise were:

1 x LM35 Temperature sensor

1 x Arduino board

1 x Terminal debugger

I uploaded the code on the “Source Code” window, here you can see the window:

Code

The code I uploaded was this:

/*
/////////////////////////////////////////////////////////////////////////////////////
AUTOR: JUAN BIONDI FECHA: FEBRERO/2014
PROGRAMA: TERMOMETRO (LM35) VERSION: 1.0
DISPOSITIVO: ATMEL 328 COMPILADOR: AVR
ENTORNO: PROTEUS SIMULADOR: VSM
TARJETA DE PROGRAMACION: DEBUGGER:
/////////////////////////////////////////////////////////////////////////////////////
The LM35 is a temperature sensor with a calibrated precision of 1ºC. It can measure from -55 C to 150 C.

The output is that one grade is equal to 10mV
150ºC = 1500mV
-55ºC = -550mV1
0ºC = 0mV

/////////////////////////////////////////////////////////////////////////////////////
*/


/////////////////////////////////////////////////////////////////////////////////////
// LIBRERIAS //
/////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////
// VARIABLES GLOBALES //
/////////////////////////////////////////////////////////////////////////////////////

//Declare the variables
#define pinA0 0
int valor_leido;
float Temperatura;
float Temp2;

/////////////////////////////////////////////////////////////////////////////////////
// FUNCIONES //
/////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////
// CONFIGURACION //
/////////////////////////////////////////////////////////////////////////////////////

void setup()
{
analogReference(INTERNAL); // Used for setting the analog reference to 1.1V
Serial.begin(9600); //Start the serial communication
}


/////////////////////////////////////////////////////////////////////////////////////
// PRINCIPAL //
// //
/////////////////////////////////////////////////////////////////////////////////////

void loop()
{
valor_leido = analogRead(pinA0); //Read the value of the analog pin

Temperatura = (valor_leido*1.1*100) / 1024; //Convert that value to temperature

Serial.print("Temperatura: "); //Print the information to the terminal window
Serial.print(Temperatura);
Serial.print("C ");

Temp2 = map(valor_leido,0,1023,0,11000); //This is another conversion using the map function

Serial.print("Temperatura por map: ");
Serial.print(Temp2/100);
Serial.print(" Lectura digital: ");
Serial.println(valor_leido);

delay(1000); //Set a delay so we can see each second the temperature we are measuring

}

I n the next picture you can see the information on the terminal debugger once we click on the play button.


Code_running


You can download the file on the following link:


https://drive.google.com/folderview?id=0B7dtMeeMPK5rfnJCSVlRVTkxRzdSeHBMWDJ6THVPWmdHdm1kZ3NwNTYzSEJ5b0ZmdlFoMG8&usp=sharing


File name: Termometro.zip


Version of Proteus 8.1

Arduino SPI and Proteus ISIS simulation

 

The SPI stands for Serial Peripheral Interface which is a serial communication and it is used for short distance communications. It common uses are in sensor, LCDs and Secure digital cards.

It uses four (4) cables where 3 of them are the same for  each device (MOSI, MISO, SCK) and the fourth one is for selecting the device you want to talk to. There is a fifth cable that it is important in every communication and that is GND.

Probably you are wondering what do MOSI, MISO and SCK mean, right? Well those are the name for the pins on SPI communication and their names came from:

MOSI: Master Out Slave In

MISO: Master In Slave Out

SCLK: Signal Clock

SS: Slave Select

Let´s say you want to have two (2) devices on the SPI communication, so you’ll need six cables, three are common for the two devices and two separated SS for each device and finally GND.

 

Devices

 

These are the components I used to do the schematics:

1 x Arduino board

1 x AD5206 SPI Potentiometer

1 x SPI debugger

This is how it looks the schematic and how should everything be connected:

 

Schematics

 

After everything was connected I wrote a code to change each potentiometer on the AD5206 to output a different value given by the microcontroller. Here you see that I wrote the code on the “Source code” window.

 

code

The code I used was this:

/*
////////////////////////////////////////////////////////////////////////////////////////////////////
AUTOR: JUAN BIONDI FECHA: FEBRERO/2014
PROGRAMA: Potentiometer SPI VERSION: 1.0
DISPOSITIVO: ATMEL 328 COMPILADOR: AVR
ENTORNO: PROTEUS SIMULADOR: VSM
TARJETA DE PROGRAMACION: DEBUGGER:
////////////////////////////////////////////////////////////////////////////////////////////////////

Control an Analog Devices AD5206 digital potentiometer.
The AD5206 has 6 potentiometer channels. Each channel's pins are labeled
A - connect this to voltage
W - this is the pot's wiper, which changes when you set it
B - connect this to ground.

The AD5206 is SPI-compatible,and to command it, you send two bytes,
one with the channel number (0 - 5) and one with the resistance value for the
channel (0 - 255).

The circuit:
* All A pins of AD5206 connected to +5V
* All B pins of AD5206 connected to ground
* An LED and a 220-ohm resisor in series connected from each W pin to ground
* CS - to digital pin 10 (SS pin)
* SDI - to digital pin 11 (MOSI pin)
* CLK - to digital pin 13 (SCK pin)



////////////////////////////////////////////////////////////////////////////////////////////////////
*/


////////////////////////////////////////////////////////////////////////////////////////////////////
// LIBRERIAS //
////////////////////////////////////////////////////////////////////////////////////////////////////

#include <SPI.h>

////////////////////////////////////////////////////////////////////////////////////////////////////
// VARIABLES GLOBALES //
////////////////////////////////////////////////////////////////////////////////////////////////////

// set pin 10 as the slave select for the digital pot:
const int slaveSelectPin = 10;

////////////////////////////////////////////////////////////////////////////////////////////////////
// FUNCIONES //
////////////////////////////////////////////////////////////////////////////////////////////////////

void digitalPotWrite(int address, int value)
{
// take the SS pin low to select the chip:
digitalWrite(slaveSelectPin,LOW);


// send in the address and value via SPI:
SPI.transfer(address);
SPI.transfer(value);
digitalWrite(slaveSelectPin,HIGH); // take the SS pin high to de-select the chip:
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// CONFIGURACION //
////////////////////////////////////////////////////////////////////////////////////////////////////

void setup()
{
pinMode (slaveSelectPin, OUTPUT); // set the slaveSelectPin as an output:
SPI.begin(); // initialize SPI:

for (int canal = 0; canal < 6; canal++) // Initialize all potentiometers to 0
{
digitalPotWrite(canal, 0);
delay(10);
}

}


////////////////////////////////////////////////////////////////////////////////////////////////////
// PRINCIPAL //
// //
////////////////////////////////////////////////////////////////////////////////////////////////////
void loop()
{
int valor = random(0,255); // Select a random number from 0 to 255
int canal = random (0,5); // Select a random number from 0 to 5
digitalPotWrite(canal,valor); // Send the data to the potentiometer
delay(1500); //Delay to see the changes

}

As you can see in the code every section is described and it is pretty simple to make changes


Once the code and the schematic are done, you can click on the play button and it should appear the SPI debugger like in the next picture:


 


Code_running


 


You can download the file on the following link:


https://drive.google.com/folderview?id=0B7dtMeeMPK5rfnJCSVlRVTkxRzdSeHBMWDJ6THVPWmdHdm1kZ3NwNTYzSEJ5b0ZmdlFoMG8&usp=sharing


File name: SPI.zip


Version of Proteus 8.1

Arduino I2C and Proteus ISIS simulation

 

Hi! today I want to talk about I2C protocol. This protocol was invented by Philips Semiconductor and it is a  multi-slave, multi-master, single-ended, serial computer bus.

This protocol is simple when you know what it does and how it does it. The best way to compare the I2C is with pipes (3 specifically) one is SDA that stands for Serial Data Line and SCL that means Serial Clock Line and last but not least Ground.


The reason why I say 3 is because we always have to have a reference when working on electronic to know what logic zero or a logic one is. Some people talk about only SDA and SCL but you must connect all GND together in order to communicate with the peripherals.

The following pictures how the devices should be connected.

            Connection

 

Each line (SDA and SCL) should be connected to "pull-up" resistors. This is necessary because all devices SDA and SCL connections are "open drain" lines: they can force the voltage on the line to 0V, or "low", but can’t raise it to 5V, or "high". High and low are the electrical representations of the 1s and 0s that are the fundamental components of digital information. Adding these two resistors – and the bus needs only two, no matter how many devices are connected to it – ensures the voltage rises back to 5V without a short circuit.

As you can see in next picture, the master begins the communication by sending the start condition (S). The master continues by sending a unique 7-bit slave device address, with the most significant bit (MSB) first. The eighth bit after the start, read/not-write (), specifies whether the slave is now to receive (0) or to transmit (1). This is followed by an ACK bit issued by the receiver, acknowledging receipt of the previous byte. Then the transmitter (slave or master, as indicated by the bit) transmits a byte of data starting with the MSB. At the end of the byte, the receiver (whether master or slave) issues a new ACK bit. This 9-bit pattern is repeated if more bytes need to be transmitted.


            Bits

 

In a write transaction (slave receiving), when the master is done transmitting all of the data bytes it wants to send, it monitors the last ACK and then issues the stop condition (P). In a read transaction (slave transmitting), the master does not acknowledge the final byte it receives. This tells the slave that its transmission is done. The master then issues the stop condition.

That is some information to have into account when working with I2C but the reality is that Arduino libraries handles everything for us and it makes it easier to talk to other devices via I2C protocol.

the next big thing is the schematic that we need to setup in order to make this happen, we´ll do it in Proteus ISIS and it should look like this:

Schematics

 

As you can see I have in the schematics the following components:

1 x Arduino board

1 x DS1307 Real Time Clock

1 x 16x2 Character LCD display

1 x DS1621 Temperature sensor

2 x 4k7 Resistor

1 x Terminal debugger

1 x I2C debugger

 

After I have connected all the components, I have to tell Proteus how to simulate the code I want the Arduino to run and I did it in the option that says “source code”. You can see the window on the following picture:

 

code

 

This is the code I used:

 

/*
////////////////////////////////////////////////////////////////////////////////////////////////////
AUTOR: JUAN BIONDI FECHA: FEBRERO/2014
PROGRAMA: TERMOMETRO I2C DS1621 VERSION: 1.0
DISPOSITIVO: ATMEL 328P COMPILADOR: AVR
ENTORNO: PROTEUS SIMULADOR: VSM
TARJETA DE PROGRAMACION: DEBUGGER:
////////////////////////////////////////////////////////////////////////////////////////////////////

The DS1621 is an Analog to digital converter for temperature
////////////////////////////////////////////////////////////////////////////////////////////////////
*/


////////////////////////////////////////////////////////////////////////////////////////////////////
// LIBRERIAS //
////////////////////////////////////////////////////////////////////////////////////////////////////
// Let´s include the libraries needed for the skecth
#include <Wire.h>
#include "RTClib.h"
#include <LiquidCrystal.h>

////////////////////////////////////////////////////////////////////////////////////////////////////
// VARIABLES GLOBALES //
////////////////////////////////////////////////////////////////////////////////////////////////////
//Let´s declare the variables needed for the sketch


//int tempC = 0;
//int tempF = 0;
//int direccion = 0x48;

RTC_DS1307 rtc;
LiquidCrystal lcd(12,11,5,4,3,2);

////////////////////////////////////////////////////////////////////////////////////////////////////
// FUNCIONES //
////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////
// CONFIGURACION //
////////////////////////////////////////////////////////////////////////////////////////////////////

void setup()
{
/*
Serial.begin (9600);
//Initiate the Serial communication

Wire.begin(); // Enable the communication
//Let´s cpnfigure the sensor
Wire.beginTransmission(direccion); //Start the device
Wire.write(0xAC); //Write configuration command
Wire.write(0x02); //Continue conversion
Wire.endTransmission(); //Stop the device
Wire.beginTransmission(direccion); 		//Restart the device
Wire.write(0xEE); //Start temperature conversion command
Wire.endTransmission();				//Stop the device
*/

lcd.begin(16,2);
Serial.begin (9600);
Wire.begin();
rtc.begin();

if (! rtc.isrunning())
{
Serial.println("RTC is NOT running");
rtc.adjust(DateTime(__DATE__,__TIME__));
}

}


////////////////////////////////////////////////////////////////////////////////////////////
// PRINCIPAL //
// //
////////////////////////////////////////////////////////////////////////////////////////////
void loop()
{

/*

//Delay to separate the communication and the measuring
delay(100);
Wire.beginTransmission(0x48); //Start the device
Wire.write (0xAA); //Read temperature command
Wire.endTransmission(); //Stop the device
Wire.requestFrom(0x48,1); // We ask for a byte
tempC = Wire.read(); //We save the temperature in centigrades
tempF = tempC * 9 / 5 + 32; //Make the conversion to Faranheit

//Let’s write the data to the terminal windows
Serial.print("Temperatura: ");
Serial.print(tempC);
Serial.print(" C/ ");
Serial.print(tempF);
Serial.println(" F");
*/

lcd.clear();
DateTime now = rtc.now();
lcd.setCursor (0,0);

lcd.print(now.year(), DEC);
lcd.print('/');
lcd.print(now.month(), DEC);
lcd.print('/');
lcd.print(now.day(), DEC);
lcd.print('/');
lcd.setCursor (0,1);
lcd.print(now.hour(), DEC);
lcd.print(':');
lcd.print(now.minute(), DEC);
lcd.print(':');
lcd.print(now.second(), DEC);
lcd.println();

///////////////////////////////////////////////////////////////////////////////////////

Serial.print(now.year(), DEC);
Serial.print("/");
Serial.print(now.month(), DEC);
Serial.print("/");
Serial.print(now.day(), DEC);
Serial.print("/");
Serial.print(now.hour(), DEC);
Serial.print("/");
Serial.print(now.minute(), DEC);
Serial.print("/");
Serial.print(now.second(), DEC);
Serial.print("/");
Serial.println();

Serial.print(" since midnight 1/1/1970 = ");
Serial.print(now.unixtime());
Serial.print("s = ");
Serial.print(now.unixtime() / 86400L);
Serial.print("d");

}

 


Once you have the schematic and the code, you can click on the play button to test the code running with the Terminal debugger and the I2C debugger, it should look like this:


Virtual_terminal-I2C_debugger


With these two debuggers you can check the data that it is being sent or received in the two protocols. This is why I spend some time writing about I2C protocol.


If you click on the “Schematic Capture” window you can the the display working and you can also change the simulated temperature.


 


Code_running


 


You can download the files in this link:


https://drive.google.com/folderview?id=0B7dtMeeMPK5rfnJCSVlRVTkxRzdSeHBMWDJ6THVPWmdHdm1kZ3NwNTYzSEJ5b0ZmdlFoMG8&usp=sharing


File name: Temperature_I2C.zip


Version of Proteus 8.1

Saturday, April 18, 2015

Simulating Arduino on Proteus ISIS


Just to give you a heads up I want to say that I will be posting about simulating Arduino Platform on Proteus ISIS which it does it really well.
It will be great for those of you that don´t have the last version of Proteus in the next video you can see how to install it. (the video is no mine)



And here you can download the library and files you need to do this.


BuzzNet Tags: ,

Tuesday, February 17, 2015

Adding libraries to Proteus 8 Professional

 

Sometimes when you are working in a group or in a company you have share the designs and some components you have made on your Proteus but the problem comes when the person you are sending the file to doesn't´t have the component on the computer.

For that reason today I´ll be showing you how to add components and libraries to Proteus.

It is a simple thing to do as you can see in the next video.

 

 

Steps to follow:

1.- Locate the files you want to copy (Libraries).

2.- Copy them the way you want (I find it easier with Ctrl + C).

3.- Look on your computer for:

C:\ProgramData\LabcenterElectronics\Proteus 8 Professional\LIBRARY

4.- Copy the files to that folder.

5.- Check if all the components and library are in Proteus. (to check that out you have to open Proteus and go to Library on the menu bar, then Library Manager where a window will show up and you can look for the libraries you just added).

 

Thursday, October 9, 2014

Components, terminals and their labels

When working with large circuits, using direct connections between different components of the circuit usually results in many wire cluttering. This may result in connection errors and makes it difficult to understand, debug or modify the design. The solution to this problem is to use terminals for connection. The video below shows how to wire up a design using labels. We can name the labels in any way we liked but sensible names make the schematic more legible and easy to understand. Essentially what we are doing by labeling a terminal is making a connection to another terminal with the same name, without placing a physical wire between the two objects.

The Power and Ground terminals are a special type of terminals. Although there is no reason not to label them; an unlabeled power terminal is assigned to the VCC or VDD net and an unnamed ground terminal will be assigned to net GND.

You can insert a terminal into the drawing area by choosing Terminal Mode then selecting DEFAULT from the Terminals list box as shown in the video below. You change the orientation of the terminal using the rotate and mirror buttons from the left bar menu.

To change the terminal name, double click on the terminal point and enter an appropriate name in the "Edit Terminal Label Window" as shown in the video.

Component Labels

You should see that all the components you have placed have both a unique reference and a value. The reference is set by a feature of ISIS called "Real Time Annotation" which can be found on the “Tools menu” and is enabled by default. Basically, when it is enabled, this feature annotates components as you place them on the schematic, saving you the time and effort of doing this manually.

You have full control over the position and visibility of component labels - you can change the values, move the position or hide information that you feel is unnecessary. The video below shows you how you can change the label orientation, name and even the size of it.

Also you’ll see how to create a component which is helpful when you don’t find the component you are looking for on the library.

 

BuzzNet Tags:

Monday, October 6, 2014

Cleaning component screen

When you are designing a schematic, sometimes we select components that we don't use, we just use them to see how they are or even take them as example that’s why we need to clean that (as I call it) component screen.

So this is a quick video on how to clean the screen component.

 

In case you didn’t see where I clicked, here are the steps to follow.

On the Menu bar > Edit > Tidy Design.

 

Stay tuned!

BuzzNet Tags:

Sunday, October 5, 2014

Showing hidden text and hiding text again

While I was designing the schematics on Proteus ISIS I found very annoying the grey hidden text on all over my screen so I decided to share how to hide this text and also put it again just in case you need to show it. It is a quick video and I hope it is helpful for you.

Stay tuned!

BuzzNet Tags:

Saturday, October 4, 2014

Create New project and Adding components Proteus ISIS

Here I´m posting a quick video and I think it is self explanatory how to create a new project and add components to Proteus ISIS and how to wire them up.
Super simple just follow the steps and you´ll be fine. Stay tuned!


BuzzNet Tags:

Friday, October 3, 2014

Getting to know the screen

Hi, today I wanted to share some basic knowledge of the Proteus ISIS windows in other to know where to go to select a tool o even changing a background o simple things and in the future it will be helpful to know how to get there to make those changes.

This is the main screen.

10

I know you´ve seen it before but probably there is someone reading only this post, the picture below shows the menu bar of Proteus ISIS

Menu 

10

As the name suggests, it holds the menu of commands. As in a restaurant menu, the commands are grouped into categories. Clicking on File will let the individual commands available under this category appear in a dropdown menu (a vertical menu literally falls from top to bottom) and this happens for all of them.

The picture below explain each icon on the top tool bar and the left tool bar.

Upperbar_xplain

MenuXplain

Here you have both toolbars explain and I think all that have something written on it those are the most used tools.

Select_ares_or_isis

In this section of the screen you can select between Schematic Capture (ISIS) and PCB Layout (ARES).

In the picture below you´ll see where to click to browse for a component and add it to you schematic. You just click on that letter “P” that stands for components and search for your component name.

Select_component

I hope it is helpful for someone out there. Stay tuned!

BuzzNet Tags:

Thursday, October 2, 2014

Introduction to PROTEUS

Proteus is a Design Suite also know as  Virtual System Modeling (VSM) offering the ability to simulate micro-controller code and also circuits.

So if you are willing to design hardware and software this is a great tool to star with. In this case Proteus ISIS is for simulation from the schematic form of the hardware and also the micro-controller code. It is possible to develop and test designs before a physical prototype is constructed.

I think that says it all about what Proteus is and it is for (can be use for more things).

Proteus ISIS combines ease of use with powerful editing tools as a very high degree of control over the drawing appearance, in terms of line widths, fill styles, fonts, etc.. It is capable of supporting schematic capture for simulation.

10

As for Proteus ARES is for PCB designs to make your own devices using the PCB layout tools and provides a powerful, integrated and easy to use suite of tools for professional PCB Design.

You can design your packages and footprints for your projects and so much more.

11

When you are designing you have to take into account so many things that you´ll have to use more than just one software but, why not to use this one that handles most of the thing we are going to need the other software for? That´s why i´m sharing with you want I´ll be learning using, this as I like to call, tool.

Let´s get started.

This is the first windows you´ll see every day you open Proteus, this is the home screen.

1
To create a new project we just simply click on "New project"

2

or we can go to File > New project

12

It will ask what do you want the project and the path (File destination on your computer) we want it to be stored

3

If it is needed you add templates to your projects or just pick one of the defaults on the screen, this selection will be the size of the document (in this case te schematics) in case we want to print it out.

4

5

Now we want also select one of the default but remember that this time we´ll be selecting the Layout template.

6

7

After selecting the template or creating a new one, we have to click on either use a firmware already on the Proteus Library or other that we will have to tell the software where it is located.

8

Then we can click on Finish button to star working on our project.

9

This pictures below show how is the environment on Proteus and it gives you plenty of space to work in.

10    11

Left picture is Proteus ISIS and the right one is Proteus ARES.

I hope you like this little introduction to Proteus, I´ll be posting more about this tool soon so, once again, it is not a radio but, stay tuned.

Monday, September 29, 2014

Proteus ISIS

I´ll be posting some Labcenter Proteus ISIS knowledge I´ve been learning on my studies.

BuzzNet Tags: