I would like to use a Leonardo as a data translator, but searching for "Leonardo Serial" or its various synonyms generates millions of not so helpful hits.
I have a device that spits out data over a USB serial connection (several NMEA sentences from a weather station). Unfortunately, I am trying to hook several of these instruments to a low powered computer. Because the stations are constantly streaming data as separate standard NMEA sentences with extraneous fields instead of just sending a single short custom sentence once per second, the computer is getting bogged down as it constantly polls different serial ports and tries to grab the data. I would like to use the Leonardo to read and parse the sentences, picking out only the data I want (and do some simple intermediate calculations), and then spit the desired data as a single sentence over the other serial USB to the computer.
I know that the Leo has 2 serial ports, Serial which communicates over the USB port and Serial1 which communicates over digital pins 0 and 1. What I can't seem to figure out is can I just wire a USB plug to +5/Gnd/TX/RX and have it work, or do I need an intermediate to translate? If I can just wire the plug up, all of the USB pinouts I've found have +5/Gnd/+Data/-Data. How do those translate to the Leo pins? If I can't just wire the plug up, what would I need? Is what I've outlined here even possible with the Leonardo?
Need to connect up a FTDI Basic or equivalent to the Serial1 port - Rx, Tx, Gnd, not Power, let it be powered from the device it is connected to.
The other device will need a FTDI Driver installed. http://www.ftdichip.com/FTDrivers.htm
I should note that I've actually accomplished everything past the read stage with another device. I have a Leonardo that is reading and parsing NMEA sentences from the Adafruit Ultimate GPS Shield, reading some pressure sensors over the I2C bus and some voltages on the analog pins, and then sending everything to the computer in a single sentence once per second. I want to be able to achieve the same thing with the larger weather station. If it matters, it's a Maretron USB100 gateway.
If you're on a boat all your devices probably have NMEA (RS485) phoenix connectors on the back for the "A" & "B" RS485 signals.
If you use MAX485 chips you might be able to connect them that way but you need to know about "talkers" & "listeners" and what the "talkers" are saying and what the "listeneners " are listening for. (all of which is in their manuals)
Is " Maretron USB100 gateway" a USB host? FTDI Basic is only a USB slave.
If Maretron USB100 gateway is also a slave, then you need a USB Host Shield to handle getting theUSB interface alive & talking.
craigim:
the computer is getting bogged down as it constantly polls different serial ports and tries to grab the data.
That is strange. Unless you're trying to poll hundreds of devices I wouldn't have predicted any performance problems using any remotely modern computer. What is it on the PC that is trying to read from these devices, and how much data is it being required to read?
I should have provided a link to the Maretron USB100: http://www.maretron.com/products/usb100.php. The USB100 can both talk and listen, but I am listening only. On my computer I can open a putty terminal and it just spits out NMEA sentences, although I do have to install a driver first. There are configuration commands that can be sent, but for my purposes, I only want to listen to the USB100, parse the sentences, and then send them out to my computer.
Although these are marine sensors, for my application they will be inside a Pelican case on a tripod on dry land.
The computer is a four year old pico-itx. It's a single core 1GHz cpu with 500Mb ram. I am also probably not doing the serial polling in the most efficient manner. My program is running a compiled LabVIEW VI (I know this is certainly not the most efficient language for this, but this is for work and I'm stuck with it). For each device I have a separate loop where it looks to see if there is anything on the appropriate port. If there is, it reads it in and parses it. If there isn't, it goes on. For my Leonardo with the GPS shield, all of the parsing happens on the Leonardo and I send a short pre-formatted data once per second, and all the computer has to do is stick it at the end of a log file. For the Maretron, there are 5 sentences that get sent (position, time, weather, etc.) and they are coming about every 100ms. I then have to loop through and parse each sentence to get out just what I need and discard the rest. So 80% of what's getting sent over the port is getting thrown away, and I have to do all of this without the benefit of multiple CPU threads. In between serial polls, there is another part of the program that is doing some CPU intensive calculations, and all of this has to occur at a 1Hz update rate. I was hoping to unload the NMEA wrangling and parsing onto the Leonardo. If I can do that and free up enough overhead on the pico-itx, I am hoping to add additional weather stations to my network.
So it's a USB slave also. You need a USB Host shield, and need the programming so it can initialize the interface and pretty much do what Windows does when Maretron is plugged into a PC.
It looks as if each device presents a single serial port. How many of these devices are you trying to support? Are you proposing one Arduino per device? What OS is the PC running?