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.

TM4C123gxl + High Speed Data Acqusition

Other Parts Discussed in Thread: TM4C123GH6PM

Hello everyone, I actually stucked at the beginning of my project and not sure how to begin. I need to get samples from a linear CCD sensor (TCD1707D) and my board is TM4C123gxl.I'm planing to visualize/record the data via a computer software. The CCD sensor requires several pwm inputs for clock inputs and two analog outputs(odd and even pixels) as I understand from the datasheet. Which method would be the fastest one to create pwm and adc conversion near theoretical speeds. In addition, at high speeds I have to transfer the data to somewhere else because each sample for 7450 pixels and 12 bits, is roughly 7450x2/1000 =~15 kb data and I can't store several hundreds of these in my SRAM. One aproach is to transfer data directly to the computer but UART can transfer roughly one per second (115200/8 =~ 14.5 kb) and not even close. Is there any other way to transfer to computer at "really" high speeds?The other approach is storing the data in a SD card (probably SD booster pack). Also what do you recommend as a comunication protocol/method to drive SD card at high speeds?  uDMA or SPI or something else? (I'm not sure if they are related?) . Sorry for my english/possible misspelling.

Best Regards 

Semih TOK

  • Why hello there, Semih.

    Well first you should determine how to gather the data from the sensor as fast as possible. I'd recommend making full use of the internal uDMA of the TivaC Series. This way, you can read the two analog input Signals with two self-sufficient ADC Modules and even process this data before you hand it back to your uDMA to transfer it via USB (I hope 1.5Mbps suffice?).

    I'd say a logic way to get going would be the following:

    1. Get the Sensor going.
      1. Hook up the PWMs. (Adaptive modulation needed? If not, this reduces to initiation routine)
      2. First Readings with the ADCs
      3. Saving data locally.
    2. Read into the USB Stack
      1. Get the USB-Examples of TivaC going.
      2. Transfer your first data per USB and handle it via PC Software
      3. If you're working on Windows, search for C# Examples for USB Communication. There are quite some.
    3. Implement the data processing
      1. What to do with the raw ADC-Data before passing it via USB?
      2. Make use of the FPU and maybe the DSP Features of TivaC

    I didn't quite understand why you'd want a SD Card though. Is this real-time data you want to process at high speed or is it just a mass of data you want to log?

    If you only want to log, SD Cards can work at up to 20MHz if i'm correctly informed and your SSI-Modules on TivaC should be fast enough to log these data away.

    Regards,

     

    Michel

  • @Michel Thanks for your fast and detailed response. I will work on the logic steps. I have actually many questions but for now I will only have a look at the examples and usage of usb and udma for embedded and computer programming. By the way I thought that if my communication speed is not enough, then I write the 1 second period of sample in a SD card then I read and send the data for 5-6 seconds it is like 'delayed' real time. The answer is I want to process the data at high speed.

    Best Regards,

    Semih TOK

  • Well, in addition to my first reply, for pwm and adc part; I'm planning to create pwm by hardware pwm module (nonadaptive just config functions..) and I will take interrupt from a pwm signal so that each time an interrupt occurs because of pwm signal adc takes a sample and add it to a fifo buffer. Is this a suitable way? is this fast enough or even applicable? Is there any other more suitable method? (Linear CCD's work like you give a pwm pulse and read and give another pwm pulse and read again and again at the same pin for next pixel everytime.)

    Regards,

    Semih

  • You won't like to hear it but I came up with some problems you might encounter.

    The CCD-Sensor requires a High Voltage of the Clock (PWMs in your case) of 5V. The Microcontroller will only achieve High Levels of 3.3V. Hope you attached a Line Driver to give it its 5V.

    If i understood you right, you need to ADC-sample everytime a PWM pulse is complete. As far as i know, the sample rate of the TM4C123GH6PM is limited to 1 Msps. Which means you can run the PWM at a maximum of 1MHz which means you can only get all 7450 samples in like 7.45ms. Is that still okay for you?

    If it is, the concept is quite simple. Synch the ADCs with your PWM and let them run at the same clock. That way you have a system which is perfectly synched, you don't have to touch at all and spits out data every µs. Since that is quite fast, i'd hook up the uDMA to the ADC to write down all the values for you so you can process them. I would NOT work with Interrupts here because as i said, it'd fire off every µs.

    Maybe you should start processing the samples when you acquired half of the data already so you can prepare them to be sent off. That way, you'd have sort of a 'moving window' of samples that you'd process and send to the PC where you again have to visualize the data.

    You can achieve that by using the uDMA yet again to put a whole package of 7450 samples into the USB-Buffer to send it to the PC once they're done.

    This solution would require a total of 7350samples * 2 * 12Bit (ADC Resolution) = 22,35KByte just for the circular and the static buffer for the USB though. Given the TM4C123GH6PM has 32KByte of SRAM, that's quite.. heavy.

    So maybe you'd want to put more thought into how or where to process the data. Or... if you have to process them at all.

    Regards,

     

    Michel

    EDIT: Concerning USB, you are going to have another problem as well. The maximum size of Reports there is 64 Byte for HID-Devices (Which is the easiest to work with). After that, the whole iteration over Devices starts again (runtime varies 1-100ms). Considering you'd have to send data in µs, you might want to look into Isochronuos Transfer of the 'Audio Device Class'. Yet, that's where USB shows its ugly face and getting this to work might take a while. But then you'd have real-time streaming data over an isochronuous USB pipe.

     

  • Thanks again for your clear explanation, firstly I actually could find very limited information about isochronous usb and even could not find any application with tiva c, is there any other way, fast enough? like ftdi to usb or different, or I can consider bulk usb or even uart because main application is actually, taking samples for 1 sec most important thing is not missing any data during this period, after that the data can be processed/sent with a delay that's why I actually asked about sd card by the way I want to describe my needs a little bit more clearly, 

    1)There are two clocks and requires shifted 2 phase pwm (one is high one is low and they intersect each other at minimum 1.5 volts)

    2)There is another clock for restarting which requires pwm (every 7450 pixels)

    3)Another clock for reset and another for clamp gate 

    4)There are two outputs  for odd and even pixels .So ;

    Can I sync all of these without high delay 

    Can I do it by setting pwm clocks and some basic coding?

    Best Regards

    Semih

  • Alright, let's clear things up a little. Sorry i got a little over my head with the Isochronuos USB. I really thought you want a constant real-time data flow, didn't intent to confuse you there.

    Yes, that all should be possible. Even with basic coding. I am using should for a reason though:

    1. Yes, you can make the PWMs work like that. They'd give out 7450 pulses at your desired frequency ( 1MHz, maybe less?) and then stop to initiate the next measurement (Maybe with a Timer @ 7.45ms)
    2. You might want to think about using the µDMA though. It is the only reasonable way i see to gather data from 2 ADC Modules running at 1Msps. ( Depending on PWM Frequency of course )
    3. Problem: Sampling for 1s straight.
      1. Simple calculation: 7450 samples done in 7.45ms @ 1MHz PWM.
      2. That's roughly around 135 complete measurements and  ~1.000.000 samples in a second.
      3. Those are ADC Data with 12Bit each. Given you'd align them at 16Bit, that's 2MByte.
      4. Everything times 2 since you have 2 input channels, even and odd pixels.
      5. So Data. Much Wow.

    So i have to ask again, even if i feel stupid. Do you want to get one measurement of 7450 samples in 1s or as much as you can?

    About the Sync: There is absolutely no problem sync-ing the PWM and ADCs. The PWM-Module of the TM4C123GH6PM even offers the possibility to tick the ADC-Modules on specific times of the PWM itself without processor interference. For example, when it reaches its peak, on rising edges, falling edges etc.

    Also, you can set up the PWMs as you like. They even offer a Bit for inversion or a register for phase-shifting in between the Generators. All described in the Datasheet.

    Another way to trigger an interrupt after 7450 samples would be the DMA btw. Just make your Transfer 7450 Bytes long, trigger the ADC per your PWM at each peak/rising edge/falling edge/whatever and voilà. Interrupt after exactly 7450 samples.

    NOTE: This interrupt is your weak point. You have to reload your uDMA in less than 0.5µs here to be sure not to lose any data. (2 PWMs intersecting at 1MHz -> 0.5µs between two samples of the 2 ADC-Modules)... Or just use PingPong Mode, gives you quite some free space to do these things (7.45ms in total)

    But honestly. Read into the uDMA. I think it'll help your application lots, considering how much data you have to move around. You can also hook it up to your SSI directly and make it send off data to your SD-Card automatically.

    Regards,

     

    Michel

  • Thank you so much for your help, I'm really appreciated. I understand the most of the concept so I will sync my signals and use uDMA to transfer data from adc to ssi and finally sd card. By the way the answer is I want to get measurements as much as I can take in a sec. Now, I'm planning to read the datasheet and your replies carefully and apply your suggestions. So, you recommend initiating pwm with respect to my required frequency and using pwm to tick adc such as after falling edge and then trasfering the data by using uDMA.

    Thank you again.

    Best Regards

    Semih

  • Hey,

    you're welcome, always glad to help here. Do study the uDMA well, it'll be one of your best friends in this sort of application.

    And yes, that is the basic idea i had. Just start the PWM whenever you're ready at your desired frequency and make it tick your ADC. However, take into consideration at which time of the PWM Cycle your sensor sends you the data. (Falling Edge, Rising Edge, Middle of the cycle?). You can acquire data at the middle of the cycle if you let your PWM run in Count Up/Down Mode. There's a 'peak' trigger available in that mode which will trigger your ADC exactly in the middle of your high cycle.

    But you got the main concept, now good luck implementing it! Looking forward to results if you mind to share.

    Regards,

     

    Michel

  • Thanks again for your valuable help, well, I have to take samples after falling edge+ ~50ns .Of course, I will share my results but as you know I have a really long way to go :)

    Best Regards

    and see you

    Semih Tok