Arduino Forum

Using Arduino => Installation & Troubleshooting => Topic started by: snooprob on Nov 06, 2012, 05:23 am

Title: Add ftdi to Mega 2560
Post by: snooprob on Nov 06, 2012, 05:23 am
Working on enhancing my Christmas light controller.  I am using vixen to program the lights and create the DMX stream.  Last year i used a Duemilanove, and this year I upgraded to a Mega 2560 to get additional control channels.  The downside is that vixen is trying to leverage a FTDI connection which I am discovering the 2560 no longer uses.  Is there a way to add TFDI to the 2560?  I have a FTDI cable like this one : https://www.sparkfun.com/products/9718 to program the pro boards I have used in other projects.  Is there a way to leverage this with the 2560?

Thanks in advance for any guidance you can offer.

-Rob
Title: Re: Add ftdi to Mega 2560
Post by: retrolefty on Nov 06, 2012, 05:57 am
Quote
Is there a way to leverage this with the 2560?


What do you mean by leverage? Can you use a FTDI cable with your mega, yes you can. But it would be better to understand what you wish to do with it, to replace the Mega's on-board USB serial converter used to upload sketches? Or just as another USB serial channel working from one of the additional serial ports available on the mega board?

Lefty
Title: Re: Add ftdi to Mega 2560
Post by: snooprob on Nov 06, 2012, 05:23 pm
Thanks for your reply retrolefty.  To clarify based on the good questions you asked, this is what I am after.

I have no need to remove the current USB interface from the Mega.  I am fine using that to update my sketch etc.  I did not know there were other serial connections/options available but that sounds promising.  I would like to use a FTDI connection between the pc and the arduino, potentially using this alternate connection.

The program I am running to control lights sends a DMX string over USB/Serial to the arduino.  On the arduino is a sketch that basically processes the streams and makes digital ports go high/low.  The current software plugin only recognizes FTDI connections, but no the new style of the MEGA.  So if I can provide an alternate connection into the mega that would be ideal.

How would that be wired?  Also, when I have the FTDI connected (now I have 2 serial connections right?) how do I manage the serial(read) on the arduino to choose the correct one?

Thanks!

-Rob
Title: Re: Add ftdi to Mega 2560
Post by: retrolefty on Nov 06, 2012, 05:38 pm
Well it sounds like just wiring the FTDI's send and rec signals (and ground) to one of the alternate serial hardware channel would serve your purposes, the Mega has four built in serial hardware ports and the standard on-board USB serial converter uses the first port. Here is link to the serial library document that explains what pins the mega has those additional serial ports on and how you access them with the serial commands.
http://arduino.cc/en/Reference/Serial

The part that should answer your questions is the following:
Quote
The Arduino Mega has three additional serial ports: Serial1 on pins 19 (RX) and 18 (TX), Serial2 on pins 17 (RX) and 16 (TX), Serial3 on pins 15 (RX) and 14 (TX). To use these pins to communicate with your personal computer, you will need an additional USB-to-serial adaptor, as they are not connected to the Mega's USB-to-serial adaptor. To use them to communicate with an external TTL serial device, connect the TX pin to your device's RX pin, the RX to your device's TX pin, and the ground of your Mega to your device's ground. (Don't connect these pins directly to an RS232 serial port; they operate at +/- 12V and can damage your Arduino board.)


In you sketch you just change the default serial.whatever command to say serial1.whatever to use the second mega serial channel. Example:

Code: [Select]
Syntax
Serial.begin(speed)  // first (if mega) or only (if Uno) serial channel
Arduino Mega only:
Serial1.begin(speed)
Serial2.begin(speed)
Serial3.begin(speed)


Lefty
Title: Re: Add ftdi to Mega 2560
Post by: snooprob on Nov 06, 2012, 06:12 pm
That was exactly the breadcrumb trail I was looking for.  I will give it a run tonight, and let you know how it turns out.  Thanks so much for your helpful insight.
Title: Re: Add ftdi to Mega 2560
Post by: snooprob on Nov 07, 2012, 02:29 pm
I did not have much luck with serial.1 or serial.2.  The DMX connection between the software I am using (vixen) and the arduino required modifying the hardware.cpp file which may have hard coded the serial connection?  The code was beyond my capabilities.  What did work is just injecting the tx/rx from my usb-FTDI right into pins 1/2 and 'bypassing' the MEGA onboard serial circuitry.  Working well.

Thanks again for your assistance and education.

=-Rob