Skip to content

Week 10, Output Devices

Assignments

Group assignment

  • Measure the power consumption of an output device.
  • Document your work on the group work page and reflect on your individual page what you learned

Individual assignment

  • Add an output device to a microcontroller board you’ve designed and program it to do something.

Checklist

From Nueval

  • Linked to the group assignment page
  • Documented how you determined power consumption
  • Documented what you learned from interfacing output devices
  • Documented your design and fabrication process
  • Explained the programming processes used
  • Explained any problems you encountered
  • Included original source code and any new design files
  • Included a hero shot of your board

Group work

See the group page for the week

Individual work

For output devices, I chose to make a board which will control a motor. This was chosen because my final project will need to control motors to shuffle and deal cards.

I started with the stepper motor control board listed in the class notes. My plans is to first make a PCB based on the components. To design a PCB, I started by placing the needed components into a schematic.

Components for board

My schematic is pulling from the Fab Library, and that component library lacks the intended connector for the motor. Digikey has models for components that they sell and I can get the Model for S4B from the Digikey site. This needs to be added to the component library. This page includes both the schematic and footprint for the component, which can be downloaded.

Page with schematic and footprint for the S4B connector

Selecting the download button gives the option for downloading in several formats. As the design is being done in KiCad, that is the appropriate format to choose.

S4B schematic download

In the schematic library editor, the schematic for the S4B is added. This lacks the automatic addition for the footprint. The download included the “pretty” footprint.

Footprint file for S4B

In the footprint editor, the diagram needs to be connected to the schematic

Importing the footprint symbol

With that completed, the footprint is available for insertion into the PCB.

Available S4B footprint

Then it was possible to return to the schematic, and intended components added to the schmatic. The design is adding buttons and an LED beyond the original design.

All components for board, unwired

All the components wired (using labels)

Wired schmatic

Moving to PCB design, all the components are imported into the editor.

Importing unaligned components in the PCB

All the components wired for the PCB

Wired PCB

Here are the KiCad design files for the design.

Using Gerber2PNG, PNGs were created for PCB fabrication. The fabrication was done like previously. Components were soldered on. The design relies upon an RP2040 to control the board.

Motor control PCB

Using the code from the FabAcademy site, the board did not fully control a connected motor. The motor would move slightly and the motor would crash. This was the stepper motor example. As I followed the same design parameters, only adding buttons and led, the primary pins are the same. I used this code unmodified. Because the motors were not operating as expected, I did not work to extend the code to use the buttons or LED. The code was run using Thonny on my MacBook laptop, with the RP-2040 connected via USB.

Examining the PCB under the microscope did not reveal any specifically problematic solders. I was concerned that there was something about my addition of buttons and LED which caused a problem. Therefore, I decided to remate the board as done in the example.

The components from the FabAcademy site.

This was wired like the example, and subsequently the board fabricated with the labs Roland MX-20.

Schematic for the simple board

After soldering components, this board also didn’t work correctly. With the week ending, I ran out of time to troubleshoot. I misplaced this board before taking a picture of it.

During this week, I felt that I was getting much better at designing and fabricating PCBs. My underlying issue is likely some aspect of soldering, which I still need to improve.

Working output device

While I didn’t complete a working board to control an output device during this week, is a critical component of my final project. While this effort specifically to this week didn’t result in a functioning output device, subsequent efforts resulted in a functioning board that controls a motor.

For example, I point to the effort in week 15, Interface Programming. In that week, while the primary effort was to make an interface that interacts with an input and/or output from a board that I have made. In that effort, I made a web interface while controlled a stepper motor from a board that I made. While the full documentation on this is on the week 15 page, I will quickly summarize some of the key points.

Motor control board

In contrast to the effort above, I elected to use an A4988 motor control board rather than the DRV8251A which was key to my attempt above. While both should be robust motor controllers, the A4988 is larger in size and is easily mounted via a socket. The larger size proved easier to solder.

PCB for the motor control

The KiCad files for the control board.

This board was milled on the lab Roland MX-20 as described on the week15 page.

Programming the board

While the programming for week15 included functionality for a web interface and the motor control, the following code turned the motor backwards and forward.

// Define pin connections & motor's steps per revolution

// Pins for original board
// Dir: D8 (GPIO7), Step: D7 (GPIO44)
// Steps per revolution: 3200 (due to microstepping)
const int dirPin = 7;
const int stepPin = 44;
const int stepsPerRevolution = 3200;

void setup()
{
    // Declare pins as Outputs
    pinMode(stepPin, OUTPUT);
    pinMode(dirPin, OUTPUT);
}
void loop()
{
    // Set motor direction clockwise
    digitalWrite(dirPin, HIGH);

    // Spin motor slowly
    for(int x = 0; x < stepsPerRevolution; x++)
    {
        digitalWrite(stepPin, HIGH);
        delayMicroseconds(200);
        digitalWrite(stepPin, LOW);
        delayMicroseconds(200);
    }
    delay(1000); // Wait a second

    // Set motor direction counterclockwise
    digitalWrite(dirPin, LOW);

    // Spin motor quickly
    for(int x = 0; x < stepsPerRevolution; x++)
    {
        digitalWrite(stepPin, HIGH);
        delayMicroseconds(100);
        digitalWrite(stepPin, LOW);
        delayMicroseconds(100);
    }
    delay(1000); // Wait a second
}

As the work this week relied upon an ESP32, this code can be compiled and uploaded using the Arduino IDE. This version of the code moves the motor backward and forward by one cycle.

Code for motor control.

As shown in the video below, the full version of the code includes the web interface. Importantly for the perspective of output devices it demostrates the motor control.

Motor control

Here is a video from week15, where the motor can be seen controlled via a web interface. I push the button when a meeting starts, and then afterwards can mark myself as free.

Motor controlled by web interface