Go Down

Topic: Using a digital pin to test a serial adapter (Read 514 times) previous topic - next topic

linxdev

I've received a USB to serial adapter from Chine I bought off eBay.  I want to test it.  I thought it would be easy to use the UNO to do this.  I'm using this simple sketch:

Code: [Select]

int ledPin = 13; // LED connected to digital pin 13
int inPin = 7;   // pushbutton connected to digital pin 7
int val = 0;     // variable to store the read value

void setup()
{
  pinMode(ledPin, OUTPUT);      // sets the digital pin 13 as output
  pinMode(inPin, INPUT);      // sets the digital pin 7 as input
}

void loop()
{
  val = digitalRead(inPin);   // read the input pin
  digitalWrite(ledPin, val);    // sets the LED to the button's value
}


So the idea is this:

To test DTR I do the following:

I connect ping 5 (SG) to GND on the UNO.
I connect pin 4 (DTR) to digital pin 7 on the UNO.

If DTR is asserted the LED with light.  On the Linux computer I'll use a C program to turn off DTR.  This should make the LED go out.

My office is RF noisy so the minute I put a piece of wire (not connected to anything else) into pin 7 the LED lights.  Can someone tell me the best way to do this?

Thanks,
Chris


Grumpy_Mike

Best way to test it is to connect the RX and TX lines together. Then fire up the serial monitor in the arduino's host appliaction. If it works you should see your own typing coming back.

linxdev


Best way to test it is to connect the RX and TX lines together. Then fire up the serial monitor in the arduino's host appliaction. If it works you should see your own typing coming back.


That would test the data capabilities of this adapter.

I've ran into issues in the past where RTS was always asserted but I could not control from the OS.  Or DCD would be read asserted on the OS with nothing attached to the adapter.  Both of these can only be tested by looking at each pin.

The problem was transients.  I put a 104 cap between pin 7 and ground and that decoupled it.  The next thing I did was set pin 8 to high.

Code: [Select]

  pinMode(8, OUTPUT);     
  digitalWrite(8, HIGH);   


I wanted this to be a known.  I attached a 100ohm resistor between 8 and a 6" lead wire.  I could touch the lead wire to an LED and it would light so  I know it was aserted but touching the lead wire to the test lead of pin 7 produced no results. 


Grumpy_Mike

Quote
I put a 104 cap between pin 7 and ground and that decoupled it.

No No No,
That is NOT decoupling. Decoupling is always across the supply of a device.

Quote
int inPin = 7;   // pushbutton connected to digital pin 7

So where is the other end, assuming it is to ground you haven't enabled the internal pull up resistor.

A simple LED connected via a 1K resistor is best for testing the interface lines.

linxdev


Quote
I put a 104 cap between pin 7 and ground and that decoupled it.

No No No,
That is NOT decoupling. Decoupling is always across the supply of a device.

Quote
int inPin = 7;   // pushbutton connected to digital pin 7

So where is the other end, assuming it is to ground you haven't enabled the internal pull up resistor.

A simple LED connected via a 1K resistor is best for testing the interface lines.


The other end of 7 is to be used to test a serial port.  for example I would assert RTS on my computer then touch this probe to RTS on this port.  It should read HIGH.

retrolefty

Quote
I've received a USB to serial adapter from Chine I bought off eBay.


Do you have a link to the one you bought? I ask because you mentioned the DTR signal and most cheap ones don't have that signal avalible at their pin connectors. Some have a RST pin, but it's a input to the module and not something you would ever use. I recently moded a cheap one to bring the DTR signal out to support the auto-reset function, so maybe I can look at yours and see what it might take.

Lefty


linxdev


Quote
I've received a USB to serial adapter from Chine I bought off eBay.


Do you have a link to the one you bought? I ask because you mentioned the DTR signal and most cheap ones don't have that signal avalible at their pin connectors. Some have a RST pin, but it's a input to the module and not something you would ever use. I recently moded a cheap one to bring the DTR signal out to support the auto-reset function, so maybe I can look at yours and see what it might take.

Lefty




http://www.ebay.com/itm/390322704186?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649

Actually it works VERY well.  It supports all the pins.  My idea was to use the UNO as a testing system to see if the pins could be asserted from the host computer.  I've ordered different ones from eBay and wanted a way to test them.

What confused me was that if I touched pin 7 to RTS the LED would light.  If I touched pin 8 to pin 7 it would not.  I want 8 to be a known good "asserted pin" so that I could make sure the Arduino was working. 

I've proved the adapter does support the pins but need to do speed tests.

I'm still curious as to why in that program pin 8 would not make pin 7 go high. 

retrolefty

#7
Aug 23, 2011, 12:45 am Last Edit: Aug 23, 2011, 12:47 am by retrolefty Reason: 1
That one appears to be a RS-232 voltage level cable. The Arduino can not safely handle the negitive voltages that a true RS-232 interface uses, you require a "TTL serial" cable for direct wiring to arduino pins. You really shouldn't use that kind of cable without using a MAX232 type chip that does RS-232 to TTL voltage translator with data inversion.

Here is a serial TTL USB serial converter module I recently obtained.
http://www.ebay.com/itm/190544446821?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649

Go Up