WiringPi.Net icon indicating copy to clipboard operation
WiringPi.Net copied to clipboard

Soft PWM Support

Open FinalFrontierPrototyping opened this issue 10 years ago • 5 comments

Hello,

I am building a quadcopter using a Raspberry PI and C#. At the moment for I2C communication between my Raspberry PI and MPU9150 (works great).

I would like to add motor control so I would need 4 PWM outputs. Does the wrapper support the Software PWM library (https://projects.drogon.net/raspberry-pi/wiringpi/software-pwm-library)?

If not, will adding this to the wrapper work:

    [DllImport("libwiringPi.so", EntryPoint = "softPwmCreate")]
    public static extern int softPwmCreate(int pin, int initialValue, int pwmRange);

    [DllImport("libwiringPi.so", EntryPoint = "softPwmWrite")]
    public static extern void softPwmWrite(int pin, int value);

It may also be a good idea to add an example of PWM usage to the test console program.

Thanks in advance and with best regards!

Hi, I haven't done any work on this library for over a year. I'm not sure if your additions will work but feel free to try them out. I would suggest you use another method of generating pwm as the library that Gordon wrote uses softpwm and may cause your C# application to run slowly, but having said that it all depends on how much processing power you need from the RasPi.

I'll take a look at this on Saturday if I can, then test it out and report back. I hope you enjoy using the library as much as I did writing it!

Regards, Dan

danriches avatar Jan 15 '15 14:01 danriches

Hey,

are you making progress on this? I cannot get it up and running ... I always get

System.EntryPointNotFoundException: softPwmCreate
  at (wrapper managed-to-native) WiringPi.GPIO:softPwmCreate (int,int,int)

In softPwm.h it says:

extern int  softPwmCreate (int pin, int value, int range) ;

When I searched for the symbol, I get the following output:

nm -A libwiringPi.so | grep softPwmCreate
libwiringPi.so:         U softPwmCreate

Best, David

davidreher avatar Apr 06 '15 18:04 davidreher

Since softPwm is not that complicated I tried to implement it on my own, but now I get

mono: symbol lookup error: /home/osmc/monoLedColor/libwiringPi.so: undefined symbol: softPwmStop

although I am not using softPwm at all ...

davidreher avatar Apr 08 '15 19:04 davidreher

Hello all,

Not sure if this is still supported, but I have install and run according to the readme but I am getting an Unhandled Exception: System.EntryPointFileNotFoundException when running the RunTest methods for all three SPITest methods. I have even tried copying all the files in the same directory as well as using adding the files in a routing path in the app.config with no success. Its rather difficult to debug as I have having to compile the code on a Windows machine and then copy the exe on the my Pi2

Any suggestions would be welcomed. Out of curiosity, why was this project never continued with? Is there a better way of doing this?

Thank you Trev

TrevorNewsome avatar May 01 '17 17:05 TrevorNewsome

Hi Trev, It looks like you don't have Gordon's WiringPi C library installed properly or compiled as a shared object library. The project wasn't continued with as it does exactly what most need it to do. Di you have any other requirements from it?

HTH, Dan

danriches avatar May 04 '17 08:05 danriches