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); ... }
  | ||||||||||||||
Serial Communication
Started by Terry Massey, Jan 24 2011 10:37 PM
10 replies to this topic
#1Posted 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 #2Posted 24 January 2011 - 10:42 PM
COM1 is pins 11,12. COM2 is pins 1,2.
#3Posted 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 #4Posted 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
#5Posted 25 January 2011 - 08:47 AM
You may have a look at my pinout diagrams posted in the Generals Sections.
Be aware that there's a bug with the SerialDataReceived Event on the Netduino Mini, outlined in this thread: SerialDataReceived Event Thread #6Posted 29 March 2011 - 01:30 AM
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! #7Posted 29 March 2011 - 04:38 AM
Hi outlet,
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 #8Posted 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
#9Posted 08 August 2011 - 01:04 AM
Hi dyadica,
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 #10Posted 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
#11Posted 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 topic0 members, 0 guests, 0 anonymous users | ||||||||||||||
|
||||||||||||||
This webpage is licensed under a Creative Commons Attribution-ShareAlike License. | ||||||||||||||