Jump to content
OMRON Forums

Pulse Generator for User-Written Servo Code


Recommended Posts

I need help with writing a pulse generator that will run in a user-written servo code routine that I'm working on.


The generator needs to allow Pulse Width Modulation (PWM) at a constant frequency (1kHz) and a variable duty cycle that can be set from 0% to 100%


0% would disable the Pulse and 100% would be full signal




Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Does this have to be generated through user-written servo code? It would be easier and have less jitter to use a PWM channel on an ACC-24E3 or similar Gate3-style axis interface. There are built-in structures for PWM signal generation -- see the Power SRM under Gate3.


You can also do this through the EQU output on a Gate1 or Gate3 chip using a virtual motor, in case your PWM channels are consumed, that would be more precise than servo code -- I believe there are some application notes on that in FileDepot showing how to do this.

Link to comment
Share on other sites

To do this in software, you would have to run your code at 20 kHz to have 5% resolution at 1 kHz. If you don't want to run your servo interrupt that fast, you might want to run your phase clock at 20 kHz (servo clock slower) and use a custom phase algorithm, probably for Motor 0. This algorithm would be very simple, and could take a commanded duty cycle from a lower-frequency routine.


If you have a Gate3 chip, you could use the PFM output to do this. You would fix the channel's Pfm (frequency) command to get a 1 kHz output, then you would vary the channel's PfmWidth to vary the duty cycle. At the default Pfm clock frequency, you would vary PfmWidth from 0 to 3125 for 0% to 100%.

Link to comment
Share on other sites



Thanks for the replies.... Your input is invaluable.


Unfortunately, I'm not familiar enough with Delta Tau and the method you are describing, to set it up and program without more detailed instruction. Do you have a good example that I can use?


Also, I'm not sure about the Gate3 chip. Where would I look?


Here is the list of hardware that I'm using


Link to comment
Share on other sites

You have an ACC-24E2x axis card, not an ACC-24E3 axis card, so you do NOT have a "Gate3" ASIC. The ASIC in your card can only provide a maximum 50% on-time duty cycle with its PFM circuit, so that is not an option.


It is possible to use a PWM output from one of your ASIC channels, but if you set your PWM frequency to 1 kHz, your maximum phase and servo update frequencies will be 2 kHz, which is probably too slow.


So I think your best option is the "fast software" option. To get your 5% resolution, you need to run your software at 20 kHz. This is done by the proper settings of Gate1.PwmPeriod and Gate1.PhaseClockDiv to obtain a 20 kHz phase update frequency (50 usec period). Your servo update frequency is divided down from this using Gate1.ServoClockDiv.


Once you have this set up, you should write a "custom phase" algorithm in C for Motor 0 to control the output (assuming you have no "real" Motor 0). It should only need to be about 5 or 6 lines long (assuming some other routine determines the desired duty cycle). Set Motor[0].PhaseCtrl to 1 to activate this.

Link to comment
Share on other sites

This topic is now closed to further replies.

  • Create New...