Pages: 1 [2] 3   Go Down
Author Topic: Can the Uno handle two serial port functions ?  (Read 3312 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 74
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What do you want to do? If you want your UNO to be a USB2Serial device you can just connect it via USB to your PC and connect the TTL serial device to pins 0 and 1. Voilà, you have your USB2Serial. You don't need any software to be run on the UNO, it acts as a USB2Serial converter.
If you need something else than a USB2Serial converter, tell us what you want to achieve!


Thanks Pylon, sounds simple and yes that is all I want to do is to send data to my serial device
from my PC and to stream TTL serial data from that device to the USB port as I can have my Lab view application parse the data...

Does this require any code on the Uno to set up the pin 0 & 1 lines?
What would the code look like if there is code needed?

(regarding the TTL levels- I am using a Max32222 chip to interface between the ardunio Uno and the serial port of the device.)
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Does this require any code on the Uno to set up the pin 0 & 1 lines?

No. If you used the Arduino previously upload a sketch that doesn't use the serial interface (the Blink example is excellent for that), so the main processor doesn't acquire the serial interface and interferes with your usage.

Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 74
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Does this require any code on the Uno to set up the pin 0 & 1 lines?

Quote
No. If you used the Arduino previously upload a sketch that doesn't use the serial interface (the Blink example is excellent for that), so the main processor doesn't acquire the serial interface and interferes with your usage.

Thanks- sounds simple...

will I be able to see the data that comes across the USB port in a terminal program?
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
will I be able to see the data that comes across the USB port in a terminal program?

If you connected everything correctly and configured the program that way: yes.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 74
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Because the Rs232 lines are ~12v, I connected a Max 32222 inline with the
txd line from the device to the Arduino Uno.

At first I could only see the ~12v data from the Serial Device txd line  on the Max 3222 chip
but the 5v side of this chip (which is connected to D0 - rxd) did not have this same signal so  I
set the pinmode of D0 as an input and now I can see the 5v signal on D0
 when I press a button on the serial device panel.

I have the USB connected to my PC and am running hyperterminal set to the correct values
of the device (9600 N81) but this data is not seen in the hyper terminal...

I am running out of ideas but it does not appear that the RXD line of the Arduino on D0 is being
echoed up the USB port to my PC...

This is the modified blink program that I am using:
Code:
/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */
 
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {               
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);   
  pinMode (0, INPUT);  // rxd
  pinMode (1, OUTPUT);  // txd
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 74
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, I got it working...

I had to actually set up a simple serial polling routine and have added the code below.

Thank you to everyone that sent some direction for your help in solving this issue!


Code:
//  Cpanel- to read the Control Panel Serial data and echo data to USB port...

 
// Pin 13 has an LED connected on most Arduino boards.
int led = 13;

// the setup routine runs once when you press reset:
void setup()
{   

  // initialize serial:
  Serial.begin(9600); 
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);   
  pinMode (0, INPUT);  // rxd
  pinMode (1, OUTPUT);  // txd
}

// the loop routine runs over and over again forever:
void loop()
{
 
  while (Serial.available() > 0)
  {
    char inChar = (char)Serial.read();
    Serial.print(inChar);
  }

}
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 74
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This set up works when reading keys pressed on the control panel as this data is sent down the serial port and echoed to the PC via the USB port when I am running Windows XP version of hyperterminal but I am unable to send data to this device when I type characters into the hyperterminal window.

Am I missing something or should this be seamless?

Or do I need to add some sort of polling code so that data gets echoed back to the serial device also?

Code:
int led = 13;

// the setup routine runs once when you press reset:
void setup()
{   

  // initialize serial:
  Serial.begin(9600); 
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);

  pinMode (0, INPUT);  // rxd
  pinMode (1, OUTPUT);  // txd
}

// the loop routine runs over and over again forever:
void loop()
{
 
  while (Serial.available() > 0)
  {
    char inChar = (char)Serial.read();
    Serial.print(inChar);
  }

}
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
  pinMode (0, INPUT);  // rxd
  pinMode (1, OUTPUT);  // txd

You must not do that. Once you called Serial.begin() pins 0 and 1 are handled by the hardware you must not call any functions that change the hardware configuration.

Quote
Or do I need to add some sort of polling code so that data gets echoed back to the serial device also?

If you want to see the characters you type in the hyperterminal, you must echo them back (or activate local echoing in the program).

Can you describe again, what your problem is? Describe what works and what doesn't as well as what you expected.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 74
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 Thank you Pylon-

Code:
  pinMode (0, INPUT);  // rxd
  pinMode (1, OUTPUT);  // txd

Quote
You must not do that. Once you called Serial.begin() pins 0 and 1 are handled by the hardware you must not call any functions that change the hardware configuration.

I have tried this code as shown above and with the pinmode lines commented out
and have not seen a difference in the operation or behavior of either one.


Quote
Or do I need to add some sort of polling code so that data gets echoed back to the serial device also?

If you want to see the characters you type in the hyperterminal, you must echo them back (or activate local echoing in the program).

Yes, I have the echo feature set in Hyper terminal and see the characters as I type them into hyper terminal. These lines are now commented out...

Quote
Can you describe again, what your problem is? Describe what works and what doesn't as well as what you expected.


OK, as you may recall from my earlier posts(s) that I have a control panel containing
60 plus buttons that is a serial device, I have this connected to my Arduino Uno
and the arduino connected to my PC's USB port. You mentioned earlier that this is a pass through type configuration because the USB and the serial port share the same ines (d0 = rxd, & d1 = txd).

I do have a level shifter between the arduino and the device to set the lines to rs232 levels and I can read data from the control panel when buttons are pressed.
When buttons on the contol panel are pressed, I can see a negative going series of
pulses on both d0 and d1 of the arduino. The d0 line's voltage level is between 0 volts
and ~ 4v while the d1 line's voltage level is between 0 volts and ~ 5v.

When I enter a key from my PC's keyboard,I can see a small negative going pulse that
appears at a voltage level of ~ 4v to a low of about ~3.5v and cannot see a pulse
on the txd line (D1).

In an attempt to isolate this to the ardunio, I have removed the level shifter part and tried this and I still am not able to see a pulse on the txd line (d1).

So the problem appears to be that I can not send data to the serial port control
panel device and the data that should be presented to d1 (from the USB port) is not...

Not sure what else to try at this point. 
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I still have no picture of how you have wired your project. Is that button control panel only sending data or do you have to send some commands to that panel? Do you have a link to the datasheet of that panel? Why do you need an Arduino?
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 74
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I still have no picture of how you have wired your project. Is that button control panel only sending data or do you have to send some commands to that panel?


This control panel sends data via a serial port and receives data from the same serial port.
I need to read data and send data to it... Currently, I can only receive data from it...

Quote
Do you have a link to the datasheet of that panel?


No, there is not a datasheet available for this as it is a company proprietary piece of equipment.

Not sure why you would need a datasheet for this when the arduino can't pass data on its D1 txd line from the USB regardless if the equipment or anything else is connected to the D1 pin...

Quote
Why do you need an Arduino?

Because this device usually interfaces to an old serial type interface and I would like to interface it directly to a USB port on my PC...
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Because this device usually interfaces to an old serial type interface and I would like to interface it directly to a USB port on my PC...

Don't you think a USB2Serial converter (like the USB2Serial Light from Arduino or a FTDI cable) will do that job cheaper and less error prone?
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 74
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Originally I was looking for a simple serial to USB converter cable but headed down the arduino path
when I couldn't find one that fit the bill...

Not sure if USB2Serial Light from Arduino or a FTDI cable would work any better/easier as they seem to convert USB TXD & RXD into a 5v TTL level and I need to interface to a true rs2s2 +/1 12v TXD & RXD.

I am using a standard configuration connection to the arduino with a Max 3222 IC but when it is connected to the arduino, the RXD line seems to be loaded down so that no signal is seen on it. When I remove the part, (or even just lift the pin of the part) this line toggles like it should when I am typing characters into my keyboard while connected to hyper terminal.

The connections are correct but I wonder if the arduino can't drive this Max 3222 line for some reason.

I am open to use an inexpensive  (+/- 12v) serial to USB adapter for this if anyone has a link of one that would fit the fill.

thanks
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Not sure if USB2Serial Light from Arduino or a FTDI cable would work any better/easier as they seem to convert USB TXD & RXD into a 5v TTL level and I need to interface to a true rs2s2 +/1 12v TXD & RXD.

That's even easier, get a USB2RS232 adapter, the ones with a Prolific PL2303 are only a few bucks.

p.e. http://www.amazon.com/RS232-SERIAL-Adapter-CABLE-PL2303/dp/B00404N0IQ

Quote
I am using a standard configuration connection to the arduino with a Max 3222 IC but when it is connected to the arduino, the RXD line seems to be loaded down so that no signal is seen on it. When I remove the part, (or even just lift the pin of the part) this line toggles like it should when I am typing characters into my keyboard while connected to hyper terminal.

The MAX 3222 doesn't generate a +/- 12V signal but a +/- 5V signal (according to the datasheet) but this should be OK for most applications.
The MAX 3222 doesn't have an RXD pin. How did you connect the Arduino to this chip?
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 74
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


 Thanks for the reply Pylon and sorry for the delayed response...

Quote
That's even easier, get a USB2RS232 adapter, the ones with a Prolific PL2303 are only a few bucks.

I actually found one of these type adapters laying around the lab here and
I started to build an interface to the RJ4 connector and power required by my device
but have not gotten it working yet.

Quote
The MAX 3222 doesn't generate a +/- 12V signal but a +/- 5V signal (according to the datasheet) but this should be OK for most applications.
The MAX 3222 doesn't have an RXD pin. How did you connect the Arduino to this chip?

I used the same circuit as the serial device that I am interfacing with
uses. The only difference is that the I am connecting to the Arduino where that
device interfaces to an FPGA...

Not sure how to post a JPG on this forum as a picture is worth a thousand words
but here is a breakdown of the pins of the MAX32222 connections

Pin1  - EN/   - VSS
Pin2  - C1+   - 0.1ufd Cap (other side connected to pin4)
Pin3  - V+    - 0.1ufd Cap (other side connected to VSS)
Pin4  - C1-   - 0.1ufd Cap (other side connected to pin2)
Pin5  - C2+   - 0.47ufd Cap (other side connected to pin6)
Pin6  - C2-   - 0.47ufd Cap (other side connected to pin5)
Pin7  - V+    - 0.1ufd Cap (other side connected to VSS)
Pin8  - T2OUT - N/C
Pin9  - R2IN  - VSS
Pin10 - R2OUT - N/C
Pin11 - T2IN  - N/C
Pin12 - T1IN  - Arduino D1
Pin13 - R1OUT - Arduino D0
Pin14 - R1IN  - To Serial Device TXD (an RJ4 connector pin1)
Pin15 - T1OUT - To Serial Device RXD (an RJ4 connector pin3)
Pin16 - GND   - VSS
Pin17 - VCC   - 3.3V
Pin18 - SHDN/ - 3.3V

For what it is worth, the RJ connector on the Serial device has the following
pinout as referenced by the device:

Pin1 - RS232 In
Pin2 - +12V
Pin3 - RS232 Out
Pin4 - Gnd

The +12V and Gnd are supplied by an external power adapter and I have tied
the GND of this to the Arduino ground.

As I stated before, I am able to read data coming from the device but unable to
send data to the device.

A new observation is that the signal on D1 (TXD) dies when the Max3222 is
connected to the D0 (RXD) line while the D0 (RXD) line receives data just fine.

When I disconnect the MAX3222 pin 13 from the D0 (RXD) line, the D1 (TXD) signal is no
longer dead (as seen on my scope) and I can then send data to the device.
In this condition, the data from the device (when a button is pressed) is seen on
the MAX3222 pin 14 but it is not read in hyper terminal with pin 13 disconnected from D0.

To carry this another step further, I reconfigured the MAX3222 so that all pins (except pin14)
were connected to see if the D1 (TXD) line was getting dragged down by the device but
found that in this configuration D1 was also dead.

For an additional sanity check, I replaced the MAX3222 with another new part and as long
as D0 (RXD) is connected to the MAX3222 pin 13, the  D1 (TXD) line is dead...

Seems like there is some sort of contention on the TXD line when the RXD line
is connected to the arduino...
Logged

Pages: 1 [2] 3   Go Up
Jump to: