Go Down

Topic: I/O after establishing a Serial Connection not working (Read 740 times) previous topic - next topic

expl0

Hi, I'm using Visual C# to read from / write to digital Pins of the board.

Everytime I establish a Serial Connection i have to manually reset the Arduino DUE board, otherwise it won't accept commands (e.g. write to digital pin) or send changes of the digital inputs via the Serial Connection.

Right now I'm using the Standard Firmata on my board and a dll for C#.

After I reset the board, everything works perfectly, until i establish a new connection.
This is really annoying, having to do a manual reset every time...

Is there a possible work around for my problem?

Any help appreciated!

Kassiopeia

As my crystal ball is broken, I would ask you to post more information, like example code.
What does that mean: "Standard Firmata on my board "

Tell, which Arduino IDE (version number!!) you are using. As the IDE and most DUE libraries are still Beta, the used version is very important.

Next step: Reduce your problem to a very small example program and post that program. Master and Slave code!

One guess into the dark:  Are you opening the connection with 1200 baud on the native port from C#?

Grumpy_Mike

My guess in the dark is that you are trying to control pins 0 & 1, these pins are used for serial communication and so can not be used as I/O at the same time.

expl0

#3
Jun 03, 2014, 01:14 pm Last Edit: Jun 03, 2014, 01:17 pm by expl0 Reason: 1
I'm using Arduino IDE 1.5.6-r2 and the Standard Firmata which was included in this version.

I had to modify the Standard Firmata a little bit to get it to work, though, sorry for not telling u this before. Instead of using the "checkDigitalInputs()" Function in "void loop" , i used the loop from the SimpleDigitalFirmata, so it looks like this now:

void loop()
{
  byte pin, analogPin, i;

  /* DIGITALREAD - as fast as possible, check for changes and output them to the
   * FTDI buffer using Serial.print()  */
  for (i = 0; i < TOTAL_PORTS; i++) {
    outputPort(i, readPort(i, 0xff), false); // Loop i mentioned i use from the SimpleDigitalFirmata
  }
  ...
}

Without this modification, the Arduino DUE wouldn't send anything back via the Serial Connection, even after a manual reset.
I have tried the newest Standard Firmata version from the website, http://firmata.org/wiki/Download (v. 2.3.6), but this won't fix my problem either.

The C# dll i use for communication with the Arduino DUE is this one:
http://www.imagitronics.org/download/arduino.cs

So the constructor I use looks like this:
       public Arduino(string serialPortName, Int32 baudRate, bool autoStart, int delay)
        {
            _serialPort = new SerialPort(serialPortName, baudRate);
            _serialPort.DataBits = 8;
            _serialPort.Parity = Parity.None;
            _serialPort.StopBits = StopBits.One;

            if (autoStart)
            {
                this.delay = delay;
                this.Open();
            }
        }

Now an example of my program:

public void test()
{
  arduino = new Arduino(COM4, 57600, true, 0); // I have to use the manual reset after this line.

  arduino.pinMode(25, arduino.OUTPUT);
  arduino.digitalWrite(25, arduino.HIGH);
}

In my program, I only use pins 18 - 53 for I/O.

I hope this is the information you need, otherwise, please ask. Sorry for not explaining it in more detail before.

Edit: I use the programming port for uploading the Firmata and for communication.

Grumpy_Mike

I thought that the Standard Firmata did not work on the Due.

Sorry but I don't use Firmata because I fundamentally disagree with what it does and the way it works.

expl0


I thought that the Standard Firmata did not work on the Due.


It does, with a little modification

Grumpy_Mike



I thought that the Standard Firmata did not work on the Due.


It does, with a little modification


Quite clearly it does not or you would not be posting this problem.

Kassiopeia

Standard Firmata with the Firmata-Test program works without any change on my DUE with 1.5.6r2.

You need to reset the DUE, once the host-program is started. That is by my understanding due to the fact, that in the setup() section "Firmata.begin()" is called, which itself contains:
Code: [Select]

  printVersion();
  printFirmwareVersion();

When that is written to the serial port before the host program start, the host will never see the output.

Furthermore its not possible to use SerialUSB as output, because of coding quirks. In addition they are assuming that 8 pins are making an port, which is not true for the 32bit DUE!

The code is not written with other architectures in mind and makes no use of SAM8XE features at all.

Go Up