Main Site Documentation

Using eblock Expansion Module with Hydra


#1

Got my Hydra board with a few gadgeteer modules. All works well!

Now I tried to link the eblock Expansion Module, then connect a 3-pin eblock to it. Questions:

  1. which socket type should it be linked to, A?
  2. When I go to the eBlock page and download the “driver” code, such as
    http://www.ghielectronics.com/downloads/FEZ/Component/FEZ_Components_LED.cs
    Visual Studio is reporting that FEZ_Pin is not defined in this line

            public LED(FEZ_Pin.Digital pin)

Am I missing some other libraries?
3. I assume I should specify the LED is an analog output and do this in Program.cs (it is physically linked to socket 8 on the expansion module


            this.eBlockExpansion.SetupAnalogOutput(GT.Socket.Pin.Eight);

Is this correct?

Thank you!


#2

Hi kurotoga,

The eblock expansion does not connect to any one particular socket. The point for the eblock is so you can use eblock type devices on any gadgeteer board. If you have say an eblock potentiometer then you would place the eblock extention onto any A socket and put the eblock connector into pin 3 to 5.

As for the fez pin, that library is not supported on Hydra. Instead you will use the OSH libraries and select FEZHydra.pin.

Hope this helps. :slight_smile:


#3

Oh… by the way, Welcome to the community. :slight_smile: I forgot to welcome you. :-[


#4

@ kurutoga

Welcome to the community. Which socket you use depends on which eblock you’re connecting to the expansion module. For example, if you wanted to drive the Piezo eblock, you’d need to plug the expansion module into a P socket (which supports PWM), and plug the eblock into one of the pins that supports PWM. There’s a chart available of all of the Gadgeteer socket types, and which kinds of I/O they support:

http://wiki.tinyclr.com/index.php?title=Gadgeteer_Sockets

In your case, LED can be driven by either digital I/O, or by PWM (if you wanted to dim the LED rather than simply turn it on or off), so you’d want either an X or Y socket for digital GPIO, or P for PWM. And you won’t be using the FEZ_Pin code, since this is Gadgeteer. Instead, check out the GT.Interfaces namespace, which should have what you need. Then you can use eBlockExpansion.SetupDigitalOutput, or SetupPWMOutput. Here’s a code sample that will blink the LED once a second:

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;
using Gadgeteer.Modules.GHIElectronics;

namespace eblockLED
{
    public partial class Program
    {
        static GT.Interfaces.DigitalOutput LED;

        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            LED = eBlockExpansion.SetupDigitalOutput(GT.Socket.Pin.Nine, false);


            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");

            GT.Timer timer = new GT.Timer(1000);
            timer.Tick += new GT.Timer.TickEventHandler(timer_Tick);
            timer.Start();

        }

        void timer_Tick(GT.Timer timer)
        {
            LED.Write(!LED.Read());
        }
    }
}

The above assumes that you have the Expansion module plugged into a digital I/O socket (I tested on Socket 3 on my Hydra, which supports Y), and that you’ve plugged the LED eblock into pin 9.

Hope that helps.


#5

Originally I misunderstood what the expansion module are used. Your answer is extremely helpful. Thanks devhammer and Aron. I still can not believe I was able to do this kind of stuff within a few minutes without any prior experience.

A very small issue, the OSH lib document url link is broken on this page
http://wiki.tinyclr.com/index.php?title=FEZ_Hydra_Developer#GHI_OSH_libraries


#6

We are in the process of renaming everything from OSH to OSHW. Link is updated.

Welcome to the community.


#7

Alright. One more question regarding PWM pins.

So according to the Gadgeteer Socket map provided by devhammer, if I link the Eblock Expansion Module to the P Socket (which will be socket #7 on the Hydra mainboard), I will be able to use Pin7,8,& 9 as PWM pins. This part is pretty clear.

However, when you look at the product comparison page,
http://www.ghielectronics.com/catalog/compare/
it mentioned Hydra has 4 PWM pins. Where is the #4 PWM pin?


#8

@ kurutoga

If you check out the schematics here:

http://wiki.tinyclr.com/index.php?title=FEZ_Hydra_Developer#The_open-source_Files *

they specify that PWM0, PWM1, and PWM2 are connected to socket 7, while PWM3 is connected to the diagnostic LED.