NEWS
LinuxCNC 2.5.2 Release
There are no translations available.

LinuxCNC 2.5.2 Update Released (changelog).
 
LinuxCNC 2.5.1 Release
There are no translations available.

LinuxCNC 2.5.1 Update Released (changelog). If the Package Manager does not prompt you to upgrade see this page.

 
LinuxCNC 2.5.0 Release
There are no translations available.

New major release (changelog). See the instructions to update your system from EMC 2.4 to LinuxCNC 2.5.
 

Welcome, Guest
Username: Password: Remember me
Forum Header

TOPIC: PWM not quite working

Re:PWM not quite working 03 Ноя 2011 03:25 #14539

  • jpka
  • jpka's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 40
  • Thank you received: 2
  • Karma: 3
This example contains some timings like
loadrt threads name1=fast period1=10000 name2=slow period2=1000000 # fast period of
    # 10000 gives 1 degree per period, or 1 degree resolution, but many PC's may
    # crash with this setting. 20000 gives 2 degrees per fast period, or 2 degree resolution.
...but it looks that, if i use it, then other than PWM stops to work in EMC?...
The administrator has disabled public write access.

Re:PWM not quite working 03 Ноя 2011 03:50 #14540

  • andypugh
  • andypugh's Avatar
  • OFFLINE
  • Moderator
  • Posts: 4136
  • Thank you received: 141
  • Karma: 130
jpka wrote:
In other words, it looks that main clock frequency of the PWM generator is too low.
Can it be as high as at least 20 kHz?

That depends on your PC. if you have a base_period of 25,000nS then the PWM base frequency is 40kHz, so you can get the resolution you want.

What base period do you have (it is in your INI file) and what is your latency test result?

If you want a 1% resolution in 0.5mS pulse width then I think you need 200kHz, and you are never going to get that with software step generation.
A 16-bit hardware PWM should have no problems, you get 15nS resolution on a 1mS base frequency. You could use a Mesa card (but they cost money) or perhaps set up a microcontroller (an Arduino is easy to use) which measures an incoming 0-100% duty cycle PWM and outputs a 0-0.2% duty cycle.
The administrator has disabled public write access.

Re:PWM not quite working 03 Ноя 2011 09:20 #14554

  • jpka
  • jpka's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 40
  • Thank you received: 2
  • Karma: 3
So i now understand why people uses microcontroller here, instead of cheap DIY-like glueless connect :-)
What base period do you have (it is in your INI file) and what is your latency test result?
Max jitter, ns, Servo thread: ~9000; Base thread: ~7000.
What base period do you have (it is in your INI file)
BASE_PERIOD = 100000
SERVO_PERIOD = 1000000

I also set 'Base period maximum jitter' in StepconfWizard to 10K instead of default 15K. (This lead to very rare 'unexpected realtime problems')
So i get some useful results. While step tune is still too coarse, hopefully my aircraft ESC have ability to use entire 1...2 mS range to drive in only one direction, in compare to 1.5...2mS default / typical, but i think it is quite non-standard. (maybe it standard for aircraft but not car ESCs, because aircrafts never use reverse :P )
(my esc is 'TUR 150A Brushless Motor Speed Controller RC ESC BEC' from Ebay). It is gluelessly connects to LPT port. So this setup can be useful in real life.
My PWM settings are:
PWM Rate  100
Speed1 0
Speed2 1000
PWM1 0.1
PWM2 0.2
and removed 'setp pwmgen.0.dither-pwm true' from .hal file.
I also attach waveforms taken from Xoscope via line input sound card directly connected to PWM input of ESC. At left is EMC out, at right is signal taken from small RC car.
Note the overrun pulse lengths which occurs if i press '+' spindle speed in Axis GUI more than 10 times.

Hope it helps someone who try to use brushless motor! :-)
You could use a Mesa card (but they cost money) or perhaps set up a microcontroller
I try to use in future some ATtiny's i have.
Last Edit: 03 Ноя 2011 09:21 by jpka. Reason: add image
The administrator has disabled public write access.

Re:PWM not quite working 28 Фев 2012 14:00 #18186

Did anyone get this to work with an RC ESC? I'm trying to set one up and am not sure what goes where.

I added this to the HAL file
loadrt pwmgen output_type=0
addf pwmgen.update servo-thread
addf pwmgen.make-pulses base-thread
net spindle-cmd <= motion.spindle-speed-out => pwmgen.0.value
net spindle-enable <= motion.spindle-on => pwmgen.0.enable
net spindle-pwm <= pwmgen.0.pwm
setp  pwmgen.0.min-dc 0.06 #0.0625=1.25ms/20ms frame (Castle Creations ESC fixed endpoint off value)
setp  pwmgen.0.max-dc 0.091 #0.091=1.8ms/20ms frame (Castle Creations ESC fixed endpoint on value)
setp pwmgen.0.pwm-freq 50.0
setp pwmgen.0.scale 30000.0
setp pwmgen.0.offset 0.0
setp parport.1.pin-01-out-invert 1
net spindle-pwm => parport.1.pin-08-out

This is on my 2.2.8 machine. This gives me the expected 1-2ms pulse range required by the RC hobby ESC (Electronic Speed Control). The problem is with scaling. It gives me a nice proportional increase in pulse width, except it reaches full pulse width at S3000, not the expcted S30000. I could actually live with this if I remember to program my spindle speed at 1/10th the required value. I really only will operate at 10-30kRPM. It's probably not linear,but I didn't check. Actually, thinking it over this is how the scaling is designed to work. Too bad the scale can't be applied between the pwm limits.

I still need to initialize the ESC manually by turning it on in Axis GUI. It looks like it's possible to just leave pwngen running all the time? other wise I was thinking about using spindle soft start to pass through the initializing PWM range. The tip from another thread doesn't give the desired result. It gives an error saying the axis pin is already assigned when it gets to initailizing the axis.

Greg
The administrator has disabled public write access.

Re:PWM not quite working 29 Фев 2012 06:32 #18204

  • jpka
  • jpka's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 40
  • Thank you received: 2
  • Karma: 3
Hi! Maybe you can try to play with 'Speed2 (1000)' parameter in Stepconf Wizard, it exist in PWM setting of it, to obtain correct scaling.
The administrator has disabled public write access.

Re:PWM not quite working 29 Фев 2012 07:05 #18206

I'm fairly certain "Speed 2" defines pwmgen.0.scale. What does "Speed 1" look like in the HAL file?

In the Hal manual it says PWM = (value/scale)+offset. that is (commanded RPM / maximum RPM)+offset in ms. Then the PWM limits are applied. So in my case 3,000/30,000=0.1, and 0.1 is the ~maximum pulse width available. If the available PWM range was scaled, that would be great. Of course, a $35 gadget gets around this, but money is tight. Here's my spindle. I have plenty of RC controllers so it would be nice to use one if possible. I hope to actually test it on the machine today.

Greg
The administrator has disabled public write access.
Time to create page: 0.954 seconds
Powered by Kunena Forum
© 2013 LinuxCNC.org
Joomla! is Free Software released under the GNU General Public License.