PWM USBizi Error

Can anyone tell me why I get a System.ArgumentException error?


using System;

using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

using GHIElectronics.NETMF.Hardware;

namespace IO_Board_Test_PWM
    public class Program
        public static void Main()
                PWM PWM_OUT1 = new PWM((PWM.Pin)USBizi.Pin.IO35);
                PWM_OUT1.SetPulse(15000, 30000);
            catch(Exception e)
                Debug.Print("exception = " + e);

You should use the PWM channel number not the pin number.

Please point at a specific example for the USBizi pwm code or give the line of code. I continue to get the error.

Click on tutorial link on the very top of this page then find PWM

My code:
PWM PWM_OUT1 = new PWM((PWM.Pin)USBizi.Pin.IO35);

Example code:

            PWM servo = new PWM((PWM.Pin)FEZ_Pin.PWM.Di5);

I have tried to use the tutorial. Evidently I have the syntax wrong. I have look extensively a the examples. All I want to know is the line of code for a USBizi pwm! I have wasted half a day on this. I am not a pro, I just need to finish a job for a customer.

Like I mentioned in my first response, use the PWM pin number instead of the io pin number. For example a pin can be IO1234 but the PWM channel is PWM2

Why don’t you take a look at the USBizi manual - you can find that IO35 is known as PWM1, and you can then use PWM.Pin.PWM1.

(and we know you’re under pressure but terse replies don’t tend to get quicker responses)

PWM PWM_OUT1 = new PWM((PWM.Pin)USBizi.Pin.PWM1); does not compile.

PWM PWM_OUT1 = new PWM((PWM.Pin)USBizi.PWM1); does not compile

Apology. Very frustrated.


I wrote the exact definition you needed, but you failed to test it and instead tried two other. Sorry you’re frustrated by that. :wink:

We’re here to help, and we do try - sometimes though there are things you just need to learn by doing (it wrong, and then fixing it). Hope you get your customer’s project done.

As a newbie with GHI products, I have to comment that the naming conventions are often confusing :

  • IO[italic]nn[/italic] of USBizi
  • Di[italic]nn[/italic] of various boards
  • Function specific pins such as PWM[italic]nn[/italic]

So I generally check 2 or 3 itmes between schematics of the Panda II , USBizi manual and GHI definitions to be sure :wink:

And I had to search for datasheet of LPC2388 to know the electrical characteristics of the pin (in/out current) as this was not listed anywhere else (at least I did not found it).


[quote]- IOnn of USBizi

  • Dinn of various boards
  • Function specific pins such as PWMnn
    Don’t be confuse my friend, let me explain

Digital pins are always IOnn on any of our products. But then a board like Panda is made to be pinout compatible with arduino so it has its own pin definition, which goes Dinn to simplify the pin numbers. If you like to just use the IOpin numbers then you can.

Now, that was for digital IOs. For other features such as analog and PWM, you are suppose to use the channel number so if a pin is IO34/An4 then you can use this pin as digital pin with IO34 or use its analog feature as An4.

Hope this clarifies it.