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

new AnalogInput() throws ArgumentException


  • Please log in to reply
4 replies to this topic

#1 Nicky

Nicky

    Advanced Member

  • Members
  • PipPipPip
  • 78 posts
  • LocationDenmark

Posted 15 October 2012 - 07:56 AM

Hi

I have problem creating an AnalogInput on the Shieldbase...

using AnalogInput = SecretLabs.NETMF.Hardware.AnalogInput;
namespace MyNamespace
{
    public class MyClass : MyBaseClass
    {
        private AnalogInput input;

        public MyClass(NetduinoGo.ShieldBase shieldbase)
            : base(shieldbase)
        {
            this.input = new AnalogInput(this.shieldbase.Pins.GPIO_PIN_A0);
        }

The abowe throws ArgumentException. The code is exceuted immediately after another instace of "MyClass" is created with digital pins. The Pin has value 1014.

Running Netduino Go firmware 4.0.0.2.

Thanks in adavance ;)

ntools
TCP Listener (Beta) · FTP Server (Alpha)
Netduino Plus Go Module · Xml Parser
http://ntools.codeplex.com/


#2 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 15 October 2012 - 08:24 AM

The abowe throws ArgumentException. The code is exceuted immediately after another instace of "MyClass" is created with digital pins. The Pin has value 1014.


You can only grab hold of a pin once. So the second instance of MyClass will fail as the first instance is still referencing A0.

Regards,
Mark

To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#3 Nicky

Nicky

    Advanced Member

  • Members
  • PipPipPip
  • 78 posts
  • LocationDenmark

Posted 15 October 2012 - 08:28 AM

You can only grab hold of a pin once. So the second instance of MyClass will fail as the first instance is still referencing A0.

Regards,
Mark


Hi Mark

Thanks, but it's not.. I've simplified the code by removing parameters and replaced pin variable with actual value.

ntools
TCP Listener (Beta) · FTP Server (Alpha)
Netduino Plus Go Module · Xml Parser
http://ntools.codeplex.com/


#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 15 October 2012 - 09:19 AM

Hi Nicky, Are you okay with switching to the new NETMF AnalogInput class? Then instead of the shieldBase.Pins enumeration, you can use the shieldBase.AnalogChannels enumeration.

#5 Nicky

Nicky

    Advanced Member

  • Members
  • PipPipPip
  • 78 posts
  • LocationDenmark

Posted 15 October 2012 - 09:27 AM

Hi Nicky,

Are you okay with switching to the new NETMF AnalogInput class? Then instead of the shieldBase.Pins enumeration, you can use the shieldBase.AnalogChannels enumeration.


Nice! Works like a charm!

I actually tried using it, and deleted the using AnalogInput in the top, but apparently VS didn't change the reference. using AnalogInput = Microsoft.SPOT.Hardware.AnalogInput did the magic.

ntools
TCP Listener (Beta) · FTP Server (Alpha)
Netduino Plus Go Module · Xml Parser
http://ntools.codeplex.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.