we try to use the software PWM on the SCM20260D Dev board.
As soon as we use a PWM frequency below 16Hz an exception is thrown.
We need a frequency of 1 Hz for our project. The minimum frequency shown on the “pwm-controller” is 7.4109846876187E-323.
What GpioPin are you using? Your code should contain something like this
var softwarePwmController = PwmController.FromName(SC20260.Timer.Pwm.Software.Id);
var pwmPinPB3 = softwarePwmController.OpenChannel(SC20260.GpioPin.PB3);
One cycle per second? Do you even need the pwm class? If the rate is that slow and if you can tolerate duty-cycle jitter on the scale of a handful of mS, then can’t you just use do this directly in C# code (a loop in a thread for instance that toggles the GPIO line).
The “slow” PWM is used as a puls-packet to control a triac with a maximum on-time of 1 second.
Less puls duration will lower the engergy of an heating element. With this idea we could vary the power between 0…100% every second.
This is a common way in injection molding (Hot runner technology)
Still certainly sounds like something you could do in managed code - doesn’t need the PWM native code which is designed for higher pulse rates and more accurate timing. mS accuracy is still .1% accuracy over the span of a second. Even your temp feedback readings probably aren’t that accurate.
Of course, whether you use the native support or spin your own managed code, hopefully your hardware protects against runaway ‘on’ conditions.
Background:
The 1 second is typically started with a zero crossing of the phase. Then the duration is varied and ends again with another zero crossing. (to reduce EMI)
This is done for up to (for this Project/Test) 16 Channels.
Each channel is controlled by its own pid controller reading thermocouple values and so on.
This type of control has been practiced with great success for years (PIC Controller C++).
Now we try to implement this with C# on GHI hardware.
I’ve found a software PWM snippet from the old GHI site code share library. It’s targeting NETMF but with small change you can make it work with TinyCLR.