Dual Stepper Clock Project (noob)

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
kevkevharhar
 
Posts: 4
Joined: Sat Jun 09, 2012 8:46 pm

Dual Stepper Clock Project (noob)

Post by kevkevharhar »

Hello everyone, I'll start by describing my project, then the issues I'm having.

My project is to make a large clock that requires the strength of stepper motors to turn gears attached to circular clock hands. The mechanics are designed in such a way that it really does need 2 steppers instead of just one, so I bought the Adafruit motor shield. Once I'm completed I'll definitely have to post some pics (still waiting for machinists to get back to me).

When I started with one stepper and the Arduino Uno, I was quickly able to get it running using the "One Step At A Time" program in the stepper library. This code is perfect for what I need with each stepper motor. When I set up the Adafruit motor shield, the code had to change, and I was stranded. My biggest issue, I believe, is that for years I've been looking at code, scripts, programs, MEL, Actionscript, Notepad?, and the structure of programs never makes sense to me. I'm trying not to be a stick in the mud, but when I modify any part of any code, I get errors. If I knew what everything meant and why certain things are required, this would be a simple project. But I'm just a professional artist who needs his big clock. I'm great with computers (3D artist), but the only language I speak other than English is visual art.

Solutions:
The first solution that comes to mind is buying a second Arduino and power supply. This way I can drive both steppers using One Step At A Time.

The other solution is your brilliant minds manifesting a program that basically does One Step At A Time for two independently timed steppers on the Adafruit motor shield. To be specific, one motor needs to run at 1,800 milliseconds per step, and the other at 21,600 milliseconds per step. Both motors are 200 steps per rotation. An accurate timer function would be icing on the cake, but I won't be picky.

I'll appreciate any help, and thank you for taking an interest.

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: Dual Stepper Clock Project (noob)

Post by adafruit_support_bill »

There is a "onestep()" function in the AF_Motor library. Since your step timing is relatively long, we can keep things simple and just poll the "millis() timer in your loop. Something like this:

Code: Select all

 uint32_t  M1_last_step;
uint32_t  M2_last_step;


void loop()
{
   uint32_t now = millis();  // get the current time stamp in milliseconds

   if ((now - M1_last_step) > 1,800)  // Is it time to step Motor 1?
   {
     stepper1.onestep(FORWARD, SINGLE);  // step it
     M1_last_step = now;  // remember for next time
   }
   if ((now - M2_last_step) > 21,600)
   {
     stepper2.onestep(FORWARD, SINGLE);
     M2_last_step = now;
   }
}
This code will 'hiccup' approximately every 49 days when the "millis" counter overflows and resets to zero. You can detect that by checking for millis() < M1_last_step.

kevkevharhar
 
Posts: 4
Joined: Sat Jun 09, 2012 8:46 pm

Almost There

Post by kevkevharhar »

I've managed to boil the errors down to:

core.a(main.cpp.o): In function `main':
C:\Users\<myname>\Arduino\hardware\arduino\cores\arduino/main.cpp:11: undefined reference to `setup'

I told the code to include the af_motor library as well as setting up the stepper1 and stepper2 motors, this remedied a number of errors except for the one. Apparently it's an issue a lot of people are having.

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: Dual Stepper Clock Project (noob)

Post by adafruit_support_bill »

The code above is just the loop function. All Arduino sketches require a setup function too.

If you have nothing to do in setup, it can be an empty function:

Code: Select all

void setup()
{
}

kevkevharhar
 
Posts: 4
Joined: Sat Jun 09, 2012 8:46 pm

Strange High Pitch Squeal

Post by kevkevharhar »

The code is now verifying correctly with the void setup bit in there. The new issue is stepper # 2 (M3/M4) isn't functioning like stepper # 1 using Multistepper, it runs strong in one direction, then poops out. I figured it could be the motor itself, but putting it on M1/M2 makes it run just fine. I'm using Multistepper because the code we've come up with still isn't working and makes both motors emit a high pitch squeal sound without any rotation. It's entirely possible that I need to go back and re-solder some lose parts because this is my first real soldering project, although everything looks and feels solid. I may have also burnt out something during the soldering process.

We have time to figure this out because the CNC company I want to work with doesn't appear to check their e-mails very often.

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: Dual Stepper Clock Project (noob)

Post by adafruit_support_bill »

If you post photos of the front & back of the shield we'll check over your soldering.

kevkevharhar
 
Posts: 4
Joined: Sat Jun 09, 2012 8:46 pm

Re: Dual Stepper Clock Project (noob)

Post by kevkevharhar »

I'm not especially proud of my soldering handiwork, but the tools I had to work with are pretty big. I'm guessing that dark amber stuff is flux, I hope it doesn't like electrons. Thanks for taking a look at my mess. If any solder responsible for the M3/M4 connections appears insufficient, I'll go back over with the iron.
Attachments
The trouble chip up close.
The trouble chip up close.
chip2.jpg (415.98 KiB) Viewed 1964 times
Front of the PCB.
Front of the PCB.
chip3.jpg (443.2 KiB) Viewed 1964 times
Rear of PCB.
Rear of PCB.
chip1.jpg (421.47 KiB) Viewed 1964 times

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: Dual Stepper Clock Project (noob)

Post by adafruit_support_bill »

It looks like you are heating the pins and not the pads. That causes the solder to ball up around the pins and not flow well onto the pad. This is the case with many of the header pins on the top side as well as some of the pins on the bottom. You should also clip those leads a little closer to the board so they don't short out on anything.

You would probably have better results using an iron with a finer tip. Try to make them look like the diagram below. Burnt flux does become somewhat conductive. Probably not enough to cause the symptoms you are seeing though. It can be cleaned with some gentle scraping and scrubbing with 90% or greater isopropyl alcohol.
Attachments
Solder Joint.gif
Solder Joint.gif (7.78 KiB) Viewed 1961 times

daremick
 
Posts: 25
Joined: Wed Sep 26, 2012 10:17 pm

Re: Dual Stepper Clock Project (noob)

Post by daremick »

I am also getting a High pitched noise and have seen a few other people with this similar problem, but no one seems to know what the noise is caused by or how to fix it... I'll keep searching.
Last edited by daremick on Mon Oct 15, 2012 10:55 pm, edited 1 time in total.

daremick
 
Posts: 25
Joined: Wed Sep 26, 2012 10:17 pm

Re: Dual Stepper Clock Project (noob)

Post by daremick »

Actually I just found this in another thread posted originally by the Adafruit Support, could this be what we are all experiencing?
-------------------------------------------------------------------
ADAFRUIT SUPPORT
"PWM is "Pulse Width Modulation". Basically, the shield controls the speed of the motor by sending it voltage pulses of varying width. (The wider the pulse the faster the speed). The PWM frequency controls the number of pulses per second.

The pulses cause small vibrations in the motor, and if the PWM frequency is in the audible range, you hear it as hum or a squeal."
-------------------------------------------------------------------

Thanks, and as a follow up question to this explanation, is this vibration that becomes audible dangerous? For example, could it blow a capacitor or one of the L293Ds or something damaging like that? And if so how can I and others avoid this? Using different motors? Using different speeds for the motor? Changing the power supply? Thanks for any help :) .

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: Dual Stepper Clock Project (noob)

Post by adafruit_support_bill »

The PWM noise is not dangerous. Try a different frequency. http://learn.adafruit.com/afmotor-library-reference

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”