IO60p16 unknown

Ellu again folks

I ordered the next bunch of stuff and started experimenting.
I’m still very unskilled in programming… i really just do simple stuff atm and try to get each module working somehow… one after another.

Actually I’m on the last Module… the io60p16 … and I somehow don’t get it working.

I wanted to make a PWM signal that I could later use to regulate a motor… but somehow I can’t use any of the features of that module.

I have it in the project added is connected to the correct socket.
Also the lines from the Developers Guide Site aren’t working (also when I correct the Capital letters thingy).

Any ideas how I can make a PWM signal or use any features at all? O.o
Maybe I do something totally wrong? >.>

greez evi~~

Regards the examples having compilation issues due to variable names: the “namespace” in the example code must be changed to match the namespace in Program.generated.cs. see http://www.ghielectronics.com/docs/35/namespaces (this is true of many of the examples in the documentation. For example if the namespace statement in Program.generated.cs is “GadgeteerApp1” then in the example code the line “namespace change_this_to_your_namespace” in the example should be changed to “namespace GadgeteerApp1”

Ah well, I didn’t just copy the example… I always add part for part to get an understanding. but this time it doesn’t work.

the example line io60p16.PWM pwm1; is unknown in that part of the programm.

Also in the initialisation methode is just io60p16 kown… but it was no options to use…

using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;

namespace PWM_test1
{
    public partial class Program
    {
        // This method is run when the mainboard is powered up or reset.   

        io60p16.PWM pwm1;     // io60p16 is Unknown here
      
        void ProgramStarted()
        {
           
            Debug.Print("Program Started");
           io60p16.      // -------------- No Options aviable here------------
            
            button.ButtonPressed += new GTM.GHIElectronics.Button.ButtonEventHandler(button_ButtonPressed);
        }

        void button_ButtonPressed(GTM.GHIElectronics.Button sender, GTM.GHIElectronics.Button.ButtonState state)
        {
            //throw new NotImplementedException();
        }
    }
}

since it doean’t know any features of the io60p16 is it also not possible to use .PWM() … or anything else like in the example

Debug.Print("Program Started");
                // -------------- No Options aviable here------------
            pwm1 new io60p16.PWM(io60p16, io60p16.PWMPin.PWM1, io60p16.PWM.TickWidth.TickWidth_Servo_23438hz_42666ns);

the [em]variable[/em] “ioio60p16” is not the same as the [em]class[/em] IO60P16 you are mixing the two up.

ahhh kay. so it’s this time a class that I use…
should this class be in the Gadgeteer library or do I have to mage that by my own?
If it try to initialisite th class, it says that it doean’t know this class.

namespace PWM_test1
{
    public partial class Program
    {
        // This method is run when the mainboard is powered up or reset.   

        IO60P16.PWM pwm1;     // IO60P6 is Unknown here
      
        void ProgramStarted()
        {

Hi Evul, can you tell us what mainboard you’re using, and what Visual Studio version you’re using?

Here’s how I did what you are attempting to do.

Created a new Gadgeteer project, my Cerberus mainboard was on the design surface, I dragged a IO60 module onto the design surface, named it “myio60”, and auto-connected it. Jumped over to the program.cs.

Then, started typing:

GTM.GHIElectronics.IO60P16.OutputPort p1 = new GTM.GHIElectronics.IO60P16.OutputPort(myio60, GTM.GHIElectronics.IO60P16.IOPin.Port0_Pin0, true);

or for PWM:

            GTM.GHIElectronics.IO60P16.PWM pwm1 = new GTM.GHIElectronics.IO60P16.PWM(myio60, GTM.GHIElectronics.IO60P16.PWMPin.PWM1, GTM.GHIElectronics.IO60P16.PWM.TickWidth.TickWidth_Servo_23438hz_42666ns);

Hopefully that can show you what you need to do?

edit: Jeff, the developers guide is what is misleading here I think, if there was an extra “using” somewhere to shortcut to GTM.GHIElectronics it would work…

ellu Brett

I use a FEZ Hydra and program on Visual Studio 2010 V. 10.0.303119.1

it seems that this:

        void ProgramStarted()
        {

           
            button.ButtonPressed += new GTM.GHIElectronics.Button.ButtonEventHandler(button_ButtonPressed);
        }

        void button_ButtonPressed(GTM.GHIElectronics.Button sender, GTM.GHIElectronics.Button.ButtonState state)
        {
            GTM.GHIElectronics.IO60P16.PWM pwm1 = new GTM.GHIElectronics.IO60P16.PWM(myio60, GTM.GHIElectronics.IO60P16.PWMPin.PWM1, GTM.GHIElectronics.IO60P16.PWM.TickWidth.TickWidth_Servo_23438hz_42666ns);

           
            //throw new NotImplementedException();
        }

it seems like that is it known for the visual Studio… got no errors.
if i press now the button, should then the pwm signal start?

I don’t see anything with the measuring-tool >.<
but i think, I’m closer to the solution now^^

edit… gotta play a bit with the arguments it seems >.<

[quote]button pressed
#### Exception System.Exception - 0x00000000 (1) ####
#### Message: This pin has already been reserved
#### Gadgeteer.Modules.GHIElectronics.IO60P16+PWM::.ctor [IP: 0046] ####
#### PWM_test1.Program::button_ButtonPressed [IP: 0012] ####
#### Gadgeteer.Modules.GHIElectronics.Button::OnButtonEvent [IP: 0058] ####
#### Gadgeteer.Modules.GHIElectronics.Button::_input_Interrupt [IP: 0068] ####
#### Gadgeteer.Interfaces.InterruptInput::OnInterruptEvent [IP: 0055] ####
#### System.Reflection.MethodBase::Invoke [IP: 0000] ####
#### Gadgeteer.Program::DoOperation [IP: 001a] ####
#### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 0054] ####
#### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001a] ####
#### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
#### Gadgeteer.Program::Run [IP: 0020] ####
Eine Ausnahme (erste Chance) des Typs “System.Exception” ist in GTM.GHIElectronics.IO60P16.dll aufgetreten.
Error invoking method “Gadgeteer.Interfaces.InterruptInput” (check arguments to Program.BeginInvoke are correct)
[/quote]

This is about the scope of the object you’re creating. Time to learn that :wink:

Because you create the pin in the button handler, as soon as the button handler exits that object is out of reference and can be garbage collected.

What I would do. Start with a Boolean object and a PWM object in your program class. In the button press handler, then you can check the Boolean - if it’s set whatever way you choose, you create the PWM object and it should then run, but if the Boolean is opposite then you dispose the object, of course you need to reverse the Boolean flag in both cases. This means the button becomes a toggle, and should stop the “re-use” issue which is what I suspect caused your error, a 2nd button press. But whether that actually stops the PWM I don’t know; I guess testing should show you :slight_smile:

I think I know what you mean… but I don’t understand how i activate the created object and how i dispose it with a toggle…

with my simple mind I’d say it must be something like (after the pwm1 object is created in the main methode):

if (Toggle == true)
{
pwm1.set(true);
}
else
{
pwm1.set(false)
}

But probably I see this waaaaay to easy and they way is much more complicated^^

my try:

public partial class Program
    {
        // This method is run when the mainboard is powered up or reset.   
        Boolean Toggle = false;
        void ProgramStarted()
        {
            Debug.Print("Start");
            GTM.GHIElectronics.IO60P16.PWM pwm1 = new GTM.GHIElectronics.IO60P16.PWM(myio60, GTM.GHIElectronics.IO60P16.PWMPin.PWM1, GTM.GHIElectronics.IO60P16.PWM.TickWidth.TickWidth_Servo_23438hz_42666ns);
            button.ButtonPressed += new GTM.GHIElectronics.Button.ButtonEventHandler(button_ButtonPressed);
        }

        void button_ButtonPressed(GTM.GHIElectronics.Button sender, GTM.GHIElectronics.Button.ButtonState state)
        {
            Debug.Print("button pressed");
            Toggle =! Toggle;
            Debug.Print("Toggle: " + Toggle);

            if (Toggle == true)
            {
                             //activate the PWM signal here... somehow
            }
            else
            {
                             //deactivate the PWM again.... somehow >.<
            }
          
        }
    }

anyhow close? O.o

I’m wondering if you’re having the same problems as Detroit.Mustang…

https://www.ghielectronics.com/community/forum/topic?id=12752

If possible I’d like to avoid to buy a PulseInOut Module… since shipping and customs duty is veeeery expensive >.<

The L298 module works with pwm too (althought it’s a horrible signal) but that one is easy to handle… I’d wish that the io60p16 module would have such easy functions to use pwn >.<

Just wondering. Is there a chance, that in the next Gadgeteer SDK, the IO60p16 gets more easy functions impemented? Such as:

SetPWM(Attributes)
EablePWM.PWM1(true)

that would be really great. I still didn’t manage to get any signals out of my module :frowning:

I’ve entered your request into our issue tracker, no guarantees, but it won’t be forgotten.

I just looked at the driver source (available from http://gadgeteer.codeplex.com/) and it appears that support for PWM is already pretty complete.