# Variable pulse train generation

I need to generate a pulse train with 12 bit resolution, controlled by an MCU.

The duty cycle can be in the range of 30 - 40%, while the frequency (0.5 - 32 kHz) is what needs controlling with 12-bit resolution.

The pulse train is to be used to control a Yaskawa Inverter which appears to operate under these parameters.

I think I have several options:

1. Find a chip that will generate this for me (controlled via SPI, I2C, etc).

2. Use a pulse generator like the 555, and find someway to vary the frequency using an output from the MCU - perhaps using the output from a DAC.

What is best way to do this?

• Please explain what characteristics of the signal you want to be fixed and what characteristic you wish to vary with 12-bit resolution. Frequency? Duty factor? Also, what is the range of frequencies you need to produce? How precisely do you need to maintain the frequency or duty factor? Commented May 2, 2019 at 19:37
• Your question is missing details such as the frequency, voltage, etc. Can we also presume that you mean that the pulse-width should be adjustable with 12-bit resolution? A 555 will not be suitable. Commented May 2, 2019 at 19:38
• Please see update Commented May 2, 2019 at 19:43
• I don't think you've thought this through yet. 12-bit is 4096 steps. 32 kHz / 4096 = 7.8 Hz per step. So the first two steps will be 0.5 and 8.3 Hz. Is that really what you want? I think another edit with some context is in order. Commented May 2, 2019 at 19:48
• @Transistor, not sure why that would be a problem? Could you elaborate please Commented May 2, 2019 at 19:51

Figure 1. The inverter provides several external speed control options.

You are not constrained to 32 kHz. Page 112 shows that the max pulse frequency can be set parameter H6-02 at anywhere between 1 kHz to 32 kHz (and as low as 100 Hz on some models). Setting a lower frequency may simplify the microcontroller requirements.

Your other option is to PWM the A1 or A2 input with a 5 V signal via an RC low-pass filter but set the parameter for the input scaling to twice the maximum speed you want. (This is because your 5 V micro can only give 5 V at 100% PWM into the 0 to 10 V input.)

Any micro with a PWM controller with ≥ 12 bits should be able to do this for you - including d'Arduino.

Note also that there's a Modbus interface so you can probably set and read the speed (and a load of other parameters) on serial comms thereby avoiding any analog circuitry.

• So, let's say that I went with a max frequency of 2khz (I presume control over 0 - 2khz), how would I generate that? Are any of the options in the original question suitable? Commented May 2, 2019 at 20:35
• Did you study the linked article? Commented May 2, 2019 at 21:36
• The one I linked? I read the first paragraph, and this sentence in particular made me realise why one might think the ratio between intervals is important: "In other words, the ratios of the frequencies of any adjacent pair of notes is the same" Commented May 2, 2019 at 21:40
• Are we on the same page now (i.e. have I understood you)? Commented May 2, 2019 at 21:41
• No, I have one link in my answer to the Arduino analogWriteResolution() function which discusses PWM, resolution and gives sample code. Oh - I see we're carrying on two conversations. Yes, the equi-tempered scale would be one example. Commented May 2, 2019 at 21:43