Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Serial Communication


  • Please log in to reply
10 replies to this topic

#1 Terry Massey

Terry Massey

    Advanced Member

  • Members
  • PipPipPip
  • 77 posts
  • LocationPekin, IL

Posted 24 January 2011 - 10:37 PM

ok so I have been reading on the forums for the Netduino how to get a serial connection working. My question is this which pins are com1 and which is com2.

I have the following code


  private static SerialPort cnn;

        public static void Main()
        {
            cnn = new SerialPort(SerialPorts.COM1, 230400);

            cnn.Open();
            cnn.DataReceived += new SerialDataReceivedEventHandler(cnn_DataReceived);
	...
	}

Thanks,
Terry Massey

#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 24 January 2011 - 10:42 PM

COM1 is pins 11,12. COM2 is pins 1,2.

#3 Terry Massey

Terry Massey

    Advanced Member

  • Members
  • PipPipPip
  • 77 posts
  • LocationPekin, IL

Posted 24 January 2011 - 11:38 PM

ok let me ask this then once I open up the serial port can I no longer deploy?
Thanks,
Terry Massey

#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 24 January 2011 - 11:55 PM

Hi Terry, Correct. Generally, you'll just want to use the _other_ COM port in your code. You can use both--but then you'll lose the ability to debug. To erase your current app (so you can deploy something new): 1. Apply 3.3VDC-12VDC power to the "DTR" pin (pin 3). 2. Power off your Netduino Mini and then repower it. 3. Press "PING" in MFDeploy. Then press "ERASE" to erase your current app. 4. Power off your Netduino Mini again and then repower it. 5. You should be good to go. Chris

#5 Tecchie

Tecchie

    Member

  • Members
  • PipPip
  • 23 posts
  • LocationGermany

Posted 25 January 2011 - 08:47 AM

My question is this which pins are com1 and which is com2.


You may have a look at my pinout diagrams posted in the Generals Sections.

    cnn.DataReceived += new SerialDataReceivedEventHandler(cnn_DataReceived);


Be aware that there's a bug with the SerialDataReceived Event on the Netduino Mini, outlined in this thread:
SerialDataReceived Event Thread

#6 outlet

outlet

    New Member

  • Members
  • Pip
  • 5 posts

Posted 29 March 2011 - 01:30 AM

Hi Terry,

Correct. Generally, you'll just want to use the _other_ COM port in your code. You can use both--but then you'll lose the ability to debug.

To erase your current app (so you can deploy something new):
1. Apply 3.3VDC-12VDC power to the "DTR" pin (pin 3).
2. Power off your Netduino Mini and then repower it.
3. Press "PING" in MFDeploy. Then press "ERASE" to erase your current app.
4. Power off your Netduino Mini again and then repower it.
5. You should be good to go.

Chris


What do you mean by "the _other_ COM port". Does this mean by using either serial ports I have to reset the module to upload new code?

I'm new to these devices, trying to clarify before I make a purchase.

Thanks!

#7 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 29 March 2011 - 04:38 AM

Hi outlet,

What do you mean by "the _other_ COM port". Does this mean by using either serial ports I have to reset the module to upload new code?

I'm new to these devices, trying to clarify before I make a purchase.

Thanks!


You can deploy/debug your code using either COM1 (pins 11/12 -- 3.3V TTL) or COM2 (pins 1/2 -- RS232). You can use one serial port while debugging.

But if you use both serial ports in your application then you'll have to put your Netduino Mini into bootloader mode to erase your current app before deploying a new one, and you'll lose the ability to debug (since the serial port is being used in your code).

BTW, welcome to the Netduino community!

Chris

#8 dyadica

dyadica

    Member

  • Members
  • PipPip
  • 17 posts

Posted 08 August 2011 - 12:38 AM

Hi, A stupid question, I know I'm missing some raw and basic knowledge, if I use Com1 (TTL) to deploy and set up a SerialPort on Com2 (RS232) will Com2 only facilitate serial to other RS232 devices or can it do TTL. Does this matter for deployment only? are RX, TX lines independent of format as so to speak? I cannot seem to get a AHRS 9DOF to read via Com2. Cheers, d

#9 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 08 August 2011 - 01:04 AM

Hi dyadica,

A stupid question, I know I'm missing some raw and basic knowledge, if I use Com1 (TTL) to deploy and set up a SerialPort on Com2 (RS232) will Com2 only facilitate serial to other RS232 devices or can it do TTL. Does this matter for deployment only? are RX, TX lines independent of format as so to speak?

I cannot seem to get a AHRS 9DOF to read via Com2.

There are no stupid questions. :)

COM1 (pins 11, 12) will always communicate using TTL voltages. COM2 (pins 1, 2) will always communicate using RS232 voltages.

Chris

#10 dyadica

dyadica

    Member

  • Members
  • PipPip
  • 17 posts

Posted 08 August 2011 - 11:06 AM

Ha, dammn and thanks :) With this in mind do you know if it is it feasible to communicate (using Com2) over xBee via a http://www.sparkfun.com/products/9132 board as this regulates the voltage down to 3v3 for the xBee from 5v. I'm not sure how the RX, TX are effected? If so I can swap the AHRS over to Com1. Any ideas? Cheers, d

#11 kneave

kneave

    New Member

  • Members
  • Pip
  • 9 posts

Posted 30 August 2011 - 04:46 PM

I'm thinking of building a cycle computer using the Netduino Mini so I've a similar situation to the original post with a question regarding a possible workaround. Assuming I were to connect a ZigBee to one of the serial ports and a GPS module to the other, with a switch denoting debug "on" or "off". I'd have code in the initialisation of the program that detects if debug mode is enabled and would either create an instance of serial for the ZigBee for telemetry purposes or if debug mode is on then it wouldn't use that serial port. I've not played with ZigBee yet however if I understand correctly when configured they can act as transparent serial cables. Is it even possible to program and debug via ZigBee on serial and if so would my workaround work in this situation and for the original poster? I'll admit I've likely got gaps in my knowledge but even if ZigBee wont work, my workaround may. :) Thanks, Keegan




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.