DVR8825 and Attiny85

Hello everyone!

I'm Marc, from Barcelona! This is the first time in years using the amazing net I felt I need some help other than the infinite solutions people have already posted here and there! My knowledge on electronics and programming is tiny, but I've always managed to get the info using a lot of patience and some luck, so thank you everyone who takes time to write questions and solutions!

This time, though, I am not finding information for what I want to do, or I am not understanding it properly. This leads me to think that what I intend to do is not possible and that I am missing something.

Here the problem:

I amb using a dvr8825 to drive a bipolar stepper with rated current of 1.7A. With a pedal, I make the motor turn for as long as I press it. To control it all, I am using an arduino mega. My intention is to have it all contained in a small box that I can just plug in and use (5V for the chip from a battery, and 12V from a power source I plug in the 220V net) and my intention is to substitute the arduino with a microcontroller that I can solder directly to the board I am making.

So, I had a couple Attiny85 and thought I could use them for this purpose. I finally managed to upload the program to the attiny after some headaches, but now I just realised I have no knowledge to make it all run.

I hope this is enough info. I feel like I am making a super complicated way to make this motor turn, but that's all I could do!

Thanks in advance for any advice!

Hi, don't know how to edit my message!

Just reread it and saw I am not making a direct question, apologies.

Here the question:

Is it possible at all, to substitute the arduino board with the Attiny85? I am considering to get an arduino nano and do it with that, although I like doing things with the minimum needed.

I didn't post the code or wiring since the code works and I just have no idea on how to wire the pins that were connecting the arduino and the driver when changing the arduino for the Attiny.

If is is possible at all, I gust need someone pointing out the direction, so I can continue searching the aswer! :wink:

Thanks again!

The nano would be easier. Or, if you are happy making your own circuit board (or using stripboard) you could use an Atmega 328 chip.

Programming the Attiny will be a bit more difficult but it should be perfectly well able to control a DRV8825 as that only needs two I/O pins for step and direction.

You will need to add the appropriate "core" to the Arduino IDE.

...R

Hello!

Thanks Robin!

I did manage to upload the code to the attiny already, but my problem comes when doing the pinout.

Here is the code I use for the motor to run (might be a wrong code, as I said, my knowledge is little in these areas, but it does the job. Super simple task actually :D)


#include <AccelStepper.h>
AccelStepper stepper(1, 9, 8); //1 vol dir que fem servir driver, 9 dir, 8 step

int polsador_arrancada = 0;

const int polsador_inici = 10;
const int pinLed = 7;

void setup()
{
stepper.setMaxSpeed(3000);
stepper.setSpeed(1500);
}

void loop()
{
polsador_arrancada = digitalRead(polsador_inici);

if (polsador_arrancada == HIGH) {

digitalWrite(pinLed, HIGH);
stepper.runSpeed();

}
else {
digitalWrite(pinLed, LOW);
}

}


Now, when I do the wiring, how do I substitute the pins (9,8 for step and dir, and 10 for the pedal. We can forget about the 7, for the LED, not important)

Thanks again!
Marc.

mbpadro:
Now, when I do the wiring, how do I substitute the pins (9,8 for step and dir, and 10 for the pedal. We can forget about the 7, for the LED, not important)

Please use the code button </> when posting code and then it won't have smileys

I don't understand what was in your mind to give rise to the above question. If you know the pins of the Attiny that you want to use for the different purposes then just enter those into the program so that the program matches your Attiny connections. But maybe you had something else in mind?

...R

Got it for the code posting, thanks!

Ok, so to start, the question is probably a stupid one because the answer is probably super simple: I don't know the "names" at the attiny's pins. In arduino they will be the number on the board, easy. But in attiny, I don't know what to write so that the code is directed to them. :confused:

All the pinouts are in the link I gave you.

...R

True that!

Thank for your time, Robin, doubts resolved!