RS232 Advice
#1
Posted 23 August 2011 - 08:09 PM
#2
Posted 24 August 2011 - 04:43 AM
You should not connect the RS232 pins to the Netduino input, because they uses different voltage levels.
The Netduino works with voltages in the 0..+3.3V range (+5V allowed for some inputs). The RS232 works also with negative voltages swinging from -10V to +10V (approx).
What you looking for is a RS232 to TTL converter shield, like this one. There are plenty of similar shields, so you may search for others. However, you should bear in mind that the shield should be equipped with the MAX232 chip (or equivalent).
Cheers
#3
Posted 24 August 2011 - 12:55 PM
Hello.
You should not connect the RS232 pins to the Netduino input, because they uses different voltage levels.
The Netduino works with voltages in the 0..+3.3V range (+5V allowed for some inputs). The RS232 works also with negative voltages swinging from -10V to +10V (approx).
What you looking for is a RS232 to TTL converter shield, like this one. There are plenty of similar shields, so you may search for others. However, you should bear in mind that the shield should be equipped with the MAX232 chip (or equivalent).
Cheers
Thanks for the advice. I'll try and get hold of the shield you suggested (or similar). My device that I'm trying to connect to claims to be 5V for the serial communication, but I guess it probably still swings -ve, so maybe that's the problem. It's expecting the message from the Netduino to go negative and it doesn't.
Still, shouldn't I be able to connect the Netduino pin 0 to pin 1 and make that board talk to itself? Just as a way to convince myself that the board is working and the right messages are getting sent? Needless to say, it ain't working. The values I'm getting back on port.Read aren't the same as what I sent out with port.Write. (edit: nevermind, it's working now)
#4
Posted 24 August 2011 - 02:22 PM
What kind of device? Perhaps it already works on TTL levels.My device that I'm trying to connect to claims to be 5V for the serial communication, but I guess it probably still swings -ve, so maybe that's the problem. It's expecting the message from the Netduino to go negative and it doesn't.
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs
#5
Posted 24 August 2011 - 03:50 PM
What kind of device? Perhaps it already works on TTL levels.
It's proprietary and so far it looks like it doesn't work, for whatever reason.
#6
Posted 25 August 2011 - 05:26 AM
Of sure you can!Still, shouldn't I be able to connect the Netduino pin 0 to pin 1 and make that board talk to itself?
The Netduino (standard and Plus) has two UARTs: I never remember which is the COM1 and the COM2.
Anyway, you may short the I/O #0 and #1, as long as the I/O #2 and #3. Afterward, you may try the echo by using the COM1. That must be work (without any additional hardware).
Cheers
- Inquisitor likes this
#7
Posted 25 August 2011 - 11:22 AM
Of sure you can!
The Netduino (standard and Plus) has two UARTs: I never remember which is the COM1 and the COM2.
Anyway, you may short the I/O #0 and #1, as long as the I/O #2 and #3. Afterward, you may try the echo by using the COM1. That must be work (without any additional hardware).
Cheers
Boom! I was about to order another one (which I will eventually) but at least I can do a test now.
Thanks Mario for stating the obvious in a mild way so I don't feel too dense.
If my message helped you... how 'bout giving me a
www.MessingWithReality.com
#8
Posted 29 August 2011 - 06:46 PM
Hello.
You should not connect the RS232 pins to the Netduino input, because they uses different voltage levels.
The Netduino works with voltages in the 0..+3.3V range (+5V allowed for some inputs). The RS232 works also with negative voltages swinging from -10V to +10V (approx).
What you looking for is a RS232 to TTL converter shield, like this one. There are plenty of similar shields, so you may search for others. However, you should bear in mind that the shield should be equipped with the MAX232 chip (or equivalent).
Cheers
Okay. Finally got it working. I bought this shield because I could buy it through Amazon and apparently emartee don't take credit cards, only paypal (no good with the corporate p-card).
So everything seems to work, after messing around finding the right cross over cable I was able to send a command to my device and have it react. I haven't yet tried reading and interpreting the messages coming back yet, one step at a time. My only problem with the board I got is that it sits directly on top of the netduino. It blocks access to the onboard button, but I can live with that for now, but the real problem is that it clashes with power connector on the netduino board meaning that I can push it all the way down. Does anybody know a good source for some kind of spacer?
#9
Posted 30 August 2011 - 06:07 AM
#10
Posted 30 August 2011 - 02:15 PM
The shield uses only two wires, plus the power supply. I would connect it using some wire.
I could do that, but I do really like the compactness of having the boards stacked like that. It'll really make finding an enclosure to fit everything a lot easier when I'm eventually done with this project.
#11
Posted 04 September 2011 - 07:27 PM
Of sure you can!
The Netduino (standard and Plus) has two UARTs: I never remember which is the COM1 and the COM2.
Anyway, you may short the I/O #0 and #1, as long as the I/O #2 and #3. Afterward, you may try the echo by using the COM1. That must be work (without any additional hardware).
Cheers
I knew Mario wouldn't lead me astray... but I was just wanting to try this out. Its been a while since I've done any serial port communications and I thought I'd try to make it a little easier on the next guy just getting started. It just lights the on-board LED via the most round-about method possible ... Pressing the switch writes a flag to the serial port 1 which is read on serial port 2 which turns on the LED. Releasing the switch goes through the same Mickey Mouse and turns off the LED. Just run a wire from UART 1 TX (pin 1) to UART 2 RX (pin 2) and drop in the code.
using System; using System.Net; using System.Net.Sockets; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.Netduino; //using SecretLabs.NETMF.Hardware.NetduinoPlus; // Use this if you have N+ project. using System.IO.Ports; using System.Text; // Hook up a wire from port 1 to port 2. namespace Serial_Port { public class Program { private static OutputPort _Led; private static InterruptPort _Switch; private static SerialPort _Send; private static SerialPort _Recv; public static void Main() { // Set up our switch and led _Led = new OutputPort(Pins.ONBOARD_LED, false); _Switch = new InterruptPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); _Switch.OnInterrupt += new NativeEventHandler(Switch_OnInterrupt); // Set up our sender and receiver _Send = new SerialPort(SerialPorts.COM1, 9600, Parity.None, 8, StopBits.One); _Recv = new SerialPort(SerialPorts.COM2, 9600, Parity.None, 8, StopBits.One); _Recv.DataReceived += new SerialDataReceivedEventHandler(Recv_DataReceived); _Send.Open(); _Recv.Open(); Debug.Print("READY TO PRESS BUTTON"); Thread.Sleep(int.MaxValue); } private static void Switch_OnInterrupt(uint data1, uint state, DateTime time) { // While we're at it want to see if we see any garbage collections between // time interrupt was received and when we get it passed to us. bool on = state == 0; DateTime now = DateTime.Now; Debug.Print(now.ToString() + ", " + (time - now).Ticks.ToString() + ", " + on.ToString()); // Make up a flag. string flag; if (on) flag = "T"; else flag = "F"; byte[] buffer = Encoding.UTF8.GetBytes(flag); _Send.Write(buffer, 0, buffer.Length); } private static void Recv_DataReceived(object sender, SerialDataReceivedEventArgs e) { DateTime now = DateTime.Now; if (e.EventType == SerialData.Eof) { Debug.Print("EOF"); return; } // Should do some error checking for valid serial port, size of receive, etc. SerialPort sp = (sender as SerialPort); if (sp.BytesToRead == 0) return; byte[] buff = new byte[sp.BytesToRead]; sp.Read(buff, 0, sp.BytesToRead); string flag = new string(Encoding.UTF8.GetChars(buff)); switch (flag) { case "T": Debug.Print("Turn on LED " + now.ToString()); _Led.Write(true); break; case "F": Debug.Print("Turn off LED " + now.ToString()); _Led.Write(false); break; default: Debug.Print("Unrecognized Flag(" + flag + ") " + now.ToString()); break; } } } }
- karthick likes this
If my message helped you... how 'bout giving me a
www.MessingWithReality.com
#13
Posted 21 August 2014 - 03:30 PM
I've had a couple of compile errors, first I've gotten around was the system.net
i found relevant reference and added .system so thats now ok. but the second error is
The type or namespace name 'SerialPort' could not be found (are you missing a using directive or an assembly reference?)
why is the namespace not recognised?
i have an original netduino (netduino 1)
#14
Posted 21 August 2014 - 07:08 PM
i'm basically using the uart's to interact with a temperature and humidity sensor, once ive got the ports working i just need to write to them
eg, $sure humidity
and it will return eg. 056%RH
or $sure temp -c
for a return eg. 023Centigrade
the next step is to read the numerical data (first three digits) into a variable so i can affect an output based on each value.
i'm no programmer, this is the learning bit for me, i can handle the if then while and set the outputs as required.
its setting the uart ports and reading the relative bits into the variable that i struggle with.
as i said previously i'm still trying to get the serial port past the name space bit.
hard ware that's the easy bit for me i could probably build this in hard ware but it would be fixed levels. plus i wouldn't learn anything new, which was the point of getting the netduino.
my netduino is the original original one using SDK4.1
#15
Posted 09 November 2014 - 01:02 AM
Do you have Microsoft.SPOT.Hardware.SerialPort.dll added as an assembly reference in your project? We include this in the default Netduino templates--but if you created a project from scratch you'll want to pull this in if you're using SerialPorts....but the second error is
The type or namespace name 'SerialPort' could not be found (are you missing a using directive or an assembly reference?)
why is the namespace not recognised?
Welcome to the Netduino community,
Chris
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users