Discussion in "Project Addition or Changes" started by    karachiites    Apr 20, 2014.
Sun Apr 20 2014, 12:44 pm
#1
Hello
I m making this as a combat robot so attach a spinner weapon on it...i m having difficulties in making assembly code to control that weapon motor(clockwise/anti clock wise).. Like in that android app,when i press A,spinner run CW and when i press B spinner run CCW and it will keep spinning while steering robot....
I will highly appreciate ur help....
I have done with hardware and components...
Wed Apr 23 2014, 01:24 am
#2
/* use DPDT relay for direction control you may refer for relay connection//--------------http://www.me.umn.edu/courses/me2011/arduino/technotes/dcmotors/bidirectional/bidirMotor.html */
//This program should work with ur project //

////----------same "android controlled robot" assembly program with embedded c---------////

#include<reg52.h>
sbit MOT=P1^0;
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// -=-=-=-=- Init Serial Port -=-=-=-=-=-=-=
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void serial_init()
{
/*--------------------------------------
Set serial port for 9600 baud at
11.0592 MHz. Note that we use Timer 1
for the baud rate generator.
--------------------------------------*/
SCON = 0x50;
TMOD |= 0x20;
TH1 = 0xFA;
TR1 = 1;
TI = 1;
PCON |= 0x80;
}
void Serial(void)
{
unsigned char mybyte;
TR1 = 1;
while(RI==1)
{
mybyte=SBUF;
if(mybyte=='U')
{ P2=0x89;RI=0;}
else if(mybyte=='D')
{ P2=0x86;RI=0;}
else if(mybyte=='R')
{ P2=0x8a;RI=0;}
else if(mybyte=='L')
{ P2=0x85;RI=0;}
else if(mybyte=='C')
{ P2=0x00;RI=0;}
else if(mybyte=='a')
{ MOT=1;RI=0;}
else if(mybyte=='c') // if u r using blucontrol software then it has B button with ==>'c' caracter and C button with 'b' as ASCII
{MOT=0;RI=0;}
else
RI=0;
}
}

void main()
{
while(1)
{
serial init();
Serial();
}
}
Wed Apr 23 2014, 11:38 am
#3
You dont have to call serial_init() everytime. Just call it once.

void main()
{
serial init();
    while(1)
    {
        Serial();
    }
}
Wed Apr 23 2014, 01:05 pm
#4
you are right............ ;P

my mistake........1 tym is sufficent
Wed Apr 23 2014, 09:16 pm
#5
awesome.. coding working perfectly on proteus.....hope it will work when i burn it tomorrow..
thank you Androswap and ajay_bhargav for ur help

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

AntoniaRoons
Fri Apr 19 2024, 09:59 pm
carpinteyrowrl
Fri Apr 19 2024, 02:51 pm
DonaldJAX
Fri Apr 19 2024, 01:08 pm
Lewisuhakeply
Thu Apr 18 2024, 06:00 pm
Darrellciz
Thu Apr 18 2024, 11:07 am
Charlessber
Thu Apr 18 2024, 09:29 am
BartonSem
Thu Apr 18 2024, 04:56 am
DonaldKnown
Thu Apr 18 2024, 12:24 am