Main Site Documentation

Gadgeteer - using eblock Piezo


#1

reposted from THE NETMF GUIDE EBOOK WAS UPDATED topic

[quote]LED = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, true);
because FEZ_Pin is not recognised “using” any of the GHI namespaces, whether referenced or not.
Instead I got the diode blinking on a button attached to socket X with this line:
LED = new OutputPort((Cpu.Pin)5, true);
[/quote]

Hi, I’m new to Gadgeteer/FEZ - hoping someone could give me some direction on this. I’m using the Spider and have the eblock extender and some modules - trying to get the piezo to work.

In the previously stated issue, what reference should be used for FEZ_Pin? I’m getting the same error. Or if it’s to be done a different way, are there some code samples?

What I found is (with FEZ_Pin having the issue):
public Piezo(FEZ_Pin.PWM pin)
{
pwm = new PWM((PWM.Pin)pin);
}

I see that FEZ_Pin is in the FEZmini_… reference, but that won’t work.

I apologize if this is a dumb question. I’m reading a couple of the beginner guides and searching for answers, but not quite finding the answers.

Thanks.


#2

@ jspy66

See my reply here:

http://www.tinyclr.com/forum/1/5597/#/1/msg55525

Basically, you should be able to use the code from:

http://code.tinyclr.com/project/407/gadgeteer-sounds-using-eblock-piezos/

to successfully drive an eblock Piezo from FEZ Spider. Make sure you’re using the Gadgeteer project template as a starting point.


#3

Thanks devhammer.

I think I initially made a wrong turn by using the driver download (http://www.ghielectronics.com/catalog/product/153) that was in the catalog. I’m now assuming that these drivers are for the FEZ mainboards, but not the Gadgeteer mainboards?

I’ve been messing around with my Spider, the piezo and other modules for a few days and probably spending way too much time on the piezo version of the Star Wars Imperial March. It’s all good practice, though. Still need to do some more reading.


#4

@ jspy66

Glad to hear that you’re enjoying working with the Spider. It’s a fun little board.

The driver on the eblock page could probably be adapted to work with the Spider, the main difference is in how you instantiate the PWM output, and tell it which pin to use. In the eblock driver, it looks like this:

pwm = new PWM((PWM.Pin)pin);

But for Gadgeteer, using the eblock expansion module, it looks more like this:

Piezo1 = eBlockExpansion.SetupPWMOutput(GT.Socket.Pin.Nine);

Once the PWM/Piezo is instantiated, the code is pretty much the same from there.


#5

not sure if this will work or not (or at least not as easily)


pwm = new PWM((PWM.Pin)pin);

It is what I tried initially, but I couldn’t find a reference to the Spider board that supported PWM.Pin. Other non Gadgeteer FEZ mainboards were listed (Cobra, Mini, etc) but not Spider or Hydra.

Either way, I’m liking the Gadgeteer way.


#6

Spider is actually EMX. You need EMX DLL.


#7

@ jspy66

Right…that was my point exactly. The “new PWM” code is not intended for Gadgeteer, so you have to use the eBlockExpansion.SetupPWMOutput technique instead, where eBlockExpansion is the name of your eBlock Expansion instance. But actually playing tones is basically the same once you have the PWM instance.


#8

gotcha - I didn’t know which DLL needed to be referenced.