Vixen + Arduino Trouble

Hoping someone can help me.
I am new to this and trying to create a light show with vixen and Arduino.
I have an arduino mega 2560 that is sending open close signals to three 8 channel, 5 volt relays to turn on and of individual Christmas light strings. I'm using Vixen to output song sequences. Note that to connect from my laptop to my mega/8 channel relays (which are housed in a box), Im using a 200' cat5E cable with USB connectors at each end, because my box is outside a long distance away.
Everything works fine except randomly, about 20 minutes to 45 minutes, my arduino stops receiving data (the Tx light stops blinking). It is still powered on, and I have verified via meter that I have about 5 Volts coming into the arduino.
Any ideas why my arduino stops receiving data? I upload my code again, and it works for a while, eventually craping out at randomly.

Your post was MOVED to its current location as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

Helpers usually don't have the capacity of Your mother. Helpers have the handicap that they need schematics and code to understand.


Hopefully this is ledgible enough. here is my code.
Any help would be greatly appreciated.
Is there a way to see if I am overloading something or if I am short on current maybe?

#define MEGA_VIXEN

#ifdef MEGA_VIXEN
#define MAX_CHANNELS 24
int channels[MAX_CHANNELS] = {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25};
#endif

int incomingByte[MAX_CHANNELS];

void setup()
{
int i;

Serial.begin(9600); // set up Serial at 9600 bps

for ( i = 0; i < MAX_CHANNELS; i ++ ) pinMode(channels[i], OUTPUT);
}

void loop()
{
int i;

if (Serial.available() >= MAX_CHANNELS)
{
for (i=0; i < MAX_CHANNELS; i ++) incomingByte[i] = Serial.read();
}

for (i = 0; i < MAX_CHANNELS; i ++ ) analogWrite(channels[i], incomingByte[i]);
}


This is a clearly picture

Issue must be in the 150ft of UTP cable, How about instead of connecting it to the USB, you use 4x MAX485 chips (2 for each direction x 2 for full duplex) and a USB to TTL converter ?
Oh and

analogWrite(channels[i],, incomingByte[i]);

You really should not be using PWM to control relays. Switch to digitalWrite() for the relay channels.

Thanks for the reply. Again, Im a bit new to this, but if I use the chips and USB to TTL converter, how am I communicating from my computer to the arduino 150' away?

My cat5E to USZB connectors are not powered and I think are USB 1.0. I think Ive read that arduino's use USZB 2.0. Would it make sense to buy a powered cat5E to USB connector that works on USB 2.0?
I was thinking this:

2 twisted pairs (within the cat-5 UTP)

  • Mega-TX -> MAX485 (DE) -> pair -> MAX485 (RE) -> TTL-RX to USB
  • USB to TTL-TX -> MAX485 (DE) -> pair -> MAX485 (RE) -> Mega-RX

at 250Kbps you should be able to get a range of about 900 feet.
You only need 150 feet, bu you can kick up the baud rate a bit anyway, and if you manage to release the reset button on time, you can upload fresh code that way.


OK. I think I understand now. Can you see if my diagram is accurate? The one thing Im not sure of is on the 485 chip, does A go to A and B go to B, or does it go A-B B-A?
And besides what you mentioned above changing AnalogWrite to DigitalWrite, no other changes are needed to the code?

Thanks again. I really appreciate your help. Ive been so demoralized trying to get this to work. I ordered the parts and will try again sunday

Hi,

Just Google:

max485 module arduino

Tom.... :smiley: :coffee: :coffee: :coffee: :australia:

So this means on the 485, A-A and B-B?

Hi,

Yes, this is to enable more than two RS-485 to share the bus.

Tom... :smiley: :+1: :coffee: :australia:

It is Frtzing ! not a diagram, you can make a diagram using windows paint or equivalent, which will be much clearer.
Regardless, i am pretty sure it isn't quite, but you have the general gist correctly.

Yes it does. (crossing these lines there inverts the logic)
I always use individual chips, instead of the pre-fab units, and these units always have a terminator (120R resistor) on them between A & B, and that resistor should not be on the transmitter, and should be removed for proper functioning. On this picture I think that would be 'R7' since that is a 120 Ohms resistor according to it's label, but you should confirm with a multimeter that the sides are connected to A & B , and then remove it from the units that are going to work as a transmitter (The ones connected to TX)
Furthermore, you will have to 'switch' the receivers (and the transmitters) to their correct mode.
You have not connected the other side correctly at all.
On the Transmitter, DI (Drive Input) should be connected to a TX pin, and pins marked DE & RE (Drive Enable & (not) Receive Enable, there should be a dash above that on the silk really), should be connected to VCC, which they probably are already through the 10K pullup resistors (R2 & R3 i suspect) but there is no harm in connecting them to VCC
On the Receiver, RO (Receive Output) should be connected to a RX-pin, and the pins DE & RE should be connected to GND (or it won't receive at all)
The pin left open on the transmitter (RO) and receiver (DI) should be pulled LOW (or HIGH actually it doesn't matter much) and i think it is already through R1 or R4.
So if you manage to actually 'draw' a 'schematic' (Not Fritzing !!) i will have another look.

No i don't think so, although it does depend on how and what Vixen sends you of course. You now receive the number of channels, but there is no header to the stream, and no 'break' searching. So it will be rather error prone. 1 extra byte sent or received will result in a 'skip' of the channels.
Please correct your post to let the code sit in between </> code-tags, for easier reading, and if you know what kind of datastream Vixen is putting out, share it with us.

Which should tell us that the reception works, as long as there is sync.

Im really trying here. This is all new to me. I downloaded a circuit designer program and I think I used it correctly.
Please see the diagram now.
Does this look accurate?
Thanks again for all your help.

Nope. It's still look like fritzing, which is very unclear.
it should be looking more like this
TX_RX Twisted pair
This is of course just for the single channel. But if it is more schematic and lees colorful, it much more clear, what is actually connected to what. I usually use windows paint. Or once i start creating PCB's Kicad, which is also really good. But even a foto of something hand drawn, be be sufficient. This isn't really, though i am confident you have not made any of the corrections from reply #13

Hi, @hockeykris
Why do you need four modules when two will do communications in both directions?
https://nerdshed.com.ng/rs-485-two-way-communications-with-arduino/

Google;

arduino rs485 bidirectional

Are you doing any research yourself?

Tom.... :smiley: :+1: :coffee: :australia:

Thanks Deva.
I will hand draw this shortly.
2 questions, and sorry if they seem overly simply.
This need an arduino at each end (one by my computer and one by the relays 150 ft away?
Also, the resistors and capacitors are built into the 485 module correct?

I know it doesn't seem like it based on how stupid my questions come across, but ivespent hours and hours the last few days on this. I've never done anything remotely like this before. So it's all new to me.
I am very appreciative of the help.

at the end of your computer, a USB to TTL converter would suffice.

That depends a bit on how you look at it. There is a 120Ohms resistor between A & B (pins 6 & 7 on the IC) which does not belong there if the module is supposed to be transmitting. There are also Pullup resistors on pin 1, 2 3 & 4 which are not really needed but important is that PIN 2 & 3 are connected to either GND or VCC (which they are through those pullups) to set the mode of the transceiver (GND for reception, VCC for 'drive' transmission)

It happens.
About those units. I am not a big fan of those, because of the terminator and pullup resistors. If you buy something 'ready-made' then it should be perfect in my opinion, and these units do not really simplify the connection process at all, compared to a bare chip.

Hey guys.
Sorry for thr delay. I'm still waiting for parts and will let you know how it goes.
Just wanted to say a big thank you for all the help thus far.
I'll let you know when I have more questions.