Host Engineering Forum

General Category => General Discussion => Topic started by: Mitch IFM on June 30, 2018, 06:20:37 PM

Title: How to generate PWM from the BRX
Post by: Mitch IFM on June 30, 2018, 06:20:37 PM
After reading the help files etc. I can find no way to establish the parameters for PWM.  I think you have to get to the Heap Item but I'm totally lost.  Which Instruction is used for this purpose??  Not trying to do anything mechanical like axis. Just need a PWM pulse train. Thanks in advance.

Mitch
Title: Re: How to generate PWM from the BRX
Post by: Mike Nash on June 30, 2018, 06:48:40 PM
There is not an instruction for PWM. I would set up the PWM output from Dashboard, click on HSIO on the BRX picture, then choose the Y0 etc, for the output.

Now you use the structure the above selection creates for you as elements in whatever devicename you gave it (say default is PWMOut1) then in your ladder you would enable the output by setting $PWMOut1.EnableOutput true as a coil or set or whatever. The other elements might be a MATH or MOVE to $PWMOut1.DutyCycle.
Title: Re: How to generate PWM from the BRX
Post by: Mitch IFM on June 30, 2018, 06:55:03 PM
Thank you so much Mike!  I will give it a try.
Title: Re: How to generate PWM from the BRX
Post by: BobO on June 30, 2018, 07:00:28 PM
1. Left click on the HSIO tab in the upper left of the CPU in the Dashboard.
2. Select PWM 1, 2, or 3 from the High Speed I/O setup page.
3. Select "Enable PWM" and assign the outputs. Optionally rename the device. Note the Heap Item name, something like $PWMOut1.
4. After accepting the config changes, the system creates the heap item, which is what you use to control the PWM.

There are no instructions associated with the PWM, just the heap item. Set 'EnableOutput' to start it. 'PeriodScale' let's you change the time scale that defines the PWM period between microseconds or milliseconds. 'Period' is the PWM period defined in us or ms. 'DutyCycle' is a floating point value that specifies the duty cycle as a value from 0.0 to 100.0.

Check out help topic DMD0408.