This begins phase two of the project – the software. Actually, I’ve been working on the software on and off for a few weeks, but I haven’t had anything to test it on until now.
I wrote the motor control and current measurement routines using samples from NI and modified them based on several discussions on the NI forums. It is fairly simple – output a pulse width modulated signal, avoid a few specific duty cycles, and measure the current at the best point in the cycle. The trick is figuring out the best time in the cycle to read the current so that it represents the average current for the cycle.
My first test was running the motor at different duty cycles, making sure it works, and seeing if the current measurements look reasonable. I propped up the cart so the gear doesn’t engage with the rack. I tried several speeds, and the motor runs great. At low speeds, the gears don’t make any noise at all. At high speeds, they make a little noise as they mesh. The current measurement is kind of weird, though. At any duty cycle over 5 percent, the current reads about 10-20 units, which is about what you expect when there is no load other than motor friction. However, under 5 percent the current reads around 600 units, which is ridiculously large. I suspect I am reading a peak value and should read some other time in the cycle. My plan is to write a routine that will sample the current at a different time in the duty cycle each time through the loop. I should be able to build a complete current waveform after many loops at constant speed. It may not be perfect, but it will give me an idea of what is going on with the current and when the best time to measure it is.
I did run the cart back and forth on the rack a few times at different speeds. It works great at low and medium speeds, but I don’t dare run it at high speeds until I have the limit switches ready to stop it before it hits the ends. The travel is nice and smooth, so I don’t expect any problems in that area.