Hi,
I wonder currently about how to use the 3DR radio with the serial USB simultaneously.
I have an APM 2.5. In the wiki is written, that a hardware muxer is preferring uart0 over uart2 at the uart0/2 port if usb cable is inserted (if I understood correctly).
So if I want that uart0/2 is always uart2, shall i simply do like described here: https://code.google.com/p/ardupilot-mega/wiki/APM2Wireless under point "(Optional) Changing your telemetry to use UART2 (aka Serial3)" and USB will work together with radio on uart0/2?
Greetings, Daniel
Replies
It worked! I really thought this would require custom firmware etc etc. But as i read your linked answer and looked at the copter wiki I finally got the nerves to solder those bridges on the mux:)
Now i can enjoy switching seemless between 3g based telemetry and direct radio telemetry!
The danish FAA equivalent will be pleased with the new redundancy;)
-I cant get my hands down. Thanks!
Thank´s for your answer. If i use an i2c to uart converter can i connect via APM i2c to CMUcam Uart?
Converter : https://www.sparkfun.com/products/9981
Either way you will ned to write some code. Easier just to use the serial ports available differently
Look here https://github.com/diydrones/ardupilot/blob/c6f3e0a81c692abe8bd90e7...
You see in the code examples to open other serial ports. For APM2.5 you can see which ports are available here HAL_AVR_APM2::HAL_AVR_APM2()
and see you can access uart0 and uart2 separately http://copter.ardupilot.com/wiki/common-apm25-and-26-overview/#Expl...
You could connect your telemetry on uart0 and the cam on uart2. chnage uart0 default baud to be 57600 (same as radio), unplug radio when you plug in via USB.
Hi,
APM have three available uart ports(A/0,B/1,C/2). Telemetry or usb using uartA dependent on the MUX.
By default uartC or uart2 are not used, right? So i connect cam on uart2 pins and write the code to connect uartC:
void CMUcom4::begin(unsigned long baud)
{
delayMilliseconds(CMUCOM4_BEGIN_DELAY);
#if defined(__AVR_ATmega1280__) || \
defined(__AVR_ATmega2560__) || \
defined(__SAM3X8E__)
switch(_port)
{
case CMUCOM4_SERIAL1: hal.uartA->begin(baud); break;
case CMUCOM4_SERIAL2: hal.uartB->begin(baud); break;
case CMUCOM4_SERIAL3: hal.uartC->begin(baud); break;
default: hal.uartD->begin(baud); break;
}
#else
Serial.begin(baud);
#endif
delayMilliseconds(CMUCOM4_BEGIN_DELAY);
}
And choose CMUCOM4_SERIAL3 to initialized the CAM.
Its logic what i have done?
Already i try change uart0 baud rate to 57600 and noting appends.
Thank you for your time.
Best regards
Hi,
I have Arducopter V3.2 with CMUcam v4 connected on Uart2. But i can connect usb or telemetry with uart2 connected. How i can use all channels together?
Best Regards
I don't understand. If you use the 3dr radio on uart0/2 it will go over uart0 as standard.
So you can use the cam over uart2 without probs. However if you disabled the muxer, than there will be an bus collision.
I use 3dr radio on telemetry port. And have a cam on uart2 pins. The cam work perfect but i can´t connect the telemetry. Have any way to use telemetry and cam at same time?
It is likely an implementation problem.
Write a firmware for testing reading and writing on uart0 & uart2
I have this in User code:
#ifdef USERHOOK_INIT
void userhook_init()
{
// put your initialisation code here
// this will be called once at start-up
cam.begin();
// Wait for auto gain and auto white balance to run.
cam.colorTracking(true);//YUV
cam.LEDOn(LED_BLINK);
delay(WAIT_TIME);
// Turn auto gain and auto white balance off.
cam.autoGainControl(false);
cam.autoWhiteBalance(false);
cam.LEDOn(CMUCAM4_LED_ON);
cam.pollMode(true);
cam.noiseFilter(NOISE_FILTER);
cam.setTrackingParameters(V_MIN, V_MAX, Y_MIN, Y_MAX, U_MIN, U_MAX);
}
#endif
#ifdef USERHOOK_FASTLOOP
void userhook_FastLoop()
{
// put your 100Hz code here
//if(cam.getButtonPressed() == true)
//{
for(;;)
{
cam.trackColor();
cam.getTypeTDataPacket(&data); // Get a tracking packet.
//Process the packet data safely here.
if((data.pixels >= PIXELS_THRESHOLD) && (data.confidence >= CONFIDENCE_THRESHOLD))
{
// Target acquired...
}
else
{
// Target lost...
}
}
// Do something else here.
//}
}
#endif
This in user variables:
#define V_MIN 180
#define V_MAX 255
#define Y_MIN 0
#define Y_MAX 255
#define U_MIN 0
#define U_MAX 255
#define LED_BLINK 5 // 5 Hz
#define WAIT_TIME 5000 // 5 seconds
#define NOISE_FILTER 2 // Figure out a good value with the CMUCam4GUI
#define PIXELS_THRESHOLD 1
#define CONFIDENCE_THRESHOLD 50
CMUcam4 cam(CMUCOM4_SERIAL3); //UART2 APM
CMUcam4_tracking_data_t data;
#endif // USERHOOK_VARIABLES
Its necessary modify any other file?
I have bus collision, telemetry try to connect on uart2, how can i do to connect telemetry only in uart0?
Best Regards