Output Devices

This week we had to add an output deviceto a microcontroller board and the program it to do something..
As Groupassignment we should measure the power consumption of an output device.

Circuit diagram and board layout

As output device I wanted to create a stepper motor controller. In my final project this should move the strainer.
Due to the Attiny 85 not having enough pins to use is as a stand alone stepper driver, I want to use a A4988 stepper motor driver instead.
You can find more information bhe A4988 stepper driver HERE.
So after some research my schematics look like this:

After everything was connected I created my board layout, which looked like this:

PCB Milling and finished board

I uses our LPKF PCb milling machine to mill out my board design.
Then I applied solder paste and the componets, before using the solder oven to solder everything to the board.
The finished board looks like this:

With the stepper driver attached it looks like this:

Note that the terminal for the 12V power supply. which is needed to power the stepper motor, is on the back of the PCB.

Code and working example

I did a quick research on how to use the A4988 stepper driver. I used this tutorial for coding, aswell as for the layouting beforehand.
My test code looks like this:

As you can see, my Attiny85 is controlling the A4988 by only using the Step and Dir pin. The Step Pin will move the stepper motor exactly one step, for every time the pin changes from Low to High.
The Dir pin is the direction pin and will turn die Steppermotor clockwise or anti clockwise, depending on setting it to High or Low.
Normaly you also have an Enable pin, that you have to set to Low (ground) to active the stepper driver, but I decided to set the pin to always ground.
I uploaded the code via the Arduino IDE, using an arduino uno, as described in this tutorial. After connection my board via an UART to USB adapter and opening the serial monitor, I could read out the distance values of my ultrasonic sensor:

Note that the ISP connection is only to power the Attiny85 with 5V.

Group Assignment

For our group assignment we had to measure the power consumption of an output device.
You can find our measuring and the documentationen on the website of our group meber Lars Mattern HERE.


KiCad project file
Arduino code