Pesky Digispark clones and stepper motors

I'm building this cable car I found on Thingiverse. I actually started on this version, driven by a cheap stepper motor. Neither quite fits my needs: I want to mount it on the underside of a bunk bed. I settled on this idea of a usb stepper motor. I.e. a stepper motor powered and controlled via a USB connection. A Digispark ATTiny85 has 4 wires left over after USB.

The stepper motor is a 28BYJ-48. It's a unipolar stepper motor, and the driver board that came with it is enormous! I'm sure it's only economic because there's some enormous stockpile of ULN2003A chips somewhere that makes them basically free, or maybe a stockpile of actual boards. Anyway, This post explains quite well how to convert it to a bipolar stepper motor. Then I can use a DRV8835 driver carrier board, which will work at 5V and is really cheap (as low as $1.50). I've designed a mount/enclosure that looks like this:




Unfortunately all I was getting the stepper motor to do was buzz.

I realised having the use of all the pins only applies to a real Digispark ATTiny85. A cheap knock-off you buy off Ebay, probably won't have been configured to allow use of the 6th pin - it's a reset pin. Mine wasn't. Sorting this out is described here among other places.

I want to use one of the clones, because I really want a micro USB connector: I have lots of appropriate cables lying around, and in any case, I have several now: I should use them for something.

The problem for me is I'm trying to fit it all in a very small space, so I'm soldering wires onto the board. Attaching a programming device to the board without headers is a challenge.

Anyway, I'll start by trying to configure one that does have headers...

I have a Leonardo. I read the instructions at the top of ArduinoISP, rather than follow the blog post or the comments, so I wired from the ICSP connector's MOSI, MISO and CLK to P0, P1, P2, and connected P5 to D10. There's no need for special wiring to stop the Leonardo from resetting on serial connection, as far as I can tell.

Then I ran:

$ avrdude -P /dev/ttyACM0 -b 19200 -c avrisp -p attiny85 -n

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e930b (probably t85)

avrdude: safemode: Fuses OK (E:FE, H:DD, L:E1)

avrdude done.  Thank you.

as per the blog post, and since it produced the expected output, I ran the next command:

$ avrdude -P /dev/ttyACM0 -b 19200 -p attiny85 -c avrisp  -U hfuse:w:0x5F:m 

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e930b (probably t85)
avrdude: reading input file "0x5F"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0x5F:
avrdude: load data hfuse data from input file 0x5F:
avrdude: input file 0x5F contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified

avrdude: safemode: Fuses OK (E:FE, H:5F, L:E1)

avrdude done.  Thank you.

And that all looks good.

Presumably this won't work again, because P5 no longer functions as the reset pin:

$ avrdude -P /dev/ttyACM0 -b 19200 -c avrisp -p attiny85 -n

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.

Yep.

I've managed to attach a board without headers using some test probes:


I'm a bit surprised when it works! I was able to program the board using USB again afterwards. Now I just need to solder in the wires to the motor controller...

Now the stepper motor turns too.

Here's the sketch I used to get it going.

The cable car is actually up and running now, but it's a bit temperamental at the moment, and I haven't posted a remix on Thingiverse yet, so I'll leave that for another post. I think it just needs some more support pulleys.


Popular posts from this blog

3D Printer ramblings

Balance Bot V2

Robot arm