USB serial comms to line camera

I'm an Arduino newbie looking for advice.
I have a line camera with a microcontroller that has a USB connection (for use on PC). It has an FTDI chip for the USB connection that can also be used as a virtual COM on the PC and when I do so I can control the camera functions using simple ASCII letter commands.

My problem is, apart from experience with the Arduino, that I don't know enough of that whole USB, USB as virtual COM port etc. to figure out if the control could be managed by the Arduino without USB host shield. (I have bought one but now wonder if I could get away without using that, saving space and complexity).

Anyone with some experience in how to realize serial comms with the Arduino over the USB port who could point me in the right direction?

thanks in advance,
Prieni

Have you the option of connecting to the downstream side of the FTDI chip - where the TTL Rx and Tx signals are? If so you may be able to bypass the USB stuff.

...R

Robin2:
Have you the option of connecting to the downstream side of the FTDI chip - where the TTL Rx and Tx signals are? If so you may be able to bypass the USB stuff.

...R

Possibly. There seems to be (or was, at least) a RS232 version of that board and there is preparation for a seven pin header that I suspect to be for a RS232 - would need to do some research on where these pads go. Could test if they have connection (and where to on) the FTDI chip.
Guess I have to look into RS232 on the Arduino anyways as I need to pipe some data from the sensor back to the ship through the cable.

Thanks for the pointer,
Prieni

Seems not the way to go, it uses a FT245BL ( http://www.ftdichip.com/Products/ICs/FT245B.htm ) which is a USB to parallel converter...

It's all very frustrating as there is no proper documentation - it's either at school kid level or way over my head.

The Sparkfun USB host shield has no documentation of their own, only pointing to circuits@home (which seems to be a bit richer in documentation but obviously not having identical boards). The test software there (USB Host Shield 2.0 board quality control routine, board_qc.ino) fails at the SPI long test (whatever that tries to do). Sometimes it get's 5 64k blocks done, sometimes not even one. So I'm none the wiser if there is anything wrong with the board... most probably it's ok.

I guess most frustrating is that I'm aware that it is my lack of understanding holding me back... :slight_smile:

I'll try to plod on, maybe the solution is to connect the line camera to the Arduino USB port and do the communication with the ship using a RS232.

I have an FTDI UM245R which may be similar. I bought it thinking I could use it as an alternative to a PC parallel port but the USB system has far too much latency for what I wanted.

My UM245 presents (or reads) each byte of the USB data on 8 I/O pins. Although it uses a lot of Arduino pins you should be able to emulate that.

Have you any way to know what data is being sent? Maybe it does not actually use all 8 bits.

...R

Now there's a thought...
Yes, I know what is sent, it's a 2048 element photo diode line, so it's sending the 2048 results with a resolution of 12 bit (there may be a trick in that). I'm looking to get one frame each second or so.

For now I decided to plod on with the USB host shield, looking at some examples at Oleg's site. As I can now talk to the line camera with my PC in the serial comms mode I know what to expect (though the camera doesn't always do what I want, sometimes it starts giving odd answers and only after a while gets into the swing).

For using parallel transmission I would need to dig deep into the camera electronics (it's taking a number of measurements (I can set that number to 1, though), stores the results in a RAM and then I can pull the measurements frame by frame). With the serial comms at least I know what to expect (and even have a vague documentation on it). It's something probably worth looking into after the cruise...

Thanks for the input,
Prieni

Meanwhile I made some progress using the USBFTDILoopback example, changing device ID and now I get the FTDI Init information (not that it seems very instructive to me).
Here is what I get:

Start
FTDI Init
Addr:01
NC:01
0000: 09 02 20 00 01 01 00 80 32 09 04 00 00 02 FF FF 
0010: FF 02 07 05 81 02 40 00 00 07 05 02 02 40 00 00 
Conf.Val: 01
Iface Num: 00
Alt.Set: 00
Endpoint descriptor:
Length:		07
Type:		05
Address:	81
Attributes:	02
MaxPktSize:	0040
Poll Intrv:	00
Conf.Val: 01
Iface Num: 00
Alt.Set: 00
Endpoint descriptor:
Length:		07
Type:		05
Address:	02
Attributes:	02
MaxPktSize:	0040
Poll Intrv:	00
NumEP:03
Conf:01
baud_value:001A
baud_index:0000
FTDI configured

That looks rather promising. I then try sending the string "BHallo" to the device, followed by CR and LF. This should be answered by the device with the string "Hallo", I don't get anything back from it, though.

The code in the loop reads:

   if( Usb.getUsbTaskState() == USB_STATE_RUNNING )
    { 
        char strbuf[] = "DEADBEEF123";

        // let's try first if we get an echo
        strcpy(strbuf,"BHallo\r\n\0");
        Serial.print(strbuf);
        rcode = Ftdi.SndData(strlen(strbuf), (uint8_t*)strbuf);

        if (rcode)
          {
            ErrorMessage<uint8_t>(PSTR("SndData"), rcode);
           Serial.print("y");
         }
         else
         {
          Serial.print("?");
         }

        delay(50);

        // make a buffer and clear it
        uint8_t  buf[64];
        for (uint8_t i=0; i<64; i++)
            buf[i] = 0;

        uint16_t rcvd = 7;
        // uint8_t FTDI::RcvData(uint16_t *bytes_rcvd, uint8_t *dataptr)
        rcode = Ftdi.RcvData(&rcvd, buf);

        if (rcode && rcode != hrNAK)
         {
          ErrorMessage<uint8_t>(PSTR("Ret"), rcode);
          Serial.print("x");
         }
         else
         {
          Serial.print("!");
          Serial.print(rcvd,HEX);
         }

        Serial.print("Received data: ");
        Serial.print((char*)buf);
        Serial.println("\nEnd of received data");

From the output over the serial monitor I get that SndData seems to send fine (?) and also RcvData doesn't throw an error (!). It does return 0, though in rcvd.
When I connect my device to the PC it does answer correctly. Any thoughts?

Well, on then to a more specific question:

How do I know with what parameters the USB Host Shield is trying to communicate with my device?
I can see a baud value of 001A, a baud index of 0000 but I have no idea what that means in real life. I get a flow control value of 0
Maybe the parameters are not right to talk to my device.

What is the bool lowspeed in FTDI::Init good for and can I change it? (in the USBFTDILoopback example in the Setup function Usb.Init() is called already, so it's too late to call FTDI::Init afterwards.)

If anyone has pointers on some info material where I could read up on all this I would be grateful.