Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Microcontroller
hellow
i have made a cut in one end of my serial port cable,i want to reconnect the wires to a null cable,but i have found only 7 wires + 1 uninsualted wire ,i also have found a foil. using the ovometer i have recoginzed wire number 2,3,4,5,6,7,and 8,i could not found wire number 1 and wire number 9using this end of the cable ,how can i connect the serial cable to a null modem?
Posted 9-Apr-12 6:43am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Assuming this is a 9 pin connector, don't worry too much about 1 and 9 - they are DCD and RI respectively so you probably don't need them.
Just try connecting 2->3, 7->8 and 4->6 and see if it works. (5 is ground, and you shouldn't need it for null modem since it doesn't go anywhere)
  Permalink  
Comments
Khalid Sabtan at 9-Apr-12 12:27pm
   
i need wire 2 and 3 to be free ,because i want to send number to max232n then to the pic
my circiut works fine with another program but with my c# program it does not works,thats why i feel i need null modem,however i might not need null
modem for this circuit ,any suggestion?
OriginalGriff at 9-Apr-12 12:54pm
   
Try connecting 2 & 3 through (you may need to cross them depending on your hardware at the PIC end) along with 5 to signal ground.
Then try setting the SerialPort.Handshake to None - it defaults to it, but it's worth a try.
Khalid Sabtan at 9-Apr-12 14:09pm
   
i need time,may be 24 hour,reason works at my job
Khalid Sabtan at 10-Apr-12 4:28am
   
this is the full program
if u need i will attach the pic assembly program too,however i do not think it has any problem
#region Using directives
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
#endregion
 
namespace SerialPort2Computer
{
public partial class Form1 : Form
{
SerialPort sp = new SerialPort();
 
public Form1()
{
InitializeComponent();
}
 
private void Form1_Load(object sender, EventArgs e)
{
sp.PortName="com2";
sp.BaudRate = 9600;
sp.DataBits = 8;
sp.Parity = Parity.None;
sp.StopBits = StopBits.One;
sp.Handshake = Handshake.None;
//
sp.Open();
sp.ReadTimeout = 500;
}

private void sendButton_Click(object sender, EventArgs e)
{
try
{
//write line to serial port
sp.WriteLine(textBox1.Text);
//clear the text box
textBox1.Text = "";
}
catch (System.Exception ex)
{
BaudRateLabel.Text = ex.Message;
}
 
}
 
private void ReadButton_Click(object sender, EventArgs e)
{
try
{
//clear the text box
textBox2.Text = "";
//read serial port and displayed the data in text box
textBox2.Text = sp.ReadLine();
}
catch (System.Exception ex)
{
BaudRateLabel.Text = ex.Message;
}
}
 
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
MessageBox.Show("Do u want to Close the App");
sp.Close();
}
 
private void startCommButton_Click(object sender, EventArgs e)
{
startCommButton.Hide();
//
PortNameLabel.Text += " = " + sp.BaudRate.ToString();
BaudRateLabel.Text += " = " + sp.Parity.ToString();
DataBitsLabel.Text += " = " + sp.DataBits.ToString();
ReadTimeOutLabel.Text += " = " + sp.ReadTimeout.ToString();
ParityLabel.Text += " = " + sp.Parity.ToString();
StopBitsLabel.Text += " = " + sp.StopBits.ToString();
HandShakeLabel.Text += " = " + sp.Handshake.ToString();
//
sendButton.Show();
readButton.Show();
textBox1.Show();
textBox2.Show();
}
 
}
}
OriginalGriff at 10-Apr-12 4:37am
   
First check you have the right serial port.
Then, when you say "it doesn't work" what does / doesn't happen? Have you tried with a terminal program?
Khalid Sabtan at 10-Apr-12 5:24am
   
i am tring to send number say 56 to the pic ,so i wrote 56 in textBox1 and pressed send button,i want to recieve this number in portb of the pic,i found all bits (b0,b1,.... b7) are zero mVolt, i have also tried at com1 and com2.i beleive i have the right serial port, i also connect the serial ground cable(pin 5) to the ground point in the pic circut.i tried to include the circuit diagram in this question but i could not
OriginalGriff at 10-Apr-12 5:38am
   
You have too many variables. The first thing to do is to show it works in some way - you can start with either end:
1) Change your PIC software to toggle an output line for every character received. Then monitor that line and send a character. When you can see them arriving, you can start to look at what you receive.
2) Change your C# software to monitor incoming data as well, and temporarily join 2 + 3 remembering to unplug it from the PIC. When you can send data and get it back, you know you have data arriving on the wires. Then start looking at data arrival at the PIC.
Khalid Sabtan at 10-Apr-12 5:49am
   
i have joined 2 and 3 at the end cable (i have removed the pic circuit)then i wrote 56 in textBox1 and pressed send button, i could not get any number in textBox2.
in sendButton_Click ,i changed my code as this
 
sp.WriteLine(textBox1.Text);
textBox2.Text = sp.ReadLine();//<--
 
it seems i have problem in the above c# code
OriginalGriff at 10-Apr-12 7:59am
   
Not necessarily - data transmission is not instant in real time - try putting a delay in: Thread.Sleep(2000) should do it.
Khalid Sabtan at 10-Apr-12 14:31pm
   
so far the program now write and read perfectly
 
sp.WriteLine(textBox1.Text);
Thread.Sleep(2000);//<-------
textBox2.Text = sp.ReadLine();
OriginalGriff at 10-Apr-12 14:38pm
   
Good! You have the right port, and your software is sending ok.
Time to look at the other end - check if you Rx any characters at the PIC at all - it may be as simple as crossing 2 & 3 over (I mentioned that yesterday)
Khalid Sabtan at 10-Apr-12 14:49pm
   
more likley it will work if i connected the cable to the pic circuit
unfurtuntly the circuit now is on my work (place of work)i am at home,i can not test it now, may be after 12 hours,i promise you with the 5 star
OriginalGriff at 10-Apr-12 14:52pm
   
Don't forget to remove the loop back! :laugh:
Khalid Sabtan at 11-Apr-12 2:06am
   
Finally it works,it is my habit to echo what i have read if i have error in files,but i never imagened that i could do that by joining the two wires(2 and 3) now i fell i have reached the other bank of the river(remember in saudi arabia there is no river at all but sure we do have hidden countless rivers of oils) thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 406
1 Marcin Kozub 225
2 Sergey Alexandrovich Kryukov 205
3 Raul Iloc 170
4 Maciej Los 164
0 OriginalGriff 8,289
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,624
3 Maciej Los 4,989
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 9 Apr 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100