mehdi_RM
07-06-2006, 21:49
ba salam
omidvaram haleton khob bashe?
darmorede IC L293
va micro 2051
age matlabi farsi dari mamnon misham komak konid va
hamchenin gataarte zir
dar rabete ba perojeh robate masr ybam chan ta zahmat dashtam
ke age momkene komakam konid.
mikhastam age dar morede gataate zire matlabi darid ya siti ro baladid
farsi bashe va text
ke dar moredeshon tosh tozih dadeh behem moarefi konid?!!!!!!!!!
liste gataat::
1. IC L293
2. keristal 11,0592 mhz
3. IC AT98C2051
4. khazan
5. mogavemat
6. diode 1N4001
7. IC 7805
8. LM324
9. LED
10. anvae sensorhaye "IR"
11. tarze sakhte girbox bra motorhaye dc (armicher)
12. ya har matlabi dar morede robate masir yab
albate madare robato va kole robat az ro in site gerfte shode
va man mikham hamino besazam
shoma ba raftan be linke zire mitonid madaresho bebinid:
[ برای مشاهده لینک ، لطفا با نام کاربری خود وارد شوید یا ثبت نام کنید ]
bad age az dastoraye barname zire chizi mifahmid lotfan rahnamei konid ya
kare astoraei ke be kar rafte ro bram benevisid ke az 4 sensor estefade shode
be sorate lozi be faseleye 2 cm:
****************surece barname *********************
#include d:\mc51\8051io.h
#include d:\mc51\8051reg.h
extern register unsigned char speedleft,speedright;
register unsigned char high,low,flag,time;
main()
{
P1=0x40;
P3=0xff;
high = 80;
low = 30;
flag = 0;
time = 50;
Start();
while(1) {
P3|= 0x0f;
Run();
}
}
Start()
{
char exit,key;
exit =1;
while(exit)
{
key = P1;
if((key & 0x40)==0) exit=0;
}
}
Run()
{
char sensors;
sensors = (P3 &=0x0f);
if((sensors & 0x01)==0) {
TurnRight();
flag = 1; }
else if((sensors & 0x08)==0) {
TurnLeft();
flag = 2; }
else if(sensors == 0x09) {
Forward(high);
flag = 0; }
else if(((sensors==0x0b)||(sensors==0x0d))&&(flag==0))
Forward(low);
}
Forward(char speed)
{
P1=0x64;
speedright = speed+10;
speedleft = speed;
delay(time);
}
TurnRight()
{
P1=0x68;
speedright = low+5;
speedleft = low;
delay(time);
}
TurnLeft()
{
P1=0x54;
speedright = low+5;
speedleft = low;
delay(time);
}
Reverse(char speed)
{
P1=0x58;
speedright = speed;
speedleft = speed+5;
delay(time);
}
***************end program*************************
ya barnameye assembelish age ye tozih bedid kheli mamnon misham
*#cpu 8051 Tiny
*
* DDS MICRO-C 8031/51 Startup Code & Runtime library for TINY model
*
* Copyright 1991-1999 Dave Dunfield
* All rights reserved.
*
ORG $0000 $0800 CODE Starts here (Normally in ROM)
LJMP START
ORG $0003
LJMP SERVICE_EX0
ORG $000B
LJMP SERVICE_TIMER0_INTERRUPT
* Fixed memory locations for alternate access to the R0-R7 register bank.
* If you are NOT useing BANK 0, these equates must be adjusted.
?R0 EQU 0 Used for "POP" from stack
?R1 EQU ?R0+1 Used to load index indirectly
?R2 EQU ?R0+2 "" "" "" ""
?R3 EQU ?R0+3 Used by some runtime lib functions
?R4 EQU ?R0+4
?R5 EQU ?R0+5
?R6 EQU ?R0+6
?R7 EQU ?R0+7
*
* Startup code entry point
*
* If you are NOT using interrupts, you can reclaim 50 bytes
* of code space by removing the following TWO lines.
* AJMP *+$0032 Skip interrupt vectors
* DS $0032-2 Reserve space for interrupt vectors
*
START EQU *
MOV SP,#?stk-1 Set up initial stack
ORL TMOD,#%00000001 set timer 0 to be counter 16 bit
SETB IE.7 $AF EA
SETB IE.1 $A9 ET0 Enable timer 0 interrupt
SETB TCON.4 start timer 0
LCALL main Execute program
SJMP * JUMP HERE
* EXIT to MON51 by calling the 'timer1' interrupt vector ($001B).
* This causes MON51 to think that a single-step operation has just
* completed, and therefore it saves the user registers, and performs
* a context switch back to the monitor.
*
* When using 2K addressing (CC51: -Z option, ASM51: -A option) this LCALL
* may fail "Out of range" because it gets translated to ACALL, and $001B
* may not be in the same 2K block as your program. Since 2K devices cannot
* support a debugger, change the ORG to $0000, and ...<continue below>...
*
* If you are NOT using MON51 (or MONICA which works the same), you will
* need to change this to whatever action you desire when main() returns.
* Suggestions: 1:freeze (SJMP *) 2:Restart (SJMP *&$FF00)
exit LCALL $001B Call Timer-1 interrupt
SJMP exit Incase he go's again
**************************** My code *********************************
SERVICE_TIMER0_INTERRUPT EQU *
PUSH ACC
PUSH PSW
MOV TH0,#$FF reload timer 0 for ms
MOV TL0,#$00
INC tick
MOV A,tick
CJNE A,#100,RIGHT
MOV tick,#0
RIGHT
CLR C
SUBB A,speedright
JC ON_RIGHT
CLR P1.0
SJMP LEFT
ON_RIGHT
SETB P1.0
LEFT
MOV A,tick
CLR C
SUBB A,speedleft
JC ON_LEFT
CLR P1.1
SJMP EXIT_I
ON_LEFT
SETB P1.1
EXIT_I
POP PSW
POP ACC
RETI
SERVICE_EX0 EQU *
INC cputick
RETI
$SE:1
*#map1 Segment 1, initialized variables
$SE:2
*#map2 Segment 2, internal "register" variables
ORG $0008 Internal ram ALWAYS starts here
tick DS 1
speedright DS 1
kheli mamnon
mehdi
bedrod.
omidvaram haleton khob bashe?
darmorede IC L293
va micro 2051
age matlabi farsi dari mamnon misham komak konid va
hamchenin gataarte zir
dar rabete ba perojeh robate masr ybam chan ta zahmat dashtam
ke age momkene komakam konid.
mikhastam age dar morede gataate zire matlabi darid ya siti ro baladid
farsi bashe va text
ke dar moredeshon tosh tozih dadeh behem moarefi konid?!!!!!!!!!
liste gataat::
1. IC L293
2. keristal 11,0592 mhz
3. IC AT98C2051
4. khazan
5. mogavemat
6. diode 1N4001
7. IC 7805
8. LM324
9. LED
10. anvae sensorhaye "IR"
11. tarze sakhte girbox bra motorhaye dc (armicher)
12. ya har matlabi dar morede robate masir yab
albate madare robato va kole robat az ro in site gerfte shode
va man mikham hamino besazam
shoma ba raftan be linke zire mitonid madaresho bebinid:
[ برای مشاهده لینک ، لطفا با نام کاربری خود وارد شوید یا ثبت نام کنید ]
bad age az dastoraye barname zire chizi mifahmid lotfan rahnamei konid ya
kare astoraei ke be kar rafte ro bram benevisid ke az 4 sensor estefade shode
be sorate lozi be faseleye 2 cm:
****************surece barname *********************
#include d:\mc51\8051io.h
#include d:\mc51\8051reg.h
extern register unsigned char speedleft,speedright;
register unsigned char high,low,flag,time;
main()
{
P1=0x40;
P3=0xff;
high = 80;
low = 30;
flag = 0;
time = 50;
Start();
while(1) {
P3|= 0x0f;
Run();
}
}
Start()
{
char exit,key;
exit =1;
while(exit)
{
key = P1;
if((key & 0x40)==0) exit=0;
}
}
Run()
{
char sensors;
sensors = (P3 &=0x0f);
if((sensors & 0x01)==0) {
TurnRight();
flag = 1; }
else if((sensors & 0x08)==0) {
TurnLeft();
flag = 2; }
else if(sensors == 0x09) {
Forward(high);
flag = 0; }
else if(((sensors==0x0b)||(sensors==0x0d))&&(flag==0))
Forward(low);
}
Forward(char speed)
{
P1=0x64;
speedright = speed+10;
speedleft = speed;
delay(time);
}
TurnRight()
{
P1=0x68;
speedright = low+5;
speedleft = low;
delay(time);
}
TurnLeft()
{
P1=0x54;
speedright = low+5;
speedleft = low;
delay(time);
}
Reverse(char speed)
{
P1=0x58;
speedright = speed;
speedleft = speed+5;
delay(time);
}
***************end program*************************
ya barnameye assembelish age ye tozih bedid kheli mamnon misham
*#cpu 8051 Tiny
*
* DDS MICRO-C 8031/51 Startup Code & Runtime library for TINY model
*
* Copyright 1991-1999 Dave Dunfield
* All rights reserved.
*
ORG $0000 $0800 CODE Starts here (Normally in ROM)
LJMP START
ORG $0003
LJMP SERVICE_EX0
ORG $000B
LJMP SERVICE_TIMER0_INTERRUPT
* Fixed memory locations for alternate access to the R0-R7 register bank.
* If you are NOT useing BANK 0, these equates must be adjusted.
?R0 EQU 0 Used for "POP" from stack
?R1 EQU ?R0+1 Used to load index indirectly
?R2 EQU ?R0+2 "" "" "" ""
?R3 EQU ?R0+3 Used by some runtime lib functions
?R4 EQU ?R0+4
?R5 EQU ?R0+5
?R6 EQU ?R0+6
?R7 EQU ?R0+7
*
* Startup code entry point
*
* If you are NOT using interrupts, you can reclaim 50 bytes
* of code space by removing the following TWO lines.
* AJMP *+$0032 Skip interrupt vectors
* DS $0032-2 Reserve space for interrupt vectors
*
START EQU *
MOV SP,#?stk-1 Set up initial stack
ORL TMOD,#%00000001 set timer 0 to be counter 16 bit
SETB IE.7 $AF EA
SETB IE.1 $A9 ET0 Enable timer 0 interrupt
SETB TCON.4 start timer 0
LCALL main Execute program
SJMP * JUMP HERE
* EXIT to MON51 by calling the 'timer1' interrupt vector ($001B).
* This causes MON51 to think that a single-step operation has just
* completed, and therefore it saves the user registers, and performs
* a context switch back to the monitor.
*
* When using 2K addressing (CC51: -Z option, ASM51: -A option) this LCALL
* may fail "Out of range" because it gets translated to ACALL, and $001B
* may not be in the same 2K block as your program. Since 2K devices cannot
* support a debugger, change the ORG to $0000, and ...<continue below>...
*
* If you are NOT using MON51 (or MONICA which works the same), you will
* need to change this to whatever action you desire when main() returns.
* Suggestions: 1:freeze (SJMP *) 2:Restart (SJMP *&$FF00)
exit LCALL $001B Call Timer-1 interrupt
SJMP exit Incase he go's again
**************************** My code *********************************
SERVICE_TIMER0_INTERRUPT EQU *
PUSH ACC
PUSH PSW
MOV TH0,#$FF reload timer 0 for ms
MOV TL0,#$00
INC tick
MOV A,tick
CJNE A,#100,RIGHT
MOV tick,#0
RIGHT
CLR C
SUBB A,speedright
JC ON_RIGHT
CLR P1.0
SJMP LEFT
ON_RIGHT
SETB P1.0
LEFT
MOV A,tick
CLR C
SUBB A,speedleft
JC ON_LEFT
CLR P1.1
SJMP EXIT_I
ON_LEFT
SETB P1.1
EXIT_I
POP PSW
POP ACC
RETI
SERVICE_EX0 EQU *
INC cputick
RETI
$SE:1
*#map1 Segment 1, initialized variables
$SE:2
*#map2 Segment 2, internal "register" variables
ORG $0008 Internal ram ALWAYS starts here
tick DS 1
speedright DS 1
kheli mamnon
mehdi
bedrod.