Main Site Documentation

Fex Hydra Analog Read...missing something


#1

Hej I am trying to read analog from the fez hydra from a sensor I know works. I have plugged into port 13 the one with an ATY by it. I wonder what I am missing?

I am using the following libraries:

[quote]using System;
using Microsoft.SPOT;
using GHIElectronics.OSH.NETMF.Hardware;
using System.Threading;
using System.Text;
[/quote]

Anrunning this:

            var ain = new AnalogIn(AnalogIn.Pin.Ain0);
            var ain1 = new AnalogIn(AnalogIn.Pin.Ain1);
            var ain2 = new AnalogIn(AnalogIn.Pin.Ain2);

I just get the following

1023 1023 1023


#2

If you mesure the voltage on your sensor whot do you obtain? A voltage greater that 3.3 could explain that the ADC saturates.


#3

I am putting 3.3 Volts from the Hydra through it. I am using pin 1 for the power. The same configuration on another controller gets accurate reads of 1.64 volts at zero g. I am wondering if I am reading the pins wrong. I have used this layout:

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

Perhaps they are backwards?

Strangely when I run the the ports with a multimeter I get 3.3 v on the number 10 which should be ground…


#4

Should I be initializing the ports in some way in C#?


#5

Multimeter readings notch down as here on the receiving end or user end…

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

1: 3.33
2: .07
3: 3.33
4: 3.33
5: .17
6: 3.33
7: .07
8: .05
9: 3.35
10: 5.05 v


#6

I am not familiar with Hydra and Gadeeter but reading 1023 shows that ADC saturates. This can be due to bad connection (plugging an unapropriate sensor into the socket, or plugging a sensor into an unapropriate socket). Maybe someone that has hydra or gadeeter can have a look on the values you have measured.


#7

What do you read if pin is connected to ground?


#8

If I put the ground on the multimeter to the ground (pin 10) and then test pin 1 I get -1.62…


#9

I think that Gus want you try to connect the AN1 pin of the socket to the GND of the same socket and give us the value seen by the hydra (if you see 1023 then there’s a problem).

Are you sure of your socket enumeration pin? PIN 1 of the socket is 3.3V so you should measure 3.3V if you connect your multimeter between pin 1 and 10


#10

I have put the ain1 onto the ground and it reads 1023. I have tried it on 2 fez hydras. I think it is a problem with my code or how I am initializing the analog ports.

  1. The analog ports are 13 and 14 correct?
  2. Pins 13 and 14 are also socket type Y. Do I have to initialize the port as an analog port? All I am writing is:

            var ain1 = new AnalogIn(AnalogIn.Pin.Ain1);
            var ain2 = new AnalogIn(AnalogIn.Pin.Ain2);

I am completely baffled by this. I have never had problems reading an analog on any other platforms including the Panda II. I have not been able to find any simple examples in the code section using analog with hydra. It must be something very simple I am missing…Any more suggestions?


#11

I don’t know the exact format of this, but there’s a Gadgeteer AnalogIn reservation process - what you’re seeing (I suspect) is that the pin AnalogIn.Pin.Ain1 does not map to where you think it is. You could try trial and error to move the point you’re connected in to see if you can find the one that changes as you connect it to GND?


#12

Brett,

That is what I suspect. I have tried all the pins using just that code and it absolutely does not work. The problem is I cannot find a simple example of the analog read for the Hydra somewhere. The documentation is really geared towards the Panda. When I start a new application for the hydra I am just using a console application. I will mess around with the gadgeteer project type. If anyone has a simple analog read example for the Hydra it would be great if you could post it. I don’t really know if I am missing a reference or what the initialization process is wíth the gadgeteer. I will be happy to add it to the code section if you can share it…

Thanks!


#13

Hydra = new
Hydra = Gadgeteer
Gadgeteer = new

Most things discussed about the Hydra are going to be Gadgeteer related.

There are no pin enums that I can see (without digging into code) in the standard includes even in a Gadgeteer app. That is the only thing you are missing, how to access the specific pin in the specific socket you want.

If I were wanting to explore this deeper I would look at the source code for the GHI Potentiometer and see what it does under the covers.


#14

OK, here’s a piece of info

http://www.tinyclr.com/forum/21/6586/

this.eBlockExpansion.SetupAnalogInput(GT.Socket.Pin.Two);

Use the eblock expansion in the gadgeteer designer, and then the above code should give you what you need, based on pin 2.

From the OSHW API reference, there’s no specific info that I can see that maps AnalogIn.Pin.AinX pins to physical pins on the Hydra hardware. So (in my view) the best chance is still to use the Gadgeteer abstraction and find it that way

http://wiki.tinyclr.com/index.php?title=FEZ_Hydra_Developer#GHI_OSH_libraries would be a good place to document this once you unravel it. The code example there in particular would be beneficial to have some description


#15

Hi All!

I am new to Gadgeteer, so excited to join you guys. I have a FEZ Hydra and am trying to figure out the pin mappings as well as, well most things really :).
What I have done so far is to use an extender module on the analog (A) sockets (13 & 14) and then test which pins (from 3-5, see http://wiki.tinyclr.com/index.php?title=Gadgeteer_Sockets) map to the pins Ain0 to Ain5 (I assume these are the only 6 analog pins) and this is what I have so far:

Socket 13:
Pin3 : Ain4
Pin4 : Ain3
Pin5 : Ain1

Socket 14:
Pin3 : Ain5
Pin4 : Ain2
Pin5 : Ain0

If anyone wants to double-check that to confirm, that would be great.

I would also like to know how to map the digital pins, for example, if I am using Socket Type A and want to set Pin6 to a digital output pin, how do I find out how to define it according to the FEZHydra.Pin Object?

Also, is there a way to define a pin in terms of the extender module instead of through the FEZHydra.Pin Object?

Thanks


#16

FEZter,

Welcome to the club!

There is a much easier way to check the pin mapping - Hydra schematics.

http://www.ghielectronics.com/downloads/Gadgeteer/Mainboard/FEZ%20Hydra%20schematics.pdf

It will tell you right away each pin’s function.


#17

Great, thanks! Got those LEDs flashing :slight_smile:

Does anyone have any idea on how to code a multiplexer? I am using the board: http://www.sparkfun.com/products/9056 and it would be nice to see some example code.


#18

Check data sheet. There is truth table for channel selection.

Pins S0 S1 S2 S3 controls what channel is selected, SIG is the signal. If you want to use it with Gadgeteer you will need Extender module.


#19

@ Architect: Thanks!
I think there is a snag. To use a 16 channel multiplexer I need 4 digital outputs and 1 analog input. According to the Sockets, the best I can do is to use an A socket and use two of the analog pins (Pin3 & Pin4) as digital pins and the GPIO pin as well, which makes 3 digital outputs and 1 analog input. I suppose I will just have to use more than one socket to get that extra digital pin. Unless there is another way anyone can think of???


#20

So you need 5 pins, right? One AnalogIn. 4 GPIO. And you have a Hydra? If so then you just need to use the AY socket (socket 14) or the AT socket (socket 13). That has the Analog In pins you need plus the ones marked [UN] on the analog socket definition are connected to digital IO pins.