Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

PWN classes after 4.2 firmware upgrade


  • Please log in to reply
18 replies to this topic

#1 Noce2k

Noce2k

    New Member

  • Members
  • Pip
  • 5 posts
  • LocationItaly

Posted 22 August 2012 - 12:38 PM

Hi all, I have a simple project to "pulse a led" using PWN classes. it worked with my Netduino plus with framework 4.1. Now I have upgraded the firmware and the project doesn't work anymore. I know that there are some changes in this area and I tried to use the correct old namespace to reuse the code. Anyway i receive this error: "An unhandled exception of type 'System.NotSupportedException' occurred in SecretLabs.NETMF.Hardware.dll" In the attachment you can see my little source code line. any suggestions? thank you Roberto

Attached Files

  • Attached File  pwn.jpg   65.13KB   51 downloads

Powered by Netduino Plus (4.2.0)
---------
http://about.me/noce2k
https://www.rebelmouse.com/noce2k/

#2 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 22 August 2012 - 12:52 PM

Hi Noce2k, Have you also re-installed the Netduino 4.2.0.1 SDK?
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#3 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 22 August 2012 - 02:20 PM

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

#4 Noce2k

Noce2k

    New Member

  • Members
  • Pip
  • 5 posts
  • LocationItaly

Posted 23 August 2012 - 12:58 AM

Many thanks to Stefan and Chris. I re-installed the 4.2.1.0 SDK and followed the suggestions. It works like a charm!

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


Powered by Netduino Plus (4.2.0)
---------
http://about.me/noce2k
https://www.rebelmouse.com/noce2k/

#5 Ellen

Ellen

    Advanced Member

  • Members
  • PipPipPip
  • 65 posts
  • LocationRotterdam, Netherlands

Posted 23 August 2012 - 07:45 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.



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 nakchak

nakchak

    Advanced Member

  • Members
  • PipPipPip
  • 404 posts
  • LocationBristol, UK

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 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 23 August 2012 - 09:50 PM

Hi Ellen,

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.

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.

Chris

#8 Carlo

Carlo

    New Member

  • Members
  • Pip
  • 7 posts

Posted 26 August 2012 - 11:07 AM

Hi to all!
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 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 26 August 2012 - 02:04 PM

Hi Carlo,

Any suggestions what the reason can be?

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

#10 Carlo

Carlo

    New Member

  • Members
  • Pip
  • 7 posts

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 Ellen

Ellen

    Advanced Member

  • Members
  • PipPipPip
  • 65 posts
  • LocationRotterdam, Netherlands

Posted 29 August 2012 - 08:14 AM

This morning I have tested the Servo very good. As i expected as in earlier tests the behavior was different.

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 Carlo

Carlo

    New Member

  • Members
  • Pip
  • 7 posts

Posted 02 September 2012 - 07:43 AM

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 Chris!
Could you verify my problem on your equipment?

Greetings

Manfred

#13 Ellen

Ellen

    Advanced Member

  • Members
  • PipPipPip
  • 65 posts
  • LocationRotterdam, Netherlands

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 Carlo

Carlo

    New Member

  • Members
  • Pip
  • 7 posts

Posted 07 September 2012 - 02:10 PM

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

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 Ellen

Ellen

    Advanced Member

  • Members
  • PipPipPip
  • 65 posts
  • LocationRotterdam, Netherlands

Posted 07 September 2012 - 05:55 PM

If you are stupid?, I do not know... :P The problem could also be a dirty windows register with pointers to old or non existing file's or program arguments. Also the quality of your equipment could be a factor. It is very hard to tell from a distance whats the problem. I say always No Plug and Play but Plug and Pray. B) For me, the install steps earlier described in other sticky posts were sufficiently. Ellen I hope the PWM class will repaired soon.

#16 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 19 September 2012 - 09:14 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

#17 Igor Kondrasovas

Igor Kondrasovas

    Advanced Member

  • Members
  • PipPipPip
  • 105 posts
  • LocationPorto, Portugal

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 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 20 September 2012 - 07:29 PM

Hi Igor,

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?

Absolutely. The new PWM classes base everything off of a 1MHz clock so frequency and period are both calculated using microsecond precision.

Chris

#19 Igor Kondrasovas

Igor Kondrasovas

    Advanced Member

  • Members
  • PipPipPip
  • 105 posts
  • LocationPorto, Portugal

Posted 20 September 2012 - 07:38 PM

Hi Chris,

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

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.