Hey guys im new and just started with .NET Gadgeteer.
I just install the release candidate and got some problems.
If I use the PWM0-PWM7 i got no problems and can easily configure my PWM.
If i use PWM8-PWM15 (PORT7) i get a PWM but i cant configure it.
It is always the same frequency.
Does anybody got a hint for me?
with the second part i can configure the pwm with the first one i cant. Maybe im doing something wrong but it is strange. If i use the first part with PWM0-PWM7 I can configure the PWM.
@ e.trautmann
It seems you are using original io60p16 driver.
How you declared “Extender1” ?
Extender1.WriteRegister(0x18, 7); // Select Port 7
Extender1.WriteRegister(0x1A, 0xff); // all pin as PWM
Extender1.WriteRegister(0x1C, 0x00); // direction as output
Extender1.WriteRegister(0x28, 0x0C); // Select PWM 12 (Port7, bit4)
Extender1.WriteRegister(0x29, 0x04); // Select clock to 1.5Mhz
Extender1.WriteRegister(0x2A, period); // set Period
Extender1.WriteRegister(0x2C, devider); // Divider needed ?
Extender1.WriteRegister(0x2B, pulseWidth); // set Pulsewidth
I don’t see any problem here, except that you need to set Port7 direction bits to output, but it’s output by default. Keep in mind that “drive mode” works also on PWM output pins.
...
pwm = io60p16.CreatePwm(
GTM.GHIElectronics.IO60P16.PwmPin.Pwm12,
400,
200,
PWM.ScaleFactor.Milliseconds,
false
);
Debug.Print("0x1C = " + io60p16.ReadRegister(0x1c).ToString());
pwm.Start();
// Blink an LED.
op15 = io60p16.CreateOutputPort(IOPin.Port0_Pin0, true);
op15.Resistor = ResistorMode.StrongDrive;
var timer = new GT.Timer(1000);
timer.Tick += new GT.Timer.TickEventHandler(timer_Tick);
timer.Start();
return;
...
and it works perfectly. I’ve used 400mS period and 200mS dutycyle (50%) at startup. In the attached image you can see the last blu line labeled PWM12 and see that it works.
The problem is that changing running PWM dutycycle, the driver lack a function that use the same parameters scale like the PWM creation or eventualy a percentage. In any case using
public void SetPwm(byte port, byte pin, uint period_ns, uint pulseWidth_ns)
OMG … Ok something is weird. The Ian’s driver in codeplex works fine. The driver included in the GHI sdk is failing on port 7. I don’t know what they changed inside, but it doesn’t work correctly.
Setting 400ms with 200ms dutycycle (50%) with the GHI included driver I get 8ms period and 4ms dutycycle (50%) but only if I power off the board, otherwise it remains in the last state.
This call has different behaviour in the original Ian’s driver.