Automatic motor tuner (Newbie)
mnemonics
Posts: 23
Hello all, I am new to spin and I am trying to come up with an automatic motor tuner code but don't know where to start..
I wanted to increment frequencies starting from 1 hz and up to it reaches max current. I was going to use the Sigma/Delta A/D code but dont know if it will be better than using the ADC0831 or the MCP3208.
Then I read that the MCP3208 is better and easier to implement than the ADC0831 because I would have to add components to that chip to make it work with the Prop . The current sensor I am using is an ACS712ELCTR-30A which puts out about .66mA per Amp. I was planning on incrementing the output freq and or maybe use PWM to look for the max val and set it there.
. I wanted the prop to ramp up from zero and look for the most efficient setting and lock on to it. I looked at a lot of demo codes and was planning on using the MCP3208 code to do the A/D conversion but I dont know how to start or how to make the prop start the Freq out and look at the MCP3208 max Val and set it there.
I am going to use the LCD Obj code to look at what it did and display it to my LCD. I think I can tie the rest of it together or I will try too, but dont know how to start the freq out or the PWM out and increment it . I looked at the incrementunitlcondition Obj and ButtonShiftSpeed.spin I can get an LED light to increment the pulses but I have it set up to look at a button and stop incrementing when it the button goes high. Thats about as far as I got. I have a Prop Demo Board and a Quick Start board but most of the code samples are for the BOE . Thanks in advance..
Comments
conversion is a separate issue. The Prop counter units do DDS for you for free in steps of 0.0186265 Hz (assuming
80MHz system clock).
I know from experience different motor controllers do well at different PWM frequencies.
I think I posted a version of my PWM and encoder software which allows one to adjust the PWM frequency on the fly in this thread. The PWM generation doesn't use the counters so you wouldn't be able to use it at very high frequencies.
I'm using a MCP3208 with the MC33926 motor controller to monitor current levels. The MCP3208 can be used with the Propeller just fine. If you use the MCP3208 at 5V you'll want to include a 10K ohm resistor between the chip's output and the Prop to protect the Prop from the 5V logic level. The MCP3208 can also be powered by 3.3V in which case you wouldn't need to worry about the logic differences.
Thanks for the reply Mark and Duane
I am using a Mosfet to drive the motor and not going through a MC33926. Also it wont be at high frequencies either or at least I dont think it will get high. I figured out how to set up the pins finally and I have the code working and the debug terminal but I am trying to flash an LED on pin 16 and the LED wont flash. The code by itself will increment pulses if the input goes high or decrement when low on pin 1. But when I pasted the code together the led does not work. Do I need to use another cog and if so how do I turn on another cog to run that piece of code? Eventually I think I can use JM piece of code to scale the A/D and then use the value to increment or decrement by itself but I cant get past the LED just flashing right now. I only started with Spin a few weeks ago. Thanks..MCP3208_With Diagramand Debug terminal (1).spin
There are tutorials inside the Propeller Tool's help menu. If you work through the Propeller Education Kit (available in help menu) it will explain about running a method in a new cog.
In order to post code to the forum you need to use code tags (not quotes).
Here's a link to a tutorial on posting code.
There's also an appnote on starting new cogs. Unfortunately there was a bug in the code. Hopefully Parallax has fixed the bug. I couldn't find the appnote I was thinking of but #11 does show how to use cognew.
What kind or type of motor are you using?
Is it a stepper motor?
or is it a
Permanent magnet DC motor?
Duane J