engineergc
New Member
Dear All;
I am making red round object tracking project by using MSP430G2553 and Matlab. When red round object moves, a car will track red round object. Project is consist of from two parts as image processing and motion part. In motion part I am using L298N motor driver card, MSP430G2553. and a car that consist of from 2 wheels with 2 dc motors and a swivel castor. Image processing part in matlab is working as smooth.
But when a red ball moves, car can not track red object. When I compiled code in Code Composer Studio, it doesn't give any error. Therefore I can not find
problem in code. I added MSP430G2553 code and parts of image processing code that provide commnication between MSP430 and MATLAB. I think remander part of matlab code is working correctly.
CODE COMPOSER STUDIO PART
MATLAB PART
I hope you will be able to provide information.
I am making red round object tracking project by using MSP430G2553 and Matlab. When red round object moves, a car will track red round object. Project is consist of from two parts as image processing and motion part. In motion part I am using L298N motor driver card, MSP430G2553. and a car that consist of from 2 wheels with 2 dc motors and a swivel castor. Image processing part in matlab is working as smooth.
But when a red ball moves, car can not track red object. When I compiled code in Code Composer Studio, it doesn't give any error. Therefore I can not find
problem in code. I added MSP430G2553 code and parts of image processing code that provide commnication between MSP430 and MATLAB. I think remander part of matlab code is working correctly.
CODE COMPOSER STUDIO PART
C:
#include <msp430.h>
//P1.3 ENA
//P1.4 IN1
//P1.5 IN2
//P1.6 ENB
//P2.0 IN3
//P2.1 IN4
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
DCOCTL = 0; //
BCSCTL1 = CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ;
P1SEL = BIT1; // P1.1 = RXD
P1SEL2 = BIT1; // P1.1 = RXD
UCA0CTL1 |=UCSWRST;
UCA0CTL1 |= UCSSEL_2;
UCA0BR0 = 104; // 1MHz 9600 baudrate
UCA0BR1 = 0; // 1MHz 9600 baud rate
UCA0MCTL = UCBRS0; // UART Baud adjustment
UCA0CTL1 &= ~UCSWRST;
IE2 |= UCA0RXIE; // USCI_A0 RX interrupt enable
__bis_SR_register(LPM0_bits + GIE); // General interrrupts and LPM0 mode are active
}
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
unsigned char received;
received = UCA0RXBUF;
if(received=='C') { //C=CENTER
P1OUT &= ~(BIT3 + BIT6);
}
else if(received=='R') { //R=RIGHT
P1OUT |=(BIT3 + BIT4);
P1OUT &= ~BIT5;
}
else if(received=='L') { //L=LEFT
P1OUT |=BIT6;
P2OUT |=BIT0;
P2OUT &= ~BIT1;
}
else if(received=='F') { //F=FORWARD
P1OUT |=(BIT3 + BIT6);
P1OUT |=BIT4;
P1OUT &= ~BIT5;
P2OUT |=BIT0;
P2OUT &= ~BIT1;
}
else if(received=='B') { //B=BACK
P1OUT |=(BIT3 + BIT6);
P1OUT |=BIT5;
P1OUT &= ~BIT4;
P2OUT |= BIT1;
P2OUT &= ~BIT0;
}
else if(received=='N') { //N=NO MOTION
P1OUT &= ~(BIT3 + BIT6);
}
}
Code:
priorPorts = instrfind % finds any existing Serial Ports in MATLAB
delete(priorPorts) % and deletes them
s = serial('COM3');
set(s,'BaudRate',4800);
fopen(s);
IMAGE PROCESSING CODES
case 1
fwrite(s,'C');
case 2
fwrite(s,'L');
case 3
fwrite(s,'R');
case 4
fwrite(s,'B');
case 5
fwrite(s,'F');
otherwise
fwrite(s,'N');
end
Last edited by a moderator: