Forum Migration Notice
We're transitioning to a more modern community platform by the end of this year. Learn about the upcoming changes and what to expect.

How to log the TCP speed every 0.01sec without using Multitask ()?

Hikaru_KIMURA
edited August 2024 in RobotStudio
Are there any way to do it smartly?

I've already found 2 ways to log the TCP speed.

1. Use [Signal Analyzer Online] of RobotStudio by monitoring the System AO called [TCP Speed].
2. Use [Multitask] option of IRC5 and create 2 tasks; one is the program of robot movements, and other is the logging program showing below.

--
MODULE MAINMODULE
  VAR iodev logfile;
  VAR clock clkv;
  
  ! Logging TCP Speed from System Analog Output every 5 [ms] using multitasking
  PROC main()
    ClkReset clkv;
    ClkStart clkv;
    
    ! Create log file named "TCPSPEEDLOG_[DATE][TIME].csv"
    Open "HOME:" \File:="TCPSPEEDLOG_"+StrPart(CDate(),1,4)+StrPart(CDate(),6,2)+StrPart(CDate(),9,2)+StrPart(CTime(),1,2)+StrPart(CTime(),4,2)+StrPart(CTime(),7,2)+".csv", logfile \Write;
    Write logfile, "TCP Speed Log";
    Write logfile, CDate()+","+CTime();
    Write logfile, "";
    Write logfile, "Time [s],TCP Speed [mm/s],TCP Speed Reference [mm/s]";
    
    ! Stop iteration when TASK "T_ROB1" is terminated by checking with DO112. 
    WHILE DO112=0 DO  
      Write logfile, ValToStr(ClkRead(clkv\HighRes))+","+ValToStr(AOutput(TCP_Speed)*1000)+","+ValToStr(AOutput(TCP_Speed_Reference)*1000);
      WaitTime 0.01;
    ENDWHILE
    Close logfile;
    TPWrite "FINISHED!";
    ClkStop clkv;
    ClkReset clkv;
  ENDPROC
ENDMODULE
--
Post edited by Hikaru_KIMURA on

Answers