11: output devices

Individual Assignment

The individual assignment for this week was to add an output device to a microcontroller board we’ve designed and program it to do something.

I decided I wanted my output to be a servo motor. I had worked with servos very briefly in the past, but never in depth. Using Neil’s board as a guide, I altered my input board schematic to include the components I would need for my new board. This included adding a 5V regulator, a 20mhz resonator, and some pin headers to connect the servo. Here is what my final schematic and board files looked like:

After receiving the components from my instructors, I soldered everything together. Here is a picture of my board post-soldering:

Apparently, I am prone to little mistakes, because I realized I forgot to route two connections. I jumper-wired these and altered my schematic and board files so they would be correct. As far as the software side, I used Arduino’s ‘Sweep’ servo code to test if my board worked. Here is the code:

/* Sweep
 by BARRAGAN <http://barraganstudio.com>
 This example code is in the public domain.

 modified 8 Nov 2013
 by Scott Fitzgerald
 http://www.arduino.cc/en/Tutorial/Sweep
*/

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

void setup() {
  Serial.begin(115200);
  myservo.attach(1);  // attaches the servo on pin 1 to the servo object
}

void loop() {
  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}

I changed the baud rate to 115200 and the pin to where my servo was connected: pin 1. When I first attempted to run the code, I was again prompted with the same error as input week: avrdude: jtagmkII_getsync(): sign-on command: status -1. Ultimately, I realized I had several issues with my hardware. I had accidentally connected the voltage regulator inncorrectly, and I also had a resistor at the UPDI pin (I was behind on input week when I did this week, so I made the same mistake and did not realize until later). I decided to take out the voltage regulator altogether and remove the resistor. This solved the problem! I uploaded the code and the servo worked.

Here is my setup:

To download my files for this week, click here.

Group Assignment

The group assignment for this week was to measure the power consumption of an output device. You can view the whole process on our group page here.