After running a gamut of tests, I’ve concluded the “drifting” of the position count is actually due to the machine *still moving* when the motors are locked. The movement is ever so slight. Thinking about it though, the only time you would have the motors locked like this, would be at the end of a job, and who cares what the position is then. So I think things are OK and I should do a second revision of the board.
Over the past month, I’ve been able to make what seems like decent progress on the magnetic position sensor.
I was able to implement a simple firmware that would allow me to do some preliminary testing. The firmware interacts with the magnetic sensor over 2 different interfaces. First, the incremental encoder interface, which gives the position information and second, the serial data interface, which gives more detailed sensor data. The encoder pins from the sensor are connected to the hardware decoder pins on the microcontroller. The hardware interface is nice because you don’t really need to write that much code, just check some flags that the hardware sets. Also, the hardware interface provides the option to use a filter on the inputs, which can be nice for noisy signals in “hostile” environments. The incremental encoder interface gives me a pulse every 1.95µm and generates an “index” pulse at every 2mm.
I configured the LEDs on the top of the board to show the current direction and another LED flips on/off every index pulse:
I got the LPC1751 up and running, using the internal 4MHz oscillator, which caused me a little bit of pain but was fairly easy to configure.
I started the migration to the base end of the LPC17xx family with my LPCXpresso 1769 dev board and worked “backwards”. First, I configured a pin to output the CPU clock, so I could use my ‘scope to see what was going on inside the chip. I was seeing a 50MHz waveform and the clock output was being divided by 2, so the CPU clock was 100MHz. Great.
Then, I modified the startup code to disable the “main oscillator” (ie, the external oscillator), enabled the internal oscillator and reconfigured the PLL to run at a slower rate. I used a spreadsheet from NXP that I found somewhere to calculate the correct values for the PLL. I put a copy of it on Google Drive for sharing.
Once I saw the clock output at 25MHz, I knew it should run OK on the 1751, so I went ahead and changed my MCU settings and flashed my board and it worked! Note: There doesn’t seem to be a dedicated clock output pin on the “smaller” 80-pin packages, so I don’t think the 1751 has one! It worked out nicely that I had a higher end model to start from.
Once I had the 1751 chugging along at 50MHz, I was off to the races. I tested out the red/green LED for magnetic field strength and also ran a counting pattern to test the white debug LEDs:
After I had enough of the blinky LEDs, I soldered down the AS5311 magnetic sensor. The chip has two status pins that indicate how “healthy” the magnetic field is around the chip. If the magnetic strip is too far away from the chip, the readings are useless. I wrote some code to read these pins and output the status on the red/green LED, which is working a treat. Next I will interface with the hardware quadrature decoder to take some actual movement measurements.
The boards arrived from OSH Park the other day and look super excellent, as usual. This time around, my order came with a sticker, which I promptly affixed to my oscilloscope.
— bryan_kaminski (@foolingmachine) January 9, 2014
I’m now waiting for a Digi-key order (and a bunch of other lab equipment, actually) to arrive so I can assemble one.
A mini-review of the boards (pictures taken with
a potato an iPhone through a microscope viewfinder):
The soldermask sharpness is excellent, as you can see by the “jagged edge thing” I made. I also “tented” the vias (which just means that soldermask will be applied over the vias). The tenting worked OK, but since the via centers are not plugged, sometimes the soldermask might sluice through the hole. For the most part though, the vias are nicely covered.
While waiting for components/tools/chemicals/whatever, I’ve been playing with the LPCXpresso LPC1769 board, so that I can become familiar with the LPC17xx family of microcontrollers. I have some PWM code up and running to drive the red/green LEDs for the magnetic field strength indicator. I was having trouble getting things up and running with the toolchain, until I said “screw this” and stripped out the LPCXpresso board library and the LPCOpen library, and just used the CMSIS library only. Too much high-level abstraction for me – I need to know the details of what registers do what, so I do not mind digging through the datasheet/user manual to learn how the chip actually works.
Finished up the MagSensor board the other night and sent it off to OSH Park.
Some design notes of (possible?) interest:
- 2-layer boards aren’t really the greatest for establishing uniform ground and power planes. I did a ground pour on the top (red) layer to simulate an unbroken ground plane (Maybe I should have just done a star-ground?). I did try to minimize traces crossing breaks in the “plane”, but it’s pretty hard to avoid entirely (Crossing breaks in the plane = longer current return loop = more EMI issues). I didn’t feel the need to do a ground pour on the bottom layer – not sure if I see a point really.
- The analog section (for the Allegro Hall Effect sensor and Analog-to-Digital converter) has extra filtering on the power rail to keep it clean and an isolated ground pour as well. The “analog” ground can be left unconnected, connected via 0Ω resistor, or connected via ferrite bead to the main “digital” ground. I plan on trying each and seeing what kind of effect it has on A/D readings.
- I got kinda weird with the copper features for the voltage regulator (U2, near reset switch – jagged soldermask). I wanted to use the copper of the PCB to draw heat away from the regulator, so I used a decent amount of pours around the chip. I didn’t do any calculations on power dissipation and generated heat beforehand though, so this is definitely just experimentation. I don’t think my current demands will be high enough to heat up the regulator anyways. We shall see.
- I wanted to see how OSH Park would perform on detailed silkscreen art, so I added a goofy Futurama image along with the Open Source Hardware icon.
I have been very slowly plugging away at the magnetic sensor board.
- Allegro A1318 sensor to detect “raw” magnetic field levels
- Analog Devices ADP3335 3.3V regulator ( ±0.9% accuracy @ 25°C – probably overkill but hey, why not?)
- AMS AS5311 magnetic position sensor
- NXP LPC1751 μController for all the brains behind this thing (I picked this chip because it has a cool sounding quadrature encoder interface!)
- 1 red/green LED for indication
- 4 white LEDs for debug/indication (ooooh, shiney)
- Pin header for I2C or CAN bus, UART
- Reset switch
- SWD/Debug header (I might change this to take up less real estate)
- Various supporting resistors, capacitors for decoupling, filtering, etc.
I should have everything I need in the schematic and layout is mostly finished. I’m not sure what I’m waiting for… (maybe a nifty logo?)
Since last update, I’ve added Improbable Construct’s Dust Shoe adapter. On the other end of the dust shoe, I’ve got a Harbor Freight dust collector to suck up the debris. It’s working well so far – I think I might have to add one of those cyclone collection bins for bigger chips? I’m not sure yet.
Finally figured out which setting in CamBam controls how deep the machine will plunge from “idle” height when going to make a cut. That setting is called “Fast Plunge Height“, for future reference.
While learning, I haven’t really had to mess with setting the machining origin (eg, 0,0) correctly – I’m more concerned about the cut itself and not really *where* the cuts are made at this point. Setting the machining origin and having it relate to a real-world position is next up on my list to figure out.
For the machine itself, the next thing I really need to sort out is a work material clamping system. The temporary clamping system I set up before doesn’t clamp well, gets in the way of the cutter, and is generally not doing me any favors. Priority for sure.
Finally, I am experimenting with adding a magnetic position sensor to my Y-axis. I came across an interesting chip, the Austria Micro AS5311 and I’m currently in the process of creating a breakout/dev board for it.
I’m interested to see how it will perform with my machine.
Well, I set out on a multi-hour adventure to try to tie up some loose ends and get the CNC in a state where I could start to cut some parts. What actually happened is a whole lot of nothing. I managed to take a picture of myself working on the machine:
Anyways, my first goal was to get AutoCAD and CamBam up and running on my laptop. AutoCAD took forever to download and even longer to install. Let it go for some hours while I did other things and still wasn’t finished. Ended up rebooting the computer (Yay, Windows!) and restarting the install. Success. Alright, now I have a software “toolchain” completed – AutoCAD to design, CamBam to convert CAD into GCode, Universal G-Code Sender to send the NC file to GRBL. Next up, I attempted to calibrate the machine.
In a previous post, I mentioned this calibration tutorial. It’s pretty good and describes what you need to do in an easy-to-understand way. I started with my “Y” axis. (ie: The longer one.) My problem, though, is how to make precise measurements across 700mm of travel! My plan? Drill holes every 140mm and put dowels in the holes. Then, take a digital caliper and add up the distances between dowels (don’t forget to include dowel diameter!). I got the idea from this blog post. I had a some problems with this method, though. First, I didn’t have any dowels that fit into the 1/4″ holes I drilled with the router bit. Me so genius. So I decided to use some 1/4″ bolts I had lying around. This is a pretty bad idea, because the threads of the bolts make it hard to measure accurately. On top of it, they didn’t even fit snugly into the hole, so they wobbled around. I decided to forge on and see what would come of it. I told the machine to go 700mm, and from my completely BS calculations, I determined it actually went 703.06mm. I recalculated my steps/mm number and put it into GRBL. Time to test!
I didn’t want to drill a bunch of holes and use the calipers again, and I shouldn’t have to really, if my calibration is correct. If told to go 700mm, this time the machine should go 700mm (instead of like 701.181 or something), which I can easily measure with a normal ruler/yardstick. Problem is, I didn’t have one of those either. More genius points awarded. I did find a “sewing tape measure” which did have a centimeter scale on it. I hacked up a pen and put it into the DW660, drew a line, moved the machine +700 in the Y-Axis and drew another line. Then I used the sewing tape to measure. Wow, completely off! Totally worse! Alright, forget this for now, it’s getting late. I reset the steps/mm to the theoretical value and tried to get CamBam to cut a part.
Earlier in the week I drew up some parts to hold limit switches. The part attaches to the motor mount plate and has an adjustable slide so you can change when the switch will hit something and trigger:
So I got this part into CamBam and then goofed with it for 20-30 minutes before I realized I had no clue what I was doing in CamBam and was entirely too tired to actually figure it out properly. At this point, it was about 1AM, so I threw my hands up in the air (appropriately, like I just didn’t care) and shut down CamBam. I ended up cutting some squares in 1/8″ thick acrylic with an 1/8″ end mill by manually jogging the machine around via Universal G-Code Sender. The cuts were OK – kinda rough edges, which probably means I did not use an appropriate feed rate!
Things accomplished: Z-Axis wired up and correct steps/mm setting calculated.
Things not accomplished: Everything else.
To do: Actually calibrate the machine. Get acquainted with CamBam. Research good cutting settings to use for acrylic. Figure out clamping mechanism. Wire up limit switches. Clean up all wiring. Whew.
I got the longer X-Axis belt and installed it, hackily. Again, better belt mounts are needed. Got some 24″x48″ 3/4″ MDF and chopped it down to 24″x36″ and secured it to the table.
Then I did the DW660 tool mod; it’s worth it and takes about 5 minutes. Time to surface that spoilboard, which basically makes the cutting surface level/parallel to the cutting tool.
Things I noted:
I need to learn GCode files better. I tried to make a program file to do all the motions for the surfacing, but the machine kept being goofy about it – it would consistently overrun and smash into the end plates, pretty much ignoring the codes I wrote. WTF! I ended up manually typing in the GCodes to make the machine move, which was super tedious, obviously.
While it was surfacing, I noticed the right end of the gantry was much lower than the left end. (The cuts towards the right end were deeper than the left end, probably 1/8″ or so.)
I’m not sure why really, everything looks pretty straight. I did make sure the tool was level also before cutting. Will have to investigate this further. Maybe my machine is not as square as I thought. Edit: It was pointed out to me that while the tool might be level to earth, the cutting table itself may not be level. Good point.
Hearing protection is a must. My work area is a fairly small, concrete walled room. Sound waves just bounce all over the place. It probably took about an hour to surface the spoilboard and when it was done and I turned the router off, my ears were ringing. Eye protection is probably a good EYE-DEA as well. (Get it?)
I used a Dremel 654 bit and then I killed it about 75% through the surfacing operation. It refused to cut anything. I think it got overheated — it looks charred. Maybe my feed rate was too high?
Luckily, I had a spare which I swapped in and finished the job. It’s probably not the right bit for the job. Proper surfacing bits are not only expensive, but come in shaft sizes (1/2″) not compatible with my DW660. I’ll look into this again when I swap to an actual CNC spindle. The Dremel bit itself doesn’t really surface smoothly either. It’s good enough for learning now though.
Dust, yo! (Please read this in Jesse Pinkman’s voice, thanks.)
Lots of MDF dust everywhere! A vacuum+dust shoe attachment would have been nice. This is definitely something I will have to add to the machine. I had a huge ShopVac running while cutting, but it was large, cumbersome and loud. I would like to get a smaller vacuum that is a little quieter.