Hi, I am trying to set up a serial link from my FEZ Mini through a Serial/USB converter to a PC. I hear that COM1 should not need any RS232/UART interface. If this is the case, what wire (COM1 Out, I am guessing) needs to be connected to what wire (Pin 2 of the PC serial interface, guessing again)? I do not seem to be able to receive any data. Am I supposed to specify a baud rate in the program, or is there a default for COM1? See code below. Thanks,
Tom
public class Program
{
// Blink board LED
static bool ledState = false;
static OutputPort led;
public static void Main()
{
SerialPort myPort = new SerialPort("COM1");
myPort.Open();
led = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, ledState);
while (true)
{
// convert the string to bytes
byte[] buffer = Encoding.UTF8.GetBytes("LED Status Is: " + led.Read().ToString());
// send the bytes on the serial port
myPort.Write(buffer, 0, buffer.Length);
Thread.Sleep(500);
}
}
}
Well,
After all sorts of experimenting with different com ports, baud rates, flow control (I’m not a serial communications expert), and using the pinouts specified in the above posts, I cannot get a single byte of data across. I have tried a PC with a COM port and a USB to serial cable in my laptop. There are differing voltage levels on the pins, but not the 12V to -12V. I do not possess an oscilloscope, but it seems from my multimeter that the levels go from about .05V to .5V. Any ideas?
Thanks,
Tom
You will not see 12v -> -12v on this type of level shifter but you should see at least a 5v swing… However!! with a trusty multimeter you would need a peak voltage selection to read the signal as the RMS of a 9600 baud signal would only be about 1/2 a volt…
Try a really short RS232 cable as the logic levels out of the FEZ is low…
High is 3.3v and low (theoretically is -12v) but you wont get that.
Hi,
I am still having problems with the COM1 output. I can read input from a PC fine, but pick up nothing on the PC end. The code I am using is show below:
using System;
using System.IO.Ports;
using System.Threading;
using System.Text;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;
namespace FEZ_Mini_Application1
{
public class Program
{
// Blink board LED
static bool ledState = false;
static OutputPort led;
static SerialPort myPort = new SerialPort("COM1");
public static void Main()
{
// create write buffer (we need one byte)
//create I2C object
I2CDevice.Configuration con = new I2CDevice.Configuration(0x38, 400);
I2CDevice MyI2C = new I2CDevice(con);
//create transactions (we need 2 in this example)
I2CDevice.I2CTransaction[] xActions = new I2CDevice.I2CTransaction[1];
byte[] writeByte = new byte[1] {0};
xActions[0] = I2CDevice.CreateWriteTransaction(writeByte);
MyI2C.Execute(xActions,500);
myPort.Open();
myPort.DataReceived += new SerialDataReceivedEventHandler(myPort_DataReceived);
led = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, ledState);
while (true)
{
// convert the string to bytes
byte[] buffer = Encoding.UTF8.GetBytes("LED Status Is: " + led.Read().ToString());
// send the bytes on the serial port
myPort.Write(buffer, 0, buffer.Length);
Thread.Sleep(1000);
}
}
static void myPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
try
{
byte[] buffer = new byte[myPort.BytesToRead];
myPort.Read(buffer, 0, myPort.BytesToRead);
char[] read = System.Text.Encoding.UTF8.GetChars(buffer);
string readString = new string(read);
Debug.Print(readString);
}
catch (Exception exp)
{
throw exp;
}
}
}
}
I am sure that the electrical connections are correct. Any ideas? This is integral to my design as I need to report analog data to a PC.
Thanks,
Tom
Can we keep this as simple as possible, I mean only send data in your code then test it . I am seeing a lot of things that are not related to testing RS232 transmit.
Once that is done, please post the code here to take a look then also provide exact details on how mini si connected to your PC
I posted earlier about this issue but I must have forgot to hit the reply button…
The code provided using the default values for baud rate, parity, data bits and stop bit size. If both sided don’t have the same values, problems can arise. Since the fex is receiving, I assume the baud rate is matched.