SX to SX serial problem
Hi All
So i have pieced together a 17 channel light controller using the SX28.
I am using the Renard protocol version 1.
Everything is generally working great.
I have built 2 boards each of which can control the lights perfectly fine by themselves.
I run into issues when i try to run them both together.
So my laptop connects to the first sx board with 17 light channels, then from the first sx board serially to the second sx board with another 17 channels.
The first board controls its 17 channels perfect, the second board generally does great but every 10 30 seconds I randomly get bright flashes on random channels.
What is the proper way to hook up serial between two SX boards?
I just have the RA.1 pin on the first board hooked directly to the RA.2 pin on the second board.
Both boards have the same ground.
Each board has its own +5 V regulator.
Serial settings are 38400 baud, 8 data bits, no parity, 1 stop bit.
Attached is the code, its not optimized "yet" but it works and i can read it.
Anyone know if i am doing someting wrong?
So i have pieced together a 17 channel light controller using the SX28.
I am using the Renard protocol version 1.
Everything is generally working great.
I have built 2 boards each of which can control the lights perfectly fine by themselves.
I run into issues when i try to run them both together.
So my laptop connects to the first sx board with 17 light channels, then from the first sx board serially to the second sx board with another 17 channels.
The first board controls its 17 channels perfect, the second board generally does great but every 10 30 seconds I randomly get bright flashes on random channels.
What is the proper way to hook up serial between two SX boards?
I just have the RA.1 pin on the first board hooked directly to the RA.2 pin on the second board.
Both boards have the same ground.
Each board has its own +5 V regulator.
Serial settings are 38400 baud, 8 data bits, no parity, 1 stop bit.
Attached is the code, its not optimized "yet" but it works and i can read it.
Anyone know if i am doing someting wrong?
Comments
1 of the boards is a homemade board, and the other is the SX tech board.
So playing around some more, i realized I only have the problem if the SX Tech board is the first in the series.
If i hook my laptop directly to my homemade board, then have it relay the serial to the SX on the Tech board everything works perfect.
Any ideas??
Maybe the SX is getting reset for some reason?, will test for that soon.
(Actually looking at it, i don't think this is it, because not all channels flash high at the same time, if it were a reset i would expect it to affect all pins equally.)
One other thing, not that i think it matters, but i do have each 5+V regulator powered by different AC-DC power supplies. The sx tech board 5V regulator is being supplied dam near 5 volts. My homemade boards 5 V regulator is being supplied about 18 volts. Again grounds are common.
(Thinking about it, i am probably not providing enough voltage to the SX tech board, but it works fine until i hook up the second board, i am thinking its unlikely to be the problem·but who knows.)
Post Edited (lboucher) : 3/15/2009 4:42:46 AM GMT
-- computerchristmas.com/ForumBoard/download.php?f=2&file=renard_protocol.txt
[noparse][[/noparse]Edit] Program removed -- wasn't implementing protocol correctly
Post Edited (JonnyMac) : 3/15/2009 4:18:47 PM GMT
Basicly version 1 doesn't do two byte values.
I am pretty sure of this, because if this was my problem i would see it all the time, with just one board hooked up.
<sync><address1><value1>....<value8> <sync><address0><value1>....<value8>
I'm going to pull down my program until I can spend more time -- right now I've got a trade show looming and don't have much time to play; when I do I'll get out my dimmer board and see if I can implement the Renard protocol on it.
So playing around some more, if i configure the outgoing serial from the Vixen software to use 2 stop bits, then everything works fine. This is perfectly good for me, it all works. I am just left not understanding why.
I have tried pulling the pin high via a 2.2K & and 4.7K resistor, and also tried pulling it low with the same resistors.
Neither worked.
Any ideas out there?
You seem to be coming from the PC without using a MAX232-type inverter; is this true? If yes, you should insert a 22k resistor between the PC TX pin and the RX pin on your first board. Using Inverted mode (as you seem to be doing) the idle state of the serial input is low, so you could pull it down through a 10K if you want.
Post Edited (JonnyMac) : 3/15/2009 5:46:05 PM GMT
As long as it works ehh.
Thanks
- How are the boards connected? Are you using logic level serial or RS-232 style with something like a MAX232 driver between each board.
- How close are the boards? Is it a very short connection between the boards or is it a longer run?
- Are the boards using the same PS or separate ones?
- Do you have any filter caps on the PS and small .1uf caps at each IC where the power comes into the chips?
From first SX board to second SX board is just logic level, no resistors.
All have common ground.
Boards are currently 6 inches apart, very short breadboard setup, will be longer once it gets to christmas.
Seperate power supplies (one is 18 V·one is 5 V)·and seperate 5 volt regulators.
All have their ground wires connected.
One of the boards is the SX tech board, and my homemade board does have 0.1uf caps.
All this makes sense right?
Thanks
Lucas
Gave it a quick try with one board.
Unfortunately it didn't work. Lights just came on full bore all the time.
The only thing i changed was some channel layouts to match my current hardware setup.
Attached is exactly what i just tested.
For reference i only have·5 channels hooked up, RA.0, RB.0-3.
When using vixen though, i am sending data for a full 34 channels.
(Not that any of this matters, should still work the same.)
Haven't looked into debugging why that didn't work.
Post Edited (lboucher) : 3/15/2009 10:17:00 PM GMT
This is what happens when you use code you didn't write and don't fully understand.
The line below in red is making the system expect 1.5 bit periods for the stop bit. (I think)
So since I was only setting vixen to 1 bit period for the stop bit, every once in a while the most significant bit would get incorrectly set to one.
Thus why I only get flashing and never quick dimming.
So i think if i change this from a #6 to a #4 it will work.
(But do i really care to take the time to test it when just setting the stop bit to 2 will work. Would up my max channel count to fix it.)
Does anyone agree this is probably the source of the problem?
bank #rx_count
movb c,/rx_pin ·····'serial receive
test rx_count
jnz :rxbit ·····'if not, :bit
mov w,#9 ·····'in case start, ready 9
sc ······'if start, set rx_count
mov rx_count,w
mov rx_divide,#6'baud15 ····'ready 1.5 bit periods
:rxbit djnz rx_divide,rxdone ···'8th time through?
mov rx_divide,#4'baud
dec rx_count ·····'last bit?
sz ······'if not, save bit
rr rx_byte
snz ······'if so, set flag
setb rx_flag
rxdone···
The stop bit is really just a dead space before the next start bit -- this gives the receiver time to do something with the byte it just received. If you tell Vixen to add an extra stop bit this just means you have an extra 26 microseconds before the next byte shows up and it has nothing to do with your bit sampling.
You may be wondering why you use #9 for the bit count -- the reason is that you need to count the start bit plus eight data bits. Once the eighth bit has arrived and rx_flag is set you have one or two bit periods (depending on the number of stop bits) to retrieve rx_byte before something else shows up.
Post Edited (JonnyMac) : 3/17/2009 9:59:43 PM GMT