## 2.x for kbob's maker space

Post your build logs here

### Re: 2.x for kbob's maker space

kbob wrote:My motors are Keling KL17H247-168-4B. The datasheet is here. http://www.automationtechnologiesinc.co ... 168-4B.pdf

The datasheet lists these.
• Phase 2
• Rated Voltage 2.8 V
• Current/Phase 1.68 A
• Resistance/Phase 1.65 Ω
• Inductance/Phase 2.8 mH
• (and some other stuff)
I guess that calculates out to 1 phase (at a time) × 1.68 A/phase × 2.8 V ≅ 4.7 watts when the motor is at rest. Right? That number, as you said, isn't very useful because of back EMF when the motor is turning and losses in the driver chip and who knows what else.

FWIW, if my calculations are correct, the fastest I've seen the motor turn under Arduino control is about 2100 RPM. Above that, it would stall. But my stepper drivers don't have heat sinks yet, so I'm using ~1 A, not 1.68A. But I digress... (-:

The standard for calculating PSU for steppers to get the best efficiency, is 2/3 of the rated current times number of motors running simultaneously and sqrt(inductance) times 32 for voltage. For steppers, current equals torque and voltage equals top speed. So for your motors, if you use 2, it would be 2/3 * 1.68A * 2 = 2.24A and sqrt(2.8) * 32 = 53.5 would give you the best torque and best speed without overloading the motor. Depending on your drivers, this voltage may overload your drivers, though.
StigOE

Posts: 96
Joined: Thu May 12, 2011 9:08 pm
Location: Norway

### More Single-Axis Motor Software

I've made some progress on motor control software. I can change the acceleration and velocity profiles on the fly, and have been writing exercise programs that cycle through various speeds and distances. I will shoot some video in the daylight. (Yes, we still get scattered daylight in the US Pacific Northwest at this time of year. Occasionally.) I'm still driving a single stepper motor which is on a bare piece of Makerslide.

Thanks to Roy's explanation, I was able to find alternate output pins to drive all four channels — X, Y, Z, and what I'm calling P for laser Pulse — from the ATmega's four 16-bit timer/counters. I've tested all of them except P.

I've done about all I want to do with a single stepper motor. In December, I will finish the mechanical assembly and start writing software to control the motors on both X and Y axes simultaneously.

The mechanicals are coming along nicely. I redid the Z table using Bart's aluminum table brackets with PEM nuts. They work better than the printed plastic pieces, because the PEM nuts float with some slack and don't bind up. I installed a plastic egg crate insert for the floor. I know plastic will burn, but I haven't been able to source any metal egg crate. During my day off tomorrow (It is Thanksgiving weekend in the US), I am going to try the local electrical and plumbing supply houses. I've already tried the home centers like Home Depot, and I've even hunted through the junk piles at the local building supply recycler.

I got the gantry ends from Bart's Batch #7, but haven't done anything more than admire them. Now that I'm done with my single motor software development test bed, I can build the gantry. I'm going to try to cut my gantry a little long -- as long as I can without keeping the Y motor shafts from reaching their bearings. I think I can probably get an extra 5 mm in the X dimension. Not a significant difference, I know. But I'm starting to wish the laser cutter were bigger.

The downside of putting the electronics into the laser cutter is that I will only be able to work on it when I'm at the maker space. These late night debugging sessions will have to stop.
Bob
"If you didn't code it, it will never own you." (-:
kbob

Posts: 147
Joined: Mon Jul 09, 2012 6:39 am
Location: Eugene, OR, US

### Re: 2.x for kbob's maker space

Comment From Buildlog Author
And limit switches. I can wire in the limit switches and write them into my software, too.
Bob
"If you didn't code it, it will never own you." (-:
kbob

Posts: 147
Joined: Mon Jul 09, 2012 6:39 am
Location: Eugene, OR, US

### Motor Control Videos

Here are three videos I threw onto the Yoot Yoob.

The first one just demonstrates a repeating pattern of three movements. It demonstrates acceleration and deceleration. It's not much to look at.

Inside, the program has two components. The mainline (the loop() routine in Arduino runtime) iterates through an array of stroke descriptions. Each stroke has a direction, plus or minus, a length in mm, a maximum V in mm/sec, and an acceleration constant in mm/sec/sec. The mainline uses that info to calculate the info needed by the real time portion to control the motor.

That info is:
• how many µsteps to accelerate
• how many µsteps to move at full speed
• how many µsteps to decelerate
• how much to accelerate per µsteps (in units of 1/65536th of a CPU clock tick)
• how fast to pulse the motor when at full speed (expressed both as µsteps/second and as clock ticks/µstep)
• how many clock ticks to wait between the first and second µsteps

The mainline puts that info into a ring buffer. The real time component reads entries from the ring buffer and uses them to control the motor.

The real time component runs from the counter overflow interrupt. When the counter overflows, the hardware s[youtube][/youtube]ets the step pulse HIGH and triggers the overflow interrupt. 1 microsecond later, the hardware sets the step pulse LOW. Whenever the interrupt service routine gets to run, it uses the info above to calculate when the next timer overflow should happen. It loads that value into the appropriate register.

There's a whole lot of bookkeeping to handle too, of course. Are we done accelerating? Is it time to start decelerating? If we've finished decelerating, is there another stroke to start on? Etc. But there's plenty of time — at worst, the interrupt service routine has about 12 microseconds, since it has until the next counter overflow to load the register, and most of the bookkeeping happens after the register is loaded.

So far, I've been limited by the mechanical speed of the stepper motors, not the Arduino. But I'm only calculating one axis. When I add the Y axis and the laser pulses, the CPU will be busier.

Here's the second video. In this one, I ran a test pattern where the carriage makes successively longer movements until it's moving about 30 cm (1 foot) at a time. The longer motions are pretty smooth and fast. The acceleration looks kind of sluggish to me, though. Vmax is 500 mm/sec. Amax is 1700 mm/sec².

I ran this for a couple of hours last night. Whenever the stepper stalled, I lowered Vmax or Amax and restarted it. The above values appear to be reliable. Obviously, if I change the mass of the carriage or the voltage or amperage of the stepper driver, I will want to re-tune those.

The third video is my favorite. In this one, the direction, distance, maximum velocity, and acceleration rates all vary randomly.

I can sit and look at this one for hours. (-:
Bob
"If you didn't code it, it will never own you." (-:
kbob

Posts: 147
Joined: Mon Jul 09, 2012 6:39 am
Location: Eugene, OR, US

### Building the Gantry

I'm back from a business trip, and I got to touch the hardware for the first time in over two weeks today.

I cut my Makerslide plank to length and started building the gantry. Cutting and tapping the slide took longer than I expected. (We have a crappy metal chop saw at the maker space. I do not recommend this product.) Then I built the carriage and screwed on the end plates. I'm trying to track Bart's 2.x plans pretty closely for the mechanicals.

Here's how far I got.

Kabelschlepp. I love it. It's fun to watch it bend, and it's fun to say the name. A sales rep from Kabelschlepp called me when I placed my order. He pronounced it Cobble-Schlepp. Now I do too.
Bob
"If you didn't code it, it will never own you." (-:
kbob

Posts: 147
Joined: Mon Jul 09, 2012 6:39 am
Location: Eugene, OR, US

### Mechanical assembly almost done

Since the last update, I've installed the gantry. I set it in place on the four upper wheels, verified the alignment and rail spacing, then attached the bottom wheels with the gantry in place. There was very little slack between the wheels. I didn't tighten the eccentric nuts at all. That makes me wonder whether something is misaligned.

Tonight I attached the min Y limit switch, which I'd forgotten to do, and attached both Y belts. I tried for a while to ensure that the gantry is square, but really couldn't. When the laser is operational, I will cut some squares and measure them for squareness. The gantry moves with very little friction. Before I attached the belts, it would roll easily whenever I tilted the frame 20° or so. With the belts on, that doesn't happen, of course.

My X cable carrier is installed. I don't see where to install the Y carrier. I see screw holes on the right gantry end (motor end) at the bottom. But I don't see where the other end can go. I vaguely remember that Bart explained it a few months ago; I'll have to track down that post.

I got some air assist tubing at the local aquarium store. I don't know exactly what it is, but it is nice and flexible. I test fitted it into the Kabelschlepp tonight, and it bent just fine. Here is the reel it came from.

There are a lot of pieces to align in this chassis. Most of them are pretty close, but none are perfect.

I received an aluminum eggcrate floor this week, and am making arrangements to use a bandsaw to cut it to size. (See post in other forum.) I think I will leave the plastic eggcrate in for a while -- the aluminum seems to be much more fragile.

Also this week, I planned out a water cooling system using PC overclockers' components: pump, radiator, fans, quick disconnects, flow and temperature sensors, etc. It came to about \$250. Then I checked Bart's recommended submersible pump. It's \$13. Tonight I stopped by Harbor Freight and bought the \$13 pump. I already have a bucket. The radiator and quick disconnects can come later, I guess.

While there was a crowd of kibbitzers at the maker space tonight, I got out the electronic components and started placing them in the chassis. It looks like there is plenty of room. I will have:
• PC power supply
• Azteeg X3, real time control
• Raspberry Pi, front end
• Air pump
• Laser power supply
• Terminal block for 110V?

It is not clear how I'll route the wiring. That's another part I've never had to do before. I will start on the wiring as soon as I've gotten the Y cable carrier installed.

Here's what it currently looks like. (Gratuitous Christmas lights/LED strip in the background)

Bob
"If you didn't code it, it will never own you." (-:
kbob

Posts: 147
Joined: Mon Jul 09, 2012 6:39 am
Location: Eugene, OR, US

### Re: 2.x for kbob's maker space

Looking good, mine's been on the back burner as of late.

Anyway, I think the second cable carrier attaches to the bottom skin. I haven't put mine on yet but can see two holes with the same spacing as the other attachment points.
greenvandan

Posts: 49
Joined: Mon May 28, 2012 1:41 am
Location: Baltimore, MD

### Y Axis Cable Carrier

Bart's original design had the Y axis cable carrier going to the front right corner of the work volume.

At several early builders' suggestion (e.g., Ben Jackson, Bill Meade) he made the design reversible. The carrier can go either to the front right or the back right corner..

The fixed end of the carrier bolts onto the bottom skin. (That's what I thought I remembered.) There are supposed to be attachment holes both at the front and at the back of the skin. Last night I turned my chassis over and looked for holes in the bottom skin. I did not see any holes at all. I'll double-check next time I'm at the maker space, but I think I'll be drilling new holes. No big deal.

Both sets of holes are clearly present in the drawings. And I'm pretty sure I oriented the bottom skin correctly because the holes marked A and B line up.

Detail from C51004 rev 7

Once the Y carrier is installed, I will run the following items through it.

• Air hose
• X motor power: 4 conductors, high current
• X min limit switch: 2 conductors, low current
• Y max limit switch: 2 conductors, low current
• LED strip (see below): 2 conductors, high-ish current plus 2 conductors, low current

That's a total of 6 conductors high current, 6 conductors low current, and a hose. The carrier will be kind of full.

LED strip? Yes. I'm getting old and blind, so I'd like to have a good light on the work piece. I bought a strip of RGB LEDs which I intend to glue onto the bottom surface of the gantry. I got RGB LEDs, individually addressible, so I'll have yet another software project to play with. At first, I'll just switch them on and leave them on, full brightness. But I have a few ideas for lighting games. The gantry is long enough for 22 LEDs at 60 mA each, so 1.3 A total. A total of four wires is needed, but the other two wires just have to carry a data signal to switch the LEDs.

Here is where I have to ask for advice. Do these wires need to be shielded? Do they need to be twisted pairs?

I thought that for the limit switches, I could just run a 4 conductor ribbon cable. It would bend very well and not take up much space in the carrier. But maybe ribbon cable will pick up too much noise?

The serial signal for the LEDs is more interesting. It's also a 5V low current signal, but it's fairly high speed. (Could be up to 2 MHz; could be lower.) So what do I need? Can I add them to the ribbon cable?

And the motors. Design current is 1.68A. Max voltage is 24V. Full step sine waves could be as high as 30 KHz, but that's probably beyond the motor's mechanical limits. The microstep frequency would be 16× higher, or 480 KHz. Does that need to be shielded? Twisted? Other?

I have some Molex Micro-Fit connectors for the high current leads. I'm thinking about mounting a tiny PC board or perf board on the end of the gantry so all the wires can unplug for disassembly. Any reason that's a bad idea?

I have to decide which way to mount the Y carrier, too.

I'm thinking the most important factor will be electrical noise from the laser and its power supply. If I make an upper shelf of ferrous metal for the power supply and ground it, that should help a lot. The positive lead could be very short, maybe a couple of inches. But the negative lead will run the length of the laser tube and wll be a big antenna in the back of the box. So I'm thinking the front of the box will be less noisy. (But I am not an EE. Is this a valid line of thought?)

If I use the original configuration, loop at the rear, exit toward the front, then I can put the electronics in the front of the box, but the signals to the gantry will be fairly close to the tube. I will also have to run cables for externally accessible Ethernet, USB, or SD card to the back panel. (Maybe USB and SD should be on the front panel?)

If I use the alternate configuration, loop at the front, exit toward the rear, then the controllers will be at the rear where it is noisier, and if I install USB or SD, I'll have to run long cables to the front.

The air hose just doesn't matter. I'm planning to put the air pump wherever it fits inside the chassis and run a second line to the grommet on the back. The line will just stop at the grommet.

I have a feeling I'm overanalyzing this. Is electrical noise a serious concern or will good cabling practice make it irrelevant?
Bob
"If you didn't code it, it will never own you." (-:
kbob

Posts: 147
Joined: Mon Jul 09, 2012 6:39 am
Location: Eugene, OR, US

### Re: 2.x for kbob's maker space

Good cabling practice would be to keep the low-voltage digital stuff (limit switches, LED data, and even LED strip power) well away from the stepper wires...

That not being a choice, you could do some of the following:
• Reduce the impedance of the limit switches. Either use ridiculously low pull-up resistors (e.g. 220 ohm), or, even better, have the microswitch changeover from VDD to GND and input into a low-impedance Schmitt trigger (for instance, a CD4050B or 74HC244 with 470 ohm resistors between the input and the output of each buffer). I'm about to do the latter for my milling machine/3D printer. In theory, it should also completely eliminate bouncing.
• Reduce the impedance of the LED data lines. That is simply a matter of using a hefty buffer (e.g. the CD4050B with three buffers in parallel for each line).
• Decouple the LED power supply at both ends with ceramic capacitors.
• Use twisted pairs for the motor (one pair for each coil); you can twist it yourself, it doesn't have to be a pre-made cable.
• Shield the motor cable and the low-voltage stuff, although that's a last-resort solution because it makes the cables bulkier and stiffer, and unlikely to be necessary.
cvoinescu

Posts: 442
Joined: Thu Aug 09, 2012 9:12 am
Location: Camberley, Surrey, UK

### Re: 2.x for kbob's maker space

cvoinescu wrote:Good cabling practice would be to keep the low-voltage digital stuff (limit switches, LED data, and even LED strip power) well away from the stepper wires...

That not being a choice, you could do some of the following:
• Reduce the impedance of the limit switches. Either use ridiculously low pull-up resistors (e.g. 220 ohm), or, even better, have the microswitch changeover from VDD to GND and input into a low-impedance Schmitt trigger (for instance, a CD4050B or 74HC244 with 470 ohm resistors between the input and the output of each buffer). I'm about to do the latter for my milling machine/3D printer. In theory, it should also completely eliminate bouncing.
• Reduce the impedance of the LED data lines. That is simply a matter of using a hefty buffer (e.g. the CD4050B with three buffers in parallel for each line).
• Decouple the LED power supply at both ends with ceramic capacitors.
• Use twisted pairs for the motor (one pair for each coil); you can twist it yourself, it doesn't have to be a pre-made cable.
• Shield the motor cable and the low-voltage stuff, although that's a last-resort solution because it makes the cables bulkier and stiffer, and unlikely to be necessary.

Thank you. Now I have things to try. I will do the low-Z pull-up resistors and ceramic caps on the LED strip initially, then if I see issues that could be noise-attributed, I'll do more.

So are we supposed to ground the gantry?
Bob
"If you didn't code it, it will never own you." (-:
kbob

Posts: 147
Joined: Mon Jul 09, 2012 6:39 am
Location: Eugene, OR, US

PreviousNext