Watching a serial port count on an oscilliscope

Want to ask about that much needed test equipment? Looking for something new? Check in here!
Post Reply
User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Watching a serial port count on an oscilliscope

Post by rperkins »

So since I got interested in RC, I finally splurged and bought an arduino. Been studying on serial communications and wanted to 'see' it in action. This doesnt actually use the arduino. It's just a perl script communicating to a usb/serial adapter. It shows the marks and spaces counting to 255. demonstrated to me that ttl serial uses a 'high' voltage as a logic 1, whereas I read that actual rs-232 uses a 'low' or negative voltage for a logic 1. Also demonstrated endian, or byte order. This is MSB order. I'd had that backwards in my mind until I saw this and thought about it. Dont really have a question, justed posted it for the entertainment value. :D my perl is probably a tangled mess also. If you see any errors or have any comments in what I think I have figured out, dont be shy.

http://www.youtube.com/watch?v=zFPpQwZqBDw

Code: Select all

#! /usr/bin/perl
# I had edited this script after I made the video, I tried to get it back the way it was, but may have missed something
use strict;
use Device::SerialPort;
use Time::HiRes;
my $file = "/dev/ttyUSB1";
my $ob = Device::SerialPort->new ($file) || die "Can't open $file: $!";

$ob->baudrate(9600)     || die "fail setting baudrate";
$ob->parity("none")     || die "fail setting parity";
$ob->databits(8)        || die "fail setting databits";
$ob->stopbits(1)        || die "fail setting stopbits";
$ob->handshake("none")  || die "fail setting handshake";
$ob->write_settings || die "no settings";

my $pass;

$pass=$ob->write("lets get ready to go");
print "We are pausing for 2 seconds to get the port open\n";
sleep 2;
while (1) {
for (my $i = 1; $i < 255; $i++) {
        print "the value of i is $i\n";
               for (my $repeat =1;$repeat < 100; $repeat++) {
                        $pass=$ob->write(pack('c',$i));
                        Time::HiRes::sleep(.01);
               }
        }
print "finished this cycle, We are pausing for 3 seconds\n";
sleep 3;    

User avatar
erazz
9x Developer
Posts: 682
Joined: Tue Dec 27, 2011 6:25 pm
Country: -
Location: NJ-USA
Contact:

Re: Watching a serial port count on an oscilliscope

Post by erazz »

Nice!
Z

BEWARE - WE ARE IN THE AIR!!!
What goes up... Should be controlled by a 9X!
User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Re: Watching a serial port count on an oscilliscope

Post by rperkins »

After spending some time looking at a DX4i's serial output, I'm now thinking this is really LSB order ?
junspers
Posts: 2
Joined: Mon Jan 06, 2014 9:33 am
Country: -

Re: Watching a serial port count on an oscilliscope

Post by junspers »

thanks for the sharing

Post Reply

Return to “Reviews”