# PCB design use with stepper motor

#### Mooafwsa

Joined Aug 17, 2020
13
I'm currently looking for a solution to a problem I have and I need to create a circuit to later develop into a PCB and these are my requirements:

- I need a device to rotate a circle with 8 intervals one interval per day.
- I also want a switch to reset the device once it has completed its 8 intervals so i can reload it and start again.

I have currently successfully used an Arduino to complete this task but it doesn't really allow for my design to be compact inside a case and the final thing I have tried is using a micro controller to rotate a stepper motor by x degrees but couldn't workout the timing to make it rotate once per day.

#### jpanhalt

Joined Jan 18, 2008
11,088
II have currently successfully used an Arduino to complete this task but it doesn't really allow for my design to be compact inside a case and the final thing I have tried is using a micro controller to rotate a stepper motor by x degrees but couldn't workout the timing to make it rotate once per day.
Welcome to AAC.

Since you have used an Arduino for that task successfully, have you considered a small microcontroller. The Arduino has a microcontroller at its heart, which is what allows it to be programmed.

There are various ways to work out a once-a-day timer. How accurately do you need to do that? Internal MCU oscillators are accurate to a few percent. An external crystal or ceramic resonator will be accurate to a few ppm.

If you need specific help with respect to the timing, i.e., how to set it up, then you will need to be more specific about the MCU you want to use.

#### AlbertHall

Joined Jun 4, 2014
11,506
I don't know which arduino you used, but there are arduinos which are alot smaller than the UNO e.g. nano, pro-mini, pro-micro

#### Mooafwsa

Joined Aug 17, 2020
13
Welcome to AAC.

Since you have used an Arduino for that task successfully, have you considered a small microcontroller. The Arduino has a microcontroller at its heart, which is what allows it to be programmed.

There are various ways to work out a once-a-day timer. How accurately do you need to do that? Internal MCU oscillators are accurate to a few percent. An external crystal or ceramic resonator will be accurate to a few ppm.

If you need specific help with respect to the timing, i.e., how to set it up, then you will need to be more specific about the MCU you want to use.
Yeah I attempted a circuit using a micro controller and crystal but I just struggle to work out what components would be the best for the task. As for accuracy if the device could rotate everyday at 1pm or so that would be fine.

#### Mooafwsa

Joined Aug 17, 2020
13
I don't know which arduino you used, but there are arduinos which are alot smaller than the UNO e.g. nano, pro-mini, pro-micro
Im using an arduino uno and the extra components im using stick out for example resistors, switches, etc and i dont want to have the device running using a bread board either I would prefer everything done on a pcb so I can 3D print a nice case for it.

#### djsfantasi

Joined Apr 11, 2010
7,843
Im using an arduino uno and the extra components im using stick out for example resistors, switches, etc and i dont want to have the device running using a bread board either I would prefer everything done on a pcb so I can 3D print a nice case for it.
Those extra components will likely also be needed if you use a standalone micro.

An Arduino Nano is 18 x 45 mm. it is totally compatible with an Arduino Uno. You can attach it to your PCB board with headers, resulting in a compact PCB board.

#### Mooafwsa

Joined Aug 17, 2020
13
Those extra components will likely also be needed if you use a standalone micro.

An Arduino Nano is 18 x 45 mm. it is totally compatible with an Arduino Uno. You can attach it to your PCB board with headers, resulting in a compact PCB board.
Even with this in mind dont you feel that the arduino is overkill for this task would this not be more cost effective if I use a cheap micro controller?

#### djsfantasi

Joined Apr 11, 2010
7,843
Look into an ATTiny85. It can be programmed with the Arduino IDE. Any software you develop on an Uno can be easily ported to the ATTiny. You will need a programmer, which can be built using an Uno. Or... This plugin programmer from Sparkfun.

#### djsfantasi

Joined Apr 11, 2010
7,843
One last thought. Using a microprocessor for timing (one interval per day) will drift especially over such a long time period.

If you need to accurately time the rotations, you may need a Real Time Clock (RTC). Small modules are available and like my previous suggestion could be mounted with headers.

#### Mooafwsa

Joined Aug 17, 2020
13
One last thought. Using a microprocessor for timing (one interval per day) will drift especially over such a long time period.

If you need to accurately time the rotations, you may need a Real Time Clock (RTC). Small modules are available and like my previous suggestion could be mounted with headers.
Ok perfect ive looked into that and the ATTiny85. So now im just trying to work out a circuit, do you have any hints so I can point myself in the correct direction?

#### jpanhalt

Joined Jan 18, 2008
11,088
You could use the same MCU included in the Arduino line (Atmega) or any other one. I use the enhanced mid-range PIC's, which are also from Microchip. What you seem to need is really quite simple to do. The chip can use its internal oscillator which you supplement with a 32,768 Hz (2^15) crystal for counting seconds. Use pre- or post-scalers. An hour is 3600 seconds; a day = 86,400 seconds.

Joined Jul 18, 2013
23,650
The small Micro's I use can use a system clock of 32Khz, that may simplify things if you have no other really time sensitive actions, I have used this method in the past.
A stepper motor requires 200 pulses/rev. As it sounds as though your step rate will be very low, you may not need a sophisticated stepper driver, just a simple power supply, but it would need to be the actual plate voltage of the motor.
A simple LM298 driver can be had on ebay for $5.00. Max. Last edited: #### Bernard Joined Aug 7, 2008 5,788 Is this device battery or AC adapter powered ? In US 60 Hz AC line is very stable long term. Might supply PCB with 120 PPS @ about 8V peak ? #### djsfantasi Joined Apr 11, 2010 7,843 Is this device battery or AC adapter powered ? In US 60 Hz AC line is very stable long term. Might supply PCB with 120 PPS @ about 8V peak ? Good idea! I’ve built many a device using line frequency. Thread Starter #### Mooafwsa Joined Aug 17, 2020 13 Is this device battery or AC adapter powered ? In US 60 Hz AC line is very stable long term. Might supply PCB with 120 PPS @ about 8V peak ? I want my device to be to be battery powered and It might help if I explain what im trying to do. I'm trying to build a device that will feed my pet once a day so for I have 3D printed a circular base which has holes that when the motor rotates to a certain point the food will drop out. This was fairly simple to program with an arduino as I mentioned before but I want to make the device smaller and more compact. Im currently trying to use a small microprocessor and a crystal for timing and im just struggling with making the connections using data sheets. Thread Starter #### Mooafwsa Joined Aug 17, 2020 13 The small Micro's I use can use a system clock of 32Khz, that may simplify things if you have no other really time sensitive actions, I have used this method in the past. A stepper motor requires 200 pulses/rev. As it sounds as though your step rate will be very low, you may not need a sophisticated stepper driver, just a simple power supply, but it would need to be the actual plate voltage of the motor. A simple LM298 driver can be had on ebay for$5.00.
Max.
I couldn't find anything under Lm298.

#### Mooafwsa

Joined Aug 17, 2020
13
My original solution for this was using an arduino uno, the A4988 stepper motor controller with a 100mF capacitor across DMOT and ground. Then connecting that to a stepper motor and writing the code to complete my task but, my ultimately I want to have this device left in a box connected to a battery so I only have to check it every 8 days to refill and having this on a breadboard doesn't work for me. Also I feel like I can slash the costs if I use another method as I need a few of them.

#### AlbertHall

Joined Jun 4, 2014
11,506