Camera app

Gus and Mike, thanks for your responses!
I’ll break down my (remaining?) issues into multiple threads.

Camera issue - doesn’t appear to work at all.

code used at end -
when I push the button, I get:
button pressed
Camera ERROR : Unable to take picture. Camera is not ready. Is the Camera connected?

I’ve tried 3 different cables to be sure is isn’t that simple - haven’t checked voltages on camera yet…
I’m using the DP client USB board on port 1 with external power (also tried using USB power only- exactly the same).

I’m wondering if there’s some missing initialization I need to include? From the API, it doesn’t seem like it. Could just be a bad unit?

My next test will be to try the USB host module as suggested to see if that works properly.

exact code I’m using:
Program.cs:


using Gadgeteer.Modules.GHIElectronics;
using Microsoft.SPOT;
using GT = Gadgeteer;

namespace GadgeteerApp1
{
    public partial class Program
    {
        void ProgramStarted()
        {
            button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);
            camera.PictureCaptured += new Camera.PictureCapturedEventHandler(camera_PictureCaptured);

            // Do one-time tasks here
            Debug.Print("Program Started");
        }

        void camera_PictureCaptured(Camera sender, GT.Picture picture)
        {
            display.SimpleGraphics.DisplayImage(picture, 5, 5);
        }

        void button_ButtonPressed(Button sender, Button.ButtonState state)
        {
            Debug.Print("button pressed");
            camera.TakePicture();
        }
    }
}

Program.generated.cs:


namespace GadgeteerApp1
{
    public partial class Program : Gadgeteer.Program
    {
        // GTM.Module defintions
		Gadgeteer.Modules.GHIElectronics.Camera camera;
		Gadgeteer.Modules.GHIElectronics.Display_T35 display;
		Gadgeteer.Modules.GHIElectronics.Button button;

		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.		
			camera = new GTM.GHIElectronics.Camera(3);
		
			button = new GTM.GHIElectronics.Button(4);
		
			display = new GTM.GHIElectronics.Display_T35(14, 13, 12, Socket.Unused);

        }
    }
}

Did you connect camera module in the visual studio gadgeteer designer?

um… yes? I really DID check the cable and replace it 3 times… that includes plugging in both ends :^)

oh - DESIGNER! – yes - did that too, you can see in Program.generated.cs the initialization for the camera to port 3.

although, sigh…
I just finished trying the USB host module, and I’m not getting a USBDriveConnected event…

running the code at the end - I never get at “Drive connected” or anything else when popping a thumb drive in (and out).

Curiously - I tried putting the led on port 11 for the first time, and got an exception telling me that there was no DaisyChain device on port 11… It works fine on port 4 or 8 (haven’t tried others).


using System;
using Gadgeteer.Modules.GHIElectronics;
using Microsoft.SPOT;
using GT = Gadgeteer;

namespace USBHostApp
{
    public partial class Program
    {
        void ProgramStarted()
        {
            this.usbHost.USBDriveConnected += new UsbHost.USBDriveConnectedEventHandler(usbHost_USBDriveConnected);
            this.usbHost.USBDriveDisconnected += new UsbHost.USBDriveDisconnectedEventHandler(usbHost_USBDriveDisconnected);
            Debug.Print("Program Started");
            led.BlinkRepeatedly(GT.Color.White, TimeSpan.FromTicks(100), GT.Color.Black, TimeSpan.FromTicks(10000));
        }

        void usbHost_USBDriveDisconnected(UsbHost sender)
        {
            led.TurnOff();
            Debug.Print("Drive disconnected");
        }

        void usbHost_USBDriveConnected(UsbHost sender, GT.StorageDevice storageDevice)
        {
            led.TurnOff();
            led.TurnRed();
            Debug.Print("Drive connected...");
            Debug.Print("ID: " + storageDevice.Volume.VolumeLabel);
            Debug.Print("");
            string[] rootFiles = storageDevice.ListRootDirectoryFiles();
            foreach (string file in rootFiles)
            {
                Debug.Print("Root file: " + file);
            }

            Debug.Print("end");
            led.TurnGreen();
        }
    }
}

for what it’s worth, I’m having the same issue with the camera

Same camera problem here, but the usb host works fine…

Try this (I haven’t tried it here but will on Monday), connect your camera directly to USB Client module, no mainboard. Now plug the USB Client module to your PC. Does the PC detect the camera?

Gus - when I try that, the PC does recognize the camera. Devices indicates a “USB 2.0 PC Cam”, properly installed.

Oh cool! So this tells us that your camera is working fine. Now you can test mainboard’s USB host functionality by using the USB Host module and connecting a keyboard/mouse or USB memory stock.

Also, what happens if you unplug the camera and plug it back while the system is running? Will this causes it to be detected? I thinking the camera sometimes is not detected when the it is plugged in at power up?

Yep - appears camera is working.
I tried the plug/unplug with the camera in the client module and got proper connect / disconnect.

When I tried the USB host module (yesterday?), I tried with a memory stick, and did NOT get insert / remove events. I didn’t try going direct to the NETMF level.

I’ll work on that a little more…

Play with the ethernet interface now - it DHCPs properly and will show up as a device if I set transport to TCP/IP. Haven’t gotten further on that yet.

Stupid question, are you sure you are using the correct USB socket!

Finally, USB devices require good 5V to run. Did you power your FEZ Spider using a power pack? You can also use a cellphone charger to power it from USB connector.

port 3 is the host USB socket, right? Same as the camera module. That’s the one I tried.

And yes - tried with a 12Vdc wall wart plugged into USB DP.

I’ll do some further testing with the USB host later… maybe try to just bypass the gadgeteer code and use the NetMF directly - at least to see if I can get any status.

Did anyone get a solution to this one. I just got a Spider kit today and am having the same issue :frowning:

@ AlexH - what issue exactly? There are 2 distinct issues mixed together in this topic. Best to start your own topic with specific details. Welcome to the community!