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.

MMWCAS-RF-EVM: How do I run the Cascade_Capture.lua script in a loop

Part Number: MMWCAS-RF-EVM
Other Parts Discussed in Thread: MMWCAS-DSP-EVM,

Hello TI Team

I am using MMWCAS-DSP-EVM along with MMWCAS-RF-EVM and capturing the data using Cascade_Configuration_MIMO.lua and Cascade_Capture.lua. Eventually, I want to scan a defined area at different spatial points using the radar and for that I wish to run the capture script in a loop so that multiple files can be created corresponding to different locations in the PostProc folder. I tried to put a for loop in the capture script for 3 positions as an example as shown below in the following code:

--[[
    A. FRAMING & CAPTURE
    1. Triggering Slave (3, 2, 1) sequentially in a hardware triggered mode.
    2. Triggering Master in a software triggered mode.

    B. TRANSFERRING FILES
    1. The data is stored in file(s) with max cap placed at 2 GB.
    2. The files can be retrieved from the SSD (/mnt/ssd folder) using WinSCP.

Note: Update lines 18 to 49 as needed before using this script.
--

Note: "capture_time"  is a timeout for this script alone to exit - it does not control the 
actual duration of capture. The actual capture duration depends on the configured frame time 
and number of frames.
--]]

capture_time                     =   2000                             -- ms
inter_loop_time                  =   2000                             -- ms
num_loops                        =   1

--[[
Note: Change the following three parameters as desired:
1. n_files_allocation: is the number of files to preallocate on the SSD.
   This improves capture reliability by not having frame drops while switching files.
   The tradeoff is that each file is a fixed 2047 MB even if a smaller number of frames are captured.
   Pre-allocate as many files as needed based on (size_per_frame * number_of_frames) to be captured.
2. data_packaging: select whether to use 16-bit ADC data as is, or drop 4 lsbits and save 4*12-bit numbers in a packed form
   This allows a higher frame rate to be achieved, at the expense of some post-processing to unpack the data later.
   (Matlab should still be able to unpack the data using the '*ubit12' argument to fread instead of 'uint16')
   The default is no-packing, for simplicity
3. capture_directory: is the filename under which captures are stored on the SSD
   and is also the directory to which files will be transferred back to the host
   The captures are copied to the PostProc folder within mmWave Studio

   Note: If this script is called multiple times without changing the directory name, then all 
         captured files will be in the same directory with filename suffixes incremented automatically. 
         It may be hard to know which captured files correspond to which run of the script.
   Note: It is strongly recommended to change this directory name between captures.
--]]

for i = 1,3 do
n_files_allocation              =   0
data_packaging                  =   0                       -- 0: 16-bit, 1: 12-bit
-- capture_directory               =   "yanik_test6_capturetime"
capture_directory = {"pos3", "pos4", "pos5"}
num_frames_to_capture           =   0                       -- 0: default case; Any positive value - number of frames to capture 

framing_type                    =   1                       -- 0: infinite, 1: finite
stop_frame_mode                 =   0                       -- 0: Frame boundary, 2: Sub-frame boundary, 
                                                            -- 3: Burst boundary, 4: HW/Sub-frame triggered

----------------------------------DATA CAPTURE-------------------------------------------
-- Function to start/stop frame
function Framing_Control(Device_ID, En1_Dis0)
    local status = 0         
        if (En1_Dis0 == 1) then 
            status = ar1.StartFrame_mult(dev_list[Device_ID]) --Start Trigger Frame
            if (status == 0) then
                WriteToLog("Device "..Device_ID.." : Start Frame Successful\n", "green")
            else
                WriteToLog("Device "..Device_ID.." : Start Frame Failed\n", "red")
                return -5
            end
        else
            status = ar1.StopFrame_mult(dev_list[Device_ID], stop_frame_mode) --Stop Trigger Frame
            if (status == 0) then
                WriteToLog("Device "..Device_ID.." : Stop Frame Successful\n", "green")
            else
                WriteToLog("Device "..Device_ID.." : Stop Frame Failed\n", "red")
                return -5
            end
        end
    
    return status
end


while (num_loops > 0)
do

WriteToLog("Loops Remaining : "..num_loops.."\n", "purple")

-- TDA ARM
WriteToLog("Starting TDA ARM...\n", "blue")
status = ar1.TDACaptureCard_StartRecord_mult(1, n_files_allocation, data_packaging, capture_directory[i], num_frames_to_capture)
if (status == 0) then
    WriteToLog("TDA ARM Successful\n", "green")
else
    WriteToLog("TDA ARM Failed\n", "red")
    return -5
end    

RSTD.Sleep(1000)

-- Triggering the data capture
WriteToLog("Starting Frame Trigger sequence...\n", "blue")

if (RadarDevice[4]==1)then
    Framing_Control(4,1)
end

if (RadarDevice[3]==1)then
    Framing_Control(3,1)
end

if (RadarDevice[2]==1)then
    Framing_Control(2,1)
end

Framing_Control(1,1)

WriteToLog("Capturing AWR device data to the TDA SSD...\n", "blue")
RSTD.Sleep(capture_time)

if (framing_type == 0) then
    
    -- Stop capturing
    WriteToLog("Starting Frame Stop sequence...\n", "blue")
    if (RadarDevice[4]==1)then
        Framing_Control(4,0)
    end

    if (RadarDevice[3]==1)then
        Framing_Control(3,0)
    end

    if (RadarDevice[2]==1)then
        Framing_Control(2,0)
    end
    
    Framing_Control(1,0)
end

WriteToLog("Capture sequence completed...\n", "blue")
    
num_loops = num_loops - 1
RSTD.Sleep(inter_loop_time)

end

-- Enable the below if required
WriteToLog("Starting Transfer files using WinSCP..\n", "blue")
status = ar1.TransferFilesUsingWinSCP_mult(1)
if(status == 0) then
    WriteToLog("Transferred files! COMPLETE!\n", "green")
else
    WriteToLog("Transferring files FAILED!\n", "red")
    return -5
end

end

I had made only two changes in the original capture script:

1. I put a for loop at line 42 and updated the capture directory as a table, instead of a single value in line 46.

2. I updated the capture directory index in line 86 so that multiple files can be created in the PostProc folder.

But when I am running this script after configuration, I get the following error:

The script does not show any error in the Output console of mmwave studio GUI but this pop-up message opens. Due to this, the for loop is not able to move forward. Data is saved only for the first iteration, i.e. only one folder is getting created instead of three.

My questions are:

1. What "Value" are they referring to?

2. Is there anything in the script that I am doing wrong? If yes, can someone please help me how to run the capture script in a loop.

  • Hi,

    Try to reformat the SSD and what about if you do the same sequence manually not via LUA script?

    Regards,

    Jitendra

  • I tried reformatting but that did not change anything. I wish to implement SAR imaging with the help of radar chip so it is not possible to do it manually. 

    The problem is resolved with a simple change in the position of for loop. Please see below code:

    --[[
        A. FRAMING & CAPTURE
        1. Triggering Slave (3, 2, 1) sequentially in a hardware triggered mode.
        2. Triggering Master in a software triggered mode.
    
        B. TRANSFERRING FILES
        1. The data is stored in file(s) with max cap placed at 2 GB.
        2. The files can be retrieved from the SSD (/mnt/ssd folder) using WinSCP.
    
    Note: Update lines 18 to 49 as needed before using this script.
    --
    
    Note: "capture_time"  is a timeout for this script alone to exit - it does not control the 
    actual duration of capture. The actual capture duration depends on the configured frame time 
    and number of frames.
    --]]
    
    for i = 1,3 do
    capture_time                     =   2000                             -- ms
    inter_loop_time                  =   2000                             -- ms
    num_loops                        =   1
    
    --[[
    Note: Change the following three parameters as desired:
    1. n_files_allocation: is the number of files to preallocate on the SSD.
       This improves capture reliability by not having frame drops while switching files.
       The tradeoff is that each file is a fixed 2047 MB even if a smaller number of frames are captured.
       Pre-allocate as many files as needed based on (size_per_frame * number_of_frames) to be captured.
    2. data_packaging: select whether to use 16-bit ADC data as is, or drop 4 lsbits and save 4*12-bit numbers in a packed form
       This allows a higher frame rate to be achieved, at the expense of some post-processing to unpack the data later.
       (Matlab should still be able to unpack the data using the '*ubit12' argument to fread instead of 'uint16')
       The default is no-packing, for simplicity
    3. capture_directory: is the filename under which captures are stored on the SSD
       and is also the directory to which files will be transferred back to the host
       The captures are copied to the PostProc folder within mmWave Studio
    
       Note: If this script is called multiple times without changing the directory name, then all 
             captured files will be in the same directory with filename suffixes incremented automatically. 
             It may be hard to know which captured files correspond to which run of the script.
       Note: It is strongly recommended to change this directory name between captures.
    --]]
    
    n_files_allocation              =   0
    data_packaging                  =   0                       -- 0: 16-bit, 1: 12-bit
    capture_directory = {"pos31", "pos32","pos33"}
    num_frames_to_capture           =   0                       -- 0: default case; Any positive value - number of frames to capture 
    
    framing_type                    =   1                       -- 0: infinite, 1: finite
    stop_frame_mode                 =   0                       -- 0: Frame boundary, 2: Sub-frame boundary, 
                                                                -- 3: Burst boundary, 4: HW/Sub-frame triggered
    
    ----------------------------------DATA CAPTURE-------------------------------------------
    -- Function to start/stop frame
    function Framing_Control(Device_ID, En1_Dis0)
        local status = 0         
            if (En1_Dis0 == 1) then 
                status = ar1.StartFrame_mult(dev_list[Device_ID]) --Start Trigger Frame
                if (status == 0) then
                    WriteToLog("Device "..Device_ID.." : Start Frame Successful\n", "green")
                else
                    WriteToLog("Device "..Device_ID.." : Start Frame Failed\n", "red")
                    return -5
                end
            else
                status = ar1.StopFrame_mult(dev_list[Device_ID], stop_frame_mode) --Stop Trigger Frame
                if (status == 0) then
                    WriteToLog("Device "..Device_ID.." : Stop Frame Successful\n", "green")
                else
                    WriteToLog("Device "..Device_ID.." : Stop Frame Failed\n", "red")
                    return -5
                end
            end
        
        return status
    end
    
    
    while (num_loops > 0)
    do
    
    WriteToLog("Loops Remaining : "..num_loops.."\n", "purple")
    
    
    -- TDA ARM
    WriteToLog("Starting TDA ARM...\n", "blue")
    status = ar1.TDACaptureCard_StartRecord_mult(1, n_files_allocation, data_packaging, capture_directory[i], num_frames_to_capture)
    if (status == 0) then
        WriteToLog("TDA ARM Successful\n", "green")
    else
        WriteToLog("TDA ARM Failed\n", "red")
        return -5
    end    
    
    RSTD.Sleep(1000)
    
    -- Triggering the data capture
    WriteToLog("Starting Frame Trigger sequence...\n", "blue")
    
    if (RadarDevice[4]==1)then
        Framing_Control(4,1)
    end
    
    if (RadarDevice[3]==1)then
        Framing_Control(3,1)
    end
    
    if (RadarDevice[2]==1)then
        Framing_Control(2,1)
    end
    
    Framing_Control(1,1)
    
    WriteToLog("Capturing AWR device data to the TDA SSD...\n", "blue")
    RSTD.Sleep(capture_time)
    
    if (framing_type == 0) then
        
        -- Stop capturing
        WriteToLog("Starting Frame Stop sequence...\n", "blue")
        if (RadarDevice[4]==1)then
            Framing_Control(4,0)
        end
    
        if (RadarDevice[3]==1)then
            Framing_Control(3,0)
        end
    
        if (RadarDevice[2]==1)then
            Framing_Control(2,0)
        end
        
        Framing_Control(1,0)
    end
    
    WriteToLog("Capture sequence completed...\n", "blue")
        
    num_loops = num_loops - 1
    RSTD.Sleep(inter_loop_time)
    
    end
    
    
    -- Enable the below if required
    WriteToLog("Starting Transfer files using WinSCP..\n", "blue")
    status = ar1.TransferFilesUsingWinSCP_mult(1)
    if(status == 0) then
        WriteToLog("Transferred files! COMPLETE!\n", "green")
    else
        WriteToLog("Transferring files FAILED!\n", "red")
        return -5
    end
    
    
    RSTD.Sleep(10000)
    
    
    end