Best Answer Chris Walker, 28 February 2013 - 11:03 PM
Hi Jeroen, If you add the following line to your code, you should be good to go
PWMspeedFwd.Start();Does that get your PWM running? Chris Go to the full post
  | ||||||||||||||
PWM usage in custom class
Started by JR.NET, Feb 28 2013 09:47 PM
Best Answer Chris Walker, 28 February 2013 - 11:03 PM Hi Jeroen, If you add the following line to your code, you should be good to go PWMspeedFwd.Start();Does that get your PWM running? Chris Go to the full post
3 replies to this topic
#1Posted 28 February 2013 - 09:47 PM Hello,
I have a Netduino plus 2 and I am making a motor controller with it
I have a class with the folowing constructor:
# region MotorControl Constructor public MotorControl(Cpu.PWMChannel pwmpinleft ,Cpu.PWMChannel pwmpinright, Cpu.Pin releasecontroller, Cpu.AnalogChannel analogpin, Cpu.Pin rpmpin, int mvToma, string name) { Debug.Print("New controller motor instance created."); PWMspeedFwd = new PWM(pwmpinleft, PWMFrequency, CurrentPWMFwd, false); PWMspeedRev = new PWM(pwmpinright, PWMFrequency, CurrentPWMRev, false); ReleaseController = new OutputPort(releasecontroller,true); Debug.Print("PWM and release ports created.");
The class is created using the following line:
/// <summary> /// Left UGV motor /// </summary> public static MotorControl motorleft = new MotorControl(PWMChannels.PWM_PIN_D5, PWMChannels.PWM_PIN_D6, Pins.GPIO_PIN_D0, Cpu.AnalogChannel.ANALOG_0, Cpu.Pin.GPIO_Pin15, 20, "Motorleft");
However, it looks like the pwm pins are not initialized? When I want to measure the signal using a scope I get no signal.
Do I initialize the PWM pins the correct way?
I set PWM values using the following code:
PWMspeedFwd.DutyCycle = i;
With i varying between 0 and 1. Is this correct or should it be between 0 and 100 %?
Thanks in advance and with best regards,
Jeroen. #2Posted 28 February 2013 - 10:53 PM
Haven't used PWM much myself but I remember reading something lately about issues with initializers of static variables - are you seeing the dubug messages?
#3Posted 28 February 2013 - 11:03 PM Best Answer
Hi Jeroen,
If you add the following line to your code, you should be good to go
PWMspeedFwd.Start();Does that get your PWM running? Chris #4Posted 01 March 2013 - 08:55 PM Thanks, that solved the problem 0 user(s) are reading this topic0 members, 0 guests, 0 anonymous users | ||||||||||||||
|
||||||||||||||
This webpage is licensed under a Creative Commons Attribution-ShareAlike License. | ||||||||||||||