# Direction and speed control of dc motor in MSP430G2553 using l298n/l293d and potentiometer

Thread Starter

#### darkest_nightt

Joined Apr 19, 2019
4
Guys, i really need help. I am new to msp430 and i have very big task. The task is PWM-based speed control of a motor by a potentiometer. I am using msp430g2553 ,L298n motor driver board, 5V DC motor, -1 x 10 kOhm potentiometer and 9V battery and its connector . I have been working for 9 hours and i just figured out how to work motor driver. Goals of our project are;

- Read an analog value from the potentiometer.

-Convert this analog value to digital level using ADC module of MSP430G.

-According to this digital value, generate a PWM signal. The duty cycle of the PWM signal must range from 0% to 100% as the analog value changes from its minimum to its maximum.

-Feed the motor driver board with this PWM signal and observe the motor speeds up as the duty cycle increases and speeds down as the duty cycle decreases.

-When the switch S2 (internally connected to the P1.3 pin) is pressed, reserve the direction of the rotation of the motor.

The code must be written in C language.

Please help me, please

#### MrChips

Joined Oct 2, 2009
24,143
Guys, i really need help. I am new to msp430 and i have very big task. The task is PWM-based speed control of a motor by a potentiometer. I am using msp430g2553 ,L298n motor driver board, 5V DC motor, -1 x 10 kOhm potentiometer and 9V battery and its connector . I have been working for 9 hours and i just figured out how to work motor driver. Goals of our project are;

- Read an analog value from the potentiometer.

-Convert this analog value to digital level using ADC module of MSP430G.

-According to this digital value, generate a PWM signal. The duty cycle of the PWM signal must range from 0% to 100% as the analog value changes from its minimum to its maximum.

-Feed the motor driver board with this PWM signal and observe the motor speeds up as the duty cycle increases and speeds down as the duty cycle decreases.

-When the switch S2 (internally connected to the P1.3 pin) is pressed, reserve the direction of the rotation of the motor.

The code must be written in C language.

Please help me, please
So let's get cracking then.
When is your deadline?

Thread Starter

#### darkest_nightt

Joined Apr 19, 2019
4
April 24, and after the setting up the circuit i had to write a report and design the circuit scheme in proteus. help please : D.
by the way i am in library, the time is 23:38 and still haven't found any solution.

#### MrChips

Joined Oct 2, 2009
24,143
April 24 is like 4 days away.
When were you given this assignment?
What have you done so far besides searching for a ready made solution?

Thread Starter

#### darkest_nightt

Joined Apr 19, 2019
4
i had really hard midterms, after the midterms, our evil teachers instantly give this assignment after one day last midterm. i slept only 4-5 hours .
i tried the many codes but they always a little bit different our materials. i use msp4302553, i tried to change it but then code composer program started to give error. our lecture notes really shit, i use internet to learn microprocessors but still haven't solution for this

#### MrChips

Joined Oct 2, 2009
24,143
4 days left to master MSP430G2553 architecture, that does not look promising.
Can you make an LED blink?

Thread Starter

#### darkest_nightt

Joined Apr 19, 2019
4
of course i can, they are easy part but when we talk about the direction of dc motors coding, i feel i am like over.
after 8 hours i am sure about the our circuit's connections but code never works and as i seen i am not good at write code in msp430g2553 especially C language. I am good at C but this microprocessor givin me very hard time.
and about the results from i have found the internet, closes thing the my project is;
https://www.electronicwings.com/ti-launchpad/dc-motor-interfacing-with-msp-exp430g2-ti-launchpad
but the code is not compatible my msp430g2553. i tried to make it by finding another libraries but it still didn't work.
how to write or change this codes in my code composer studio compiler for msp430g2553

#### MrChips

Joined Oct 2, 2009
24,143
The problem is not with the MSP430G2553. The problem is with the coder.
So you know how to blink an LED.
Next, do you know how to connect the MSP430 to L298N?
Don't just copy someone else's code. That is where you run into trouble.
Show your circuit diagram.
Show your code.