Sensor Data?

Hi,
I am absolute Noob so please forgive me my somewhat noobish and maybe naïve questions:
I am wondering if I could use FEZ Spider to acquire analogues sensor data from an external sensor or multiple sensors and give them out on my PC? And how would I best start and proceed on such a project?
If someone could give me some starting advice I would be really grateful. But please remember: Noob here :-[

Cheers and thanks

Welcome to the community.

Yes you absolutely can and it should be easy :slight_smile: What sensors are you planning on using?

I thought of measuring distance using ultrasonic sound? But if that is too complex to start of I am open for suggestions…

The easiest is by starting with an existing module http://www.ghielectronics.com/catalog/category/275/

O.k. then I will first try to use the light sensor from the eblock kit.
Am I right that I need then the following modules?

  • eblock light sensor
  • eblock expansion module
  • FEZ Spider mainboard
  • USB client SB module (to connect to my PC)
    With this it should be possible to readout a value for the light intensity on the sensor right?

As Gus implied, there isn’t a Gadgeteer compatible sensor for measuring distance yet. As a matter of fact, there aren’t any sensor modules currently available (as of 12/12). There is a long list of requested modules on the Wiki, and GHI (plus other companies) are cranking them out as fast as possible.

In the meantime, you can use the extender or eBlock modules to hook up a simple sensor like a thermistor. While this approach is not plug and play, it is much more educational IMHO. Don’t let your self imposed noob-ness slow you down. Ask lots of questions. We’ve got your back.

[edit] looks like you came up with the idea on your own! And yes, your component list will work. I would recommend getting the DP power module, though. The SP will work for low power consuming setups like you propose, but as soon as you expand into using more power intensive components (like display and/or ethernet/WiFi), you’ll need more power than the SP module will provide.

And once you’ve gotten a little more familiar with how the Gadgeteer projects work in general, you could get the Extender module, solder up a header, and plug it into a breadboard, which would allow you to build your own custom circuit with an ultrasonic sensor, or other components as desired.

I just started working with Gadgeteer in October, with no prior embedded experience whatsoever, and I recently started playing with breadboarding. Fun to explore, and gives you options when a module isn’t available to do exactly what you want.

Thanks for the encouragement and the first hints!

Here is what I have tried basically considering it to be easy an analogous to this post: http://www.tinyclr.com/forum/21/5029/
Here is my setup:

Hardware:
-FEZ Spider mainboard
-USBDP → connected to PC and to socket 1 on mainboard
-eblock expansion module connected to socket 9 on mainboard
-eblock light sensor, connected to pin three on eblock expansion module

Code:

using System;
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 GadgeteerApp3
{
    public partial class Program
    {
        
        void ProgramStarted()
        {
            
            Debug.Print("Program Started");
            GT.Interfaces.AnalogInput LightVoltage = BlockExpansion.SetupAnalogInput(GT.Socket.Pin.Three);
            
            while (true)
            {
                Debug.Print("The Voltage is: " + LightVoltage.ReadVoltage());
               
                Thread.Sleep(500);
            }
        }
    }
}


Result: When eblock light sensor is connected I get a output of constant value of 0; when I remove the eblock I get values of > 0.01 (artefacts?)?

Question: Am I missing something with my setup or code? I am afraid something might be wrong with my hardware…

Thanks for any help :slight_smile:

@ pfeiffer72

So, you’re not seeing any variance in the voltage reading if you cover and/or uncover the light sensor?

I’ve got my board sitting right next to me, so let me wire it up like yours and I’ll see if I can replicate.

BRB…

I’ve tested using my eblock light sensor, and the same code you’re using, and I get a variable output based on whether the sensor is covered (voltage is higher) or uncovered or has a light shining on it (voltage is lower).

Have you double-checked that your eBlockExpansion module is plugged into the correct socket on the mainboard? Also, double-check that the eblock light sensor is plugged into the correct pin.

PS - as a rule you should not plug in or remove any components while power is applied to the mainboard. Doing so could potentially damage your components.

Thanks devhammer for your effort!

I double checked the connections and I am pretty sure I did not plug or unplug powered components ???

However it seems it must be a hardware problem :’( Oh dear…

I replaced the sensor with the poti - nothing
I switched the module to socket 10 (hope this works?) and the poti to pin 4 - nothing

Once I am home I will try some other modules on those sockets - LEDs should be o.k.?
I fear that my eblock expansion mod is somehow damaged but this I would have to order…

Any other tips on closing in on the problem? Can I measure voltage on the sockets pins or the eblock pins to test if those are o.k.?

@ pfeiffer72

An important point with respect to the eblocks is that you do need to make sure they’re plugged into a compatible socket for the type of eblock you wish to use. The light sensor and/or potentiometer are analog inputs, so they would need to connect to a socket with an A next to it.

Socket 9 or 10 should work, and pins 3, 4, and 5 should be fine for analog input.

See [url]GHI Electronics – Where Hardware Meets Software for additional documentation on the eBlock Expansion Module.

You’re not going to be able to test an analog input pin using an LED…LED uses a digital output socket/pin.

Can you snap a picture of the mainboard and eblock expansion module so we can see how you have this hooked up?

Remember that the eblock light sensor is essentially a variable resistor that should allow more voltage as light on it is increased, and vice-versa. So in normal ambient lighting, you should definitely detect a voltage if everything is hooked up properly.

Here 3 pics of my setup:

#2

#3

@ pfeiffer72

Your physical connections look fine. One last thing to check…can you double-check the designer in your gadgeteer project and make sure the connections match what you’ve done physically, specifically that the eblock expansion module is connected to socket 9 in the diagram. The designer automatically generates the code that configures the software for the correct sockets for any connected modules, so if the module isn’t connected properly there, things won’t work right. I would think you’d get an exception, were that the case, but perhaps not.

What I’m thinking here is that if you had the designer connect the modules for you, it might have chosen a different socket than the one you are physically connected to.

As an example, here’s what my design surface looks like, for the test project I set up:

mine looks the same and here is the program.generated.cs

using Gadgeteer;
using GTM = Gadgeteer.Modules;

namespace GadgeteerApp1
{
    public partial class Program : Gadgeteer.Program
    {
        // GTM.Module defintions
		Gadgeteer.Modules.GHIElectronics.UsbClientDP usbClient;
		Gadgeteer.Modules.GHIElectronics.EBlockExpansion eBlockExpansion;

		public static void Main()
        {
			//Important to initialize the Mainboard first
            Mainboard = new GHIElectronics.Gadgeteer.FEZSpider();			

            Program program = new Program();
			program.InitializeModules();
            program.ProgramStarted();
            program.Run(); // Starts Dispatcher
        }

        private void InitializeModules()
        {   
			// Initialize GTM.Modules and event handlers here.		
			usbClient = new GTM.GHIElectronics.UsbClientDP(1);
		
			eBlockExpansion = new GTM.GHIElectronics.EBlockExpansion(9);

        }
    }
}

I’m at a loss for what’s going on then, as it seems like our setups are identical, and mine is working as expected. If you have a digital multimeter, you might check continuity between the pins on the eblock expansion module socket, and the individual pins for the pin 3 eblock socket, to make sure that there isn’t a problem there. Might also check while it’s running for 3.3V between the positive and ground pins, both at the module socket and at the pin 3 eblock socket.

I’m a little confused about the problem… Why are you concerned about what happens when you remove the sensor? Regardless, it sounds like you just need a pull-down resistor to absorb that surplus current that’s leaking in. You don’t get it when the eBlock is connected because it has a built-in resistor.

O.k. the problem with the eblock is solved, I replaced the old eblock expansion module with a new one and now I can readout the voltage from the light sensor. So I conclude my old eblock expansion module was not working correctly.
With that issue solved and my first experience gained, I went back to my original plan to measure ultrasonic sound. I bought therefore a Polaroid 6500 Sonar Ranging module. From reading I concluded that instead of using the eblock I rather use the extender module.
In order to get some experience with this, I PWM controlled a servo as described by devhammer (thanks to devhammer!): ;D
http://code.tinyclr.com/project/405/servo-control-with-the-gadgeteer-extender-module/

Now the ranging module has 3 inputs (INIT,BLNK,BINH) and 2 Outputs (ECHO, OSC). I plan to control the inputs via PWMOutput pins 7,8,9 on the extender module (using socket 8 on the spider mainboard).

But here I get stuck as 2 questions arise which so far I did not find a good answer for: ::slight_smile:

  1. which pin should I use for the ECHO response from the ranging module? Pins 3-6 on socket 8… but which one can I use?
  2. more important the echo has a maximum voltage of 6.8V which is higher that the 3.3V that I should give back. Any electronic expert which can tell me how I can get the 6.8V down? Maybe a resistor?

Thanks ;D