Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
part1:Read Analog input (0 to +5V)
and display its value (0 to 1023)
*Read the input voltage 2 (0; +5V )
incoming to pin AN0 (RA0) and display
the voltage as an integer between 0 and
1023 on two LED-bargraphs connected to
ports C (least signiffcant) and D
(most signiffcant).
-------
ISIS:
RA0:potentionmeter to above VCC
and below to gnd.
RC0 to RC7: respack(220)to ledbargraph
(pin9&10 out)and to other hand
from (pin 20 to 13 to gnd//pin11 and
12 out ).
RD0 to RD7:respack(220)to ledbargraph
(pin9&10 out)and to other hand
from (pin 20 to 13 to gnd//pin11 and
12 out ).
-----
code :
#include "ee445.h"
void main(void)
{
OSCCON=0x73;
ADCON1 = 0xE;
TRISC=0;
TRISD=0;
TRISA0=1;
ADCON0 = 0x1;
ADCON2 = 0xAE;
while(1) {
__delay_ms(1);
GO = 1;
while(GO == 1);
PORTC=ADRESL;
PORTD=ADRESH;
__delay_ms(50);
}
}
#############
part2: Temperature measurement
using LM35
ISIS:
RA0: to potentionmeter
above to VCC and below to gnd
pin25:to V.termintor(Rxd)
pin26:to V.terminator(Txd)
RD0 to RD7:to Led=Bargraph
(pin 9&10 out)to Respack330(pin9 to gnd)
--------
code:
#include "ee445.h"
void main(void)
{
unsigned int vin0, vin01;
OSCCON=0x73;
serial_init(51,1);
ADON=1; CHS0=0; CHS1=0;
CHS2=0; CHS3=0;
PCFG0=0; PCFG1=1; PCFG2=1;
PCFG3=1; VCFG1=0; VCFG0=0;
ADFM=1; ACQT2=1; ACQT1=1;
ACQT0=1; ADCS2=1;
ADCS1=1; ADCS0=0;
TRISD=0;
for(;;)
while(GO==1);
vin0=(ADRESH<<8)+ADRESL;
vin01=ADRES;
printf("Input: decimal =%d, %d analog voltage = %f Temp.=%frn",
vin0, vin01, vin0*5.0/1023.0, (vin0*5.0/1023.0)/(10e-3));
PORTD= (unsigned char) ((vin0*5.0/1023.0)/(10e-3));
}
}
###########
part3: digital to analog
converter
----
ISIS:
RA0: with signal generator(sin)
and (squ)to gnd.
RD0 to RD7: to resistor network1 then
to resistor network2 (these pins :
16 with 2
15 with 3
14 with 4
13 with 5
12 with 6
11 with 7
10 with 8
9 out )))
and in RN2(pin1 to 2K to gnd)
and in RN2(pin8 to Osclliscope A)
-----
code:
#include "ee445.h"
void main(void)
{
unsigned int vin0;
unsigned char vout;
OSCCON=0x73;
serial_init(51,1);
ADON=1; CHS0=0; CHS1=0; CHS2=0; CHS3=0;
PCFG0=0; PCFG1=1; PCFG2=1; PCFG3=1; VCFG1=0; VCFG0=0;
ADFM=1; ACQT2=1; ACQT1=1; ACQT0=1; ADCS2=1; ADCS1=1; ADCS0=0;
DDRD=0;
for(;;)
{
GO=1;
while(GO==1);
vin0=(ADRESH<<8)+ADRESL;
vout=vin0>>2;
PORTD= vout;
}
}
#############
part4:Function generator
------
ISIS:
RA0: 10K to VCC then switch to gnd
RA1:10K to VCC then switch to gnd
RA2:10K to VCC then switch to gnd
RC0:led to res=220 to gnd
RD0 to RD7: to resistor network1 then
to resistor network2 (these pins :
16 with 2
15 with 3
14 with 4
13 with 5
12 with 6
11 with 7
10 with 8
9 out )))
and in RN2(pin1 to 2K to gnd)
and in RN2(pin8 to Osclliscope A)
-------
code:
#include "ee445.h"
#include <math.h>
#define pi 3.14159265359
#define Ns 80
#define fs 400
#define f 50
unsigned char SQ[Ns];
unsigned char TR[Ns];
unsigned char SI[Ns];
unsigned char count=0, signal_type;
void interrupt timer_isr(void)
{
unsigned char tmp;
if(signal_type == 0) tmp = 0;
if(signal_type == 1) tmp = SQ[count];
if(signal_type == 2) tmp = TR[count];
if(signal_type == 3) tmp = SI[count];
PORTD = tmp;
count = count + 1;
if(count == Ns) count = 0;
TMR2IF = 0;
RC0=RC0^1;
}
void Timer2_Init(void)
{
T2CON = 0x4C;
PR2 = 49;
TMR2IE = 1;
PEIE = 1;
}
void Lookup_Init(void)
{
unsigned char i;
float tx;
for(i=0;i<Ns;i++)
{
if(i<Ns/2)
{
SQ[i]=0xFF;
TR[i]=(unsigned char) (i*480/Ns);
}
else if(i>=Ns/2)
{
SQ[i]=0x00;
TR[i]=(unsigned char) ((Ns-i)*480/Ns);
}
tx = (1.0+sin(2.0*pi*f*i/fs))*127.0;
SI[i] = (unsigned char) tx;
}
}
void wait(void)
{
unsigned char x;
for (x=0; x<20; x++) {__delay_ms(50);}
}
void main (void)
{
unsigned char temp, i;
OSCCON=0x73;
ADCON1 = 0x0F;
TRISA = 0xFF;
TRISD = 0x00;
TRISC0=0;
RC0=1;
count = 0;
signal_type = 0;
Lookup_Init();
Timer2_Init();
GIE = 1;
while(1)
{
wait();
temp = PORTA;
if((temp == 0x01) || (temp == 0x02) || (temp == 0x04))
{
if((temp & 0x01) == 0x01)
signal_type = 1;
if((temp & 0x02) == 0x02)
signal_type = 2;
if((temp & 0x04) == 0x04)
signal_type = 3;
}
else signal_type = 0;
}
}
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team