problem using serial on any tx/rx pins without a usb cable plugged in

05 Jun 2011

Can I use serial comms on pins tx p9 and rxp10 WITHOUT the USB cable plugged in? As soon as I unplug the USB cable I can no longer do serial communication. i was wanting to use the mbed on a mobile robot. I just want to continually print "hello world" from my mbed to a pc without a usb cable plugged in. i have a working comm port on my windows machine and i've used it many times before. the code below works only when a usb cable is plugged into my mbed.

#include "mbed.h"

Serial device(p9,p10);

int main() {
    device.baud(9600);
    while (1) {
        device.printf("Hello World\n");
        wait(0.2);      
    }
}
05 Jun 2011

Yes you can use any of the serial uarts without the USB plugged in. The question I would ask you is, when you remove the USB plug how are you getting power to your Mbed? No volts, no comms (or much else).

05 Jun 2011

I have external power connected... 9v from a power supply

What do you suggest is happening then? What do I need to get my uarts working correctly? Why does plugging the usb cable in allow me to communicate through pins p10/p9 when they should be completely are unrelated?

Jay

05 Jun 2011

Hi Jay -

This might be a good time to post a schematic of your setup. It could be something very simple that another set of eyes might pick up on very quickly.

Best regards,

Mike

05 Jun 2011

I get the same result if i use a different uart - pins 28, 27 this time I just print the letter 'H'. I can only get the letter if the usb cable is plugged into the mbed. I want to use an xbee at a later stage and replace the wires to my com port.

#include "mbed.h"

DigitalOut myled(LED1);

Serial xbee(p28, p27);

int main() {
    xbee.baud(19200);
    myled=1;
    while(1) {
        xbee.printf("H");
        wait(0.1);
        myled = !myled;
    }
}
05 Jun 2011

My circuit setup is very, very simple.

9v connected to Vin, 0v to Gnd, Pin 9 (mbed tx) to COM6 rx, Pin 10 (mbed rx) to COM6 tx,

that is the only thing that is on my breadboard. Only an mbed with external power, and wires to the uart.

If i take out the usb cable I can see LED1 flashing which tells me I should be sending bytes from the uart.

I have a Pololu USB programmer that I use as a serial port on COM6 in windows. I've never had a problem communicating via serial with this programmer before.

05 Jun 2011

I use two serial connections:
- Serial pc(USBTX, USBRX); this is for debug messages using the C stdout with printf (not pc.printf )
- a serial LCD from 4D, connected to Serial uart_ecran(p9,p10);

There is a external power 5V for the serial LCD and for the Vin pin of the mbed. In fact the mbed receives normally power from the usb and the external source.The USB alone is not enough for the lcd and the mbed.

I tried now this application without the USB connected to the PC and my serial lcd is working.
The answer is YES to the question "Can I use serial comms on pins tx p9 and rxp10 WITHOUT the USB cable plugged in?"

Robert

05 Jun 2011

The signals coming out of the PC com port are RS-232 levels. The signal levels at the mBed are 3.3V TTL. See this thread - http://mbed.org/forum/mbed/topic/2352/

Best regards,

Mike

05 Jun 2011

Mike, I was expecting RS-232 levels. This makes sense.

I have also just found a very dirty solution. I connected a common ground between my comm port and the mbed. It looks like the Pololu USB Serial Port port can handle TTL levels, but without the common ground it is marginal.

Thank you kindly to all of you who have taken the time to help me with this problem. Part of the reason I wanted to try the mbed was to avoid the intricacies getting to know my hardware before using it. Lesson learned.

Cheers,

Jay

06 Jun 2011

Your dirty solution sounds like the correct solution to me. You need to make sure that the mbed and the PC you are communicating with over RS-232 share a common ground reference. When you power from USB, the mbed would have been tied to the ground on the PC from which it was being powered.

04 Feb 2012

serial communication how cmps10??

30 Mar 2012

Hi, best regards, I'm new and I have a problem simiar, uh read the posts, and i applied his advice but my project does not work. two mbeds , communicate with each pin9y10 serial; the USB cable is connected to respective mbed .( different pc) and the comunicaion is perfect...But dont work when is conected to power sources ; when using power supplys, pin 39 is not used.

The only way to communicate with sources of power is to share the GND.

This seems illogical because when the USB plug of the MBEDS is connected to different computers. (in theory is different GND.)

i don´t know for what is the pin 3 &4, i never see connected pins 3&4 in a circuit...

¿¿ONE SOLUTION??