Forum Discussion
12 Replies
- Altera_Forum
Honored Contributor
What kind of motor? (stepper, DC, ....)
What kind of control for motor driver? (pulse, pwm, analog, ... ) - Altera_Forum
Honored Contributor
--- Quote Start --- What kind of motor? (stepper, DC, ....) What kind of control for motor driver? (pulse, pwm, analog, ... ) --- Quote End --- Hi Cris72, I plan to use DC motor and pwm as a driver. Can u give an idea? - Altera_Forum
Honored Contributor
If you are only supposed to generate a pwm signal for open loop drive control, it's an easy task with fpga.
You basically need a counter+comparator and possibly some extra logic for setting the pwm level. Whiile if you want a complete closed loop controller, your system must provide some sort of feedback signals in order to adjust the pwm level in real-time. - Altera_Forum
Honored Contributor
--- Quote Start --- If you are only supposed to generate a pwm signal for open loop drive control, it's an easy task with fpga. You basically need a counter+comparator and possibly some extra logic for setting the pwm level. Whiile if you want a complete closed loop controller, your system must provide some sort of feedback signals in order to adjust the pwm level in real-time. --- Quote End --- I have some different opinion about this. If the stepper motor controler is supposed with PWM,the stepper motor's speed is relation with the pwm's frequency.That is to say,if I want to get the variable stepper motor speed,I should get variable frequency of pwm. If the input frequency of FPGA is 50MHz,using the counter++,may get those frequency,like 25MHz,12.5MHz,6.25Mhz,....and so on. But,there is some frequency can no be reached,like 20MHz,or 999999Hz. I do not kown how to deel with this. Do you have any opinion about those? - Altera_Forum
Honored Contributor
--- Quote Start --- I have some different opinion about this. If the stepper motor controler is supposed with PWM,the stepper motor's speed is relation with the pwm's frequency.That is to say,if I want to get the variable stepper motor speed,I should get variable frequency of pwm. If the input frequency of FPGA is 50MHz,using the counter++,may get those frequency,like 25MHz,12.5MHz,6.25Mhz,....and so on. But,there is some frequency can no be reached,like 20MHz,or 999999Hz. I do not kown how to deel with this. Do you have any opinion about those? --- Quote End --- generate clock enable using modulo accumulator. add your word non-stop. then at overflow generate a pulse The equation for frequency becomes: f = clk speed * accum word value/accum resolution e.g. if accum is 32 bits and word is 2^30 and clock is 50MHz then: f = 50 * 2^30/2^32 = 50/4 Mhz - Altera_Forum
Honored Contributor
--- Quote Start --- generate clock enable using modulo accumulator. add your word non-stop. then at overflow generate a pulse The equation for frequency becomes: f = clk speed * accum word value/accum resolution e.g. if accum is 32 bits and word is 2^30 and clock is 50MHz then: f = 50 * 2^30/2^32 = 50/4 Mhz --- Quote End --- I konw what you mean. e.g. if accum is 32 bits and word is 2^30 and clock is 50MHz then: f = 50 * 2^30/2^32 = 50/4 Mhz.I can get 12.5Mhz frequency pwm,this is surely. But if I want to get stable frequency of 12.4Mhz,or 12.6MHz,this way can not work. - Altera_Forum
Honored Contributor
There's another way to generate a frequency with a (almost) continous range.
You must use an adder with an overflow detector. The registered adder output is fed back to one of the inputs, while the second input is a value proportional to the desired frequency. For example, let's suppose a 32bit wide adder, with inputs A and B and output (registered) Q. Let P be the overflow output. You connect Q back to A. At each clock pulse you have Q = Q + B, then the overflow pulse is generated every 2^32 / B clocks. In other words, the frequency of P signal is Fclock x B / 2^32 which can be modulated with a good resolution, provided you don't get too close to Fclock. This is easy, if you only need a frequency synthesizer. Generating the actual pwm could be more tricky, especially if you need an exact duty cycle rather than fixed width pulses, - Altera_Forum
Honored Contributor
Oops, Sorry. I didn't see you had already got an answer
- Altera_Forum
Honored Contributor
--- Quote Start --- I konw what you mean. e.g. if accum is 32 bits and word is 2^30 and clock is 50MHz then: f = 50 * 2^30/2^32 = 50/4 Mhz.I can get 12.5Mhz frequency pwm,this is surely. But if I want to get stable frequency of 12.4Mhz,or 12.6MHz,this way can not work. --- Quote End --- you will get any frequency. In many cases the exact pulse frequency wouldn't be as a clean clock but over a window of time it will be correct and for stepper motor it should be more than enough. example 50MHz * 2333456/2^32 = ? Anyway from 50MHz you cannot get exact frequencies except for cases like half/quarter etc unless you use variable analogue PLL - Altera_Forum
Honored Contributor
--- Quote Start --- There's another way to generate a frequency with a (almost) continous range. You must use an adder with an overflow detector. The registered adder output is fed back to one of the inputs, while the second input is a value proportional to the desired frequency. For example, let's suppose a 32bit wide adder, with inputs A and B and output (registered) Q. Let P be the overflow output. You connect Q back to A. At each clock pulse you have Q = Q + B, then the overflow pulse is generated every 2^32 / B clocks. In other words, the frequency of P signal is Fclock x B / 2^32 which can be modulated with a good resolution, provided you don't get too close to Fclock. This is easy, if you only need a frequency synthesizer. Generating the actual pwm could be more tricky, especially if you need an exact duty cycle rather than fixed width pulses, --- Quote End --- Yes,maybe my expression is wrong. In fact,I need generate fixed width pulses. Your reply seems feasible.I will try it.