Most of the Intel Galileo MRAA examples work on the IOT2020 straight away. So does this PWM example. I've tested this because I need to control the backlight of an LCD display. I want to check if the IOT2020 Supports it. The code is the pure Intel MRAA example, unchanged by me.
SIMATIC's IOT2020 Operating Instructions show the output ins that are PWM capable.
In my project, digital output 3 (X11.4) happens to be a good candidate. I need several output pins to drive the my LCD display, D3 happened to be free and (really, coincidence does happen) the PWM example for this board uses that pin.
The D3 line will drive a transistor in my design. The frequency isn't critical as long as it's higher than our eye's persistence threshold.
The IOT2020's frequency happens to be 200 Hz - well above the flicker frequency of our vision. That's good news: our code will just have to set the duty cycle.
PWM in MRAA codeThe source I use for my MRAA code is Intel's MRAA C++ github. And PWM may be the easiest of all? I just have to set the duty cycle.
mraa::Pwm* pwm;
pwm = new mraa::Pwm(3);
pwm->enable(true);
pwm->write(0.5);
// ...
delete pwm;
The example above sets a duty cycle of 50%. If you use the example from Intel's github I linked below, your IOT2020 will generate a signal at X11 pin 4 that loops a duty cycle from 0 to 100%.
Comments