Trying to run a program(doesn't work)

HomeForumsMonoBrick EV3 FirmwareTrying to run a program(doesn't work)

This topic contains 5 replies, has 4 voices, and was last updated by Author Image Anders Søborg 2 years, 9 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #4795
    Author Image
    Roy Toren
    Participant

    Hello,

    I have just recently started working with EV3 and monobrick.
    Up until now everything was working well, I managed to boot the monobrick through the SD
    and managed to run a few of the example programs.
    However when I wrote my own program and transfered it using USB cable and the WINSCP program, the program in the EV3 says it is running but a second after it returns back to the program manu in the brick.

    I though it might be the way I transfered the exe and the dll but when I downloaded an example program from the brick and upload it again with a different name it ran ok.

    the examples i have tried are:

    using System;
    using MonoBrickFirmware;
    using MonoBrickFirmware.Display;
    using MonoBrickFirmware.UserInput;
    using MonoBrickFirmware.Sensors;

    using System.Threading;
    namespace ev3test
    {
    class MainClass
    {
    public static void Main(string[] args)
    {
    LcdConsole.WriteLine(“Hello World!”);
    System.Threading.Thread.Sleep(10000);
    }
    }
    }

    and

    using System;
    using MonoBrickFirmware;
    using MonoBrickFirmware.Display;
    using MonoBrickFirmware.UserInput;
    using MonoBrickFirmware.Sensors;

    using System.Threading;
    namespace ColorSensorExample
    {
    class MainClass
    {
    public static void Main (string[] args)
    {
    EventWaitHandle stopped = new ManualResetEvent(false);
    ColorMode[] modes = {ColorMode.Color, ColorMode.Reflection, ColorMode.Ambient, ColorMode.Blue};
    int modeIdx = 0;
    var sensor = new EV3ColorSensor(SensorPort.In1);
    ButtonEvents buts = new ButtonEvents ();
    LcdConsole.WriteLine(“Use color on port1″);
    LcdConsole.WriteLine(“Up read value”);
    LcdConsole.WriteLine(“Down raw value”);
    LcdConsole.WriteLine(“Enter change mode”);
    LcdConsole.WriteLine(“Esc. terminate”);
    buts.EscapePressed += () => {
    stopped.Set();
    };
    buts.UpPressed += () => {
    LcdConsole.WriteLine(“Sensor value: ” + sensor.ReadAsString());
    };
    buts.DownPressed += () => {
    LcdConsole.WriteLine(“Raw sensor value: ” + sensor.ReadRaw());
    };
    buts.EnterPressed += () => {
    modeIdx = (modeIdx+1)%modes.Length;
    sensor.Mode = modes[modeIdx];
    LcdConsole.WriteLine(“Sensor mode is set to: ” + modes[modeIdx]);
    };
    stopped.WaitOne();
    }
    }
    }

    some more technical stuff:
    I am using Visual Studio 2010 and I run the program in my computer, the commands throw exeptions all the time and then I transfer the exe and dll in the debug folder of the program i ran to the brick, is that how you should do it or should you just build the program?

    P.S
    When I run the color sensor example in the brick it confuses orange and red which is problematic to me because I need to create a rubik’s cube solver and it has to distinguish between the colors, is there any way to solve this?

    Thank you,

    EDIT1:
    I am using a 8gb SD card with the 4gb image booted to it and the dll all from the site,
    http://www.monobrick.dk/guides/firmware-guides/monobrickfirmwaresdcardwindows/ – the 4gb image

    http://www.monobrick.dk/guides/firmware-guides/running-and-manually-transfering-a-program/ – the dll

    I downloaded both of them on 4/9/14 (telling this just to make sure that there were no updates or mismatch between the versions at that date)

    • This topic was modified 2 years, 9 months ago by Author Image Roy Toren.
    #4797
    Author Image
    Tcm0
    Participant

    Sounds like the program is throwing an exception. Can you please post the code you wrote?

    #4798
    Author Image
    Roy Toren
    Participant

    I posted it already, I have tried both of them:

    first:

    using System;
    using MonoBrickFirmware;
    using MonoBrickFirmware.Display;
    using MonoBrickFirmware.UserInput;
    using MonoBrickFirmware.Sensors;

    using System.Threading;
    namespace ColorSensorExample
    {
    class MainClass
    {
    public static void Main (string[] args)
    {
    EventWaitHandle stopped = new ManualResetEvent(false);
    ColorMode[] modes = {ColorMode.Color, ColorMode.Reflection, ColorMode.Ambient, ColorMode.Blue};
    int modeIdx = 0;
    var sensor = new EV3ColorSensor(SensorPort.In1);
    ButtonEvents buts = new ButtonEvents ();
    LcdConsole.WriteLine(“Use color on port1″);
    LcdConsole.WriteLine(“Up read value”);
    LcdConsole.WriteLine(“Down raw value”);
    LcdConsole.WriteLine(“Enter change mode”);
    LcdConsole.WriteLine(“Esc. terminate”);
    buts.EscapePressed += () => {
    stopped.Set();
    };
    buts.UpPressed += () => {
    LcdConsole.WriteLine(“Sensor value: ” + sensor.ReadAsString());
    };
    buts.DownPressed += () => {
    LcdConsole.WriteLine(“Raw sensor value: ” + sensor.ReadRaw());
    };
    buts.EnterPressed += () => {
    modeIdx = (modeIdx+1)%modes.Length;
    sensor.Mode = modes[modeIdx];
    LcdConsole.WriteLine(“Sensor mode is set to: ” + modes[modeIdx]);
    };
    stopped.WaitOne();
    }
    }
    }

    secound:

    using System;
    using MonoBrickFirmware;
    using MonoBrickFirmware.Display;
    using MonoBrickFirmware.UserInput;
    using MonoBrickFirmware.Sensors;

    using System.Threading;
    namespace ev3test
    {
    class MainClass
    {
    public static void Main(string[] args)
    {
    LcdConsole.WriteLine(“Hello World!”);
    System.Threading.Thread.Sleep(10000);
    }
    }
    }

    What I dont get is, I copied the first source code from the sensor example and so it is supposed to work.
    but when i compile in the visual studio it throws an exeption and when i try to use the exe in the brick it runs it for 2 seconds and then quits

    #4800
    Author Image
    Vlad Ruzov
    Participant

    Hi Roy,
    The applications that have been builded for running on EV3 can not be runned on Windows or others platforms.
    So You should simply build application in Visual Studio (or Xamarin Studio) and then copy ALL files (not only .exe and .dll) from the debug folder to the EV3 app folder.

    http://www.monobrick.dk/guides/firmware-guides/running-and-manually-transfering-a-program/

    If you will use Xamarin you will be able to use MonoSoftDebugger for remote debugging of applications that runned on EV3 on Windows machine.

    All programs from the monobrick site should be compiled and runned successufuly on EV3 brick.
    You can also take many examples from the github repository.

    #4801
    Author Image
    Roy Toren
    Participant

    Hi,
    I have managed to successfully run the program, I used xamain instead of visual, thank you.

    I have another problem, I need to detect the color orange and with the color sensor program it detects orange as red. As I said before I’m building a rubiks cube solver and I need to distinguish between red and orange, is there a way I can do this?
    Thank you

    #4804
    Author Image
    Anders Søborg
    Key Master

    Hi Roy

    Nice of you to try MonoBrick firmware. Glad you solved your problem. Could you please post your next question in a new thread? This makes it easier for other people to find answers to similar problems.

    /Anders

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

Posted in

Make a donation