logo

Select Sidearea

Populate the sidearea with useful widgets. Itโ€™s simple to add images, categories, latest post, social media icon links, tag clouds, and more.
[email protected]
+1234567890
 

Tutorial Microcontroller MCS-51 ATMEL ISP

Tutorial Microcontroller MCS-51 ATMEL ISP

image

Microcontroller Kits
Programmer and Target 89s51
image

Simple Mikrokontroller 89s51 Trainer
image

Standart
Mikrokontroller 89s51 Trainer
image

Super Mikrokontroller Trainer 89s51
image

All Item Include

Programmer
Via USB

image

ย 

BACKNEXT

4.4. Send ADC data to PC serially – RS 232

This experiment is very good for the process of data acquisition for the process of measurement of long distance serially. You should learn more about Serial communication RS232.

ย 

Figure 4.1. Sending ADC data serially to PC

ย 

Step 1st
Build the circuit as shown in figure 4.1. As you seen on figure 4.1. Remember, that all we want to do with this lesson is send out ADC data to PC serially.

Step 2nd
In this step, you must tipe the assembly program to make your serial working, we assume that you have already known the editor, we used MIDE-51 to edit the program. ( Download File : exp41.zip ,Download Complete Circuit File : SerialADC.PDF )

       org 0h       call initserial;start: mov a,p2; ambil data dari adc       call Sendout       sjmp start;Sendout:detect: jnb ti,detect;         clr ti ;         mov sbuf,a ;         ret;initserial:       mov scon,#52h;initialize serial mode 1       mov tmod,#20h;timer1 mode 2       mov th1,#0F3h;Reload value for baud rate 2400       setb tr1       retend

To get the data from microcontroller serially, computer must run the program to get data from port communication RS232, in this experiment I have been used Delphi programming: ( Download Delphi File : adcserial.zip )

image
Figure 4.2. Delphi Programming Display Data ADC

unit serial1;interfaceusesWindows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,ExtCtrls, StdCtrls;
type         TForm1 = class(TForm)         Button1: TButton;         Timer1: TTimer;         Edit1: TEdit;         Label1: TLabel;         Label2: TLabel;         procedure Button1Click(Sender: TObject);         procedure Timer1Timer(Sender: TObject);         private         { Private declarations }         public         { Public declarations }         end;
var         Form1: TForm1;         data,status:byte;
const         base = $3f8;{base address port serial}         lcr = 3; {line control register}         dll = 0; {divisor lacht low byte}         dlh = 1; {divisor lacht high byte}         lsr = 5; {line status register}
implementation
{$R *.DFM}
Procedure Initserial;begin asm  mov dx,base+lcr; {address line control register}  mov al,$80 ; {10000000b = access bit divisor lacht}  out dx,al         ;  mov dx,base+dll; {address divisor lacht low byte}  mov al,$30 ; {DLLB = 30h}  out dx,al         ;  mov dx,base+dlh; {address divisor lacht high byte}  mov al,$00 ; {DLLH = 00h}  out dx,al         ; {Pada saat ini Port serial}         ; {memp.baud rate = 2400 bps}  mov dx,base+lcr;{address line control register}  mov al,$03 ; {00000011b =}  out dx,al ; {bit 7=0, access to Rx buffer & Tx         ; {bit 6=0, set break disable         ; {bit 5-4-3=000, no parity         ; {bit 2=0, one stop bit         ; {bit 1-0=11,data lenght 8 bit} end;end;
Procedure Receive_Data_Serial;begin asm  mov dx,base  in al,dx  mov data,al  endend;
procedure TForm1.Button1Click(Sender: TObject);begin initserial; timer1.enabled:=true;end;
procedure TForm1.Timer1Timer(Sender: TObject);begin Repeat  asm   mov dx,base+lsr ; { address line status register }   in al,dx   and al,$01      ; {LSR = 00000001b, detects bit 0}   mov status,al   ; {bit 0 = data ready}  end; until status = $01;{ jika bit 0 = 1 then data ready} Receive_Data_Serial; edit1.text:=inttostr(data);end;end.

Step 3rd
Safe your assembly program above, and name it with exp41.asm (for example) Compile the program that you have been save by using MIDE-51, see the software instruction.

Step 4th
Download your hex file ( exp41.hex ) into the microcontroller by using Microcontroller ATMEL ISP software, see the instruction.After download this hex file you’ll see the action of serial transmition( of course if your cable connection and your program are corrected ).

Comments, questions and discussion about this topic

BACKNEXT

ย 

ย 

ย 

ย imageimageimageimage