Building an Inverted Pendulum System The Ups and Downs of Defying Gravity…

January 22, 2010

Current spikes smaller

Filed under: Software — Bruce Ammons @ 10:58 pm

I removed the capacitors from the motor and repeated the test.  The current waveform looks better, but it still has spikes.  They are much smaller, but they still make it impossible to measure the current at low duty cycles.

Current waveform, 25 percent duty cycle, no capacitors

Current waveform, 25% duty cycle, no capacitors

The oscillations are much more visible, even though they are the same magnitude as before.  I noticed that the frequency of the oscillations is proportional to the speed of the motor.  They don’t worry me too much at this point.

My big unknown at the moment is how to measure the average current accurately.  My whole control strategy is based on adjusting the duty cycle to control the motor current.  If I can’t measure the current, I’m not sure how I will control the motor.  My only thought at the moment is to perhaps add an inductor to the motor circuit to increase the inductance and smooth out the current waveform.  I have no idea if that would actually work, though.

January 21, 2010

Current spikes

Filed under: Software — Bruce Ammons @ 12:35 pm

I modified the software to sample the current at different offsets from the start of the duty cycle.  After 2000 duty cycles, I get a complete picture of the current waveform over a single duty cycle.  As long as the system is in a steady state, the waveform is quite repeatable.  I used this program to examine the current waveform at different duty cycles and found out why the current measurements are way off during short duty cycles.  Take a look at this graph of the current waveform at 25% duty cycle and no load.

Current waveform, 25% duty cycle, no load

Current waveform, 25% duty cycle, no load

From the graph, I realized there is a large positive current spike when the voltage turns on, and a large negative spike when the voltage turns off.  When the duty cycle is short, the two spikes run together and make it impossible to measure the current during the on cycle.  After studying it for a while, I decided the filtering capacitors I put on the motor terminals are most likely causing the spikes.  There is a large current flow each time a capacitor is charged or discharged.  I am going to try removing the capacitors to see if that improves the current waveform.  It will be a challenge to remove them, though, because when I put them on I wound the wires around the terminals and put a huge blob of solder on them.  I could cut them off easily, but then I wouldn’t be able to put them on again.

January 19, 2010

Software begins

Filed under: Software — Bruce Ammons @ 10:10 pm

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.

« Newer Posts

Powered by WordPress