No announcement yet.

Works with any UART/USB Adaptor but not Arduino?

  • Filter
  • Time
  • Show
Clear All
new posts

  • Works with any UART/USB Adaptor but not Arduino?

    Hi - first off thanks for a great product and made in Australia too! Great to see! nice documentation aswell.

    The 4D Systems IDE is really great, it's nice to have some working platform to plug in the device and start seeing which bytes are transmitted.

    However my camera unit will only work reliably with a UART/USB adaptor (perfectly infact), I've connected it to an Arduino Pro Mini (have tried 8mhz and 16mhz versions), set the port baud rate to 38400 and sent the sync byte's over, I get the ACK back however the bytes dont seem right


    Connected to my oscilloscope I see the uCam is sending back exactly the same stream to the Arduino as if it was connected to the always working UART/USB adaptor but it just seems garbled. (attached is the screenshot from the oscilloscope so you can see the bytes are arriving fine) My program below simply echos the bytes out to the software serial debug. The camera is connected to the hardware UART

    Some things I've considered are

    - Arduino is using a resonator, perhaps the timing is not lining up?
    - AVR datasheet says it should be a very low baudrate error at 16mhz/38400
    - Perhaps the external resonator is not good enough and needs a real crystal?
    - I have a GPRS modem that communicates via serial and works 100% of the time
    - I never ever see errors in the debug output when communicating via software serial
    - I dont get any response if the camera is connected to the software serial
    - Does it need a pullup resistor?

    Some things I've tried

    - A variety of baud rates
    - Different AVR/Arduino boards
    - 8mhz 3.3v and 16mhz 5v versions
    - Issuing a RESET command after the system starts incase it picks up faulty auto-baud information/noise

    The closest I've come to it working is receiving a 0xAA, 0x0F, when it should be 0xAA, 0x0E in the ack (sometimes I get 0xAA, 0x0D but it always changes/alternates)

    So yeah, a bit stuck! I'de like to use this in production soon, thanks! Sorry about the Arduino code

    const unsigned char SYNC[] = {0xAA, 0x0D, 0x00, 0x00, 0x00, 0x00};
    const unsigned char BAUD_38400[] = {0xAA, 0x07, 0x1F, 0x02, 0x00, 0x00};
    const unsigned char RESET[] = {0xAA, 0x08, 0x00, 0x00, 0x00, 0x00};

    int state = 0;
    #include <SoftwareSerial.h>
    SoftwareSerial mySerial(3, 2); // For the debug output
    void setup(void)


    void syncCam() {
    for (int i = 0; i < 6; i++) {

    void resetCam() {
    for (int i = 0; i < 6; i++) {

    void loop() {
    if (state == 0 ) {
    state = 1;
    if (state == 1 && millis() > 2000) {
    state = 2;

    void serialEvent() {
    char i;
    while (Serial.available()) {
    i =;
    mySerial.println(i, HEX);


    Attached Files

  • #2
    Assuming there isn't too much wire and/or logic between the uCAM and the Adriuno (how are they connected?) the most likely cause is a significant baud rate missmatch between the two at 38400.

    The actual error is the sum of both errors, both devices could have, say a 1% error, but if one was 1% high and the other was 1% low they wouldn't work together.

    You should be able to use your scope to measure the actual baud rates and thus calculate which will work the best. (usually you can tweak a baud rate, eg if one device is low and the other is high increasing the one that is low to the next 'actual' rate can sometimes fix any problems).

    Don't be scared of trying higher rates (eg the best baud rate to connect Picaso to Arduino is 200kbaud).

    Ideally the total error rate should be <1%

    Let me know how you get on.


    • #3
      Thanks for the reply

      Yeah so there's about 15CM of wire between the two,

      uCam TX -> Arduino UART RX
      uCam RX <- Arduino UART TX

      I've tried all rates mentioned in the datasheet (9600 bps • 14400 bps • 56000 bps • 57600 bps • 115200 bps • 921600 bps) that it will autobaud, as well as some other common baud rates

      At 9600 I get


      I'll do some measurements on the scope and compare the TX with the RX timing, is that how you mean? unfortunately I don't have a logic analyser


      • #4
        Definitely an Arduino issue, I've tried several different boards but the same result, I'm not really sure where to with this now

        Mt SIM900 GPRS modem works totally fine with the Arduino so hmm.. not sure!

        Here is the Arduino sending the SYNC command, 104us indicates 9600bps spot on Click image for larger version

Name:	Arduino-TX.jpg
Views:	80
Size:	32.4 KB
ID:	45344

        Here is the uCam sending the SYNC ACK reply - 104us indicates 9600bps also exactly spot on Click image for larger version

Name:	uCam-TX.jpg
Views:	74
Size:	31.6 KB
ID:	45345

        Sometimes I get closer and get 0xAA, 0xF , 0x0, 0xE, 0xD, 0x0 as the ACK reply but not the {0xAA, 0x0E, 0x0D, 0x00, 0x00, 0x00} as required

        (Debug log of the device working perfectly on USB/UART @ 57k6

        At 38400BPS the TX RS232C pulses are measured at 26.4us (which is correct for 38400), but I get no response from the device (I have power cycled it), I havent tried it at 38400BPS on the UART/USB adaptor

        At Arduino's 57600 which I have tried and works succesfully from the USB/UART adaptor i get pulse time of 16.8us which is starting to get a bit out of tollerance (104/6 should be 17.3), and no response from the uCamII at all (no trigger caught on the scope)

        So hmm..
        Last edited by dgtlmoon; 24th May 2015, 12:22 AM.


        • #5
          I'm sure someone else on the forum has/had this working at 9600, so I'm thinking there's something odd with your code. I'll see if we have any demo Aruino code.


          • #6
            Ah you wont believe this, so it turns out the rise/fall time of the UART pulse was a bit loose because I suspect the camera+breadboard+arduino connected to the USB port was not quite getting enough power, added a power supply (battery) to the arduino and camera VCC bus and all seems to work very reliably!

            SYNC at 115200 now seems fine, as do other baud rates.