PDA

View Full Version : Need help using MEL command "Xout" with an X-10 PCS-05 bidir pwr-line interface



guglulenun
- 20th January 2011, 06:53
I need help understanding the physical interface between the microchip PIC16F73 I am using and the X10pro psc05 bidirectional power line interface. The info in the MEL PBP manual is very sketchy about this command and the electronic interface to the psc05. My PBP manual only talks about a TW-523, which is no longer available, but was supposedly replaced by the newer psc05. When I get onto the x-10 site, it says they offer the suggested schematic for interfacing with the psc05, but no further information will be provided. I see their schematic for the psc05 has opto-isolators. The Xout command, they say, should go through a pnp inverter and then into the opto-isolator. Although I have had good success with the MEL pbp "Xin" instruction, I cannot make the "Xout" instruction control any equipment through the psc05. In fact, the red led on the psc05 just dims, rather than blinking, as it does when I command the same codes out over a hand-held X-10 remote. I have tried direct coupling the PIC pin (capable of 30 mA) right to the pin-4 on the RJ-11 and also taking it there through X10pro's suggested pnp inverter circuit, also through a 7404 inverter, also through a 74xx buffer. The psc05 has a 1K resistor in series with the led in the opto-coupler, so it should only pull about 3.5 mA, when conducting. Does the Xout signal really need inverting on the way over to the psc05? When X10pro shows the suggested OEM interface (12 page, free download), I assume they do not know what equipment I will be using to drive that pin, so how can they know I will be using a PIC, or the MEL PBP "Xout" instruction? I cannot seem to make this puppy work. I am driving the psc05 from the PortB.1 pin on my pic (not open-drain), configured as a digital output. The zero-crossing input pin works properly on my pic, when driven by the psc05's RJ-11, pin1, for the "Xin", so it should also be working for the "Xout"...... I am stumped. Any suggestions out there??? Please assist if you can!!!

dhouston
- 20th January 2011, 11:43
The TW523 and PCS-05 are identical - the only difference seems to be the price.

The PL513 and TW523 are detailed at http://software.x10.com/pub/manuals/technicalnote.pdf. The PSC-O4 and PSC-05 have the same details.

The diagram showing how to connect your OEM product is a little confusing until you understand that everything outside the OEM product is internal to the PSC-05. Specifically, the optos are internal to the PSC-05.

Refer to [b]Typical OEM Connection diagram (p11). All you need is a pull-up on your X10 signal (to the PSC-05). You really don't need to invert the X-10 signal from the PSC-05 as you can handle that in your program logic. The clamping diodes and the 100 ohm current limiting resistor are overkill.

I don't have access to my PBP manual, as it has been in a storage unit since my lengthy stay in the hospital last year , but as best I recall, it shows exactly what you need.

X-10 is being cautious as the same basic approach is used for both 120VAC and 230VAC. The optos protect you and your circuitry should something go amiss within the PSC-05.

Bruce, Anand Dhuru and mackrackit can all advise you on the specifics.

mackrackit
- 20th January 2011, 12:29
I am not all that familiar with X-10, but posting the problem code may help. Could be something as simple as forgetting
Include "modedefs.bas"

dhouston
- 20th January 2011, 13:03
I am not all that familiar with X-10, but posting the problem code may help. Could be something as simple as forgetting
Include "modedefs.bas"I was thinking more on the line that you probably have your PBP manual at hand. I believe its Xin and Xout show what is needed to interface.

This happens to be about the only instance where I suggest a non-PIC solution. PBP's Xin and Xout commands are quite limited. Xin requires you to either wait in a loop until you receive an entire command or to use an interrupt on ZC to check for an input during the 100mS just after ZC. It can take nearly 1/2 second to receive an entire command and this is a long time to wait in a loop. And most users find interrupts a bit daunting.

Don Kinzer, the proprietor of ZBasic has written low level interrupt-driven X-10 functions that operate in the background, buffering both inputs and outputs, that operate in much the same way as UARTs. All the user has to do is check a flag periodically to see if a command has been received and to fill the output buffer with the bits needed to send a command. You can get this in a $10 chip, the ZX-328n http://www.zbasic.net/Microcontrollers/ZX-328n-Microcontroller/p-68.html. It is by far the easiest way to handle X-10. It does require a little more external circuitry than a PIC does.

mackrackit
- 20th January 2011, 13:39
I was thinking more on the line that you probably have your PBP manual at hand. I believe its Xin and Xout show what is needed to interface.
In this case the online version is the same as the book.
http://melabs.com/resources/pbpmanual/

dhouston
- 20th January 2011, 14:23
Per the PBP online manual...
Output from the X-10 interface (zero crossing and receive data) are open-collector and require a pull up resistor of around 4.7K to 5 volts.That's all that is necessary.

ardhuru
- 20th January 2011, 17:47
Bruce, Anand Dhuru and mackrackit can all advise you on the specifics.

Thanks for the reference, Dave.

I would like to add Darrel Taylor to that list. In a thread I'd started a few years back, http://www.picbasic.co.uk/forum/showthread.php?t=3057 he suggested a small edit to the pbppicxx.lib that modifies the XOUT to give pre-modulated X10 signals without using any extra modulating hardware or complex programming. Comes in very handy for TW523-less, direct-to-mains designs. ANYBODY TRYING THIS, PLEASE BE VERY CAREFUL OF THE MAINS VOLTAGES. Personally, I think this is worthy of being added permanently to the .lib as a canned command, say XMOut, along with the regular Xout.

Guglulenun, as has been pointed out, the pull-up is mandatory. Let us know if that works. Xin is a far more involved command from the hardware viewpoint, so if that works the zero crossing detection is indeed working. If the pullup doesnt help, I'd only suspect the transmission related circuit within the PSC05. OR, if you are in a 50hz country, take a look at post #9 at http://www.picbasic.co.uk/forum/showthread.php?t=1696 , although the mains in my country is 50hz too, and I have had no problems with the default.

Regards,

Anand

dhouston
- 20th January 2011, 19:13
I would avoid the 50Hz thread that Anand referenced - it's only likely to confuse things.

The ONLY time that the 50Hz vs 60Hz issue is a problem is when the electrical system is 3 phase and you need to control devices on phases other than the phase into which the PSC-05 is plugged. The first signal burst of 120kHz is at ZC, the second is at ZC+PERIOD/6 and the third is at ZC+PERIOD/3 where PERIOD=1/60 or 1/50 depending on the mains frequency.

The PCS-05 only sees the ZC of the phase into which it is plugged. Similarly, receiver devices only see the ZC of their specific phase. Whatever is controlling the PCS-05 must calculate the other two ZCs and control the timing according to the mains frequency.

If all of the devices to be controlled are on the same phase as the PSC-05, it is best to send only a single burst per half-cycle - sending to all three phases tends to sap the PSC-05 power supply.

EDIT: A final point. X-10 showing an inverter on the X-10 gate signal to the PCS-05 is probably to reduce the current load on the PIC (or other MCU) drive pin.

guglulenun
- 20th January 2011, 22:01
Thank you everyone, so much, for all your responses! It is wonderful to know that I am not all alone on the island of X-10 programming land. To answer some questions, I am using single-phase, 60Hz here in California. I have employed both 4.7K pull-up resistors to 5 volts, as specified in the MEL PBP manual, on the collectors outputs of the opto-isolators of the psc05. In the X-10pro diagram, they show an OEM box on the left and the psc05 on the right side of the rj-11 connection pins, but in the middle, they show the suggested interface circuitry, which includes a pnp transistor that serves as an inverter to the input of an opto-isolator in the psc05 (when base of pnp goes low, the transistor's collector pulls up to 5V, to source current wrt the led inside the opto-isolator). I am thinking that maybe everything is OK, electrically, but maybe I am just sending incorrect codes to activate anything in X-10 land. But, it did seem strange that psc05 led just seemed to dim and stay dimmed, rather than blinking off when valid X-10 codes were going across the link, as when I used a real X-10 remote to do that same job.

dhouston
- 20th January 2011, 22:57
Have you included MODEDEFS.BAS?

guglulenun
- 20th January 2011, 23:35
yes, I have used INCLUDE "modedefs.bas"

guglulenun
- 20th January 2011, 23:40
Very intriguing idea--the Darrel Taylor link to single-chip TW-523 idea--Thanks


Thanks for the reference, Dave.

I would like to add Darrel Taylor to that list. In a thread I'd started a few years back, http://www.picbasic.co.uk/forum/showthread.php?t=3057 he suggested a small edit to the pbppicxx.lib that modifies the XOUT to give pre-modulated X10 signals without using any extra modulating hardware or complex programming. Comes in very handy for TW523-less, direct-to-mains designs. ANYBODY TRYING THIS, PLEASE BE VERY CAREFUL OF THE MAINS VOLTAGES. Personally, I think this is worthy of being added permanently to the .lib as a canned command, say XMOut, along with the regular Xout.

Guglulenun, as has been pointed out, the pull-up is mandatory. Let us know if that works. Xin is a far more involved command from the hardware viewpoint, so if that works the zero crossing detection is indeed working. If the pullup doesnt help, I'd only suspect the transmission related circuit within the PSC05. OR, if you are in a 50hz country, take a look at post #9 at http://www.picbasic.co.uk/forum/showthread.php?t=1696 , although the mains in my country is 50hz too, and I have had no problems with the default.

Regards,

Anand

ardhuru
- 21st January 2011, 04:48
But, it did seem strange that psc05 led just seemed to dim and stay dimmed, rather than blinking off when valid X-10 codes were going across the link, as when I used a real X-10 remote to do that same job.

Not strange, really. It just reiterates what you have already observed. The fact that it is working well as a receiver. You are having a problem transmitting thru' the PSC05; when you use any other transmitter and find the LED blinking, the PSC05 is actually acknowledging the *receipt* of an X10 signal; the signal it sees on the mains created by another device, not itself. Which again suggests your problem to be related to its transmission circuit, either internal or external.

Could you send us a screen-grab of the actual signal Xout produces taken at the input of the PSC05?

Regards,

Anand

guglulenun
- 21st January 2011, 07:39
Hi Anand,

Here is an attached copy of my code from Notepad, FYI. I'm not sure how to attach files. I did a drag-and-drop as it instructed, but then the menu disappeared and was replaced by my file contents, so I hope it worked.

It won't be until tomorrow afternoon before I get a chance to do the waveform screenshot, but will as soon as I am again available. I'll take it on the send side of the psc05 input, as you said.

Thank you.

mackrackit
- 21st January 2011, 07:52
It did not attach.
Try again but not drag and drop.

guglulenun
- 22nd January 2011, 05:26
Well, it seems strange how I had to do it, but it seems to have attached this time.

I just pulled my picoscope 3206 out of mothballs and tried to load the drivers for it, but my computer fails to recognize the usb port to which it is attached. I'll send pictures as soon as I get it going.

G

guglulenun
- 22nd January 2011, 07:02
Hi Anand,

This one pdf includes 5 views of my Picoscope model 2306 screenshots (so you don't have to load the picoscope viewer software): 1st is the wide view of what looks like 4 pulse-groups, all on the screen at once [presumably 2 sets of pairs of pulse-groups, with a wider gap in between the pairs]; 2nd is a screenshot of a zoom in on the 1st of 4 sets of pulse-groups; 3rd is a zoom of the 2nd of 4 sets; 4th is the 3rd set of zoomed pulse-groups; and 5th is the 4th set of zoomed pulses in the last group.

Notice that these are all positive pulses with respect to ground. When there is no data traffic, then the PIC output to the psc05's opto-isolator is low (not pulling led current inside the opto-isolator). It seems to me that this is the way it should be, rather than inverted and pulling current without data traffic. If so, then the inverter, shown by x10pro, between the OEM equipment and the input of the psc05 really should not be there. But still, this does not activate any X-10 devices. I bought 3 psc05's, so I am about to build another identical circuit to eavesdrop on the other and compare what a real x10 remote sends to activate/deactivate house-1, module-1. Then, I can see the differences between my signal and the actual x10 remote signals, from the view of another x10 psc05's receive line.

Thanks very much,
G

ardhuru
- 22nd January 2011, 10:08
Okay, set your receiver module to House 'A', Unit '1'.

Substitute the XOUT statements from your code to

XOUT PORTB.1,PORTC.5,[0\0,0\unitOn) 'Send an 'ON' to A1
and
XOUT PORTB.1,PORTC.5,[0\0,0\unitOff) 'Send an 'OFF' to A1

Lets see where this gets you; if it doesnt work I'll take a closer look at the waveforms, but I think that might be unnecessary.

BTW, connect your pic XOUT pin directly to the interface; as Dave pointed out the extra components are really not required.

Regards,

Anand

guglulenun
- 23rd January 2011, 23:31
Hi Anand, and everyone else who responded to my plight,

Anand, Your suggested code worked like a charm, on the first try--THANK YOU !!!

I am thrilled to have it finally working. I'll need to go troubleshoot why my code did not work, so I can better understand my mistake and how not to repeat it in the future. And, whew--I'm sure glad to not need that other circuitry that X10pro showed in between the PIC-chip and the psco5.

Fantastic, and thanks again,
Guglulenun

ardhuru
- 24th January 2011, 02:42
Hi guglulenun,

I am glad you have got it working.

The problem was with the syntactic construction of your XOUT line.

Once you have defined the House and Unit codes, the line should be in the format:

XOUT SIG_OUT,ZEROX,[HOUSE\UNIT,HOUSE\unitOn]

Since you have included modedefs.com, you can also use all the pre-defined X10 commands directly .

Also, you can use byte variables for House and Unit, as they only go up to 16.

Regards,

Anand.