FEZ Mini RS232 COM1 question

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);
            }
        }


    }

You can’t connect directly - different voltage levels. You do need a converter.

If he is using COM1 on Mini than he should be fine

[url]http://www.tinyclr.com/forum/2/2231/[/url]

COM1 Out <-> Pin 2 (correct)
GND <-> Pin 5 (missing)

This way FEZ Mini will only send and not receive data.

Architect… I’m sure the mini has the rs232 circuitry in the form of two level shifters, x1 pin 1(rs232 out) and 2 (rs232 in)

Cheers Ian

Yes Mini has RS232 on COM1.

To connect to a PC, you need to wire the out pin from Mini to pin 2 on DB9 going to the PC. Also, connect the in pin from mini to pin 3 on the PC.

Note you need to connect both as the TX from Mini relies on having RX to work…don’t worry about details, if you connect both then it will work.

So GND is not required ?

Oh yes absolutely required!

@ tommyvdp Apologies for misleading answer, still sore from putting 15 yards of mulch over the weekend.

Pandas don’t get sore.

Too much bamboo then!!

Cheers Ian

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

Those voltages do not make sense!

Connect pin 2 to 3 on your PC and see if the data is echoed back

Hi,
Echo is working on both the FEZ and the PC. I just cant seem to get the one to talk to the other!

I added the following code:

        static void myPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
                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);
        }

Using this code, I can receive from the PC as well! I just am having trouble transmitting from FEZ to PC…
Any help is appreciated.
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.

Cheers Ian

[quote]Using this code, I can receive from the PC as well! I just am having trouble transmitting from FEZ to PC…
Any help is appreciated.[/quote]

I am not clear. You said it RX wasn’t working but with this code it is now working?! What changed? Maybe the problem is in the code?

Sorry to confuse, I was not testing RX before. RX works, TX does not. I will do some more experimenting based on suggestions…

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.

But rts handshaking could be enabled but not connected. Try setting all serial parameters.