Main Site Documentation

Hydra Serial


#1

Hi Everyone,

I’m trying to run a mini maestro servo driver and am running into an exception with the serial port on the Fez Hydra.

Using mainboard GHI Electronics FEZHydra version 1.2
    #### Exception System.ArgumentException - 0xfd000000 (1) ####
    #### Message: 
    #### System.IO.Ports.SerialPort::InternalOpen [IP: 0000] ####
    #### System.IO.Ports.SerialPort::Open [IP: 0018] ####
    #### Ahmed.Micro.Contollers.Maestro.SerialServoController::.ctor [IP: 001d] ####
    #### ServoDriver.Program::ProgramStarted [IP: 0014] ####
    #### ServoDriver.Program::Main [IP: 0015] ####
A first chance exception of type 'System.ArgumentException' occurred in Microsoft.SPOT.Hardware.SerialPort.dll
An unhandled exception of type 'System.ArgumentException' occurred in Microsoft.SPOT.Hardware.SerialPort.dll

Firstly have I set up the serial port on the extender correctly? Otherwise is it likely to be the way I’ve set up the hardware?

I’m using this from the codeshare: http://www.tinyclr.com/codeshare/entry/157

And this is how I’ve setup my serial.


namespace ServoDriver
{
    public partial class Program
    {
        // This method is run when the mainboard is powered up or reset.   

        private static SerialServoController servoController;

        // Gadgeteer.Interfaces.Serial serialPort;

        void ProgramStarted()
        {
           
            SerialPort serialPort = new SerialPort("COM2", 9600, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.None);
            servoController = new SerialServoController(serialPort);
            servoController.GoHome();
            Debug.Print("Program Started");
        }
    }
}


#2

There’s a .connect or .open you need to call before using it.


#3

Yes - thank you I need one stopbit and it’s working.

Nothing is moving yet but I’m not getting an error which is good.

I’ve got a level converter on there so that should be fine.

Thank you.


#4

Hi Everyone,

I’ve tried a few things and I’m still not able to get the mini maestro to work, I was hoping someone might spot my mistake.

My schematic is attached and this is the code I’m using. I’m using socket 7 on the hydra. Thank you.

using System;
using System.IO.Ports;
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 Ahmed.Micro.Contollers.Maestro;
using Ahmed.Micro.Contollers.Maestro.Variables;
using Gadgeteer.Modules.GHIElectronics;

namespace ServoDriver
{
    public partial class Program
    {
        // This method is run when the mainboard is powered up or reset.   

        private static SerialServoController servoController;

        // Gadgeteer.Interfaces.Serial serialPort;

        void ProgramStarted()
        {
           
           
            Debug.Print("Started");

            SerialPort serialPort = new SerialPort("COM2", 9600, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
            servoController = new SerialServoController(serialPort);
            servoController.GoHome();

            button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);
      
        }

        void button_ButtonPressed(Button sender, Button.ButtonState state)
        
        {
            Debug.Print("Pressed");

            servoController.SetTarget(0, 1040);   
        }


    }
}

#5

As with what Skewworks mentioned above, try to open the serial port with the open command and see if that fixes the issue.


#6

@ andre.m - I did not realize that the open function call was in the driver on Codeshare.

@ shapingstuff - can you step through the code and give a specific line when the exception is thrown?


#7

Also, what logic converter do you use?


#8

Yeah its opened in the driver.

Actually there is no longer an exception I’m just not able to talk to the maestro with this setup.

It’s the sparkfun logic converter https://www.sparkfun.com/products/8745