Please login or register.

Login with username, password and session length
Advanced search  

News:

The X10Hub (PiX10Hub) is here! Created by the Community, for the Community.:)% #:)

Pages: 1 [2] 3

Author Topic: Powerlinc II  (Read 35728 times)

pconroy

  • Hero Member
  • *****
  • Helpful Post Rating: 9
  • Posts: 294
Re: Powerlinc II
« Reply #15 on: June 17, 2010, 11:05:27 PM »

I'll try to assemble some relevant snippets and get them to you.

Java serial port programming is a little bit of a pain - you have to download some extra libs.
If you have your heart set on Java - you can start prepping your environment to give Java access to the serial port.
Google away for that one.

C/C++ will be able to open the ports without hassle.

Jesse Peterson wrote some good Java code.
"heyu" is a C program that accesses the port - but finding what you're after in that code base can be a little daunting if you've not looked at it before.

Here, I pulled up my IDE.
This is the open() code I use:

// -----------------------------------------------------------------
int X10Controller::connect (const string portName, const int baudRate)
{
    setPortName( portName );

    //
    //  open up the serial port
    struct  termios     adtio;
    int     portstatus;

    if ((this->portNum = open( this->portName.c_str(), O_RDWR | O_NOCTTY | O_NONBLOCK)) < 0)    {
        std::cout << "Unable to open the X10Controller on serial device " << this->portName << "\n";
        this->isOpen = false;
    } else {
        //
        // We want full control of what is set and simply reset the entire adtio struct
        memset( &adtio, 0, sizeof( adtio ) );

        // Serial control options
        adtio.c_cflag &= ~PARENB;      // No parity
        adtio.c_cflag &= ~CSTOPB;      // One stop bit
        adtio.c_cflag &= ~CSIZE;       // Character size mask
        adtio.c_cflag |= CS8;          // Character size 8 bits
        adtio.c_cflag |= CREAD;        // Enable Receiver
        adtio.c_cflag &= ~HUPCL;       // No "hangup"
        adtio.c_cflag &= ~CRTSCTS;     // No flowcontrol
        adtio.c_cflag |= CLOCAL;       // Ignore modem control lines

        // Baudrate, for newer systems
        cfsetispeed( &adtio, baudRate );
        cfsetospeed( &adtio, baudRate );

        // Serial local options: adtio.c_lflag
        // Raw input = clear ICANON, ECHO, ECHOE, and ISIG
        // Disable misc other local features = clear FLUSHO, NOFLSH, TOSTOP, PENDIN, and IEXTEN
        // So we actually clear all flags in adtio.c_lflag
        adtio.c_lflag = 0;

        // Serial input options: adtio.c_iflag
        // Disable parity check = clear INPCK, PARMRK, and ISTRIP
        // Disable software flow control = clear IXON, IXOFF, and IXANY
        // Disable any translation of CR and LF = clear INLCR, IGNCR, and ICRNL
        // Ignore break condition on input = set IGNBRK
        // Ignore parity errors just in case = set IGNPAR;
        // So we can clear all flags except IGNBRK and IGNPAR
        adtio.c_iflag = IGNBRK|IGNPAR;

        // Serial output options
        // Raw output should disable all other output options
        adtio.c_oflag &= ~OPOST;

        adtio.c_cc[ VTIME ] = 10;           // timer 1s
        adtio.c_cc[ VMIN ] = 0;             // blocking read until 1 char

        if (tcsetattr( this->portNum, TCSANOW, &adtio ) < 0) {
            // cout << "Unable to initialize serial device";
        } else {
            tcflush( this->portNum, TCIOFLUSH );

            //
            // Set DTR low and RTS high and leave other ctrl lines untouched
            ioctl( this->portNum, TIOCMGET, &portstatus);    // get current port status
            portstatus &= ~TIOCM_DTR;
            portstatus |= TIOCM_RTS;
            ioctl( this->portNum, TIOCMSET, &portstatus );    // set current port status

            this->isOpen = true;
        }
    }

    return ( this->isOpen ? this->portNum : 0 );
}   // open

Logged

neo11

  • Full Member
  • ***
  • Helpful Post Rating: 1
  • Posts: 31
  • Bitbucket sinkhole
Re: Powerlinc II
« Reply #16 on: June 17, 2010, 11:14:46 PM »

I have no great love of Java just that I can use it if I have to . Java is a pig and a
pain sometimes. C,C++ is fine . The snippet you sent is great thanks. OO in C++
is faster which is an issue for control systems I would think. A hacking I will go eh?
  B:(
Logged
Working  -:)

pconroy

  • Hero Member
  • *****
  • Helpful Post Rating: 9
  • Posts: 294
Re: Powerlinc II
« Reply #17 on: June 18, 2010, 06:50:07 PM »

Well, we're off in the weeds, but I'll toss out I have no love for C++.  I much prefer Java and am glad that I only do C++ when forced.   ;D
I agree Java is a pig - which is why I turned to C and C++ for this, as it's running on my 450MHz PII, ten year old, twenty dollar, craigslist laptop, with 256MB.  My 36K C executable (statically linked too) would be 36MB or more in Java.   rofl

Anyway - once the port is opened, the nice thing about the Powerlinc, is that 0x0D will end all xmissions. You can loop and read bytes until you hit 0X0D.

My write code:
// -----------------------------------------------------------------
int     X10Controller::writeData (byte *buffer, unsigned int bufLen)
{
    if (!this->isOpen)
        return 0;

    int numWritten = (int) write( this->portNum, buffer, bufLen );
    tcdrain( this->portNum );   // wait for all output written
    return numWritten;
}


I can post my read code, but it probably isn't what you wanted.
I implemented the serial port read as a separate thread - that thread plucks chars off the port and stuffs them into a buffer.
Other threads, lock the buffer, pluck characters out, and move the buffer pointers.

To start off you're going to want to do, more or less:

do {
   read();
until (buf[ 0 ] = 0x0D);


One thing to watch for is that I ended up reading a ton of NAKs (0x15), NULLs (0x00) in the stream.
I felt the only way to make sense of the data was to skip over those.

Also started getting some 0xC5s and the end too, before I gave up on the unit.
Logged

neo11

  • Full Member
  • ***
  • Helpful Post Rating: 1
  • Posts: 31
  • Bitbucket sinkhole
Re: Powerlinc II
« Reply #18 on: June 18, 2010, 08:12:24 PM »

Well, we're off in the weeds, but I'll toss out I have no love for C++.  I much prefer Java and am glad that I only do C++ when forced.   ;D
I agree Java is a pig - which is why I turned to C and C++ for this, as it's running on my 450MHz PII, ten year old, twenty dollar, craigslist laptop, with 256MB.  My 36K C executable (statically linked too) would be 36MB or more in Java.   rofl

Anyway - once the port is opened, the nice thing about the Powerlinc, is that 0x0D will end all xmissions. You can loop and read bytes until you hit 0X0D.




Thanks a bunch for your input  >! Didnt want you to have to get your weed wacker out  :'(
Also didnt want to start a language war  ;). They generate more heat then light unfortunately.
Please excuse as I truncated your code in the quote in the interest of saving bandwidth. This
looks the kind of stuff I had to do for terminal emulation code .  It's nice to see some real world
experience with this stuff.  I shall quote you copiously in anything I come up with. :)%. Just a
couple of questions . I read someplace that the baudrate of this things serial port is 19200. Is that
true?  and does this unit accept the PSC05/523 commands ? Before I start in earnest I need to
get a filter for my computers UPS as I found it's a major signal sucker (eats x10 signals).
This is way cool I should have something working pretty soon. Thanks++
 #:)

Logged
Working  -:)

Brian H

  • Community Organizer
  • Hero Member
  • ***
  • Helpful Post Rating: 289
  • Posts: 12690
Re: Powerlinc II
« Reply #19 on: June 19, 2010, 06:45:49 AM »

There is a 1132B programming manual available on the 1132B's sales page link in your earlier post.
It says 9600 baud; 8 bit; 1 stop bit; no parity.
It also shows the PSC05/TW523 pins on the 1132B's interface connector.
I have used an 1132B with a WGL V572 all house code transceiver. It uses the PSC05/TW523 to send X10 power line signals.
The PSC05/TW523 is not serial. You physically have to toggle control lines to send and receive X10 signals. You have to do all the encoding of the data to properly toggle the control lines in sync with the zero crossing signal. There is also a link to a PSC05 manual on the 1132Bs sales page in your earlier post.

You may have seen the 2412S PLM's specifications. It is 19,200 baud; 8 bit; 1 stop bit; no parity
The 2412S PLM uses a completely different set of commands to do things versus the 1132B.

There is data on the 2412S here:
http://www.madreporite.com/insteon/insteon.html
« Last Edit: June 19, 2010, 07:00:23 AM by Brian H »
Logged

neo11

  • Full Member
  • ***
  • Helpful Post Rating: 1
  • Posts: 31
  • Bitbucket sinkhole
Re: Powerlinc II
« Reply #20 on: June 19, 2010, 09:32:35 PM »

There is a 1132B programming manual available on the 1132B's sales page link in your earlier post.
It says 9600 baud; 8 bit; 1 stop bit; no parity.
It also shows the PSC05/TW523 pins on the 1132B's interface connector.
I have used an 1132B with a WGL V572 all house code transceiver. It uses the PSC05/TW523 to send X10 power line signals.
The PSC05/TW523 is not serial. You physically have to toggle control lines to send and receive X10 signals. You have to do all the encoding of the data to properly toggle the control lines in sync with the zero crossing signal. There is also a link to a PSC05 manual on the 1132Bs sales page in your earlier post.

You may have seen the 2412S PLM's specifications. It is 19,200 baud; 8 bit; 1 stop bit; no parity
The 2412S PLM uses a completely different set of commands to do things versus the 1132B.

There is data on the 2412S here:
http://www.madreporite.com/insteon/insteon.html

Thanks guys. Mucho info has been provided , This board is WAY COOL !  >! Don't think I could have got
this info anywhere else. I am impressed with the technical knowledge available here. This in no way
normal for most devices I have tried to work with. Even those I have worked with as a
contractor for a manufacturer  :o. Almost scary but Great  :)% . Enough of my babbling
now on to work >*<.
Logged
Working  -:)

neo11

  • Full Member
  • ***
  • Helpful Post Rating: 1
  • Posts: 31
  • Bitbucket sinkhole
Re: Powerlinc II
« Reply #21 on: July 10, 2010, 10:20:24 PM »

Well, found something I really didnt want to know, looks like I threw away $40.00. After fooling around
with a scope and a serial sniffer program, found no activity at all in the serial interface, not even a
RS232 voltage on the DB9 cable. So I did the unthinkable and took the thing apart. There is no intelligence
at all in this thing. Just a power supply and a pass through 3 prong socket plug. Sucks . I guess I have to
buy something else but cant tell from the web page I ordered it on. No wonder nobody knows anything
about it. I could have made a 12v power supply for about $20.00 . Maybe I can find out how to still use it
but there nothing there , not even a processor chip. I am kinda pissed as you prolly can tell. Thanks for
the help anyways guys. Dont buy thing thinking to use it with your computer. If anyone knows anything
to make this thing something other then a paperweight , please speak up.  >*< Maybe I have to get a
PSC05 or something. I have one in my junk box.  ::)
Logged
Working  -:)

Brian H

  • Community Organizer
  • Hero Member
  • ***
  • Helpful Post Rating: 289
  • Posts: 12690
Re: Powerlinc II
« Reply #22 on: July 11, 2010, 10:04:31 AM »

My 1132B definitely has electronics in it. The controller and RS232 ICs are surface mounted on the back of the PC Board and not visible.
If you just removed the top cover and saw the power supply components and AC pass through outlet pins. You may have thought there was no Processor and RS232 ICs in it.

Near the right edge of the board near J4 {Firmware programming connector} is there a silk screened PowerLinc II?

On mine with the serial cable. Pin 2, RX Data to PC,  is about -9.76 volts when referenced to the Pin 5 common.
My RS232 breakout box with a dual color LED is not fast enough to see the swing but on an analog meter the pointer does kick toward the plus side. When an X10 signal is received from the power line.

On the RJ45 style connector. Pin 1 RX Data to PC is -9.76 volts referenced to pin 7 common and pin 2 raw +12 Volts is about 20 volts with no load with reference to again pin 7 common.

If there is no RS232 voltage on pin 2 to pin 5 of the DB9 cable from the 1132B. The RS232 cable or the PowerLinc II maybe defective.

Since the PowerLinc II does not have hardware handshaking. Make sure your RS232 port is not wanting a handshake.

Any chance you have a computer that can run the PowerLinc Synapse {on the sale page}  program to test it?

PSC05 is not a serial device.
« Last Edit: July 11, 2010, 02:10:05 PM by Brian H »
Logged

pconroy

  • Hero Member
  • *****
  • Helpful Post Rating: 9
  • Posts: 294
Re: Powerlinc II
« Reply #23 on: July 11, 2010, 11:45:44 AM »

Also - I have an older Powerlinc Serial.
I don't know where you live Neo, but I live in Colorado.

I'd be willing to ship you mine, temporarily, to see if you can get your software going.
Or we can swap units - temporarily, as I'm pretty sure you don't want mine long term - to see if we can get each others to work.

:)

Good luck!
Logged

neo11

  • Full Member
  • ***
  • Helpful Post Rating: 1
  • Posts: 31
  • Bitbucket sinkhole
Re: Powerlinc II
« Reply #24 on: July 11, 2010, 04:03:03 PM »

My 1132B definitely has electronics in it. The controller and RS232 ICs are surface mounted on the back of the PC Board and not visible.
If you just removed the top cover and saw the power supply components and AC pass through outlet pins. You may have thought there was no Processor and RS232 ICs in it.

Near the right edge of the board near J4 {Firmware programming connector} is there a silk screened PowerLinc II?

On mine with the serial cable. Pin 2, RX Data to PC,  is about -9.76 volts when referenced to the Pin 5 common.
My RS232 breakout box with a dual color LED is not fast enough to see the swing but on an analog meter the pointer does kick toward the plus side. When an X10 signal is received from the power line.

On the RJ45 style connector. Pin 1 RX Data to PC is -9.76 volts referenced to pin 7 common and pin 2 raw +12 Volts is about 20 volts with no load with reference to again pin 7 common.


If there is no RS232 voltage on pin 2 to pin 5 of the DB9 cable from the 1132B. The RS232 cable or the PowerLinc II maybe defective.

Since the PowerLinc II does not have hardware handshaking. Make sure your RS232 port is not wanting a handshake.

Any chance you have a computer that can run the PowerLinc Synapse {on the sale page}  program to test it?

PSC05 is not a serial device.

Thanks for this info. My ignorance is not in doubt here. That I got prematurely pissed is probably correct. :-[  I did buy this thing
so It's my problem . I will look at this thing with your info in mind. I wouldn't pitch in any event. Thanks for the information and it just
goes to prove that it pays to ask somebody that knows WTF they are doing when you don't  :-[ I understand the PSC05 is not a serial
device. I will poke around in my cable box to see if I have a way of hooking my windows laptop to the unit. The laptop has a Db25 serial
cable plug not a Db9. Is an older Think pad T42 laptop. Boy, when your jump to conclusions sometimes you hit the ground hard  :o ouch.
Logged
Working  -:)

neo11

  • Full Member
  • ***
  • Helpful Post Rating: 1
  • Posts: 31
  • Bitbucket sinkhole
Re: Powerlinc II
« Reply #25 on: July 11, 2010, 04:31:07 PM »

My 1132B definitely has electronics in it. The controller and RS232 ICs are surface mounted on the back of the PC Board and not visible.
If you just removed the top cover and saw the power supply components and AC pass through outlet pins. You may have thought there was no Processor and RS232 ICs in it.

Near the right edge of the board near J4 {Firmware programming connector} is there a silk screened PowerLinc II?

On mine with the serial cable. Pin 2, RX Data to PC,  is about -9.76 volts when referenced to the Pin 5 common.
My RS232 breakout box with a dual color LED is not fast enough to see the swing but on an analog meter the pointer does kick toward the plus side. When an X10 signal is received from the power line.

On the RJ45 style connector. Pin 1 RX Data to PC is -9.76 volts referenced to pin 7 common and pin 2 raw +12 Volts is about 20 volts with no load with reference to again pin 7 common.

If there is no RS232 voltage on pin 2 to pin 5 of the DB9 cable from the 1132B. The RS232 cable or the PowerLinc II maybe defective.

Since the PowerLinc II does not have hardware handshaking. Make sure your RS232 port is not wanting a handshake.

Any chance you have a computer that can run the PowerLinc Synapse {on the sale page}  program to test it?

PSC05 is not a serial device.

Oh BTW the silk screen Powerlinc II is as you describe so all is not lost for me I guess.
Logged
Working  -:)

neo11

  • Full Member
  • ***
  • Helpful Post Rating: 1
  • Posts: 31
  • Bitbucket sinkhole
Re: Powerlinc II
« Reply #26 on: July 11, 2010, 05:25:27 PM »

My 1132B definitely has electronics in it. The controller and RS232 ICs are surface mounted on the back of the PC Board and not visible.
If you just removed the top cover and saw the power supply components and AC pass through outlet pins. You may have thought there was no Processor and RS232 ICs in it.

Near the right edge of the board near J4 {Firmware programming connector} is there a silk screened PowerLinc II?

On mine with the serial cable. Pin 2, RX Data to PC,  is about -9.76 volts when referenced to the Pin 5 common.
My RS232 breakout box with a dual color LED is not fast enough to see the swing but on an analog meter the pointer does kick toward the plus side. When an X10 signal is received from the power line.

On the RJ45 style connector. Pin 1 RX Data to PC is -9.76 volts referenced to pin 7 common and pin 2 raw +12 Volts is about 20 volts with no load with reference to again pin 7 common.

If there is no RS232 voltage on pin 2 to pin 5 of the DB9 cable from the 1132B. The RS232 cable or the PowerLinc II maybe defective.

Since the PowerLinc II does not have hardware handshaking. Make sure your RS232 port is not wanting a handshake.

Any chance you have a computer that can run the PowerLinc Synapse {on the sale page}  program to test it?

PSC05 is not a serial device.

Of coarse , you are correct. Downloaded the synapse program and ran on my laptop and the powerlinc works fine. I however don't
evidently  :-[ . The powerlinc was found and could control some appliance modules I had hooked up previously. At least I know it
works. That's a fabulous step for me. Now I can troubleshoot the computer comm problem. Probably as you say a handshake problem.
Thanks++ for the tips. As always , you guys ROCK !
Logged
Working  -:)

Brian H

  • Community Organizer
  • Hero Member
  • ***
  • Helpful Post Rating: 289
  • Posts: 12690
Re: Powerlinc II
« Reply #27 on: July 11, 2010, 06:02:13 PM »

Glad you are making some progress.
Logged

pconroy

  • Hero Member
  • *****
  • Helpful Post Rating: 9
  • Posts: 294
Re: Powerlinc II
« Reply #28 on: July 11, 2010, 11:18:58 PM »

Time to compare our code that opens the serial port, would be my next guess.
Logged

neo11

  • Full Member
  • ***
  • Helpful Post Rating: 1
  • Posts: 31
  • Bitbucket sinkhole
Re: Powerlinc II
« Reply #29 on: July 12, 2010, 02:54:38 AM »

Time to compare our code that opens the serial port, would be my next guess.

Ok, When I get to that point. Right now I am just sniffing the power line stuff via the powerlinc.
I have gotten to the point were I can see the traffic. (Wiring problem in the computers serial port).
The powerlinc is working ok now after fixing that. Now going around to find all the signal suckers and
noise generators in the house. This to insure I have a stable signal environment in which to work.
I am using a program called slsniff to watch the serial traffic. I am using this so I can be sure that
my Linux box can see the traffic. Also have the source code. To this point , it can. I am having some
intermittent strangeness with X-10 stuff but it's not software related as it happens with a palm remote
HR12a-> TM751 so its probably a noise issue somewhere in the house. Want to ferret that out before
I have another stupidity attack (blaming the wrong thing like I did before  ;). )  Very frustrating when
you can't depend on your working environment. Many computers/devices have been hammered to death
from that  ::). But I think I am on my way to doing something other then whine   8). Now on to reading
about the X-10 troubleshooting info on this board. Thanks a lot for your help along with Brian H for setting
me straight. Still say U guys ROCK #:) 
Logged
Working  -:)
Pages: 1 [2] 3
 

X10.com | About X10 | X10 Security Systems | Cameras| Package Deals
© Copyright 2014-2016 X10.com All rights reserved.