You are on page 1of 4

Harini Rai Godugu

Project_02_Servo_Motors

Overview:

Using STM32L476 Discovery Board we run the two servo motors meeting basic requirements
using custom controlled language. Firstly, we set up a pair servo motors with Pulse Width
Modulation (PWM), then we blink red, and green led accordingly and lastly, we implement
using Mnemonics. We control a pair servo motors according to recipe commands. We control
both servo motors together and independently.
Cover Page
Project_2_Servo_Motors
Harini Rai Godugu
Email ID: hg4248@rit.edu
Date: 11-March-2021
Analysis and Design: We use three components i.e., STM32L476, two servo motors and
oscilloscope. We design and work on multitasking recipes using STM32CUBEIDE and C
language. First and fore most we set up PWM signals in six positions at 160 degree. Pulses are
given in range of 0.4 milliseconds to 2 milliseconds. Duty cycle will be given between 2 and 10
percent. SG90 positions controls the two servo motors. Lowest pulse is at 0.4 ms , moderate at 1
ms and highest will be 2 ms over a period of 20 ms . First, we check these pulses in DS212
oscilloscope then will provide to servo motors. While connecting servo motors we should be
utmost care to avoid shortage or burn out of servo motors. Servo motors consumes 5V which is
for red wire, GND for brown and PWM signal is given to Orange wire. Timer interrupts for every
100 milliseconds.

Pulse Width Modulation for Servo Motor (Class Notes)

We do coding for mnemonic opcodes MOV, WAIT, LOOP, END_LOOP, RECIPE_END, and as
per graduate requirement I consider MOV NOT. Opcode width is 3 bits and parameter range is 5
bits wide. We should not use 011, 110 and 111 as these opcodes considered as illegal. For MOV
it ranges up to 0 to 5. And for WAIT and LOOP ranges from 0 to 31 steps. Any thing out of this
range should be shown as error. The WAIT is command considers complete clock cycle and
sometimes skips for a second before execution and wait +1 shows takes 2 more seconds and it
continues. Nested loops are shown as error.
Along with this we do recipe work for LEDs if recipe is running then only green light blinks, if
paused everything goes off, and error occurs red will ON and lastly Both green and red light will
blink ON if the Nested loop occurs.
Next, we use user commands for the recipe to execute P/p , continue C/c, right only one step R/r,
left only one step L/l, No-operation N/n and begin B/b. Other than this any other command is given
it shows error.
Used Recipe Snippets:
MOV+0,
LOOP+2,
MOV+0,
MOV+2,
MOV+3,
MOV+4,
LOOP+2,
END_LOOP, // To find Nested Error.
Test Plan:
1. Check the PWM whether it is giving proper division of time period before giving to servo
motors.
2. Run the Program, Check for recipe snippets and working codes MOV, WAIT, LOOP,
RECIPE_END, MOV_NOT and END_LOOP.
3. Provide commands as to check motors working as suggested commands.
4. Check LED Blinkers.
Project Results:
1. Arrange Recipe Snippets. Working with all 6 positions for all commands MOV, WAIT,
LOOP, RECIPE_END, MOV_NOT and END_LOOP.

2. Demonstrated Recipe Running (only green on), Recipe Paused (all off), Recipe
Command Error (red on) and Recipe Nested Loop Error (red and green both on)

3. p for pause , c for continue, r for right when paused, l for left when paused, n for do
nothing and b for begin again (restart).
In Demo we gave pp to pause both servos, cp for continue and pause, v to counter error,
Bb begin for both servos and rr right for both servos. (Independent for either of these)

4. Includes required test recipe snippets in demo. This is the recipe from the project that has
3 successive wait 31 steps. When running this recipe observe that the recipe pauses for
approximately 9.3 seconds.
7 seconds__ observed wait time

5. Graduate Extension MOV NOT is used as new mnemonic and opcode ranges from 1 to 5.
which is opposite to MOV function.
Lessons Learned:
Experienced hands-on Servo Motor setup Using STM32L476 Discovery Board. Setup and
Configured recipe commands and mnemonics.

You might also like