Serial Communication with PCs

Last Modified: August 7, 2011

Intro

The Cogwheel Nixie Driver board allows for serial communcations over USB and optionally Bluetooth. Future versions may include other methods, but these notes should apply to any abstraction which results in the board’s serial port being visible on a PC.

B7971x8 Perl Script

The following  Perl script was used to test the B7971 during development. It has been tested under Windows XP. Download it Here by saving the link.  Follow the instructions in the comments at the top to install Perl and get it running.

#! C:\perl\bin\perl.exe
 
#
# B7971x8.pl - Diagonstic Utility for communicating with Cogwheel Nixie System Driver board when configured
# to drive 8 B7971 tubes
#
# Usage:
#
#  perl B7971x8.pl
#
#  This will run the script. As shipped it will communicate on COM3, and run a list text in the
#  array $AllCmds. Commends preceded with a # are interpreted locally; #P means pause. #D means delay
#
# Known to work under Activestate Perl for Win32 5.10 or later. Download from
# http://www.activestate.com/activeperl/downloads Note, you will need to install the following
# two Perl modules:
use Time::HiRes  qw (usleep); # If you get a 'missing package' type "ppm install Time-HiRes"
use Win32::SerialPort;# If you get a 'missing package' type "ppm install Win32-SerialPort
# To do this, from the cmd prompt type 'ppm', the app should start, Click View->All Packages, then
# in the search box type Time::HiRes, then Click Action->Install, Then search on Win32-SerialPort,
# and also mark it for install. Then do a File->Run Marked Actions. Verify you can communicate
# with the Driver Board using a general purpose terminal emulator program (described in the documentation)
# You may need to adjust this port setting:
#
my $PortName = 'COM3';
my $PortObj = new Win32::SerialPort ($PortName) || die "Can't open $PortName: $^E\n";    # $quiet is optional
 
$PortObj->user_msg(ON);
$PortObj->databits(8);
$PortObj->baudrate(57600);
$PortObj->parity("none");
$PortObj->stopbits(1);
$PortObj->handshake("none");
$PortObj->buffers(4096, 4096);
$PortObj->write_settings || undef $PortObj;
 
$DelayTenths = 150;
 
$AllCmds=<<EOF;
#P
wir 5
tfx 1
txo c f
#D 120
txt !
txt Cogwheel
txt Circuit
txt Works
txt B7971 X8
txt B7971 X8
txt Nixie
txt Clock
txt And
txt Display
txt !
txt Use
txt BuiltIn
txt Font Or
txt Program
txt Indi-
txt vidual
txt Elements
txb 00010002000400080010002000400080
txb 00100020004000800100020004000800
txb 01000200040008001000200040008000
txb 10002000400080010002000400080000
#D 120
txt !
txt Lots
txt Of
txt Effects
txt !
txo c s
txt Shift
txt Words
txt On
txt Or
txt !
#D 450
txo c o
txt Shift
txt 1 by 1
txt !
txo c f
tfx 1
#D 120
txt Simple
txt Blink
txt Between
txt Messages
txt Or
txt !
txo c f
tfx 2
D 250
txt Fade
txt Between
txt Messages
txt !
#D 150
wis 0
tfx 3
txt Wipe
txt R to L
txt !
wis 1
txt Wipe
txt L to R
wis 3
#D 350
txt ***Or***
txt **Wipe**
txt  Random
wis 2
wir 2
#D 120
txt Wipe
txt Faster
wir 8
#D 400
txt Wipe
txt Slower
wir 4
#D 120
txo c f
tfx 4
wis 2
txt Or
txt Wipe
txt With
txt FX
txt !
wir 5
txo c f
tfx 2
#D 120
txt Cogwheel
txt Circuit
txt Works
txt B7971 X8
txt B7971 X8
txt !
tfx 2
ymd
EOF
 
$AllCmds2=<<EOF;
wir 5
tfx 1
txo r f
#D 55
txt X
txt XX
txt XXX
txt XXXX
txt XXXXX
txt X
txt XX
txt XXX
txt XXXX
txt XXXXX
txt !ABDCEFGH
txt !0123456
txt !ABDCEF
txt !01234
txt !ABDC
txt !012
txt !AB
txt !0
txt !AB
txt !012
txt !ABDC
txt !01234
txt !ABDCEF
txt !ABDCEFG
txt !01234567
txo c f
txt !ABDCEFGH
txt !0123456
txt !ABDCEF
txt !01234
txt !ABDC
txt !012
txt !AB
txt !0
txt !AB
txt !012
txt !ABDC
txt !01234
txt !ABDCEF
txt !ABDCEFG
txt !01234567
txo l f
txt !ABDCEFGH
txt !0123456
txt !ABDCEF
txt !01234
txt !ABDC
txt !012
txt !AB
txt !0
txt !AB
txt !012
txt !ABDC
txt !01234
txt !ABDCEF
txt !ABDCEFG
txt !01234567
EOF
 
$AllCmds3=<<EOF;
wir 5
tfx 1
#D 75
txt !XXXXXXXX
txt !
txt !XXXXXXXX
txt !X
txt !XXXXXXXX
txt !XX
txt !XXXXXXXX
txt !XXX
txt !XXXXXXXX
txt !XXXX
txt !XXXXXXXX
txt !XXXXX
txt !XXXXXXXX
txt !XXXXXX
txt !XXXXXXXX
txt !XXXX
EOF
 
sleep 2;
$PortObj->write("\r");
sleep 2;
 
my @Cmds = split "\n", $AllCmds3;
my @Cmds = split "\n", $AllCmds2;
my @Cmds = split "\n", $AllCmds;
 
while(1)
{
 RunEm();
}
exit;
 
sub RunEm()
{
 
foreach $m (@Cmds)
{
 # Leading / in stream is a command to us and not the clock
 if (!($m =~ /^#/))
 {
 print "$m\n";
 $PortObj->write($m. "\r");
 }
 else
 {
 if ($m =~ /^#P/)
 {
 ($p1,$p2) = split $m,' ';
 print $p2;
 print  "(Pause:  ?)";
 $m = <STDIN>;
 }
 elsif ($m =~ /^#D/)
 {
 ($p1,$DelayTenths) = split ' ',$m;
 print  "(Setting Delay to $DelayTenths)\n";
 }
 }
 $Dly = 25;
 $Dly = $DelayTenths if ($m =~ /^txt/);
 $Dly = $DelayTenths if ($m =~ /^txb/);
 foreach $x (1..$Dly)
 {
 usleep (10000);
 }
}
}
 
# ===
 
=cut
txt BUILT-IN
txt CHARSET:
txt ABCDEFGH
txt IJKLMNOP
txt QRSTUVWX
txt YZabcdef
txt ghijklmn
txt opqrstuv
txt qxyz0123
txt 456789!"
txt #$%&amp;amp;amp;amp;amp;'()*
txt +,-./_;<
txt =>?@[\]^
=cut
.

 

This project is released under the Creative Commons Attribution Share-alike license CC-BY-SA.