Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need a MSP430G2553 assembly language program in IAR Embedded Workbench for a lin

ID: 3809060 • Letter: N

Question

Need a MSP430G2553 assembly language program in IAR Embedded Workbench for a line follower robot car that has two motors (one for each wheel) and three tracking sensors. Need a MSP430G2553 assembly language program in IAR Embedded Workbench for a line follower robot car that has two motors (one for each wheel) and three tracking sensors.

Explanation / Answer

#include #define LEFT_MOTOR BIT0 #define RIGHT_MOTOR BIT6 #define LEFT_LDR BIT4 #define RIGHT_LDR BIT5 #define SENSOR_LED BIT7 #define MAX_COUNT 100 // Sensor Calibration #define CAL_SAMPLES 5 #define CAL_SPEED1 75 #define CAL_SPEED2 40 #define CAL_MOVE_DELAY 320 // PWM Duty Cycle Threshold #define MAX_THRESHOLD 75 #define MIN_THRESHOLD 60 // Sensor Status #define LEFT_SENSOR 0 #define RIGHT_SENSOR 1 unsigned int pwm_count=0; unsigned int pwm_m1=0; unsigned int pwm_m2=0; unsigned int min_leftLDR=0; unsigned int max_leftLDR=0; unsigned int min_rightLDR=0; unsigned int max_rightLDR=0; unsigned int adc2cycle(unsigned int adc, unsigned int in_min, unsigned int in_max) { unsigned int adc_val; // Calculate the result and put it within 0 to 100% PWM Duty Cycle value adc_val = 100 - ((adc - in_min) * 100 / (in_max - in_min)); if (adc_val = MAX_THRESHOLD) adc_val=MAX_THRESHOLD; return(adc_val); } void DelayMs(unsigned int ms) { while(ms--) { __delay_cycles(1000); // 1 ms delay for 1 MHz Internal Clock } } // TimerA Channel 0 interrupt service routine #pragma vector=TIMERA0_VECTOR __interrupt void Timer_A (void) { // The PWM Period is about: 101 x 0.1 ms = 10.1 ms pwm_count++; if (pwm_count >= MAX_COUNT) { pwm_count=0; P1OUT |= LEFT_MOTOR; // Turn On Left Motor P1OUT |= RIGHT_MOTOR; // Turn On Right Motor } if (pwm_count == pwm_m1) { P1OUT &= ~LEFT_MOTOR; // Turn Off Left Motor } if (pwm_count == pwm_m2) { P1OUT &= ~RIGHT_MOTOR; // Turn Off Right Motor } } unsigned int ReadSensor(unsigned char chn_stat) { ADC10CTL0 &= ~ENC; // Disable ADC10 if (chn_stat) { ADC10CTL1 &= ~INCH_4; // Deselect ADC Channel 4 ADC10CTL1 |= INCH_5; // Select ADC Channel 5 (A5), Right LDR } else { ADC10CTL1 &= ~INCH_5; // Deselect ADC Channel 5 ADC10CTL1 = INCH_4; // Select ADC Channel 4 (A4), Left LDR } ADC10CTL0 |= ENC + ADC10SC; // Enable ADC10 and Conversion start while (ADC10CTL1 & ADC10BUSY); // Wait for ADC Conversion return(ADC10MEM); // Return ADC Value } void CalibrateSensor() { unsigned char i; unsigned int tmp_left,tmp_right; // Get the Maximum Value Sensor Value (over black line) P1OUT |= SENSOR_LED; // Turn On the Sensor LED DelayMs(1000); // Give enough time to light the LDR tmp_left=0; tmp_right=0; for(i=0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote