PWN classes after 4.2 firmware upgrade
#1
Posted 22 August 2012 - 12:38 PM
#2
Posted 22 August 2012 - 12:52 PM
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#3
Posted 22 August 2012 - 02:20 PM
#4
Posted 23 August 2012 - 12:58 AM
Thank you again for the quick response.
ciao
Roberto
Hi Roberta,
No worries. This is most likely a mismatch between the beta SDK and the production firmware for NETMF 4.2.
With .NET MF 4.2, you'll need to add the following assembly as a reference to your project:
SecretLabs.NET.Hardware.PWM.dll
Once you do this, update to the Netduino 4.2.0.1 SDK...and you should be good to go!
Chris
#5
Posted 23 August 2012 - 07:45 PM
I have this code, and the behavior is much different.
Namespace Servo_Control Public Class ServoControl Private servo As PWM Public inverted As Boolean = True Public Sub New(ByVal pin As Cpu.Pin, ByVal toInvert As Boolean) inverted = toInvert servo = New PWM(pin) servo.Dispose() End Sub Public Sub ServoToNul() servo.SetDutyCycle(0) End Sub Public Sub DisposeServo() servo.Dispose() End Sub Public WriteOnly Property ServoPulse() As Double Set(ByVal value As Double) ' Range checks' If value > 2000 Then value = 2000 End If If value < 0 Then value = 0 End If ' Are we inverted?' If inverted Then value = 2000 - value End If servo.SetPulse(20000, CUInt(value + 600)) End Set End Property End Class End Namespace
#6
Posted 23 August 2012 - 09:13 PM
But the SecretLabs.NET.Hardware.PWM.dll is NOT compatible with the RC5 ( the version before the official release).
I have this code, and the behavior is much different.
Hi Ellen
The 4.2 release is based on Netmf 4.2 QFE2, where as 4.2 RC5 is based upon netmf 4.2 QFE1, there is considerable differences between QFE1 and QFE2, so unfortunately you cant mix and match, between rc5 and 4.2.
Nak.
#7
Posted 23 August 2012 - 09:50 PM
The behavior _should_ be identical, but it's possible that there are some small differences. Can you please explain a bit more about what is acting differently? We can try to reproduce here, pull it up on an oscilloscope, etc.But the SecretLabs.NET.Hardware.PWM.dll is NOT compatible with the RC5 ( the version before the official release).
I have this code, and the behavior is much different.
Chris
#8
Posted 26 August 2012 - 11:07 AM
I run a small test program with PWM.
/.. SecretLabs.NETMF.Hardware.PWM _pwm = new SecretLabs.NETMF.Hardware.PWM(Pins.GPIO_PIN_D5); uint _period = 1000; uint _duration = 500; _pwm.SetPulse(_period, _duration); ../This works fine so far, except that the period shown on the scope is longer than it should be.
I think it should be 1 ms but I measure a little less than 2 ms.
Any suggestions what the reason can be?
I use the latest 4.2 framework and SDK.
Thank you in advance
Edited by Chris Walker, 26 August 2012 - 02:02 PM.
added [code] tags
#9
Posted 26 August 2012 - 02:04 PM
Can you take a quick photo or screenshot from your oscilloscope? We'd like to try to repro your project here and double-check the results. We want to make sure that PWM periods are as accurate as possible.Any suggestions what the reason can be?
Chris
#10
Posted 26 August 2012 - 03:18 PM
Hi Carlo,
Can you take a quick photo or screenshot from your oscilloscope? We'd like to try to repro your project here and double-check the results. We want to make sure that PWM periods are as accurate as possible.
Chris
Hi,
here it is. It took a little to find the camera, as holidays are over.
;-)
The timebase is 50us, which means that 4 squares are 200us.
Thus the frequency is a little more than 5KHz because it is less than 200us.
As my program has following code:
SecretLabs.NETMF.Hardware.PWM _pwm = new SecretLabs.NETMF.Hardware.PWM(Pins.GPIO_PIN_D5);
uint _period = 100;
uint _duration = 50;
_pwm.SetPulse(_period, _duration);
the scope should show 10KHz.
My frequency counter says it is around 5KHz.
Btw. the duration seems to be a little shorter than 50%.
Carlo
P.S.: Can you delete the photo after looking at, as I want to keep my quota...
#11
Posted 29 August 2012 - 08:14 AM
Did the tests with this servo:
http://www.pieterflo...p?id_product=38
In the earlier version 4.2 QFE(1):
servoWatt.ServoPulse = 0 result: to zero point
servoWatt.ServoPulse = 1000 result: to half way (90 degrees rotation)
servoWatt.ServoPulse = 2000 result: to full (180 degrees rotation)
In latest version 4.2 QFE(2):
servoWatt.ServoPulse = 0 result: to zero point
servoWatt.ServoPulse = 1000 result: to (90+ to 100 degrees rotation)
servoWatt.ServoPulse = 2000 result: back (0 degrees rotation)
Imports Microsoft.SPOT Imports Microsoft.SPOT.Hardware Imports SecretLabs.NETMF.Hardware Imports SecretLabs.NETMF.Hardware.NetduinoPlus Imports SecretLabs.NETMF.Hardware.PWM Module Module1 Sub Main() Dim servoWatt As New Servo_Control.ServoControl(Pins.GPIO_PIN_D9, True) servoWatt.ServoPulse = 0 Thread.Sleep(3000) Debug.Print("0") servoWatt.ServoPulse = 1000 Thread.Sleep(3000) Debug.Print("1000") servoWatt.ServoPulse = 2000 Thread.Sleep(3000) Debug.Print("2000") servoWatt.ServoPulse = 0 Thread.Sleep(3000) Debug.Print("0") End Sub End Module Namespace Servo_Control Public Class ServoControl Private servo As SecretLabs.NETMF.Hardware.PWM Public inverted As Boolean = True Public Sub New(ByVal pin As Cpu.Pin, ByVal toInvert As Boolean) inverted = toInvert servo = New SecretLabs.NETMF.Hardware.PWM(pin) End Sub Public Sub ServoToNul() servo.SetDutyCycle(0) End Sub Public WriteOnly Property ServoPulse() As Double Set(ByVal value As Double) ' Range checks' If value > 2000 Then value = 2000 End If If value < 0 Then value = 0 End If ' Are we inverted?' If inverted Then value = 2000 - value End If servo.SetPulse(20000, CUInt(value + 600)) End Set End Property End Class End Namespace
#12
Posted 02 September 2012 - 07:43 AM
Hi Chris!Hi Carlo,
Can you take a quick photo or screenshot from your oscilloscope? We'd like to try to repro your project here and double-check the results. We want to make sure that PWM periods are as accurate as possible.
Chris
Could you verify my problem on your equipment?
Greetings
Manfred
#13
Posted 03 September 2012 - 06:28 PM
Hi Chris!
Could you verify my problem on your equipment?
Greetings
Manfred
Manfred,
I had to go back to the earlier version 4.2 QFE(1). That release works better and recommend you to do also.
Ellen
#14
Posted 07 September 2012 - 02:10 PM
Ellen,Manfred,
I had to go back to the earlier version 4.2 QFE(1). That release works better and recommend you to do also.
Ellen
How did you succeed in doing that?
I uninstalled both frameworks (QFE2 + Netduino SDK) and installed QFE1 and Netduino Framework.
After that I could not use my old projects because of wrong references. I tried to repair this but with no success.
So I made a new one and it compiled properly, but it could not be deployed because it did not find my netduino.
I uninstalled both and switched back to QFE2. This did not work either.
With mfdeploy I reinstalled the firmware and now my QFE2 - Samples worked again.
The whole mess took quite a lot of time without any result.
I had these problems also with switch from the 4.1 Version to 4.2.
I had to redo the programs all from the scratch. I did not find a way to just upgrade my projects.
Am I stupid??
Manfred
#15
Posted 07 September 2012 - 05:55 PM
#16
Posted 19 September 2012 - 09:14 PM
#17
Posted 20 September 2012 - 07:02 PM
We have fixed the issue and will be posting updated firmware (4.2.0.1) later today.
For those interested...the PWM prescaler on SAM7X is (48MHz / (2^x)). We were calculating it as (48MHz / x). Since this figure is then divided by 48, a prescaler of 1 was driving the PWM clock at 500KHz instead of 1MHz as intended.
Chris
Hi Chris,
With this new PWM class available from 4.2.0, are PWM classes still running at 10KHz? Can I specify a greater frequency using this new PWM constructor overload. For instance, can I specify frequency_Hz parameter something like 1000000 and run a PWM at 1MHz?
public PWM(Cpu.PWMChannel channel, doublefrequency_Hz, double dutyCycle, bool invert);
Sorry, I have no oscilloscope here to check.
Thank you,
Igor.
Igor Kondrasovas
www.inovativatec.com
#18
Posted 20 September 2012 - 07:29 PM
Absolutely. The new PWM classes base everything off of a 1MHz clock so frequency and period are both calculated using microsecond precision.With this new PWM class available from 4.2.0, are PWM classes still running at 10KHz? Can I specify a greater frequency using this new PWM constructor overload. For instance, can I specify frequency_Hz parameter something like 1000000 and run a PWM at 1MHz?
Chris
#19
Posted 20 September 2012 - 07:38 PM
Hi Igor,
Absolutely. The new PWM classes base everything off of a 1MHz clock so frequency and period are both calculated using microsecond precision.
Chris
Great!
I used 1MHz as an example. Can I use the same clock frequency as the micro controller (48 MHz)? Is there any limit?
I have no application for that at the moment. Just trying to answer some questions!
Thank you,
Igor.
Igor Kondrasovas
www.inovativatec.com
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users