Go Down

Topic: Saving data from Serial Monitor to USB using FTDI Module (Read 537 times) previous topic - next topic

sill_david

Hi everyone, I'm relatively new to Arduino so apologies if my question may seem unusual.


I am in the process of setting up an automated loom resistance tester for a loom that has 66 wires.
It uses relays to sequentially switch between the wires in the loom using a matrix formation and interfaces with an Agilent 34401A DMM (sends commands via software serial and receives via hardware serial) to take the measurements, but that's not important!

I have got to the point now where the setup measures the resistance of each wire in turn and sends the data from the DMM to the serial monitor of my Arduino Mega, it checks a wire every 3 seconds and so the resistance measurements appear in the serial monitor every 3 seconds with the next result, like so:

0.14
0.23
0.22
0.20
0.13

etc etc.

Is there a way I can take this data directly from the Arduino Hardware Rx and send it straight back out of the Hardware Tx? So the data comes in from the DMM and goes straight out via the Tx?

I have a USB FTDI Module (link at bottom) to which I have set the Arduino Tx to the FTDI Rx so in theory, the data should come straight from the DMM to the Arduino and then straight back to the FTDI module where I then want to save it to a notepad, word or Excel file on a USB stick.

I understand this is a mammoth task but could anyone show me some code (as simple as possible please) that could save this data from the serial monitor onto a USB somehow?

Thanks very much in advance, I am pulling my hair out here!




USB FTDI Module I'm using:
https://uk.rs-online.com/web/p/products/0406552/?grossPrice=Y&cm_mmc=UK-PPC-DS3A-_-google-_-3_UK_EN_Interface+Development+Kits_FTDI+Chip_BMM-_-FTDI+Chip+-+Interface+Development+Kits+-+0406552-_-%2Bvdip1&matchtype=b&aud-359121783289:kwd-371955029258&s_kwcid=AL!7457!3!273636743994!b!!g!!%2Bvdip1&gclid=EAIaIQobChMI59_6hYSJ3wIVxksNCh0IXgtrEAAYASAAEgItPfD_BwE&gclsrc=aw.ds

I have also attached my code if it helps  :)

Lucario448

First: if you're using an Arduino Mega, then there is no need to use a software serial port. Remember that the Mega has other 3 hardware ports too

Second: what's wrong with the board's built-in USB to serial converter that you end up using an external one instead? You know the Arduino also interfaces with a PC via USB, right?

Third: from what I understand, you want to retransmit data. Since Serial is always fixed to the USB port, use Serial1 for the multimeter. So... use Serial1 to interface with the meter, and Serial to interface with the PC.


You at least should know how to send and receive data on those ports (which is exactly the same in both cases, only the class names are different); so now you should have it all set from now.

sill_david

Thanks very much, Lucario448.


With regards to the FTDI Module, I used this as it has a USB A port to plug a USB Stick into whereas the Arduino only has the USB B port.

Do you happen to know of any code that may help me write this data to the USB stick, as I can't seem to get the USB to hold any data at all at the moment!

Thanks again, the help is much appreciated
David

Lucario448

With regards to the FTDI Module, I used this as it has a USB A port to plug a USB Stick into whereas the Arduino only has the USB B port.
But still, how do you program the Arduino? If you do it the usual way, then you already have plugged an A to B cable anyways.
Nevertheless, I'm going to assume that the first serial port (aka Serial, the no number one) is interfacing with the PC, no matter which converter you choose.



Do you happen to know of any code that may help me write this data to the USB stick, as I can't seem to get the USB to hold any data at all at the moment!
For "USB stick" I think you mean the external converter. Since that device also behaves as a UART port, the Arduino sees it as just another serial device (like your meter, but it's actually the PC).

So, what you have to do, is read from the meter's port (e.g. Serial1); and then write to the converter's port (e.g. Serial), print() to pass textual (and presumably processed) data, or write() to simply pipe the raw (unprocessed) data stream.


Am I clear now?


PD: the meter uses RS-232 signals, so I guess you're using the corresponding MAX chip to convert them to the suitable TTL signals the Arduino needs.

sill_david

Thanks again for all the detail.

Have now changed the software serial stuff over to Serial3 as you suggested.

Am still working on saving the data to a memory stick plugged into the FTDI module.

I am using a MAX232ACPE chip to convert to serial when communicating with the DMM, would I also need to use a MAX232 chip when communicating between the Arduino and FTDI aswell?

I am sending commands to the DMM and receiving results back in the Serial monitor, I just want to save these results exactly as they appear in the serial monitor onto a USB/memory stick as a txt file or ideally an Excel document.

Thanks,

Delta_G

Quote
Am still working on saving the data to a memory stick plugged into the FTDI module.
Can you write to a memory stick like that?  Don't you need a USB host controller to handle a memory stick?  All that converter is doing is passing along serial data. It isn't a USB host. 

If you want to be able to do this with the Mega then it will be MUCH easier to use an SD card instead of a memory stick.  The SD card can be handled directly by the Mega. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

Lucario448

#6
Jan 25, 2019, 04:17 am Last Edit: Jan 25, 2019, 11:53 pm by Lucario448 Reason: Post-data and other info (striked) written in the wrong thread
Am still working on saving the data to a memory stick plugged into the FTDI module.
What? I guess you mean through a PC because I haven't seen such chip as a USB host, or even as a reader of a proprietary format.


would I also need to use a MAX232 chip when communicating between the Arduino and FTDI aswell?
Nope, both ends already "speak" TTL.


I am sending commands to the DMM and receiving results back in the Serial monitor, I just want to save these results exactly as they appear in the serial monitor onto a USB/memory stick as a txt file or ideally an Excel document.
In this case, it's just a simple dump.

Once again, I know RealTerm can do that; although compatibility with Excel depends on how the Arduino formats the output. CSV (Comma-Separeted Values) is a well-known format of plain text data importing for Excel; as the name implies, you split the individual values with commas, and each record (triplet the 66 values) is separated by lines of text (by the couple of characters "\r\n", aka carriage return and line feed).


If you want to be able to do this with the Mega then it will be MUCH easier to use an SD card instead of a memory stick.  The SD card can be handled directly by the Mega.
This way you could dump (save) the data stream in a more standalone way.



PD: printing textual data might be a huge overhead for such underpowered CPU (the ATmega2560 MCU) when timing matters, so I guess that's why you couldn't output the triplet at 100 Hz.
Piping raw data is way more straightfoward (also giving some room to remove any headers and footers the multimeter might send in response, in order to transmit only the meaningful data), although post-processing is still required since Excel can't import binary data (for that you'll have to create your own program that handles the job).

Lucario448

Update: ignore the postdata. Today I realized that my mind was crossed with this thread; since both intend to send data to a PC, I easily got confused to type a reply in the wrong place.

I apologize any caused inconvenience :smiley-sweat:

Go Up