This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Transfering ADC data to PC

Hello again everybody,

First of all, I was trying to figure out uDMA for TIVA TM4C1294XL. However, I've not worked so much with TIVA to have this familiarity, so uDMA seemed to be a bit harder for me than simply ADC.

I was wondering if there's a way to transfer the data that I receive on TIVA's ADC to my PC in a txt file for example, or any kind of file that I can open and see the results different from UART.

Thank you all in advance. J.

  • Hello Pablo,

    The simplest method would be to use UART to send the data to the PC. It would be slow. A faster method is USB but would require a PC application that can enumerate the TM4C129x as a USB device and read the data.

    Regards
    Amit
  • Hello Amit,

    Thank you.

    Is there any way for me to download this application or is there any tutorial regarding this?

    Thank you again Amit Ashara
  • Hello Pablo,

    If you are referring to USB, then no, there is no ready made application. The closest you may get is the Serial Boot Loader application note, which shows how to exchange data and is based on the usb_dev_bulk example.

    If you are referring to UART, then a Serial Console application like TeraTeram and examples in TivaWare like uart_echo should be good to start.

    Regards
    Amit
  • Pablo Juanito said:
    ... if there's a way to transfer the data that I receive on TIVA's ADC to my PC

    Amit's given several examples - all transfer in (near) real time.

    That said - I don't believe "real time" is your (present) goal.

    My small tech firm - in contrast - copies the ADC data to SRAM - carefully managed so as not to disturb any (other) MCU processes.   Under our pro IDE (IAR) we can simply copy/paste this RAM data (over 380KB w/our M4 MCU) into "Excel" - and benefit from the powerful capabilities of the program & PC in combination.  

    Suspect this method will work well for you - too..

  • Hello @cb1_mobile, thanks for the feedback!

    You said that this method would work for me - definitely! That's what I need. However, as I said before, I'm just a beginner. Do you think I could develop a code like yours by myself from scratch?

    Hello @Amit Ashara. I'm looking for any kind of transfer, but UART. I mean, I'm not considering UART as transfering because I don't really have "access" to the values, that's just a command prompt being filled with the values I want. I would like to really have access to the values - either excel, .txt, .doc... whatever form. Is USB the only way I believe, so I'll take a look at the Serial Boot Loader that you mentioned.

    As I'm working with TM4C1294XL, I have ETHERNET available (what I could use to transfer data), but reading a bit, that seems extremely hard for me. 

    Any suggestion is super welcome!


    Thank you both again! J.

    :)

  • Pablo Juanito said:
    Do you think I could develop a code like yours by myself from scratch?

    From scratch - maybe - but if you do the bulk of the work - I'm quite sure Amit, Robert, f.m. and this reporter will provide tips & encouragement.

    Firm/I believe (always) in KISS.   (don't interpret that negatively - last S stands for "Student.")   So - how do we simplify - break the big task into more manageable, smaller pieces?

    • master the ability to write "fixed" test values into RAM, incrementing the RAM address after each write - while testing for, "Ram at its end"
    • master the ability to achieve proper ADC operation w/in your desired channels
    • then - and only then - combine these two - which should satisfy your expressed requirement

    It is usual to employ pointers to write (or read) from RAM.   And following that write/read w/address increment enables you to place vast stores of data into RAM.

    We're no fan of vendor's CCS (we work w/many ARM MCUs) and very much prefer "pro/real" IDEs (IAR & Keil).   Both of the pro IDEs enable the display of RAM data - and the retrieval of that data so that it may be "pasted" into Excel.   While "not" real time - your data rate is likely to exceed that of any "Live Transfer" and you'll find it very hard to beat the power of Excel for data analysis.

    You'll have to experiment to see if CCS (if that's what your using) enables you to view and copy sequential data stored in RAM.   I know that the "free, code-size limited version of IAR (Kickstarter)" achieves this.   You may download IAR for ARM from IAR's website - again it's free.

    Any attempt to use USB or (worse still) Ethernet will add weeks to your project - if it can even be done.   The KISS method should get you "On the Air" by this Friday - if you follow instruction and proceed w/care.

  • Hello Pablo,

    You can always print the data in CSV format and use the Terminal's log to file option to save the data in .csv file which can be opened in Excel.

    Regards
    Amit
  • Greetings Amit,

    Recall that poster's data is 12 bit ADC data - thus writing via UART becomes a non-trivial matter.   Writing 12 bit data to RAM is far easier - and "light-years" faster - is it not?

    Using the UART or USB or other methods draws the poster's task out - violates KISS - and will extend this thread into (the usual) 50+ "back-forth."

    Writing directly into MCU's RAM is a fast, eased, powerful technique - unwise to bypass!

  • Faster, yes. Easier I would disagree. Terminal capture to a file is dead simple as is serial printing. Neither involve adding debugger complexities.

    The data quantity is also effectively unlimited.

    Robert
  • Robert - this IS 12 bit data - easy to write to RAM - not so much to transfer via UART.   (or - have I missed something?)


  • The data quantity is also effectively unlimited.

    The data rate, however, is not. And beginners often fail to realize the bandwidth requirements for such a data transfer.

    And second, implementing such a data transfer to run concurrently with sampling is often over their head, too (not real KISS).

  • Thank you f.m. - KISS (practically banned here) {due to misguided "PC," I guess} receives too little (NO) emphasis.

    Instead - "always & only" force the MCU into (other) than it's "sweet spot!"   (while leading eager posters (unwarned) to, "high cliff!")

    One doubts that "massaging" each/every, 12 bit, binary, ADC value into, "4 digit ASCII" (required for UART/USB transfer) qualifies as, "easy." NO such "monkey motion" (especially such "monkey motion") is required under the (greatly eased) method I've (earlier) described...

  • Hello everybody,

    Thanks again for the feedback.

    I've tried a little bit of UART - and I've been able to see the ADC values using TeraTerm (0 to 4095). In this experiment I was using a cooler fan plus a boost simple circuit(as cooler's power supply). I definitely did what Amit said, started recording the values and save them in txt format. However, now, I'd like to do something "automatic", I mean, keep sending this data to Matlab for example, or something like that, but using that method I'd have to always start the program, set the configs, start the process, save, save as, change the name of the file and export to Matlab.

    I took a look at this (www.mathworks.com/.../107921-reading-with-serial-port-in-matlab - sorry if I can't post external links), and I'll try to follow this later.

    I may not be the right person to opine, however I believe UART was "fair simple" to get the data. I don't know if I did correctly or the best way (at the end of the day I'll post the code so you could analyze).

    But regarding RAM writing, I'm not that sure if that would be a simple task for me. Would you (cb1_mobile) have any guidelines for the smaller pieces you posted? I'd really appreciate it.

    For now - thank you all!
  • I may not be the right person to opine, however I believe UART was "fair simple" to get the data. I don't know if I did correctly or the best way (at the end of the day I'll post the code so you could analyze).

    What happens if one or more characters are corrupted and/or lost during transmission ? That happens frequently with UART/RS232 transmissions. For a stable and robust transfer, you should include such a kind of "rainy day" scenario.

  • Following upon (again) f.m.'s thoughtful posting - how do you send the 12 bit, ADC value - via UART? Do you first convert to 4 digit ASCII (i.e. convert 0xFFF to "0x34""0x30""0x39""0x35") and (only then) make a call to the UART send function?    That's four separate calls to "UART Send" - might that invite error/trouble?

    Hasn't that slowed your conversion rate?    And hasn't the ADC data rate (some) importance to your measures?

    Writing the ADC conversion values directly to SRAM (remains) the fastest, simplest and most robust means to achieve your objective...


  • Writing the ADC conversion values directly to SRAM (remains) the fastest, simplest and most robust means to achieve your objective...

    As I understood it, getting this ADC data to a PC is one of his main objectives - which would not be achieved by sampling into RAM.

    Sending the data per UART is easy at first glance, but achieving a stable and robust transfer is not that trivial.

    First, the UART throughput must be higher than the ADC throughput (sampling rate), for obvious reasons. However, the data amount to pass through the UART is usually at least twice as large as that of the binary sampling data (see below).

    Second, for robustness, one (usually) needs to introduce redundancy in the transfer protocol. Binary transmissions are a bad idea, and prone to fail quickly. Proved methods to improve transfer reliability are:

    • conversion to ASCII
    • splitting up into packets, with unique start/stop byte
    • checksums

    This allows the receiver to detect transmission errors and drop-outs, and to re-sync at (almost) any time. NMEA183, as used by GPS receivers, is a good example for such a (mostly) unidirectional transfer protocol. But as said, here the implementation starts to become non-trivial ...

  • f. m. said:
    As I understood it, getting this ADC data to a PC is one of his main objectives - which would not be achieved by sampling into RAM.

    May I disagree?   Nowhere does the poster state - nor limit - the "How" of, "Getting data to a PC."  

    My first post described (just) how my firm does that - IAR enables the quick/easy copy of RAM memory - and then "ONE, simple mouse click" GETS that RAM stored, ADC Data - into a PC!   (ideally into the opened, properly prepared Excel file)   

    Note that this method - though simple - avoids "all" communication delays and errors - while imposing NO/ZERO delays upon the ADC conversion process...

  • Hello cb1

    On question on the RAM method. Storing on the RAM is possible for short time, but not when the data collection will run for extended periods. the data must be transferred to another medium

    Regards
    Amit
  • f. m. said:
    The data rate, however, is not. And beginners often fail to realize the bandwidth requirements for such a data transfer.

    Yep, OTOH they also usual considerably overestimate the analog bandwidth they nee and that their sensors are capable of..

    And the low frequency simplifies the analog requirements as well.

    Robert

  • I'm with f.m. on this one and conversion to ASCII is a simple and robust call to the standard library. And considering TIVAWare's support for serial I/O it really doesn't get much simpler.

    Once you move into noisy environments or automatic collection then you have to consider more robust transfer methods but then the ICE method doesn't really suit either.

    The downside to ICE (besides the limited data) is you need to add some sort of triggering method, where with the serial you can just send the data out and start collecting whenever you want.

    Robert

  • Pablo Juanito said:
    However, now, I'd like to do something "automatic", I mean, keep sending this data to Matlab for example

    That's a significant step in complexity. You will need to follow whatever format Matlab requires. Make note of the bandwidth limits f.m., cb1 and I have noted.

    Pablo Juanito said:
    But regarding RAM writing, I'm not that sure if that would be a simple task for me.

    Decidely not simple for this use. It may be necessary if you need bursts of high speed.

    Continuous high speed will likely require moving to a different interface method entirely.

    Robert

  • Due to dreaded, "NO/ZERO" forum guidance of posters - responders are (forced) to guess/anticipate poster's (real) restrictions/requirements.

    Poster made NO mention of "time duration of the data acquisition." My firm's method employs multiple, 18MHZ ADC sampling Cortex M4 MCUs "handing off" sampling when one fills - and each powered by solar powered, battery backed, Li-Ion arrays.

    When the acquisition is judged "complete" this MCU "cluster" can "Call for assistance or "Radio Out" its (still) RAM stored, ADC & other, data.