' ============================================================================= ' Folder Programs ' File Demo-ImagesVideoSounds.txt ' ============================================================================= ' Theremino Automation ' Demo program for: "Load" (images, video, sounds, programs and web pages) ' The video quality is low, to reduce download time from Theremino site ' Images ".jpg" and ".bmp" ' Video ".avi", ".wmv", ".mpg", ".mp4", ".mov", ".gif" ' Sounds ".mp3", ".wav" ' Programs ".txt" ' WebPages "http://www.sitename.com Button 1 Text Start music Button 2 Text Images Button 3 Text First video Button 4 Text Second video Button 5 Text Animated GIF Button 6 Text Internet Label Start music Load Hide Load "Science Picnic 2014.mp3" ' Music is played by the video player Wait Seconds 1 Wait Seconds 1 Wait Seconds 1 Label Images Load Image1.jpg ' Images can be ".jpg", ".bmp" and so on... Wait Seconds 3 Load Image2.jpg Wait Seconds 1 Load Hide ' Show the program execution Wait Seconds 14.8 Load Stop ' Stop sounds or video Label First video Load Video2.mp4 ' First video could take some seconds to start Wait Seconds 20 Load Video1.avi Wait Seconds 3.5 Load Video3.avi Wait Seconds 4 Label Second video Load Video4.wmv Wait Seconds 27 Load Hide ' Show the program execution Wait Seconds 3 Load Video5.mov Wait Seconds 15 Label Animated GIF ' Animated GIF can be loaded too (played like video) Load StirlingMotor.GIf Wait Seconds 5 Load Hide ' Show the program execution Wait Seconds 2 Label Internet Load http://www.theremino.com ' <--- Web exploration Stop ' ============================================================================= ' Folder Programs ' File HELP_ButtonsAndKeys.txt ' ============================================================================= ' ---------------------------------- ' Buttons and Keys example ' ---------------------------------- Button 1 Text Function1 Button 2 Text Function2 Key 3 Gosub Open Key 4 Gosub Close Stop Label Function1 v1 = v1 + 1 Print v1 Goto Function1 Label Function2 v1 = v1 + 1000 Goto Function2 Label Open Slot 7 = 750 Beep Return Label Close Slot 7 = 480 Beep Return ' ============================================================================= ' Folder Programs ' File HELP_ENG.txt ' ============================================================================= '------------------------------------------------------------- ' Theremino Automation - Quick Reference ' Please read the complete: Theremino_Automation_Help_ENG.pdf '------------------------------------------------------------- ' RUN THE PROGRAM ' Press the EDIT button and adjust "Speed" and "Zoom". ' Set speed to slow, to debug the execution of the program. ' Raise Speed to 1000 instructions per second for a "normal" run. ' With max Speed the CPU usage may increase. ' VALID KEYWORDS ' The bottom status bar displays the valid keywords. ' While composing the instruction line, the status bar changes. ' ERRORS ' Errors are displayed with a red line. ' The bottom status bar displays information about the error. ' CORRECT MISTAKES ' Delete from the right. ' Delete until the lower status line does not begin with ERROR. ' Rewrite the line following the status line instructions. ' THE INSTRUCTIONS ' Beep - Emits a short beep. ' Button N Slot - Button is pressed when the Slot value exceeds 500. ' Button N Text - Used to change the text on the buttons. ' Button N Enabled - Enables the "N" button (with N from 1 to 32). ' Button N Disabled - Disables the "N" button (with N from 1 to 32). ' Controls OpenTextBox - Opens the text box to be used with "Print" ' Controls CloseTextBox - Closes the text box ' Controls ClearTextBox - Clears all the text in the text box ' For v1 = 1 To 5 - Executes five times the statements between FOR and NEXT. ' (you can also add the Step word at the end) ' Next - The execution returns to the FOR row. ' Exit - The execution jumps after the Next instruction ' GoSub LABEL - The execution jumps to the LABEL (and come back here). ' GoTo LABEL - The execution jumps to the LABEL. ' If CONDITION - If the condition is true, the execution continues. ' Else - If the condition is false the execution continues here. ' EndIf - End of the conditional execution. ' Key k GoSub LABEL - The execution jumps to the LABEL (and come back here). ' Key k GoTo LABEL - The execution jumps to the LABEL (k is a Key). ' PressKeys KEYS - The keys are pressed (also with SHIFT CTRL ALT) ' Label - Label destination GoSub, GoTo and buttons. ' Load Slots - Loads all the Slots (from 0 to 999) from file "_Slots" ' Load Vars - Loads all the variables (V1..V9 e S1..S9) from file "_Vars" ' Load fileName - Load pictures, video, sounds, or programs. ' Load Pause - Pause for sounds and video. ' Load Play - Restart for paused sounds and video. ' Load Position SEC. - New position for sounds and video in seconds and fractions. ' Load Stop - Closes definitively sounds and video. ' Load Hide - Return to the normal program view. ' Option GlobalKeys En. - With "Enabled" you enable the keyboard also without "focus" ' Option GlobalKeys Di. - With "Disabled" you disable the keyboard without "focus" ' Option Speed 1..9 - Execution speed from 1 to 100 000 lines per second. ' Print EXPRESSION - The text is written in the lower status line. ' Return - Return to the line of the last Gosub or button pressed. ' Save Slots - Save all the Slots (from 0 to 999) to file "_Slots" ' Save Vars - Save all the variables (V1..V99 e S1..S99) to file "_Vars" ' Select ESPRESS. - Start of the Select/Case ' Case EXSPRESSION - Conparation with the Select expression ' CaseElse - To be executed if all the preceding Cases are not valid. ' EndSelect - End of the Select/Case ' Slot(N) = EXPR. - The number or the calculated value is written to Slot N. ' Slot N = EXPRESS. - An alternative way to write it (without parentheses). ' Slot N = COMMAND - SlotZero commands are: Sleep Reset Recognize Calibrate. ' SlotText(N) = "abcd" - The characters "abcd" are written to the SlotText N ' SlotText N = "abcd" - An alternative way to write it (without parentheses). ' Stop - Stop the program until you press a button. ' End - Ends the program execution ' Wait CONDITION - Stop the program until the condition becomes true. ' Wait Seconds N - Stop the program for N seconds (also decimal numbers). ' Wait Key KEY-NAME - Stop the program until the KEY is pressed. ' Variable Numeric nn - User defined numerical-variable declaration ' Variable String str - User defined string-variable declaration ' V1..V99 = EXPRESS. - Variables that can contain numbers for calculations. ' S1..S99 = EXPRESS. - Variables that can contain text strings. ' V1..V99 = Input - Prompt the user for a number. ' S1..S99 = Input - Prompt the user for a text string. ' Window Sizable - Window becomes resizable ' Window Maximized - Window becomes maximized ' Window FullScreen - Window to full screen ' WRITE TO FILE ' Save StringToFile s1 s2 - Append a row with the string variable S1 to the file s2 ' Save DeleteFile s2 - Deletes the file s2 ' The file names does not contain the path (example: "TestFile.txt") ' The files path is always in the "Files" folder ' The "Files" folder is created automatically near to the "Automation.exe" file ' EXPRESSIONS ' Expressions can contain functions, operators, variables and constants. ' FUNCTIONS ' Slot(number) DecodeCommandSlot(n) ' Sin(v) Cos(v) Asin(v) Acos(v) Tan(v) Atan(v) Atan2(v, v) Sqrt(v) ' Abs(v) Sign(v) Min(v, v) Max(v, v) Mod(v, mod) ' Pow(v, v) Exp(v) Exp2(v) Exp10(v) Log(v) Log2(v) Log10(v) Int(v) Round(v) ' Mid(string, index) Mid(string, index, len) Len(string) Trim(string) ' Left(string, len) Right(string, len) PadLeft(str, places) PadRight(str, places) ' Replace(str, oldStr, newStr) UCase(string) LCase(string) WCase(string) ' Chars(string, number) ' Now() Today() Date(year, month, day) ElapsedTime Rnd ' COM_Status COM_Received COM_Portnames MouseX MouseY MouseXP MouseYP MouseButtons ' GetCursorPixelColor GetPixelColor(x,y) GetColorRed(c) GetColorGreen(c) GetColorBlue(c) ' GetColorHue(c) GetColorSaturation(c) GetColorLightness(c) GetColorIndex(c) ' GetSaturatedColorName(c) GetNearestColorName(c) CommandText() ' GetSeparatedStringCount(str) GetSeparatedStringCount(str, separator) ' GetSeparatedString(str) GetSeparatedString(str, separator) ' Key(str) DecodeXML(str) FormatXML(str) FormatXML(str,n) ' Limit(n, Min, Max) LimitReached() ' CONVERSION FUNCTIONS ' Chr(n) Asc(str) Bin(n) FromBin(Str) Hex(n) FromHex(Str) ' Format(v, style) Format(v) Str(v, style) Str(v) ' OPERATORS AND CONSTANTS ' And Or False True CRLF CR LF CLS NBSP TAB Math_PI Math_E Infinity ' USER DEFINED VARIABLES - EXAMPLES ' Variable Numeric number ' Variable Numeric Goofy ' Variable String Pluto ' PREDEFINED VARIABLES ' v1 v2 v3 ... v98 v99 - Numerical variables (double precision with decimals) ' s1 s2 s3 ... s98 s99 - String variables (use "" to assign the text) ' CONDITIONS ' The conditions are expressions ending with True or False. ' True or False is determined by comparisons (> <=> = <= <>). ' In some situations ZERO is FALSE and any other number is TRUE. ' EVENTS ' Label EventStop - Called when the program stops ' Label EventTimer - Called ten times per second ' Label Event_CommandsFromCobot ' - Called when there is a command in the "Slot_CommandsFromCobot" ' - To get the command text use the function "CommandText" ' THE "Key" INSTRUCTION ' The execution jumps to a Label when a Keyboard Key is pressed. ' Valid keys are: ' 0..9 / A..Z / F1..F12 / Left / Right / Up / Down / Space / Esc ' THE INSTRUCTIONS "Option GlobalKeys Enable" and "Option GlobalKeys Disable" ' Normally the Key instruction and the Key () function receive keys ' only if the Automation application is selected and not minimized. ' With "Option GlobalKeys Enable" the keys always work. ' With "Option GlobalKeys Disable" you return to normal operation. ' THE "Option Speed" INSTRUCTION ' Normal regulations are: ' Option Speed 0 = the speed is restored to the track-bar regulation ' Option Speed 5 = 20 instructions per second (slow debug execution) ' Option Speed 7 = 1000 instructions per second (fast execution) ' Option Speed 8 and 9 can increase CPU usage (use only for short loops) ' ZERO CPU USAGE WHILE RUNNING AT SPEED 9 ' Add a "Wait Seconds 0.001" instruction at the end of each loop. ' Minimize the main window. ' Or load a static image (with: Load xxx.jpg) ' ADVICES ' Press RUN to execute the following lines. ' Use the "Slot Viewer" to view and change the Slot values. ' EXAMPLE OF CONDITIONAL EXECUTION Label 1 If Slot(1) < 500 Gosub 2 Else Gosub 3 EndIf Goto 1 ' EXAMPLE THAT COPY THE SLOT 1 TO SLOT 2 CONTINUOUSLY Label 2 v1 = Slot(1) Slot 2 = v1 Return ' EXAMPLES with and without parentesis and without using a variable Label 3 Slot(3) = Slot(1) Slot 4 = Slot(3) Return ' ============================================================================= ' Folder Programs ' File HELP_ITA.txt ' ============================================================================= '------------------------------------------------------------- ' Brevi istruzioni per Theremino Automation ' Leggete il file completo Theremino_Automation_Help_ITA.pdf '------------------------------------------------------------- ' ESEGUIRE IL PROGRAMMA ' Premere il pulsante EDIT e regolare "Speed" e "Zoom". ' Usare una Speed bassa per controllare la esecuzione del programma. ' Alzare Speed a 1000 istruzioni per secondo per una esecuzione "normale". ' Con Speed al massimo il consumo di CPU aumenta. ' PAROLE CHIAVE USABILI ' Nella barra di stato inferiore vengono visualizzate le parole usabili. ' Mentre si compone la riga di istruzioni le parole cambiano. ' ERRORI ' Gli errori vengono visualizzati con una riga rossa. ' La barra di stato inferiore mostra alcune informazioni sull'errore. ' CORREGGERE GLI ERRORI ' Cancellare partendo da destra. ' Cancellare fino a che la riga di stato inferiore non inizi piu' con ERROR. ' Riscrivere seguendo le istruzioni della riga di stato. ' LE ISTRUZIONI UNA PER UNA ' Beep - Emette un breve suono. ' Button N Slot - Pulsante premuto se il valore dello Slot supera 500. ' Button N Text - Si usa per cambiare testo ai pulsanti. ' Button N Enabled - Abilita il pulsante "N" (con N da 1 a 32). ' Button N Disabled - Disabilita il pulsante "N" (con N da 1 a 32). ' Controls OpenTextBox - Apre la casella di testo da usare con "Print". ' Controls CloseTextBox - Chiude la casella di testo. ' Controls ClearTextBox - Svuota la casella di testo. ' For v1 = 1 To 5 - Esegue cinque volte le istruzioni tra FOR e NEXT. ' (si può anche aggiungere la parola Step alla fine) ' Next - La esecuzione torna alla riga FOR ' Exit - La esecuzione esce dal ciclo ForNext ' GoSub LABEL - La esecuzione salta alla LABEL (e torner con Return). ' GoTo LABEL - La esecuzione salta alla LABEL. ' If CONDIZIONE - Se la condizione è vera la esecuzione prosegue. ' Else - Se la condizione è falsa le esecuzione prosegue qui. ' EndIf - Fine della esecuzione condizionale. ' Key k GoSub LABEL - La esecuzione salta alla LABEL (e tornerà con Return). ' Key k GoTo LABEL - La esecuzione salta alla LABEL (k è un tasto). ' PressKeys KEYS - I tasti vengono premuti (anche con SHIFT CTRL e ALT) ' Label - Etichetta destinazione di GoSub, GoTo e pulsanti. ' Load Slots - Carica tutti gli Slot(da 0 a 999) dal file "_Slots" ' Load Vars - Carica le variabili (V1..V99 e S1..S99) dal file "_Vars" ' Load nomeDelFile - Carica immagini, video, suoni, pagine WEB o programmi. ' Load Pause - Ferma suoni e video in pausa. ' Load Play - Fa ripartire suoni e video che erano in pausa. ' Load Position SEC. - Nuova posizione per suoni e video in secondi e frazioni. ' Load Stop - Chiude definitivamente suoni e video. ' Load Hide - Torna alla normale visualizzazione del programma. ' Option GlobalKeys En. - Con "Enabled" si abilita la tastiera anche senza "focus" ' Option GlobalKeys Di. - Con "Disabled" si disabilita la tastiera senza "focus" ' Option Speed 1..9 - Velocità di esecuzione da 1 a 100 000 righe per secondo. ' Print ESPRESSIONE - Il testo viene scritto nella riga di stato inferiore. ' Return - Ritorna alla riga dell'ultimo Gosub o pulsante premuto. ' Save Slots - Salva tutti gli Slot(da 0 a 999) nel file "_Slots" ' Save Vars - Salva le variabili (V1..V9 e S1..S9) nel file "_Vars" ' Select ESPRESS. - Inizia il costrutto Select/Case ' Case ESPRESSIONE - Confronta con la espressione del Select ' CaseElse - Parte da eseguire se tutti i Case precedenti falliscono ' EndSelect - Fine del costrutto Select/Case ' Slot(N) = ESPRESS. - Il numero o il valore calcolato viene scritto nello Slot N ' Slot N = ESPRESS. - Un modo alternativo di scriverlo (senza parentesi). ' Slot N = COMMAND - SlotZero commands are: Sleep Reset Recognize Calibrate. ' SlotText(N) = "abcd" - I caratteri "abcd" vengono scritti nello SlotText N ' SlotText N = "abcd" - Un modo alternativo di scriverlo (senza parentesi). ' Stop - Ferma il programma fino a che non si preme un pulsante. ' End - Esce definitivamente dalla esecuzione del programma. ' Wait CONDIZIONE - Ferma il programma fino a che la condizione diventa vera. ' Wait Seconds N - Ferma il programma per N secondi (anche numeri decimali). ' Wait Key NOME-TASTO - Ferma il programma fino a che viene premuto il tasto. ' Variable Numeric nn - Dichiarazione di variabile numerica definita dall'utente ' Variable String str - Dichiarazione di variabile stringa definita dall'utente ' V1..V99 = ESPRESS. - Variabili che possono contenere numeri per i calcoli. ' S1..S99 = ESPRESS. - Variabili che possono contenere stringhe di testo. ' V1..V99 = Input - Richiesta all'utente di immettere un numero. ' S1..S99 = Input - Richiesta all'utente di immettere una stringa di testo. ' Window Sizable - Finestra con dimensioni variabili ' Window Maximized - Finestra massimizzata ' Window FullScreen - Finestra a schermo intero ' SCRIVERE SU UN FILE ' Save StringToFile s1 s2 - Appende una riga con la stringa s1 al file s2 ' Save DeleteFile s2 - Elimina il file s2 ' I nomi dei file non contengono il percorso (esempio: "TestFile.txt") ' Il percorso dei file è sempre nella cartella "Files" ' La cartella "Files" viene creata automaticamente accanto a "Automation.exe" ' LE ESPRESSIONI ' Le espressioni possono contenere funzioni, operatori, variabili e costanti. ' LE FUNZIONI ' Slot(number) DecodeCommandSlot(n) ' Sin(v) Cos(v) Asin(v) Acos(v) Tan(v) Atan(v) Atan2(v, v) Sqrt(v) ' Abs(v) Sign(v) Min(v, v) Max(v, v) Mod(v, mod) ' Pow(v, v) Exp(v) Exp2(v) Exp10(v) Log(v) Log2(v) Log10(v) Int(v) Round(v) ' Mid(string, index) Mid(string, index, len) Len(string) Trim(string) ' Left(string, len) Right(string, len) PadLeft(str, places) PadRight(str, places) ' Replace(str, oldStr, newStr) UCase(string) LCase(string) WCase(string) ' Chars(string, number) ' Now() Today() Date(year, month, day) ElapsedTime Rnd ' COM_Status COM_Received COM_Portnames MouseX MouseY MouseXP MouseYP MouseButtons ' GetCursorPixelColor GetPixelColor(x,y) GetColorRed(c) GetColorGreen(c) GetColorBlue(c) ' GetColorHue(c) GetColorSaturation(c) GetColorLightness(c) GetColorIndex(c) ' GetSaturatedColorName(c) GetNearestColorName(c) CommandText() ' GetSeparatedStringCount(str) GetSeparatedStringCount(str, separator) ' GetSeparatedString(str) GetSeparatedString(str, separator) ' Key(str) DecodeXML(str) FormatXML(str) FormatXML(str,n) ' Limit(n, Min, Max) LimitReached() ' LE FUNZIONI DI CONVERSIONE ' Chr(n) Asc(str) Bin(n) FromBin(Str) Hex(n) FromHex(Str) ' Format(v, style) Format(v) Str(v, style) Str(v) ' GLI OPERATORI E LE COSTANTI ' And Or False True CRLF CR LF CLS NBSP TAB Math_PI Math_E Infinity ' VARIABILI DEFINITE DALL'UTENTE - ESEMPI ' Variable Numeric number ' Variable Numeric Pippo ' Variable String Pluto ' LE VARIABILI PREDEFINITE ' v1 v2 v3 ... v98 v99 - Variabili numeriche con decimali ' s1 s2 s3 ... s98 s99 - Variabili stringa (usare "" per il testo) ' LE CONDIZIONI ' Le condizioni sono espressioni che terminano con Vero o Falso. ' Vero o Falso viene determinato da confronti (> < = >= <= <>). ' In alcuni casi si considera falso lo ZERO e vero ogni altro numero. ' GLI EVENTI ' Label EventStop - Chiamata quando il programma si ferma ' Label EventTimer - Chiamata dieci volte al secondo ' Label Event_CommandsFromCobot ' - Chiamato quando c'è un comando nello "Slot_CommandsFromCobot" ' - Il testo del comando si legge con la funzione "CommandText" ' L'ISTRUZIONE "Key" ' L'esecuzione salta a una Label quando si preme un tasto della tastiera. ' I tasti validi sono: ' 0..9 / A..Z / F1..F12 / Left / Right / Up / Down / Space / Esc ' LE ISTRUZIONI "Option GlobalKeys Enable" e "Option GlobalKeys Disable" ' Normalmente l'istruzione Key e la funzione Key() ricevono i tasti ' solamente se la applicazione Automation è selezionata e non minimizzata. ' Con "Option GlobalKeys Enable" i tasti funzonano sempre. ' Con "Option GlobalKeys Disable" si torna al funzionamento normale. ' L'ISTRUZIONE "Option Speed n" ' Le regolazioni normali sono: ' Option Speed 0 = la velocità viene reimpostata come indica il cursore regolatore ' Option Speed 5 = 20 istruzioni al secondo (esecuzione lenta di prova) ' Option Speed 7 = 1000 istruzioni al secondo (esecuzione veloce) ' Option Speed 8 e 9 incrementano il lavoro della CPU (usare solo per cicli brevi) ' AZZERARE IL CONSUMO DI CPU ANCHE CON SPEED 9 ' Aggiungere "Wait 0.001" alla fine di ogni loop. ' Minimizzare la finestra principale. ' Oppure caricare una immagine statica (con: Load xxx.jpg) ' CONSIGLI ' Premere RUN per eseguire le righe seguenti. ' Usare lo "Slot Viewer" per vedere e modificare i valori degli Slot. ' ESEMPIO DI ESECUZIONE CONDIZIONALE Label 1 If Slot(1) < 500 Gosub 2 Else Gosub 3 EndIf Goto 1 ' ESEMPIO CHE COPIA IN CONTINUAZIONE LO SLOT 1 NELLO SLOT 2 Label 2 v1 = Slot(1) Slot 2 = v1 Return ' ESEMPI di copia, con o senza parentesi, e senza passare da una variabile Label 3 Slot(3) = Slot(1) Slot 4 = Slot(3) Return ' ============================================================================= ' Folder Programs ' File HELP_Select-Case_ENG.txt ' ============================================================================= ' Theremino Automation ' Demo program for "Select/Case/EndSelect" ' Use SlotViewer to set Slots 1 and 2 with values 1 and 2 Button 1 Text Loop1 Button 2 Text Loop2 Stop Label Loop1 Select Slot(1) Case 1 Beep Case 2 Beep CaseElse Beep EndSelect Goto Loop1 ' This demonstrates that "Select" could also be nested ' and that you can also use expressions Label Loop2 Select Slot(1) Case 1 Beep Select Slot(2) Case 1 Beep Case 6 - 4 Beep Beep EndSelect Case Slot(3) - 1 Beep Beep EndSelect Goto Loop2 ' The Select instruction is case insensitive. ' ============================================================================= ' Folder Programs ' File HELP_Select-Case_ITA.txt ' ============================================================================= ' Theremino Automation ' Help per "Select/Case/EndSelect" ' Usare SlotViewer per impostare gli Slot 1 e 2 con i valori 1 e 2 Button 1 Text Loop1 Button 2 Text Loop2 Stop Label Loop1 Select Slot(1) Case 1 Beep Case 2 Beep CaseElse Beep EndSelect Goto Loop1 ' Questo dimostra che i Select-Case possono anche essere annidati ' e che si possono utilizzare delle espressioni Label Loop2 Select Slot(1) Case 1 Beep Select Slot(2) Case 1 Beep Case 6 Beep Beep EndSelect Case 2 Beep Beep EndSelect Goto Loop2 ' L'istruzione Select non fa differenze tra lettere maiuscole o minuscole. ' ============================================================================= ' Folder Programs ' File HELP_STRINGS_ENG.txt ' ============================================================================= '-------------------------------------------- ' Theremino Automation - Strings '-------------------------------------------- ' Early versions of Theremino Automation ' did not distinguish between numbers and strings. ' The variables were all the same (V1 to V9) ' and this was very simple, but in some cases ' the results became, not intuitive and unpredictable. ' So from version 3.0 there are two types of data. ' Numbers (double precision floating point numbers) ' Strings (simple sequences of ASCII characters) ' ----------------------------------------------------------------------------------- ' USER DEFINED VARIABLES - EXAMPLES ' ----------------------------------------------------------------------------------- ' Variable Numeric Goofy ' Numerical variable (initially = 0) ' Variable String Pluto ' String variable (initially = "") ' ----------------------------------------------------------------------------------- ' PREDEFINED VARIABLES ' ----------------------------------------------------------------------------------- ' v1 v2 v3 v4 v5 v6 v7 v8 v9 ' Numerical variables ' s1 s2 s3 s4 s5 s6 s7 s8 s9 ' String variables ' String text must be enclosed with "" ' Examples: v1 = 12345.67 s1 = "This is a string" ' ----------------------------------------------------------------------------------- ' STRING TO NUMBER CONVERSIONS ' ----------------------------------------------------------------------------------- ' The symbol "=" is used. ' The decimal separator is alwais the dot. ' Examples: v1 = "12345.67" Print v1 ' ----------------------------------------------------------------------------------- ' NUMBER TO STRING CONVERSIONS ' ----------------------------------------------------------------------------------- ' The "Format" Instruction is used. ' For more instructions search: "VBNET Format" on Google ' Examples: Print Format(1234.56, "000000.000") 'Result "001234.560" Print Format(1234.56, "0.0") 'Result "1234.6" Print Format(1234.56, "0") 'Result "1235" Print Format(Math_PI, "") 'Result "3.14159265358979" Print Format(1234.56, "+0.000;-0.000") 'Result "+1234.6" or "-1234.6" ' ----------------------------------------------------------------------------------- ' STRING COMPARATIONS ' ----------------------------------------------------------------------------------- ' Strings comparations are: > < = >= <= <> ' The result "True" or "False" can be printed ' or used in the conditional instruction "If". ' Examples: Print "Duck" = "Cat" ' Result "False" Print Mid("Duck", 4, 1) = "k" ' Result "True" s1 = "Duck" If s1 = "Duck" ' Condition is True Beep ' the Beep is executed EndIf Stop ' ----------------------------------------------------------------------------------- ' STRING FUNCTIONS ' ----------------------------------------------------------------------------------- ' Mid(string, index, len) ' Extracts characters, index starts at 1 ' Len(string) ' The result is the number of characters ' Trim(string) ' Remove leading and final spaces ' PadLeft (string, length) ' Returns the string padded with spaces up to "length" ' PadRight (string, length) ' Returns the string padded with spaces up to "length" ' Str(number) ' Turn a number in string with the max number of figures ' Format(number) ' Turn a number in string with the max number of figures ' Str(number, style) ' Turn a number in string with specified style ' Format(number, style) ' Turn a number in string with specified style ' UCase(string) ' Transforms the entire string to uppercase ' LCase(string) ' Transforms the entire string to lowercase ' WCase(string) ' Transforms the string capitalized ' Chars(string, number) ' Returns the first char of the string repeated "n" times ' Chr(code) ' Returns the character with the specified code ' Asc(string) ' Returns the code of the first character of the string ' Bin(number) ' Returns a string with the binary representation of the number ' FromBin(string) ' Returns a number converted from the binary string ' Hex(number) ' Returns a string with the hex representation of the number ' FromHex(string) ' Returns a number converted from the hexadecimal string ' This function returns a string with all the "OldStr" replaced with "NewStr" ' Replace(string, OldStr, NewStr) ' This function returns a string without the comments starting from ' ' RemoveComments(string) ' These functions count and extract substrings separated by spaces ' GetSeparatedStringCount(str) ' GetSeparatedString(str) ' These functions count and extract substrings with any separator (string too) ' GetSeparatedStringCount(str, separator) ' GetSeparatedString(str, separator) ' ----------------------------------------------------------------------------------- ' STRING CONSTANTS ' ----------------------------------------------------------------------------------- ' CRLF ' String containing CR and LF (characters 10 and 13) ' CR ' String containing CR (character 13) ' LF ' String containing LF (character 10) ' CLS ' String containing the character 12 (that clears the print area) ' NBSP ' Returns a string containing a non-breakable-space ' TAB ' Returns a string containing a TAB (tabulation) (character 9) ' ----------------------------------------------------------------------------------- ' TIME FUNCTIONS ' ----------------------------------------------------------------------------------- ' Now() ' Responds a string with date and time ' Today() ' Responds a string with the date ' Date(year, month, day) ' Create a date from numeric values ' ElapsedTime() ' The time from the program start in seconds and fractions ' ============================================================================= ' Folder Programs ' File HELP_STRINGS_ITA.txt ' ============================================================================= ' -------------------------------------------- ' Theremino Automation - Stringhe ' -------------------------------------------- ' Le prime versioni di Theremino Automation ' non facevano distinzioni tra numeri e stringhe. ' Le variabili erano tutte uguali (da V1 a V9) ' e questo era molto semplice, ma in alcuni casi ' i risultati diventavano poco intuitivi e imprevedibili. ' Cosi, dalla versione 3.0, esistono due tipi di dati. ' I numeri (numeri con la virgola mobile in doppia precisione) ' Le stringhe (semplici sequenze di caratteri ASCII) ' ----------------------------------------------------------------------------------- ' VARIABILI DEFINITE DALL'UTENTE - ESEMPI ' ----------------------------------------------------------------------------------- ' Variable Numeric Pippo ' Variabile numerica (inizialmente = 0) ' Variable String Pluto ' Variabile stringa (inizialmente = "") ' ----------------------------------------------------------------------------------- ' LE VARIABILI PREDEFINITE ' ----------------------------------------------------------------------------------- ' v1 v2 v3 v4 v5 v6 v7 v8 v9 ' Variabili numeriche con decimali ' s1 s2 s3 s4 s5 s6 s7 s8 s9 ' Variabili stringa ' Il testo delle stringhe deve essere attorniato da doppi apici. ' Esempi: v1 = 12345.67 s1 = "Questa è una stringa" ' ----------------------------------------------------------------------------------- ' CONVERSIONI DA STRINGHE A NUMERI ' ----------------------------------------------------------------------------------- ' Si usa il simbolo "=" ' Anche in Italia si usa il punto come separatore decimale. ' Esempi: v1 = "12345.67" Print v1 ' ----------------------------------------------------------------------------------- ' CONVERSIONI DA NUMERI A STRINGHE ' ----------------------------------------------------------------------------------- ' Si usa l'istruzione Format ' Per ulteriori istruzioni cercare su Google: "VbNet Format" ' Esempi: Print Format(1234.56, "000000.000") 'Risultato "001234.560" Print Format(1234.56, "0.0") 'Risultato "1234.6" Print Format(1234.56, "0") 'Risultato "1235" Print Format(Math_PI, "") 'Risultato "3.14159265358979" Print Format(1234.56, "+0.000;-0.000") 'Risultato "+1234.6" oppure "-1234.6" ' ----------------------------------------------------------------------------------- ' CONFRONTI TRA STRINGHE ' ----------------------------------------------------------------------------------- ' Le stringhe si confrontano con: > < = >= <= <> ' Il risultato "Vero" o "Falso" può essere stampato ' o usato nelle istruzioni condizionali "If". ' Esempi: Print "Duck" = "Cat" ' Risultato "False" Print Mid("Duck", 4, 1) = "k" ' Risultato "True" s1 = "Duck" If s1 = "Duck" ' Condizione vera Beep ' viene eseguito il Beep EndIf Stop ' ----------------------------------------------------------------------------------- ' LE FUNZIONI PER LE STRINGHE ' ----------------------------------------------------------------------------------- ' Mid(string, index, len) ' Estrae caratteri, index inizia da 1 ' Len(string) ' Il risultato ? il numero di caratteri ' Trim(string) ' Elimina spazi iniziali e finali ' PadLeft (string, length) ' Ritorna la stringa addizionata di spazi fino a "length" ' PadRight (string, length) ' Ritorna la stringa addizionata di spazi fino a "length" ' Str(number) ' Numero in stringa con il massimo numero di cifre ' Format(number) ' Numero in stringa con il massimo numero di cifre ' Str(number, style) ' Numero in stringa con stile specificato ' Format(number, style) ' Numero in stringa con stile specificato ' UCase(string) ' Trasforma tutta la stringa in maiuscolo ' LCase(string) ' Trasforma tutta la stringa in minuscolo ' WCase(string) ' Trasforma la stringa con iniziale maiuscola ' Chars(string, number) ' Restituisce il primo carattere ripetuto "n" volte ' Chr(code) ' Ritorna il carattere corrispondente al codice specificato ' Asc(string) ' Ritorna il codice del primo carattere della stringa ' Bin(number) ' Ritorna una stringa che rappresenta il numero in binario ' FromBin(string) ' Ritorna un numero convertito dalla stringa binaria ' Hex(number) ' Ritorna una stringa che rappresenta il numero in esadecimale ' FromHex(string) ' Ritorna un numero convertito dalla stringa esadecimale ' Questa funzione ritorna una stringa con tutte le "OldStr" sostituite da "NewStr" ' Replace(string, OldStr, NewStr) ' Questa funzione ritorna una stringa senza i commenti inizianti con ' ' RemoveComments(string) ' Queste due funzioni contano e estraggono parti di stringa separate da spazi ' GetSeparatedStringCount(str) ' GetSeparatedString(str) ' Due funzioni uguali alle precedenti ma specificando il separatore (anche stringa) ' GetSeparatedStringCount(str, separator) ' GetSeparatedString(str, separator) ' ----------------------------------------------------------------------------------- ' LE COSTANTI STRINGA ' ----------------------------------------------------------------------------------- ' CRLF ' Stringa contenente i caratteri 10 e 13 ' CR ' Stringa contenente il carattere 13 ' LF ' Stringa contenente il carattere 10 ' CLS ' Stringa contenente il carattere 12 (cancella l'area di stampa) ' NBSP ' Stringa contenente uno spazio "non divisibile" ' TAB ' Stringa contenente un TAB (tabulazione) (carattere 9) ' ----------------------------------------------------------------------------------- ' LE FUNZIONI DI DATA E TEMPO ' ----------------------------------------------------------------------------------- ' Now() ' Risponde una stringa con data e ora ' Today() ' Risponde una stringa con la data ' Date(year, month, day) ' Crea una data a partire da valori numerici ' ElapsedTime() ' Il tempo, dall'avvio del programma, in secondi e frazioni ' ============================================================================= ' Folder Demo Programs ' File Kicad_PosToCsv.txt ' ============================================================================= Button 1 Label Drop POS-File here String DroppedFilename String DroppedString Stop Label Event_DroppedFile s2 = "" v1 = GetSeparatedStringCount(DroppedString, CRLF) For v2 = 4 To v1 - 1 s1 = GetSeparatedString(DroppedString, v2, CRLF) s1 = Replace(s1,"#", "") If s1 = " End" Exit EndIf v3 = GetSeparatedStringCount(s1, " ") s2 = s2 + GetSeparatedString(s1, 0, " ") + "," s2 = s2 + GetSeparatedString(s1, 3, " ") + "," s2 = s2 + GetSeparatedString(s1, 4, " ") + "," s2 = s2 + GetSeparatedString(s1, 5, " ") + "," s2 = s2 + GetSeparatedString(s1, 6, " ") s2 = s2 + CRLF Next 'Print DroppedFilename + s2 s3 = DroppedFilename + "_.csv" Save DeleteFile s3 Save StringToFile s2 s3 Return ' ============================================================================= ' Folder Demo Programs\Arrays ' File ArrayInitializaton_Test.txt ' ============================================================================= Array1 = 000.1, 111, 222, 333 Array1(6) = 666 Array1(9) = 999 Print ArrayToString(1) Stop ' ============================================================================= ' Folder Demo Programs\Arrays ' File ArrayInitializaton_Test2.txt ' ============================================================================= Numeric value4 = 444 Array1 = 000.1 111 222, 333, value4 Array1(6) = 666 Array1(9) = 999 Print ArrayToString(1) Stop ' ============================================================================= ' Folder Demo Programs\Arrays ' File Test_Arrays_1.txt ' ============================================================================= Array1(0) = 100 Array1(1) = 200 Array2(0) = 1 Array2(1) = 2 Array2(2) = 3 Print "Array2 has been automatically dimensioned to " + ArrayLength(2) + " elements" For v1 = 0 To ArrayLength(1) - 1 TTS SpeakWait Array1(v1) Next For v1 = 0 To ArrayLength(2) - 1 TTS SpeakWait Array2(v1) Next Stop ' ============================================================================= ' Folder Demo Programs\Arrays ' File Test_Arrays_2.txt ' ============================================================================= Array1(999) = 123 Array2(999) = 123 ArrayClear(2) Print ArrayLength(1) + " " + ArrayLength(2) Stop ' ============================================================================= ' Folder Demo Programs\Audio and Beep ' File Demo - AudioGenerator1.txt ' ============================================================================= ' For this example start the AudioGenerator app ' and set AudioGenerator Slots to 1, 2, 3, -1 Slot(1) = 1 '<-- Waveform Slot(3) = 700 '<-- Volume Option Speed 8 v1 = 500 v2 = 1 Label Loop v1 = v1 + v2 If v1 > 600 Or v1 < 500 v2 = -v2 EndIf Slot(2) = v1 '<-- Frequency Goto Loop ' ============================================================================= ' Folder Demo Programs\Audio and Beep ' File Demo - AudioGenerator2.txt ' ============================================================================= ' For this example start the AudioGenerator app ' and set AudioGenerator Slots to 1, 2, 3, -1 Slot(1) = 1 '<-- Waveform Slot(3) = 800 '<-- Volume Option Speed 8 Label Loop v1 = Sin(ElapsedTime) + 1 Slot(2) = v1 * 500 '<-- Frequency Goto Loop ' ============================================================================= ' Folder Demo Programs\Audio and Beep ' File DEMO Beep Strings.txt ' ============================================================================= Button 1 Label PlaySong Button 2 Label StopPlaying Button 3 Label TimeSignal Beep "440-100,0-200,330-100,440-100,660-100" Stop Label PlaySong Load s1 "HappyBirthday.txt" Beep s1 Return Label StopPlaying Beep 0 0 Return Label TimeSignal Beep 440 500 Wait Seconds 0.5 For v1 = 1 To 6 Beep 1000 100 Wait Seconds 1 Next Return ' ============================================================================= ' Folder Demo Programs\Audio and Beep ' File DEMO BeepWithFrequency ClickTester.txt ' ============================================================================= Variable Numeric Frequency = 100 Variable Numeric Duration = 52 Key Space Gosub PlayBeep Key Up Gosub KeyUp Key Down Gosub KeyDown Key Left Gosub KeyLeft Key Right Gosub KeyRight Print Frequency + " " + Duration For v1 = 1 To 10000 PlayBeep Wait Seconds 0.05 Next Stop ' -------------------------------- Play Beep Label PlayBeep Beep Frequency Duration Print Frequency + " " + Duration Wait Seconds duration / 1000 Return ' -------------------------------- Keys Label KeyUp Delta = 1 ChangeFrequency Return Label KeyDown Delta = -1 ChangeFrequency Return Label KeyLeft Delta = -1 ChangeDuration Return Label KeyRight Delta = 1 ChangeDuration Return ' -------------------------------- Modify delta Variable Numeric Delta Label ChangeFrequency ModifyDelta Frequency = Frequency + Delta Return Label ChangeDuration ModifyDelta Duration = Duration + Delta Return Label ModifyDelta If Key("shift") Delta = Delta * 100 EndIf If Key("ctrl") Delta = Delta * 10 EndIf Return ' ============================================================================= ' Folder Demo Programs\Audio and Beep ' File Midi_To_Steppers_V1.txt ' ============================================================================= Load Theremino_HAL.exe Load Theremino_SlotViewer.exe Load Theremino_SlotViewer2.exe Load Theremino_SlotsToMidi\Theremino_SlotsToMidi.exe EnableAll Goto Loop Stop Variable Numeric FirstMidiSlot = 500 Variable Numeric NumMidiSlots = 72 ' = 6 ottave Variable Numeric FirstStepperSlot = 101 Variable Numeric FirstEnableSlot = 106 Label Loop v1 = 0 For v2 = 0 To 4 ScanSlots Next Goto Loop Label ScanSlots Frequency = 1e7 For v1 = v1 + 1 To NumMidiSlots If Slot(FirstMidiSlot + v1) > 0 NoteToFrequency(v1) Exit EndIf Next Slot(FirstStepperSlot + v2) = Frequency Return Label NoteToFrequency Variable Numeric Note Variable Numeric Octave Variable Numeric Frequency Octave = Int((Note - 1) / 12) Note = Mod(Note - 1, 12) + 1 Select Note Case 1 ' DO Frequency = 261.63 Case 2 ' DO # Frequency = 277.18 Case 3 ' RE Frequency = 293.66 Case 4 ' RE # Frequency = 311.13 Case 5 ' MI Frequency = 329.63 Case 6 ' FA Frequency = 349.23 Case 7 ' FA # Frequency = 369.99 Case 8 ' SOL Frequency = 392.00 Case 9 ' SOL # Frequency = 415.30 Case 10 ' LA Frequency = 440 Case 11 ' LA # Frequency = 466.16 Case 12 ' SI Frequency = 493.88 EndSelect Frequency = Frequency * Pow(2, Octave) Return Label EventStop DisableAll End Label EnableAll For v1 = FirstEnableSlot To FirstEnableSlot + 4 Slot(v1) = 1000 Next Return Label DisableAll For v1 = FirstEnableSlot To FirstEnableSlot + 4 Slot(v1) = 0 Next Return ' ============================================================================= ' Folder Demo Programs\Audio and Beep ' File NotesToFrequency.txt ' ============================================================================= PlaySong1 'PlaySong2 Stop Label PlaySong1 s1 = "Do Re Mi Do P1 Do Re Mi Do P1 " s1 = s1 + "Mi Fa Sol P1 Mi Fa Sol P1 " s1 = s1 + "Sol La Sol Fa Mi Do P1 " s1 = s1 + "Sol La Sol Fa Mi Do P1 " s1 = s1 + "Re P1 Sol3 P1 Do P2 " s1 = s1 + "Re P1 Sol3 P1 Do P2 " DecodeSong(s1) Return Label PlaySong2 Load s1 "HappyBirthday.txt" DecodeSong(s1) Return Label DecodeSong Variable String NF1 Variable String NF2 Variable Numeric NF3 For NF3 = 0 To GetSeparatedStringCount(NF1) NF2 = GetSeparatedString(NF1, NF3) Select NF2 Case "Sol3" PlayNote(196.00) Case "Do" PlayNote(261.63) Case "Do#" PlayNote(277.18) Case "Re" PlayNote(293.66) Case "Re#" PlayNote(311.13) Case "Mi" PlayNote(329.63) Case "Fa" PlayNote(349.23) Case "Fa#" PlayNote(369.99) Case "Sol" PlayNote(392.00) Case "Sol#" PlayNote(415.30) Case "La" PlayNote(440.00) Case "La#" PlayNote(466.16) Case "Si" PlayNote(493.88) Case "P1" Wait Seconds 0.1 Case "P2" Wait Seconds 0.2 Case "P3" Wait Seconds 0.3 EndSelect Next Return Label PlayNote Variable Numeric PN1 'Slot(1) = PN1 Beep PN1 400 Wait Seconds 0.4 Return ' ============================================================================= ' Folder Demo Programs\Audio and Beep ' File Test_LongBeep.txt ' ============================================================================= Button 1 Label Beep100 Button 2 Label Beep330 Button 3 Label Beep440 Button 4 Label Beep660 Button 6 Label Beep60sec Button 7 Label StartAndStop Button 9 Label StopPlaying 'Beep "440-100,0-200,330-100,440-100,660-100" 'Beep60sec Stop Label Beep100 Beep 1000 60000 Return Label Beep330 Beep 330 60000 Return Label Beep440 Beep 440 60000 Return Label Beep660 Beep 660 60000 Return Label StartAndStop Beep 300 60000 Wait Seconds 1 Beep 0 0 Return Label StopPlaying Beep 0 0 Return ' ============================================================================= ' Folder Demo Programs\Autocompletion ' File Autocompletion - EndIf Next label Select - Copia.txt ' ============================================================================= ' ======================================================= ' AUTOCOMPLETION FOR EndIf/Next/EndSelect/Return ' ======================================================= ' Press ENTER on the lines ' ======================================================= If v1 = 3 For v1 = 1 To 4 Select v1 = v2 Select v1 = v2 Label foo If v1 = 3 For v1 = 1 To 4 Select v1 = v2 ' ============================================================================= ' Folder Demo Programs\Autocompletion ' File Autocompletion - Test2 .txt ' ============================================================================= ' ======================================================= ' AUTOCOMPLETION FOR EndIf/Next/EndSelect/Return ' ======================================================= ' Press ENTER at the end of the lines ' ======================================================= If v1 = 3 For v1 = 1 To 4 Select v1 = v2 Select v1 = v2 Label foo If v1 = 3 For v1 = 1 To 4 Select v1 = v2 ' ============================================================================= ' Folder Demo Programs\Autocompletion ' File Autocompletion - Test3.txt ' ============================================================================= ' ======================================================= ' AUTOCOMPLETION FOR EndIf/Next/EndSelect/Return ' ======================================================= ' Press ENTER at the end of the lines ' ======================================================= If v1 = 3 For v1 = 1 To 4 Select v1 = v2 Select v1 = v2 Label foo If v1 = 3 For v1 = 1 To 4 Select v1 = v2 ' ============================================================================= ' Folder Demo Programs\BUTTONS ' File Button IMAGES 1.txt ' ============================================================================= String Img1 = Image1.jpg String Img2 = Image2.jpg String Img3 = Image3.jpg String Img4 = Image4.jpg Button 1 Label "Button1" Button Button1 Text "123 abc" Button Button1 Image Img1 Button 2 Label "Button2" Button Button2 Text "aaa bbb" Button Button2 Image Img2 Button 3 Label "Button3" Button Button3 Text " " Button 3 Image Img3 Button 4 Label "Button4" Button Button4 Text "Btn. 4 " Button Button4 Image img4 Button 5 Label Button5 Button Button5 Text "123 abc" Button Button5 Image Image2.jpg Button 6 Label Button6 Button Button6 Text CRLF + "Low text" Button Button6 Image Theremino1.png Button Button6 Color Flashing2 255,255,200 30,255,255,200 Button 7 Label Button7 Button Button7 Text CRLF + "Rainbow fish " Button Button7 Image rainbow.ico Button Button7 Color Flashing7 255,255,200 30,255,255,200 Button 17 Label Button17 Button Button17 Text "Without border" Button Button17 Image0 Button3.png Button Button17 Color 255,255,200 Button 18 Label Button18 Button Button18 Text "Border 1 pixel" Button Button18 Image1 Button3.png Button Button18 Color 255,255,200 Button 19 Label Button19 Button Button19 Text "Border 3 pixel" Button Button19 Image3 Button3.png Button Button19 Color 255,255,200 Button 20 Label Button20 Button Button20 Text "Border 5 pixel" Button Button20 Image5 Button3.png Button Button20 Color 255,255,200 Button 22 Label Button22 Button Button22 Text "IMAGE" + CRLF + "STRETCHED" Button Button22 Image0S Button1.png Button Button22 Color 255,255,200 Button 23 Label Button23 Button Button23 Text " " Button Button23 Image0S Theremino1.png 'Button Button23 Color 10,0,255,255 Button 25 Label EnableButtons Button 26 Label DisableButtons Stop Label EnableButtons For v1 = 1 To 22 Button v1 Enabled Next Return Label DisableButtons For v1 = 1 To 22 Button v1 Disabled Next Return ' ============================================================================= ' Folder Demo Programs\BUTTONS ' File Button IMAGES 2.txt ' ============================================================================= ' =============================================== ' Button images are without the border ' and are stretched using "Image0S" ' ----------------------------------------------- ' Test with CTRL-SHIFT and moving the mouse ' =============================================== Controls SetBackColor 240, 240, 150 For v1 = 1 To 5 Button v1 Label " Button" + v1 Button V1 Image0S Button2.png Button v1 Color 240,240,0 Next Button 17 Label "Data" Button Data Color Gray9 Button Data Image0S Button3.png Button 18 Label "Open" Button Open Color Gray9 Button Open Image0S Button3.png Button 20 Label "Logo" Button Logo Color 240,240,150 Button Logo Text " " Button Logo Image0S LogoTrasparent.png Stop ' ============================================================================= ' Folder Demo Programs\BUTTONS ' File Button RGB COLORS.txt ' ============================================================================= Button 1 Label Button1 Button Button1 Text "Color RGB" Button Button1 Color 100,150,200 Button 2 Label Button2 Button Button2 Text "RGB with Alpha" Button Button2 Color 50,255,0,0 Button 3 Label Button3 Button Button3 Text CRLF + "Color RGB flashing" Button Button3 Color Flashing7 255,255,200 255,200,200 Button 4 Label Button4 Button Button4 Text CRLF + "PULSED COLOR" Button 6 Label EnableButtons Button 7 Label DisableButtons Label Loop If ButtonsAreDisabled = 0 String col = 128 + 128 * Sin(ElapsedTime * 5) + ", 250, 100" Button Button4 Color col EndIf Goto Loop Stop Label EnableButtons For v1 = 1 To 4 Button v1 Enabled Next ButtonsAreDisabled = 0 Return Numeric ButtonsAreDisabled = 0 Label DisableButtons ButtonsAreDisabled = 1 For v1 = 1 To 4 Button v1 Disabled Next Return ' ============================================================================= ' Folder Demo Programs\BUTTONS ' File Buttons 16.txt ' ============================================================================= Button 1 Label "B1" Button 2 Label "B2" Button 3 Label "B3" Button 4 Label "B4" Button 5 Label "B5" Button 6 Label "B6" Button 7 Label "B7" Button 8 Label "B8" Button 9 Label "B9" Button 10 Label "B10" Button 11 Label "B11" Button 12 Label "B12" Button 13 Label "B13" Button 14 Label "B14" Button 15 Label "B15" Button 16 Label "B16" Button B1 Color Flashing1 LightSalmon Blue Button B2 Color Flashing2 Honeydew Red Button B3 Color Flashing3 YellowGreen Black Button B4 Color Flashing4 Green Yellow Button B5 Color Flashing5 Yellow Black Button B6 Color Flashing6 Yellow Black Button B7 Color Flashing7 Red Blue Button B8 Color Flashing8 Red Blue Button B9 Color Flashing9 Red Blue Button B10 Color YellowGreen Button B11 Color LightPink Button B12 Color Orange Stop ' ============================================================================= ' Folder Demo Programs\BUTTONS ' File Buttons 80.txt ' ============================================================================= Button 1 Label "B1" Button 2 Label "B2" Button 3 Label "B3" Button 4 Label "B4" Button 5 Label "B5" Button 6 Label "B6" Button 7 Label "B7" Button 8 Label "B8" Button 10 Label "B10" Button 20 Label "B20" Button 30 Label "B30" Button 40 Label "B40" Button 50 Label "B50" Button 60 Label "B60" Button 70 Label "B70" Button 71 Label "B71" Button 72 Label "B72" Button 73 Label "B73" Button 74 Label "B74" Button 75 Label "B75" Button 76 Label "B76" Button 77 Label "B77" Button 78 Label "B78" Button 79 Label "B79" Button 80 Label "B80" Stop ' ============================================================================= ' Folder Demo Programs\BUTTONS ' File Buttons Flashing.txt ' ============================================================================= Button 1 Label "B1" Button 2 Label "B2" Button 3 Label "B3" Button 4 Label "B4" Button 5 Label "B5" Button 6 Label "B6" Button 7 Label "B7" Button 8 Label "B8" Button 9 Label "B9" Button 10 Label "B10" Button 11 Label "B11" Button 12 Label "B12" Button B1 Color Flashing LightSalmon Blue Button B2 Color Flashing Honeydew Red Button B3 Color Flashing YellowGreen Black Button B4 Color Flashing Green Yellow Button B5 Color Flashing7 Yellow Black Button B6 Color Flashing7 Yellow Black Button B7 Color Flashing9 Red Blue Button B8 Color Flashing9 Red Blue Button B9 Color Cyan Button B10 Color YellowGreen Button B11 Color LightPink Button B12 Color Orange Stop ' ============================================================================= ' Folder Demo Programs\BUTTONS ' File Buttons LongText and TwoLines.txt ' ============================================================================= Button 1 Label "Test1" Button 2 Label "Test2 Long 1234" Button 3 Label "Test3 Long 12345678" Button 4 Label "Test4 Long 1234567890" Button 5 Label "Test5 Long 123456789 0123456789" Button 7 Label "Very long Label message" + CRLF + "using two lines of Label" Button 8 Label CRLF + "Second line only" Button 9 Label "First line only" + CRLF + " " Stop Label Test1 Beep Wait Seconds 1 Return Label Test2 Beep Wait Seconds 1 Return Label Very Beep Wait Seconds 1 Return ' ============================================================================= ' Folder Demo Programs\BUTTONS ' File Buttons with colors 8-8.txt ' ============================================================================= Button 1 Label "B1" Button 2 Label "B2" Button 3 Label "B3" Button 4 Label "B4" Button 5 Label "B5" Button 6 Label "B6" Button 7 Label "B7" Button 8 Label "B8" ' Button 17 Label "B17" Button 18 Label "B18" Button 19 Label "B19" Button 20 Label "B20" Button 21 Label "B21" Button 22 Label "B22" Button 23 Label "B23" Button 24 Label "B24" ' Button B1 Color Flashing Yellow9 Red7 Button B2 Color Honeydew Button B3 Color Yellow Button B4 Color Cyan Button B5 Color YellowGreen Button B6 Color LightPink Button B7 Color Orange Button B8 Color LightGray Button B17 Color Lavender Button B18 Color LavenderBlush Button B19 Color LawnGreen Button B20 Color LemonChiffon Button B21 Color LightBlue Button B22 Color LightCoral Button B23 Color LightCyan Button B24 Color LightGoldenrodYellow Stop ' ============================================================================= ' Folder Demo Programs\BUTTONS ' File Buttons with colors 8.txt ' ============================================================================= Button 1 Label "B1" Button 2 Label "B2" Button 3 Label "B3" Button 4 Label "B4" Button 5 Label "B5" Button 6 Label "B6" Button 7 Label "B7" Button 8 Label "B8" Button B1 Color LightSalmon Button B2 Color Honeydew Button B3 Color Yellow Button B4 Color Cyan Button B5 Color YellowGreen Button B6 Color LightPink Button B7 Color Orange Button B8 Color LightGray Stop ' ============================================================================= ' Folder Demo Programs\BUTTONS ' File ButtonsFlashing SpeedTester 1.txt ' ============================================================================= Button 1 Label "B1" Key Up Gosub Increment Key Down Gosub Decrement Controls OpenTextBox v1 = 5 Gosub SetFlashingSpeed Stop Label SetFlashingSpeed Select v1 Case 1 Button B1 Color Flashing1 Blue Yellow Case 2 Button B1 Color Flashing2 Blue Yellow Case 3 Button B1 Color Flashing3 Blue Yellow Case 4 Button B1 Color Flashing4 Blue Yellow Case 5 Button B1 Color Flashing5 Blue Yellow Case 6 Button B1 Color Flashing6 Blue Yellow Case 7 Button B1 Color Flashing7 Blue Yellow Case 8 Button B1 Color Flashing8 Blue Yellow Case 9 Button B1 Color Flashing9 Blue Yellow EndSelect 'Controls ClearTextBox s1 = CLS + CRLF + "Press UP DOWN arrows to change speed" s1 = s1 + CRLF + CRLF + "Flashing speed = " + v1 Print s1 Return Label Increment v1 = v1 + 1 If v1 > 9 v1 = 9 EndIf Gosub SetFlashingSpeed Return Label Decrement v1 = v1 - 1 If v1 < 0 v1 = 0 EndIf Gosub SetFlashingSpeed Return Label EventStop Controls CloseTextBox End ' ============================================================================= ' Folder Demo Programs\BUTTONS ' File Demo ButtonBistable.txt ' ============================================================================= ' Theremino Automation demo program ' Bistable button that changes state and color ' ------------------------------------ INITIALIZATIONS Variable Numeric LED = 1 Button 1 Label LedToggle Gosub LedOFF Stop ' ------------------------------------ FUNCTIONS Label LedToggle If Slot(LED) = 0 Gosub LedON Else Gosub LedOFF EndIf Return Label LedON Slot LED = 1000 Button LedToggle Text "LED OFF" Button LedToggle Color PowderBlue Return Label LedOFF Slot LED = 0 Button LedToggle Text "LED ON" Button LedToggle Color Cyan Return ' ============================================================================= ' Folder Demo Programs\BUTTONS ' File Demo ButtonMultipleStates.txt ' ============================================================================= ' Theremino Automation demo program ' Bistable button that changes multiple states ' ------------------------------------ INITIALIZATIONS Button 1 Label LedChange Gosub LedOFF Variable Numeric LED = 1 Stop ' ------------------------------------ FUNCTIONS Label LedChange Select Slot(LED) Case 0 Gosub Led30% Case 300 Gosub Led60% Case 600 Gosub Led100% Case 1000 Gosub LedOFF EndSelect Return Label LedOFF Slot LED = 0 Button LedChange Text "LED is OFF" Return Label Led30% Slot LED = 300 Button LedChange Text "LED is 30%" Return Label Led60% Slot LED = 600 Button LedChange Text "LED is 60%" Return Label Led100% Slot LED = 1000 Button LedChange Text "LED is 100%" Return ' ============================================================================= ' Folder Demo Programs\BUTTONS ' File Demo-Buttons1.txt ' ============================================================================= Gosub SetButtons Stop Label SetButtons Button 1 Label PenDown Button PenDown Text "Pen DOWN" Button PenDown Color SkyBlue Button 2 Label PenUp Button PenUp Text "Pen UP" Button PenUp Color White Button 4 Label PenSingle Button PenSingle Text "Pen single" Button PenSingle Color PaleGreen Button 5 Label "TEST" Button TEST Color Aqua Button TEST Slot 12 Button 8 Label DisableButtons Button DisableButtons Color Salmon Return Label DisableButtons For v1 = 1 To 32 Button v1 Color Moccasin Button v1 Disabled Next Return Label PenDown Slot(15) = 0 Wait Seconds 0.1 Return Label PenUp Slot(15) = 500 Wait Seconds 0.1 Return Label PenSingle Gosub PenDown Load sound\Click3.wav Wait Seconds 0.5 Gosub PenDown Return ' ============================================================================= ' Folder Demo Programs\BUTTONS ' File Demo-Buttons2.txt ' ============================================================================= ' DEMO - BUTTONS PRESSED FROM SLOTS Button 1 Label B1 Button 2 Label 2 Button 3 Label " " Button B1 Slot 5 Button 2 Slot 6 Stop Label 1 Beep 1000 100 Stop Label 2 Beep 1500 100 Stop ' ============================================================================= ' Folder Demo Programs\BUTTONS ' File Demo-ButtonsFromSlots.txt ' ============================================================================= ' Theremino Automation demo program ' Two loops, called "1" and "2" and two buttons to call them Button 1 Label B1 Button 2 Label B2 ' Buttons are also pressed when Slots 5 and 6 values are > 500 Button B1 Slot 5 Button B2 Slot 6 Stop Label B1 Slot 1 = 1000 Slot 1 = 0 Slot 2 = 1000 Slot 2 = 0 Goto B1 Label B2 Slot(1) = 1000 Slot(2) = 1000 Slot(3) = 1000 Slot(3) = 0 Slot(2) = 0 Slot(1) = 0 Goto B2 ' ============================================================================= ' Folder Demo Programs\BUTTONS ' File Demo-ButtonsLongText.txt ' ============================================================================= ' Eight buttons example Button 1 Label Start Button 2 Label Stop Button 3 Label "Long looong teeeeeeext" Stop Label Start Print "" Goto Start Label Stop Stop Label Long Beep Return ' ============================================================================= ' Folder Demo Programs\BUTTONS ' File Demo-ButtonsRefresh.txt ' ============================================================================= Button 1 Label "Button1" Button 2 Label "Button2" Button 4 Label "Button4" Button 5 Label "Button5" Button 6 Label "Button6" Button 7 Label "Button7" Button 8 Label "Button8" Button 9 Label "Button9" Button 11 Label Test1 Button 12 Label Test2 For v1 = 0 To 9e99 Variable String Str1 = "Test1" Button Button1 Text Str1 + " = " + Format(v1, "0") Button Button2 Text "Test2 = " + Format(v1, "0") Button Button4 Text "" + Format(Rnd * 10, "0.00000") Button Button5 Text "" + Format(Rnd * 10, "0.00000") Button Button6 Text "" + Format(Sin(Rnd) * 10, "0.00000") Button Button7 Text "" + Format(Cos(Rnd) * 10, "0.00000") Button Button8 Text "" + Format(Tan(Rnd) * 10, "0.00000") Button Button9 Text "" + Format(Log(Rnd) * 10, "0.00000") Button Test1 Text "Test1" + CRLF + "two lines" Button Test2 Text "Test2" Print v1 Wait Seconds 0.001 Next Stop Label Test1 Beep Wait Seconds 1 Return Label Test2 Beep Wait Seconds 1 Return ' ============================================================================= ' Folder Demo Programs\BUTTONS ' File Demo-EightButtons.txt ' ============================================================================= ' Eight buttons example Button 1 Label Start Button 2 Label Stop Button 3 Label "Button3" Button 4 Label "Button4" Button 5 Label "Button5" Button 6 Label "Button6" Button 7 Label "Button7" Button 8 Label "Button8" Stop Label Start Stop Label Stop Stop Label Button7 Beep Return Label Button8 Beep Return ' ============================================================================= ' Folder Demo Programs\BUTTONS ' File Demo-EnableDisableButtons.txt ' ============================================================================= Button 1 Label "Button1" Button Button1 Color Blue9 Button 2 Label "Button2" Button Button2 Color SlateGray Button 3 Label "Button3" Button Button3 Color IndianRed Button 4 Label "Button4" Button Button4 Color IndianRed Button 7 Label EnableButtons Button EnableButtons Color Tan Button 8 Label DisableButtons Button DisableButtons Color Tan Gosub DisableButtons Stop ' ===================================================================== ' ENABLE/DISABLE BUTTONS ' ===================================================================== Label EnableButtons For v1 = 1 To 4 Button v1 Enabled Next Return Label DisableButtons For v1 = 1 To 4 Button v1 Disabled Next Return ' ============================================================================= ' Folder Demo Programs\BUTTONS ' File Demo-Loops1and2.txt ' ============================================================================= ' Theremino Automation demo program ' Two loops, called "Loop1" and "Loop2" and two Buttons to call them ' Buttons with long names can call labels with the complete long name ' or abbreviated to the first word (Loop1 in this example) Button 1 Label "Loop1 (Button with long name)" Button 2 Label Loop2 Stop Label Loop1 Button 5 Text "Executing Loop1" Slot 1 = 1000 Slot 1 = 0 Slot 2 = 1000 Slot 2 = 0 'Button 5 Text " " Goto Loop1 Label Loop2 Button 5 Text "Executing Loop2" Slot(1) = 1000 Slot(2) = 1000 Slot(3) = 1000 Slot(3) = 0 Slot(2) = 0 Slot(1) = 0 'Button 5 Text "" Goto Loop2 ' ============================================================================= ' Folder Demo Programs\BUTTONS ' File Demo-StartStop.txt ' ============================================================================= ' Theremino Automation demo program ' Button names and simple Start Stop Button 1 Label Start Button 2 Label Stop Button 3 Label "" ' An empty string to hide the button Button 4 Label " " ' A space to see an empty button Stop Label Start Slot(1) = 1000 Slot(1) = 0 Slot(2) = 1000 Slot(2) = 0 Goto Start Label Stop Beep 1000 100 Stop ' ============================================================================= ' Folder Demo Programs\BUTTONS ' File Demo-WaitButton.txt ' ============================================================================= ' Theremino Automation demo program ' Demonstrating "Partial button names" and "Wait Button" Button 1 Label "sTrAnGe nAmE" Button 2 Label "five" Label Start ' Wait Button Strange Slot(1) = 1000 Slot(1) = 0 ' Wait Button Five Slot(2) = 1000 Slot(2) = 0 ' Goto Start ' ============================================================================= ' Folder Demo Programs\BUTTONS\Direct access with numbers ' File Buttons as Labels __ TEST-LABELS.txt ' ============================================================================= Variable String ButtonName1 ButtonName1 = "Test1" For v1 = 0 To 9e99 Button 1 Label ButtonName1 + " = " + Format(v1, "0") Button 2 Label "Test2 = " + Format(v1, "0") Button 4 Label Format(Rnd * 10, "0.00000") Button 5 Label Format(Rnd * 10, "0.00000") Button 6 Label Format(Sin(Rnd) * 10, "0.00000") Button 7 Label Format(Cos(Rnd) * 10, "0.00000") Button 8 Label Format(Tan(Rnd) * 10, "0.00000") Button 9 Label Format(Log(Rnd) * 10, "0.00000") Button 11 Label "Test1" + CRLF + "two lines" Button 12 Label "Test2" Print v1 Wait Seconds 0.01 Next Stop Label Test1 Beep Wait Seconds 1 Return Label Test2 Beep Wait Seconds 1 Return ' ============================================================================= ' Folder Demo Programs\BUTTONS\Direct access with numbers ' File Buttons as Labels.txt ' ============================================================================= Variable String ButtonName1 ButtonName1 = "Test1" For v1 = 0 To 9e99 Button 1 Text ButtonName1 + " = " + Format(v1, "0") Button 2 Text "Test2 = " + Format(v1, "0") Button 4 Text Format(Rnd * 10, "0.00000") Button 5 Text Format(Rnd * 10, "0.00000") Button 6 Text Format(Sin(Rnd) * 10, "0.00000") Button 7 Text Format(Cos(Rnd) * 10, "0.00000") Button 8 Text Format(Tan(Rnd) * 10, "0.00000") Button 9 Text Format(Log(Rnd) * 10, "0.00000") Button 11 Text "Test1" + CRLF + "two lines" Button 12 Text "Test2" Print v1 Wait Seconds 0.01 Next Stop Label Test1 Beep Wait Seconds 1 Return Label Test2 Beep Wait Seconds 1 Return ' ============================================================================= ' Folder Demo Programs\BUTTONS\Direct access with numbers ' File ButtonsWithFormula __ TEST-LABELS.txt ' ============================================================================= ' To set the button number with a formula ' the formula must NOT contain spaces ' This is an exception ! ' normally spaces in the formula are accepted For v1 = 0 To 3 Button v1*16+1 Label "Cell " + (v1+1) Button v1*16+1 Color SandyBrown Button v1*16+2 Label "V elec" Button v1*16+2 Color LightGoldenrodYellow Button v1*16+3 Label "I Elec" Button v1*16+3 Color Ivory Button v1*16+4 Label "Vwire" Button v1*16+5 Label "Iwire" Button v1*16+6 Label "Rwire1" Button v1*16+7 Label "Rwire2" Button v1*16+8 Label "R/R0_" + (v1+1) Button v1*16+9 Label "T1" Button v1*16+10 Label "T2" Button v1*16+11 Label "VPeltier" Button v1*16+12 Label "P IN" Button v1*16+13 Label "P OUT" Button v1*16+14 Label "P OUT Peltier" Next Stop ' ============================================================================= ' Folder Demo Programs\BUTTONS\Direct access with numbers ' File ButtonsWithFormula.txt ' ============================================================================= ' To set the button number with a formula ' the formula must NOT contain spaces ' This is an exception ! ' normally spaces in the formula are accepted For v1 = 0 To 3 Button v1*16+1 Text "Cell " + (v1+1) Button v1*16+1 Color SandyBrown Button v1*16+2 Text "V elec" Button v1*16+3 Text "I Elec" Button v1*16+4 Text "Vwire" Button v1*16+5 Text "Iwire" Button v1*16+6 Text "Rwire1" Button v1*16+7 Text "Rwire2" Button v1*16+8 Text "R/R0_" + (v1+1) Button v1*16+9 Text "T1" Button v1*16+10 Text "T2" Button v1*16+11 Text "VPeltier" Button v1*16+12 Text "P IN" Button v1*16+13 Text "P OUT" Button v1*16+14 Text "P OUT Peltier" Next Stop ' ============================================================================= ' Folder Demo Programs\Chinese Characters ' File ChineseCharacters.txt ' ============================================================================= s1 = "㼡㴧㡬ְ㨤" s2 = "嗨春天" Print s1 + "    " + s2 ' ============================================================================= ' Folder Demo Programs\Chinese Characters ' File ChineseCharacters_2.txt ' ============================================================================= s1 = "汉字测试" Print s1 ' ============================================================================= ' Folder Demo Programs\COM Port ' File Test COM - Commands.txt ' ============================================================================= ' --------------------------------------------------------- ' Run the program and move the cursor over function names ' --------------------------------------------------------- COM Open 1 9600 s1 = COM_Status Print s1 s2 = COM_Received Print s1 s1 = COM_PortNames Print s1 COM WriteString s1 + CRLF COM WriteLine s1 COM DiscardOutBuffer COM DiscardInBuffer COM EnableDTR COM EnableRTS COM DisableDTR COM DisableRTS COM Close ' ============================================================================= ' Folder Demo Programs\COM Port ' File Test COM - RECEIVE TextBox.txt ' ============================================================================= COM Open 13 115200 COM DiscardInBuffer s1 = COM_Status s1 = COM_PortNames Controls OpenTextBox Label loop s2 = COM_Received If s2 <> "" Print s2 + CRLF 'Print Mid(s2, 3, 5) EndIf Wait Seconds 0.001 Goto loop ' ============================================================================= ' Folder Demo Programs\COM Port ' File Test COM - RECEIVE.txt ' ============================================================================= COM Open 13 115200 s1 = COM_Status Label Loop s2 = COM_Received If s2 <> "" Print s2 EndIf Wait Seconds 1e-3 Goto Loop ' ============================================================================= ' Folder Demo Programs\COM Port ' File Test COM - SEND RND.txt ' ============================================================================= COM Open 12 115200 s1 = COM_Status Print s1 Controls OpenTextBox v1 = 1 Label loop v1 = Rnd * 10 s1 = Format(v1, "0.00000000000000") + CRLF COM WriteString s1 Print s1 Wait Seconds 0.001 Goto loop ' ============================================================================= ' Folder Demo Programs\COM Port ' File Test COM DSR and CTS.txt ' ============================================================================= ' ------------------------------------------------------- ' IF DSR and/or CTS are high, then you ear beep sounds ' ------------------------------------------------------- S1 = COM_PortNames COM Open 4 9600 Label Loop If COM_Dsr Beep 400 20 Wait Seconds 0.2 EndIf If COM_Cts Beep 800 20 Wait Seconds 0.2 EndIf Wait Seconds 0.2 Goto Loop ' ============================================================================= ' Folder Demo Programs\COM Port ' File TestCOM_Chars0to255_Receive.txt ' ============================================================================= ' ------------------------------------------ ' You need Com0Com with COM17 and COM18 ' ------------------------------------------ ' To send chars open a Terminal on COM17 ' or start a second Automation.exe ' with SHIFT + DoubleClick ' ------------------------------------------ Controls CloseTextBox COM Open 18 9600 Print COM_Status + CRLF Controls ClearTextBox Controls OpenTextBox ReceiveLoop Stop Label ReceiveLoop ReceiveFromSerial Wait Seconds 0.01 Goto ReceiveLoop Label ReceiveFromSerial String Terminator = Chr(13)+Chr(10) String ReceivedLine String HexLine ReceivedLine = COM_ReceiveUntil(Terminator) If ReceivedLine <> "" HexLine = "" For v1 = 1 To Len(ReceivedLine) HexLine = HexLine + Right("0" + Hex(Asc(Mid(ReceivedLine, v1))), 2) + " " Next Controls ClearTextBox Print HexLine + CRLF EndIf Return ' ============================================================================= ' Folder Demo Programs\COM Port ' File TestCOM_Chars0to255_Send.txt ' ============================================================================= ' ------------------------------------------- ' You need Com0Com with COM17 and COM18 ' ------------------------------------------- ' To receive chars open a Terminal on COM18 ' or start a second Automation.exe ' with SHIFT + DoubleClick ' ------------------------------------------- Controls CloseTextBox COM Open 17 9600 Print COM_Status + CRLF Controls ClearTextBox Controls OpenTextBox Button 1 Label "SendToSerial" Stop Label SendToSerial For v1 = 20 To 255 s1 = Chr(v1) Print Asc(s1) + " " COM WriteString s1 Next 's1 = Chr(1) + Chr(3) + Chr(80)+ Chr(128) + Chr(191) + Chr(255) 's1 = Chr(255) 'Print Asc(s1) 'COM WriteString s1 COM WriteString CRLF Return ' ============================================================================= ' Folder Demo Programs\COM Port ' File Test_ComOpen.txt ' ============================================================================= Numeric ComPort = 32 Numeric Bauds = 9600 COM Open ComPort Bauds Loop Stop Label Loop Print COM_Status ' ----------------------------------------- If COM_Status = "CLOSED" Print "Port " + ComPort + " is closed. Valid ports are: " + COM_PortNames COM Open ComPort Bauds EndIf ' ----------------------------------------- Wait Seconds 0.5 Goto Loop ' ============================================================================= ' Folder Demo Programs\COM Port\Send Receive File via COM ' File Receive File.txt ' ============================================================================= ' ============================================================= ' This example receive all the file with a single buffer ' It could not work if file-length is more then buffer-length ' ============================================================= FileName = "FileReceived.csv" COM Open 13 115200 Gosub ReceiveFileFromCOM Stop Label ReceiveFileFromCOM Variable String FileName Variable String Str1 ' COM DiscardInBuffer ' For v1 = 1 To 9e99 s1 = COM_Received If s1 <> "" If s1 = "{{{FileStartMarker}}}" Wait Seconds 1 Str1 = COM_Received Str1 = Replace(Str1, "{{{CRLF}}}", CRLF) Save DeleteFile FileName Save StringToFile Str1 FileName Exit EndIf EndIf Wait Seconds 0.01 Next Return ' ============================================================================= ' Folder Demo Programs\COM Port\Send Receive File via COM ' File Send File.txt ' ============================================================================= ' ============================================================= ' This example sends all the file with a single buffer ' It could not work if file-length is more then buffer-length ' ============================================================= FileName = "FileToSend.csv" COM Open 12 115200 Gosub SendFileToCOM Stop Label SendFileToCOM Variable String FileName Variable String FileString ' COM DiscardOutBuffer ' Load FileString FileName COM WriteString "{{{FileStartMarker}}}" + CRLF Wait Seconds 0.2 ' FileString = Replace(FileString, CRLF, "{{{CRLF}}}") FileString = Replace(FileString, CR, "{{{CRLF}}}") FileString = Replace(FileString, LF, "{{{CRLF}}}") COM WriteString FileString + CRLF Return ' ============================================================================= ' Folder Demo Programs\COM Port\Send Receive File via COM ' File ShortBuffer - Receive File.txt ' ============================================================================= ' ============================================================ ' This example receives the file line by line ' It works also with short buffers ' ============================================================ FileName = "FileReceived.csv" COM Open 13 115200 Gosub ReceiveFileFromCOM Stop Label ReceiveFileFromCOM Variable String FileName Variable String Str1 ' COM DiscardInBuffer ' Str1 = "" For v1 = 1 To 9e99 s1 = COM_Received If s1 <> "" s1 = Replace(s1, "{{{CRLF}}}", CRLF) Str1 = Str1 + s1 If s1 = "{{{FileEndMarker}}}" Str1 = Replace(Str1, "{{{FileEndMarker}}}", "") Save DeleteFile FileName Save StringToFile Str1 FileName Exit EndIf EndIf Wait Seconds 0.01 Next Return ' ============================================================================= ' Folder Demo Programs\COM Port\Send Receive File via COM ' File ShortBuffer - Send File.txt ' ============================================================================= ' ============================================================ ' This example sends the file line by line ' It works also with short buffers ' ============================================================ FileName = "FileToSend.csv" COM Open 12 115200 Gosub SendFileToCOM Stop Label SendFileToCOM Variable String FileName Variable String FileString ' COM DiscardOutBuffer ' Load FileString FileName v2 = Len(FileString) For v1 = 1 To v2 Step 32 s1 = Mid(FileString, v1, 32) s1 = Replace(s1, CRLF, "{{{CRLF}}}") COM WriteString s1 + CRLF Next Wait Seconds 1 COM WriteString "{{{FileEndMarker}}}" + CRLF Return ' ============================================================================= ' Folder Demo Programs\Debug ' File Test - Beep with Breakpoint.txt ' ============================================================================= ' Test with Debug widow closed or opened ' - RUN FROM CURSOR ' - SINGLE STEP Beep 'Breakpoint v1 = v1 - 1 Beep 'Breakpoint v1 = v1 + 10 ' ============================================================================= ' Folder Demo Programs\Debug ' File Test - Debug RunFromCursor.txt ' ============================================================================= ' ------------------------------------------------- ' Open the Debug window ' Test with Single-Step ' ------------------------------------------------- Label Peppo v1 = v1 + 1 Print v1 If v1 >= 9 Beep v1 = 0 EndIf Goto Peppo Label Pippo v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 Goto Pippo Label Pappo v1 = v1 + 1 Goto Pappo ' ============================================================================= ' Folder Demo Programs\Debug ' File Test - Debug-Breakpoins.txt ' ============================================================================= v1 = Cos(2 * Math_PI) v1 = Rnd ' ------------------------ 'Breakpoint Slot(1) = Slot(1) + 1 v1 = 2 ' ------------------------ 'Breakpoint v1 = 3 v2 = v2 + 1 'Breakpoint ' ------------------------ Beep 'Breakpoint ' ============================================================================= ' Folder Demo Programs\Debug ' File Test - Debug-Watches-Countdown.txt ' ============================================================================= ' ------------------------------------------------- ' Open the Debug window ' Run the program ' See the watches values ' ------------------------------------------------- Slot(1) = 30 Label Loop Slot(1) = Slot(1) - 1 If Slot(1) <= 0 End EndIf Goto Loop ' ============================================================================= ' Folder Demo Programs\Debug ' File Test - Debug-Watches2.txt ' ============================================================================= ' ------------------------------------------------- ' Open the Debug window ' Run the program ' See the watches values ' ------------------------------------------------- v1 = Rnd * 1000 v2 = v1 * 10 v3 = Sqrt(v2) Slot(1) = Sin(v3) ' ============================================================================= ' Folder Demo Programs\Debug ' File Test - END returns to editor.txt ' ============================================================================= Button 1 Text Close all And Return to editor Stop Label Close all And Return to editor Slot 1 = 0 Slot 2 = 0 End ' ============================================================================= ' Folder Demo Programs\Encoders ' File EncoderReader.txt ' ============================================================================= Load Theremino_SlotViewer.exe Load Theremino_VideoPlayer.exe Load Theremino_Hal.exe Label Loop ReadEncoder Print FinalValue Wait Seconds 0.01 Goto Loop ' ========================================================== ' This function read an encoder channel ' The "Multiplier" changes the variation speed ' The "Final Value" is limited from Min to Max ' ========================================================== Variable Numeric EncoderSlot = 1 Variable Numeric OutputSlot = 2 Variable Numeric Multiplier = 15 ' 22.3 or 0.12 are valid too Variable Numeric MaxValue = 1000 Variable Numeric MinValue = 0 Variable Numeric FinalValue ' This could be changed while running Variable Numeric NewValue Variable Numeric OldValue = Infinity Variable Numeric Difference Label ReadEncoder NewValue = Slot(EncoderSlot) If OldValue <> Infinity Difference = NewValue - OldValue EndIf OldValue = NewValue ' If Difference > 32000 Difference = Difference - 65536 EndIf If Difference < -32000 Difference = Difference + 65536 EndIf ' Difference = Difference * Multiplier FinalValue = FinalValue + Difference FinalValue = Limit(FinalValue, MinValue, MaxValue) ' Slot OutputSlot = FinalValue Return ' ============================================================================= ' Folder Demo Programs\EventStop ' File Beep while stopping.txt ' ============================================================================= Button 1 Text EventStop Stop Label EventStop Beep End ' ============================================================================= ' Folder Demo Programs\EventStop ' File Stop and Windows MinSize.txt ' ============================================================================= Button 1 Label EventStop Window MinSize Stop Label EventStop Window Sizable End ' ============================================================================= ' Folder Demo Programs\EventTimer ' File Demo EventTimer 1.txt ' ============================================================================= 'Controls OpenTextBox Gosub Loop Stop Label EventTimer Print "----------------------------------" + CRLF v1 = v1 + 1 Return Beep Label Loop Print Rnd + CRLF v2 = v2 + 1 Wait Seconds 0.001 Goto Loop ' ============================================================================= ' Folder Demo Programs\EventTimer ' File Demo EventTimer 2.txt ' ============================================================================= Controls OpenTextBox Gosub Loop Stop Label EventTimer v1 = v1 + 1 If v1 > 10 v1 = 0 EndIf Print "=================================" + CRLF Return Label Loop v2 = v2 + 1 Print Rnd + CRLF Goto Loop ' ============================================================================= ' Folder Demo Programs\EventTimer ' File Demo EventTimer 3.txt ' ============================================================================= Controls OpenTextBox Button 1 Text Loop Gosub Loop Stop Label Loop Print Rnd + CRLF Wait Seconds 0.01 Goto Loop Label EventTimer If v1 = 0 v1 = 1 Button 1 Color Yellow Else v1 = 0 Button 1 Color Red EndIf v2 = v2 + 1 Print "==================================" + CRLF Return ' ============================================================================= ' Folder Demo Programs\EventTimer ' File Demo EventTimer 4.txt ' ============================================================================= Button 1 Text Loop 'Controls OpenTextBox 'Gosub Loop Stop Label Loop Print Rnd + CRLF Wait Seconds 0.01 If Key("Space") Return EndIf Goto Loop Label EventTimer Gosub EventTimer2 Return Label EventTimer2 If v1 = 0 v1 = 1 Button 1 Color Green9 Else v1 = 0 Button 1 Color Yellow8 EndIf v2 = v2 + 1 Print "=====================================" + CRLF Return ' ============================================================================= ' Folder Demo Programs\EventTimer ' File Demo EventTimer 5.txt ' ============================================================================= Wait Key("space") Beep Wait Not Key("space") Beep Stop Label EventTimer If v1 = 0 v1 = 1 Print Rnd + CRLF Else v1 = 0 Print "=====================================" + CRLF EndIf v2 = v2 + 1 Return ' ============================================================================= ' Folder Demo Programs\EventTimer ' File Demo EventTimer 6.txt ' ============================================================================= Wait Seconds 5 Beep Stop Label EventTimer If v1 = 0 v1 = 1 Print Rnd + CRLF Else v1 = 0 Print "=====================================" + CRLF EndIf v2 = v2 + 1 Return ' ============================================================================= ' Folder Demo Programs\Execution and Scroll ' File Demo - Scroll with three functions.txt ' ============================================================================= Label Loop1 Print "Loop 1" Slot(1) = 1000 Slot(1) = 0 Slot(2) = 1000 Slot(2) = 0 Wait Seconds 1 Gosub sub1 Beep Wait Seconds 1 Slot(3) = 1000 Slot(3) = 0 Slot(4) = 1000 Slot(4) = 0 Goto Loop1 Label sub1 Print "Sub 1" Wait Seconds 1 Gosub sub2 Beep Wait Seconds 1 Return Label Sub2 Print "Sub 2" Wait Seconds 1 Return ' ============================================================================= ' Folder Demo Programs\Execution and Scroll ' File Demo - Scroll.txt ' ============================================================================= ' Try with Scroll enabled and Scroll disabled ' With Speed = 4 the scroll is continue ' With Speed > 4 the scroll is not continue Option Speed 4 ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ Label Loop v1 = v1 + 1 v1 = v1 + 2 v1 = v1 + 3 v1 = v1 + 4 v1 = v1 + 5 v1 = v1 + 6 v1 = v1 + 7 v1 = v1 + 8 v1 = v1 + 9 v1 = v1 + 10 v1 = v1 + 11 v1 = v1 + 12 v1 = v1 + 13 v1 = v1 + 14 v1 = v1 + 15 v1 = v1 + 16 v1 = v1 + 17 v1 = v1 + 18 v1 = v1 + 19 v1 = v1 + 20 v1 = v1 + 21 v1 = v1 + 22 v1 = v1 + 23 v1 = v1 + 24 v1 = v1 + 25 v1 = v1 + 26 v1 = v1 + 27 v1 = v1 + 28 v1 = v1 + 29 v1 = v1 + 30 Goto Loop ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ============================================================================= ' Folder Demo Programs\FastDebug ' File Debug - DecodeXML.txt ' ============================================================================= ' ---------------------------------------------- ' RUN THIS PROGRAM ' AND MOVE THE CURSOR ON THE FUNCTION NAMES ' ---------------------------------------------- Load XML "NotebookTest.xml" XML = FormatXML(XML) Stop Variable String XML XML = DecodeXML(XML, "WinSAT") XML = DecodeXML(XML, "ProgramInfo") XML = DecodeXML(XML, "Version") XML = DecodeXML(XML, "WinSAT") XML = DecodeXML(XML, "SystemEnvironment") XML = DecodeXML(XML, "ExecDateTOD") XML = DecodeXML(XML, "WinSAT") XML = DecodeXML(XML, "Metrics") XML = DecodeXML(XML, "GraphicsMetrics") XML = DecodeXML(XML, "VideoMemBandwidth") ' ============================================================================= ' Folder Demo Programs\FastDebug ' File Debug Info 1.txt ' ============================================================================= ' ------------------------------------------------ ' RUN THIS PROGRAM ' AND MOVE THE MOUSE CURSOR ON THE PROGRAM LINES ' ------------------------------------------------ For v1 = 0 To Infinity For v2 = 10 To 20 Slot 1 = v1 * v2 v9 = v1 + v2 s1 = v1 + Log(v2) If Rnd > 0.5 s9 = "The Beatles" Else s9 = "Rolling Stones" EndIf Next Next ' ============================================================================= ' Folder Demo Programs\FastDebug ' File Debug Info 2.txt ' ============================================================================= ' ------------------------------------------------ ' RUN THIS PROGRAM ' AND MOVE THE MOUSE CURSOR ON THE PROGRAM LINES ' ------------------------------------------------ Variable Numeric Slot_Motor Slot_Motor = 9 Slot Slot_Motor + 1 = 4 Variable String String1 String1 = "The Beatles" Slot 0 = Reset For v1 = 0 To Infinity For v2 = 10 To 20 Slot Slot_Motor = v1 * v2 Next Next Stop ' ----------------------- the following instructions are not executed ' so s1 and the Slot_Motor are not updated s1 = DecodeCommandSlot(0) s1 = Now s1 = Cos(Rnd()) Slot Slot_Motor + 1 = 9 Print Slot(Slot_Motor) Print Slot(Slot_Motor + 1) Slot ( Slot_Motor ) = Abs(Sin(Slot(Slot_Motor))) ' ============================================================================= ' Folder Demo Programs\FastDebug ' File Debug Info 3.txt ' ============================================================================= ' ------------------------------------------------ ' RUN THIS PROGRAM ' AND MOVE THE MOUSE CURSOR ON THE PROGRAM LINES ' ------------------------------------------------ Variable String String1 String1 = "The Beatles" Variable Numeric Slot_Motor Slot_Motor = 3 For v1 = 0 To Infinity For v2 = 10 To 20 Slot Slot_Motor = v1 * v2 Next Next Stop ' ------------------- the following instructions are not executed ' so v1 and s1 are not updated v1 = 1.3e4 s1 = Now s1 = Rnd s1 = Abs(Cos(Rnd() * Math_PI)) v1 = Abs(Sin(Slot(Slot_Motor))) ' ============================================================================= ' Folder Demo Programs\FastDebug ' File Debug Info 4.txt ' ============================================================================= ' ------------------------------------------------ ' RUN THIS PROGRAM ' AND MOVE THE MOUSE CURSOR ON THE PROGRAM LINES ' ------------------------------------------------ ' ------------------- v1 is updated here For v1 = 1 To Infinity Next Stop ' ------------------- the following instructions are not executed ' so v1 and s1 are not updated v1 = 1.3e4 s1 = Now s1 = Rnd s1 = Log(Rnd * 1e3) s1 = Abs(Cos(Rnd() * Math_PI)) s1 = Format(Now, "dd/MMM/yyyy HH:mm:ss") ' ============================================================================= ' Folder Demo Programs\FastDebug ' File _HOW TO USE THE FAST DEBUG.txt ' ============================================================================= ' ================================================ ' TO FAST DEBUG VARIABLES AND VALUES ' ================================================ ' - WHILE RUNNING THE PROGRAM - ' MOVE THE MOUSE CURSOR ON THE PROGRAM LINES ' ================================================ ' - WHILE NOT RUNNING THE PROGRAM - ' OPEN THE DEBUG WINDOW ' MOVE THE MOUSE CURSOR ON THE PROGRAM LINES ' ================================================ Controls OpenTextBox Print Rnd + CRLF Print Format(Now, "dd/MMM/yyyy HH:mm:ss") + CRLF Stop ' ============================================================================= ' Folder Demo Programs\Files ' File DropFiles_Test.txt ' ============================================================================= String DroppedFilename String DroppedString Stop Label Event_DroppedFile Controls OpenTextBox Print DroppedFilename + CRLF + DroppedString Return ' ============================================================================= ' Folder Demo Programs\Files ' File Open Folders.txt ' ============================================================================= Button 1 Text OpenMainFolder1 Button 2 Text OpenMainFolder2 Button 4 Text OpenFilesFolder Button 5 Text OpenMediaFolder Button 7 Text OpenDiskC Button 8 Text OpenWindows Button 9 Text OpenWin32 Stop Label OpenMainFolder1 Load ".\" Return Label OpenMainFolder2 Load "" Return Label OpenFilesFolder Load ".\Files" Return Label OpenMediaFolder Load "Media" Return Label OpenDiskC Load "C:\" Return Label OpenWindows Load "C:\windows" Return Label OpenWin32 Load "C:\windows\system32" Return ' ============================================================================= ' Folder Demo Programs\Files ' File Open Notepad and Apps.txt ' ============================================================================= Button 1 Text OpenNotepad Button 2 Text OpenCalculator Button 3 Text OpenPaint Stop Label OpenNotepad Load "C:\Windows\Notepad.exe" Return Label OpenCalculator Load "C:\Windows\system32\Calc.exe" Return Label OpenPaint Load "C:\Windows\system32\mspaint.exe" Return ' ============================================================================= ' Folder Demo Programs\Files ' File Open Notepad With Files.txt ' ============================================================================= Gosub InitNotepadPaths Button 1 Text OpenNotepad Button 2 Text OpenSequence1 Button 3 Text OpenSequence2 Stop Label InitNotepadPaths Variable String EditorFolder Variable String NotepadApp Variable String EditSequence1 Variable String EditSequence2 EditorFolder = "Theremino_HAL\Theremino_Editor\" NotepadApp = "C:\Windows\Notepad.exe" EditSequence1 = NotepadApp + " " + EditorFolder + "Sequences\CircleTest.seq" EditSequence2 = NotepadApp + " " + EditorFolder + "Sequences\TestSeq.seq" Return Label OpenNotepad Load NotepadApp Return Label OpenSequence1 Load EditSequence1 Return Label OpenSequence2 Load EditSequence2 Return ' ============================================================================= ' Folder Demo Programs\Files ' File SelectAndGetFilesAndFolders.txt ' ============================================================================= Button 1 Text EditSequence Button 2 Text SelectSequence Button 4 Text GetFileNames Button 5 Text GetFolderNames Button 6 Text GetTextFile Button 8 Text ApplicationPath Button 9 Text FilePath Button 10 Text FileName Variable String SequenceName SequenceName = "TestSeq.seq" Gosub ShowSequenceName Controls OpenTextBox Controls ClearTextBox Stop ' ' ===================================================================== ' SEQUENCES ' ===================================================================== Label InitSequencePaths Variable String EditorFolder Variable String EditorApp Variable String SequencePathAndName ' EditorFolder = ".\Theremino_HAL\Theremino_Editor\" ' EditorApp = EditorFolder + "Theremino_Editor.exe" ' SequencePathAndName = EditorFolder + "Sequences\" + SequenceName Return Label EditSequence Gosub InitSequencePaths If FileExists(SequencePathAndName) Load EditorApp + " " + SequencePathAndName EndIf Return Label SelectSequence Gosub InitSequencePaths s1 = SelectFile(EditorFolder + "Sequences\") If s1 <> "" SequenceName = s1 Gosub ShowSequenceName EndIf Return Label ShowSequenceName Button SelectSequence Text "Sequence" + CRLF + SequenceName Return ' ===================================================================== ' GetFileNames GetFolderNames GetTextFile ' ===================================================================== Label GetFileNames Gosub InitSequencePaths s1 = GetFileNames(EditorFolder + "Sequences\") Print s1 + CRLF Return Label GetFolderNames Gosub InitSequencePaths s1 = GetFolderNames(EditorFolder) Print s1 + CRLF Return Label GetTextFile Gosub InitSequencePaths s1 = GetTextFile(SequencePathAndName) Print s1 + CRLF Return ' ===================================================================== ' GetApplicationPath GetFilePath GetFileNameWithoutPath ' ===================================================================== Label ApplicationPath s1 = GetApplicationPath() Print s1 + CRLF Return Label FilePath Gosub InitSequencePaths s1 = GetFilePath(SequencePathAndName) Print s1 + CRLF Return Label FileName Gosub InitSequencePaths s1 = GetFileNameWithoutPath(SequencePathAndName) Print s1 + CRLF Return ' ============================================================================= ' Folder Demo Programs\Files ' File WriteFile_ReadFile_SelectFile.txt ' ============================================================================= Button 1 Label Open_Folder Button 3 Label Write_File Button 4 Label Write_File_ASCII Button 6 Label Read_File Button 7 Label Select_File ' -------------------------------------- ' WARNING - THE FOLDER MUST EXIST ! ' -------------------------------------- Variable String FolderName = "C:\Temp\" Variable String FilePathAndName = FolderName + "ExampleFile.txt" Controls OpenTextBox Controls ClearTextBox Stop Label Open_Folder Load FolderName Return Label Write_File Controls ClearTextBox Save DeleteFile FilePathAndName For v1 = 1 To 5 s1 = Now s1 = s1 + " " s1 = s1 + " Random number = " s1 = s1 + Format(Rnd * 100, "0") Print s1 + CRLF Save StringToFile s1 FilePathAndName Next Return Label Write_File_ASCII Controls ClearTextBox Save DeleteFile FilePathAndName For v1 = 1 To 5 s1 = Now s1 = s1 + " " s1 = s1 + " Random number = " s1 = s1 + Format(Rnd * 100, "0") Print s1 + CRLF s1 = ""+ s1 Save StringToFile s1 FilePathAndName Next Return Label Read_File Controls ClearTextBox s1 = GetTextFile(FilePathAndName) Print s1 Return Label Select_File Controls ClearTextBox s1 = SelectFile(FolderName) Print s1 Return ' ============================================================================= ' Folder Demo Programs\Files ' File WriteToFile.txt ' ============================================================================= Button 1 Label Open_Folder Button 3 Label Write_File Button 4 Label Read_File Button 7 Label Select_File Button 9 Label Test_CmdExe ' -------------------------------------- WARNING - THE PATH MUST EXIST ! Variable String FolderName = "C:\Temp\" Variable String FilePathAndName = FolderName + "ExampleFile.txt" Controls OpenTextBox Controls ClearTextBox Stop Label Open_Folder Load FolderName Return Label Write_File Controls ClearTextBox Save DeleteFile FilePathAndName For v1 = 1 To 100 s1 = Now s1 = s1 + " " s1 = s1 + " Random number = " s1 = s1 + Format(Rnd * 100, "0") Print s1 + CRLF Save StringToFile s1 FilePathAndName Next Return Label Read_File Controls ClearTextBox s1 = GetTextFile(FilePathAndName) Print s1 Return Label Select_File Controls ClearTextBox Print SelectFile(FolderName) Return Label Test_CmdExe Load "C:\Windows\System32\Cmd.Exe" Wait Seconds 0.1 SendKeys "systeminfo{ENTER}" Return ' ============================================================================= ' Folder Demo Programs\Filters ' File Filters - Test and Example.txt ' ============================================================================= ' ============================================================= ' Filters test ' ============================================================= Label loop v1 = Slot(1) 'v2 = FilterHP(v1, 1, 99) 'v2 = FilterLP(v1, 1, 99) v3 = FilterLP(v1, 1, 1) Slot 2 = v2 Slot 3 = v3 Goto loop ' ============================================================= ' CURRENT METER ' This example demonstrates that you can use the variable mA ' for the input of the filter and for the output too ' ============================================================= Label CurrentMeter Variable Numeric mA mA = Slot(108) + Slot(208) + Slot (308) mA = mA * 6.5 mA = FilterLP(mA, 0.5, 1) 'Button CurrentMeter Text Str(mA, "0 mA") Slot 999 = mA Return ' ============================================================================= ' Folder Demo Programs\FOR NEXT ' File Demo - Changing value inside.txt ' ============================================================================= For v1 = 1 To 1000 Print v1 If v1 = 500 Beep v1 = 2000 Wait Seconds 1 EndIf If v1 = 1500 Beep v1 = -1000 Wait Seconds 1 EndIf Next Stop ' ============================================================================= ' Folder Demo Programs\FOR NEXT ' File Demo - Errors when same value.txt ' ============================================================================= Controls ClearTextBox Controls OpenTextBox For v1 = 1 To Infinity For v2 = 2 To 2 Print v1 + " " v2 = 99 Next Next Stop ' ============================================================================= ' Folder Demo Programs\FOR NEXT ' File Demo - ForNext Nested 1.txt ' ============================================================================= Option Speed 4 For v1 = 8 To 5 For v2 = 1 To 4 For v3 = 9 To 6 Print v1 + " " + v2+ " " + v3 Next Next Next ' ============================================================================= ' Folder Demo Programs\FOR NEXT ' File Demo - ForNext Nested 2.txt ' ============================================================================= For v1 = 8 To 5 For v2 = 1 To 4 For v3 = 9 To 6 Print v1 + " " + v2+ " " + v3 Slot 1 = v1 Slot 2 = v2 Slot 3 = v3 Wait Seconds 0.05 Next Next Next ' ============================================================================= ' Folder Demo Programs\FOR NEXT ' File Demo - ForNext Nested 3.txt ' ============================================================================= Label ExitForNext 'Beep For v1 = 8 To 5 For v2 = 1 To 4 For v3 = 9 To 6 Print v1 + " " + v2+ " " + v3 Next Goto ExitForNext Next Next ' ============================================================================= ' Folder Demo Programs\FOR NEXT ' File Demo - ForNext Nested 4.txt ' ============================================================================= Label loop For v1 = 8 To 5 For v2 = 1 To 4 For v3 = 9 To 6 Gosub Sub1 Next Gosub Sub1 Next Gosub Sub1 Next Goto loop Label Sub1 Print v1 + " " + v2+ " " + v3 Return ' ============================================================================= ' Folder Demo Programs\FOR NEXT ' File Demo - Infinite ForNext 1.txt ' ============================================================================= ' ------------------------------------------- ' INFINITE FOR NEXT ' This demo shows: ' - How to create infinite loops ' - How to exit from the FOR loop ' ------------------------------------------- ' Press SPACE to exit from the FOR LOOP For v1 = 1 To Infinity If Key("SPACE") v1 = Infinity EndIf Print v1 Wait Seconds 0.01 Next Stop ' ------------------------------------------- ' You could also exit with the Exit keyword ' as shown in the next example ' ------------------------------------------- For v1 = 1 To Infinity If Key("SPACE") Exit EndIf Print v1 Wait Seconds 0.01 Next ' ============================================================================= ' Folder Demo Programs\FOR NEXT ' File Demo ForNext 1.txt ' ============================================================================= Option Speed 4 For v1 = 50 To 40 Step -0.5 Print v1 Next For v1 = 10 To 20 Step 0.6 Print v1 Next ' ============================================================================= ' Folder Demo Programs\FOR NEXT ' File Demo ForNext 2.txt ' ============================================================================= ' Theremino Automation demo program ' Demonstrating the FOR-NEXT statements Variable Numeric nn1 Variable Numeric nn2 Variable Numeric nn3 nn2 = 11 nn3 = 13 v2 = 8 v3 = 6 For v1 = v2 To v3 For nn1 = nn2 To nn3 Beep Wait Seconds 0.05 Next Next For nn1 = v3+100 To "v2 + 100 + int(rnd * 8)" Beep Wait Seconds 0.05 If nn1 = 25 Exit EndIf Next Stop ' ============================================================================= ' Folder Demo Programs\FOR NEXT ' File Demo ForNext 3.txt ' ============================================================================= For v1 = 23 To 440 Beep 2000 10 Wait Seconds 0.1 Print "....0000" Next ' ============================================================================= ' Folder Demo Programs\FOR NEXT ' File Demo ForNext 4.txt ' ============================================================================= Option Speed 4 Label loop For v2 = 1 To 4 Slot(1) = v1 Slot(2) = v2 Wait Seconds 0.1 Next Beep Goto loop ' ============================================================================= ' Folder Demo Programs\FOR NEXT ' File Demo ForNext Nested with EXIT.txt ' ============================================================================= Option Speed 5 For v1 = 0 To 1000 If v1 >= 10 Exit EndIf For v2 = 0 To 1000 Print v1 + " " + v2 If v2 >= 5 Exit EndIf Next Next Print v1 + " " + v2 Beep Stop ' ============================================================================= ' Folder Demo Programs\FOR NEXT ' File Demo ForNext with EXIT 2 and 3.txt ' ============================================================================= Option Speed 9 For v1 = 1 To 1000 For v2 = 1 To 1000 If v1 > 10 Exit 2 EndIf Print v1 + " " + v2 Next Next Beep For v1 = 1 To 1000 For v2 = 1 To 100 For v3 = 1 To 10 If v1 > 10 Exit 3 EndIf Next Print v1 + " " + v2 + " " + v3 Next Next Beep Stop ' ============================================================================= ' Folder Demo Programs\FOR NEXT ' File Demo ForNext with EXIT.txt ' ============================================================================= Option Speed 9 For v1 = 0 To 1000 If v1 >= 10 Exit EndIf Next Print v1 Beep Stop ' ============================================================================= ' Folder Demo Programs\FOR NEXT ' File Demo ForNext with STEP.txt ' ============================================================================= ' Theremino Automation demo program ' Demonstrating For Next with STEP For v1 = 1 To 1.00000000001 Step 0.000000000000001 Print v1 Next Stop ' ============================================================================= ' Folder Demo Programs\FOR NEXT ' File Demo ForNext.txt ' ============================================================================= ' Theremino Automation demo program ' Demonstrating For Next v1 = 1 v2 = 5 v3 = 15 For v1 = v2 To v3 For v2 = v1 To v2 Beep Next Next For v1 = v2 To v3 Next Stop ' ============================================================================= ' Folder Demo Programs\FOR NEXT ' File Demo Nested ForNext with EXIT.txt ' ============================================================================= For v1 = 0 To 1000 If v1 >= 10 Exit EndIf For v2 = 0 To 1000 If v2 >= 10 Exit EndIf Next Next Print v1 + " " + v2 Beep Stop ' ============================================================================= ' Folder Demo Programs\FOR NEXT ' File Test - FOR without NEXT.txt ' ============================================================================= ' Theremino Automation demo program ' Test for error ' A FOR without NEXT must be RED For v1 = 1 To 3 For v2 = 1 To 10 Print v1 + " " + v2 Next Nex ' ============================================================================= ' Folder Demo Programs\Function Parameters ' File Calls Without Parameters.txt ' ============================================================================= Gosub FunctionWithParameters Gosub FunctionWithParameters(3)("bau") 'FunctionWithParameters 'FunctionWithParameters(3)("bau")("Miao") Stop Label FunctionWithParameters Variable Numeric FWP1 Variable String FWP2 Variable String FWP3 Print FWP1 + " " + FWP2 + " " + FWP3 Return ' ============================================================================= ' Folder Demo Programs\Function Parameters ' File Function_Parameters_1.txt ' ============================================================================= Button 1 Label Test1 Button 2 Label Test2 Button 3 Label Test3 Button 5 Label Test5 Stop Label FunctionWithStrings Variable String F2a Variable String F2b Variable String F2c Print F2a + " " + F2b + " " + F2c Return Label Function2 Variable Numeric F3a Variable Numeric F3b Variable Numeric F3c Print F3a + " " + F3b + " " + F3c Return Label Test1 Gosub FunctionWithStrings("Dog")(Rnd)(Now) Return Label Test2 FunctionWithStrings("SomeText")(Rnd)(Now) Return Label Test3 Function2("SomeText")(Rnd)(Now) Return Label Test5 ' working also with SPACES and TABS FunctionWithStrings ("SomeText") (Now) (Rnd) Return ' ============================================================================= ' Folder Demo Programs\Function Parameters ' File Parameter With Errors.txt ' ============================================================================= FunctionWithParameters(Number1 * 3)(String1 + "bau") FunctionWithParameters(Number2 * 3)(String1 + "bau") FunctionWithParameters(Number2 * 3)(String2 + "bau") Variable Numeric Number1 = 33 Variable String String1 = "77" Stop Label FunctionWithParameters Variable Numeric FWP1 Variable String FWP2 Variable String FWP3 Print FWP1 + " " + FWP2 + " " + FWP3 Return ' ============================================================================= ' Folder Demo Programs\Function Parameters ' File Parameter With Errors2.txt ' ============================================================================= FunctionWithParameters '(Rnd (Now 'FunctionWithParameters (Rnd)(Now)(Rnd) FunctionWithParameters (Rnd)(RRR)(Rnd) 'FunctionWithParameters(Rnd) FunctionWithParameters Stop Label FunctionWithParameters Variable Numeric FWP1 Variable String FWP2 Variable String FWP3 Print FWP1 + " " + FWP2 + " " + FWP3 Return ' ============================================================================= ' Folder Demo Programs\Function Parameters ' File Parameter With Errors3.txt ' ============================================================================= Gosub FunctionWithStrings(Dog)(Rnd)(Now) FunctionWithStrings(Dog)(Rnd)(Now) Gosub Function2(Dog)(Rnd)(Now) Function2(Dog)(Rnd)(Now) FunctionWithStrings("Dog")(Rnd)(Now) Function2("Dog")(Rnd)(Now) Stop Label FunctionWithStrings Variable String F2a Variable String F2b Variable String F2c Print F2a + " " + F2b + " " + F2c Return Label Function2 Variable Numeric F3a Variable Numeric F3b Variable Numeric F3c Print F3a + " " + F3b + " " + F3c Return ' ============================================================================= ' Folder Demo Programs\Function Parameters ' File Test_PARAMETERS_1.txt ' ============================================================================= SpeakMultiple1(1)("22")("33") SpeakMultiple2(2)("22")("33") SpeakMultiple3(3)("22")("33") Stop ' --------------------------- Using the prefix "Variable" Label SpeakMultiple1 Variable Numeric SM11 Variable String SM12 Variable String SM13 TTS SpeakWait SM11 TTS SpeakWait SM12 TTS SpeakWait SM13 Return ' --------------------------- Not using the prefix "Variable" Label SpeakMultiple2 Numeric SM21 String SM22 String SM23 TTS SpeakWait SM21 TTS SpeakWait SM22 TTS SpeakWait SM23 Return ' --------------------------- Not using/using the prefix "Variable" Label SpeakMultiple3 Numeric SM31 Variable String SM32 String SM33 TTS SpeakWait SM31 TTS SpeakWait SM32 TTS SpeakWait SM33 Return ' ============================================================================= ' Folder Demo Programs\Function Parameters ' File Test_PARAMETERS_2.txt ' ============================================================================= Gosub FunctionWithParameters Gosub FunctionWithParameters(3)("bau") 'FunctionWithParameters 'FunctionWithParameters(3)("bau")("Miao") Stop Label FunctionWithParameters Variable Numeric FWP1 Variable String FWP2 Variable String FWP3 Print FWP1 + " " + FWP2 + " " + FWP3 Return ' ============================================================================= ' Folder Demo Programs\Functions and Errors ' File Error messages.txt ' ============================================================================= ' ----------------------------------- ERRORS v99 = 4 v1 = 3 + 4) * 3 v1 = 3 + & 5 v1 = 3 + Sin(tan) - 5 v1 = (3 > 2) And 4 v1 = 255 And 2 = 3 v1 = 255 Or 2 = 3 v1 = 255 Xor 2 = 3 ' ----------------------------------- OK v1 = 3 And 2 v2 = 3 Or 11 v3 = 3 Xor 11 v4 = 255 Xor 4 Print v1 & " " & v2 & " " & v3 & " " & v4 ' ============================================================================= ' Folder Demo Programs\Functions and Errors ' File Functions.txt ' ============================================================================= Button 1 Text Asc Chr Button 2 Text Bin FromBin Button 3 Text Hex FromHex Button 4 Text Empty string producing zero values Stop Label Asc Chr v1 = Asc("A") v2 = Asc("abcd") v3 = Asc(Chr(255)) v4 = Asc(Chr(65535)) Print v1 & " " & v2 & " " & v3 & " " & v4 Stop Label Bin FromBin s1 = Bin(255) v2 = FromBin("10101010") v3 = FromBin(Bin(255)) v4 = FromBin(Bin(65535)) Print s1 & " " & v2 & " " & v3 & " " & v4 Stop Label Hex FromHex s1 = Hex(255) v2 = FromHex("FF") v3 = FromHex(Hex(255)) v4 = FromHex(Hex(65535)) Print s1 & " " & v2 & " " & v3 & " " & v4 Stop Label Empty string producing zero values s1 = "" v1 = Asc(s1) v2 = FromBin(s1) v3 = FromHex(s1) Print v1 & " " & v2 & " " & v3 Stop ' ============================================================================= ' Folder Demo Programs\Functions and Errors ' File Strings and Numbers.txt ' ============================================================================= Variable Numeric Num1 ' When assigning a string to a numerical variable ' an implicit conversion is performed Num1 = "9.11" v1 = "9.11" ' But in a formula you must use the "Val" function Num1 = Val("9.11") * 1.2 v1 = 1.2 * Val("9.11") Stop ' ============================================================================= ' Folder Demo Programs\Get Files and Folders ' File GetFilesAndFolders.txt ' ============================================================================= Button 1 Text EditSequence Button 2 Text SelectSequence Button 4 Text GetFileNames Button 5 Text GetFolderNames Button 6 Text GetTextFile Button 8 Text ApplicationPath Button 9 Text FilePath Button 10 Text FileName Variable String SequenceName SequenceName = "TestSeq.seq" Gosub ShowSequenceName Controls OpenTextBox Controls ClearTextBox Stop ' ' ===================================================================== ' SEQUENCES ' ===================================================================== Label InitSequencePaths Variable String EditorFolder Variable String EditorApp Variable String SequencePathAndName ' EditorFolder = ".\Theremino_HAL\Theremino_Editor\" ' EditorApp = EditorFolder + "Theremino_Editor.exe" ' SequencePathAndName = EditorFolder + "Sequences\" + SequenceName Return Label EditSequence Gosub InitSequencePaths If FileExists(SequencePathAndName) Load EditorApp + " " + SequencePathAndName EndIf Return Label SelectSequence Gosub InitSequencePaths s1 = SelectFile(EditorFolder + "Sequences\") If s1 <> "" SequenceName = s1 Gosub ShowSequenceName EndIf Return Label ShowSequenceName Button SelectSequence Text "Sequence" + CRLF + SequenceName Return ' ===================================================================== ' GetFileNames GetFolderNames GetTextFile ' ===================================================================== Label GetFileNames Gosub InitSequencePaths s1 = GetFileNames(EditorFolder + "Sequences\") Print s1 + CRLF Return Label GetFolderNames Gosub InitSequencePaths s1 = GetFolderNames(EditorFolder) Print s1 + CRLF Return Label GetTextFile Gosub InitSequencePaths s1 = GetTextFile(SequencePathAndName) Print s1 + CRLF Return ' ===================================================================== ' GetApplicationPath GetFilePath GetFileNameWithoutPath ' ===================================================================== Label ApplicationPath s1 = GetApplicationPath() Print s1 + CRLF Return Label FilePath Gosub InitSequencePaths s1 = GetFilePath(SequencePathAndName) Print s1 + CRLF Return Label FileName Gosub InitSequencePaths s1 = GetFileNameWithoutPath(SequencePathAndName) Print s1 + CRLF Return ' ============================================================================= ' Folder Demo Programs\Get Files and Folders ' File OpenWithNotepad.txt ' ============================================================================= Button 1 Text EditFile Stop ' Label EditFile Load "Notepad" '+ " " Return ' ============================================================================= ' Folder Demo Programs\GetColors ' File Demo_GetColorsFromScreen.txt ' ============================================================================= v1 = GetCursorPixelColor s1 = "Red=" + GetColorRed(v1) + " " s1 = s1 + "Green=" + GetColorGreen(v1) + " " s1 = s1 + "Blue=" + GetColorBlue(v1) + " " s1 = s1 + "Hue=" + GetColorHue(v1) + " " s1 = s1 + "Saturation=" + GetColorSaturation(v1) + " " s1 = s1 + "Lightness=" + GetColorLightness(v1) s1 = s1 + CRLF s1 = s1 + "ColorIndex(0..8)=" + GetColorIndex(v1) + " " s1 = s1 + "SimpleColorName=" + GetSimpleColorName(v1) + " " s1 = s1 + "NearestColorName=" + GetNearestColorName(v1) Print s1 ' ============================================================================= ' Folder Demo Programs\GetColors ' File Demo_GetCursorColor and PixelColor.txt ' ============================================================================= s1 = GetCursorPixelColor + " " + GetPixelColor(MouseXP, MouseYP) s1 = s1 + CRLF s1 = s1 + Hex(GetCursorPixelColor) + " " + Hex(GetPixelColor(MouseXP, MouseYP)) Print s1 ' ============================================================================= ' Folder Demo Programs\GOSUB and RETURN ' File Demo-Gosub by BUTTONS.txt ' ============================================================================= ' Theremino Automation demo program ' Demonstrating GoSub by button events and Return to the following line Button 1 Text Sub1 Button 2 Text Sub2 Label Loop1 Print "1" Print " 2" Print " 3" Goto Loop1 Label Sub1 Beep Wait Seconds 0.5 Return Label Sub2 Beep Wait Seconds 0.5 Return ' ============================================================================= ' Folder Demo Programs\GOSUB and RETURN ' File Demo-GOSUB RETURN.txt ' ============================================================================= ' Theremino Automation demo program ' Demonstrating nested GoSub and Return Label Loop1 Print "Loop 1" Slot(1) = 1000 Slot(1) = 0 Slot(2) = 1000 Slot(2) = 0 Wait Seconds 1 Gosub sub1 Beep Wait Seconds 1 Slot(3) = 1000 Slot(3) = 0 Slot(4) = 1000 Slot(4) = 0 Goto Loop1 Label sub1 Print "Sub 1" Wait Seconds 1 Gosub Sub2 Beep Wait Seconds 1 Return Label Sub2 Print "Sub 2" Wait Seconds 1 Return ' ============================================================================= ' Folder Demo Programs\Graphic Chars ' File BoxExamples.txt ' ============================================================================= ' ╔════════════════════════╗ ' ║ GRAPHIC BOX EXAMPLES ║ ' ╚════════════════════════╝ ' Single line ' ┌─────────────────────────────────────────────┐ ' │ │ ' │ │ ' │ │ ' │ │ ' │ │ ' │ │ ' └─────────────────────────────────────────────┘ ' Split lines ' ┌─────────────────────────────────────────────┐ ' │ │ ' │ │ ' ├─────────────────────────────────────────────┤ ' │ │ ' ├─────────────────────────────────────────────┤ ' │ │ ' └─────────────────────────────────────────────┘ ' Double lines ' ╔═════════════════════════════════════════════╗ ' ║ ║ ' ║ ║ ' ║ ║ ' ║ ║ ' ║ ║ ' ║ ║ ' ╚═════════════════════════════════════════════╝ ' Split lines single and double ' ╔═════════════════════════════════════════════╗ ' ║ ║ ' ║ ║ ' ╟─────────────────────────────────────────────╢ ' ║ ║ ' ╠═════════════════════════════════════════════╣ ' ║ ║ ' ╚═════════════════════════════════════════════╝ ' Black border ' █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█ ' █ █ ' █ █ ' █ █ ' █ █ ' █ █ ' █ █ ' █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█ ' Black border with split lines ' █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█ ' █ █ ' █■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■█ ' █ █ ' █▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂█ ' █ █ ' █▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂█ ' █ █ ' █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█ ' Gray scales ' ╔═════════════════════════════════════════════╗ ' ║ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ ║ ' ║ ░░░░░ ░░░░░ ║ ' ║ ▓▓▓▓▓ ▓▓▓▓▓ ║ ' ║ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ║ ' ║ █████ █████ ║ ' ║ █████ █████ ║ ' ║ ███████████████████████████████████████████ ║ ' ╚═════════════════════════════════════════════╝ ' ============================================================================= ' Folder Demo Programs\Graphic Chars ' File GraphicChars.txt ' ============================================================================= ' Fonts supporting all the graphic chars: ' - DejaVu Sans Mono ' - Fira Mono ' Fonts supporting some graphic chars only: ' - Cousine ' - Cascadia ' - Courier New ' - Lucida Console ' ╔════════════════════════╗ ' ║ GRAPHIC CHARS ║ ' ╚════════════════════════╝ ' ▼ ▲ ▼ ◀ ▶ ◢ ◣ ◥ ◤ △ ▽ ◿ ◺ ◹ ◸ ' ▴ ▾ ◂ ▸ ▵ ▿ ◃ ▹ ◁ ▷ ◅ ▻ ◬ ⟁ ⧋ ⧊ ⊿ ∆ ∇ ◭ ◮ ⧩ ⧨ ' ⌔ ⟐ ◇ ◆ ◈ ⬖ ⬗ ⬘ ⬙ ⬠ ⬡ ⎔ ⋄ ◊ ⧫ ⬢ ⬣ ' ▰ ▪ ◼ ▮ ◾ ▗ ▖ ■ ∎ ▃ ▄ ▅ ▆ ▇ █ ▌ ▐ ▍ ▎ ▉ ▊ ▋ ' ❘ ❙ ❚ ▀ ▘ ▝ ▙ ▚ ▛ ▜ ▟ ▞ ░ ▒ ▓ ▂ ▁ ▬ ▔ ' ▫ ▯ ▭ ▱ ◽ □ ◻ ▢ ⊞ ⊡ ⊟ ⊠ ▣ ▤ ▥ ▦ ⬚ ▧ ▨ ▩ ' ⬓ ◧ ⬒ ◨ ◩ ◪ ⬔ ⬕ ❏ ❐ ❑ ❒ ⧈ ◰ ◱ ◳ ◲ ◫ ⧇ ⧅ ⧄ ⍁ ⍂ ' ○ ◌ ◍ ◎ ◯ ❍ ◉ ⦾ ⊙ ⦿ ⊜ ⊖ ⊘ ⊚ ⊛ ⊝ ' ◜ ◝ ◞ ◟ ◠ ◡ ⋒ ⋓ ⋐ ⋑ ⥰ ╰ ╮ ╭ ╯ ⌒ ' ⥿ ⥾ ⥽ ⥼ ⥊ ⥋ ⥌ ⥍ ⥎ ⥐ ⥑ ⥏ ╳ ✕ ⤫ ⤬ ╱ ╲ ⧸ ⧹ ' ─ ━ ┄ ┅ ┈ ┉ ╌ ╍ ═ ≣ ≡ ☰ ☱ ☲ ☳ ☴ ☵ ☶ ☷ ' ⌞ ⌟ ⌜ ⌝ ⌊ ⌋ ⌈ ⌉ ⌋ ┌ ┍ ┎ ┏ ┐ ┑ ┒ ┓ ' └ ┕ ┖ ┗ ┘ ┙ ┚ ┛ ├ ┝ ┞ ┟ ┠ ┡ ┢ ┣ ┤ ' ┥ ┦ ┧ ┨ ┩ ┪ ┫ ┬ ┭ ┮ ┳ ┴ ┵ ┶ ┷ ┸ ┹ ┺ ┻ ' ┼ ┽ ┾ ┿ ╀ ╁ ╂ ╃ ╄ ╅ ╆ ╇ ╈ ╉ ╊ ╋ ╏ ' ║ ╔ ╒ ╓ ╕ ╖ ╗ ╚ ╘ ╙ ╛ ╜ ╝ ╞ ╟ ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ ' ● ⚫ ⦁ ◐ ◑ ◒ ◓ ◔ ◕ ⦶ ⦸ ◵ ◴ ◶ ◷ ⊕ ⊗ ⦇ ⦈ ⦉ ⦊ ◘ ◙ ' ⌓ ◦ ❖ ✖ ✚ ✜ ⧓ ⧗ ⧑ ⧒ ⧖ ' _ ⚊ ╴ ╼ ╾ ‐ ⁃ ‑ ‒ - - ⎯ - ― ╶ ╺ ╸ '╵ ╷ ╹ ╻ │ ▕ ▏ ┃ ┆ ┇ ┊ ╎ ┋ ╿ ╽ ' ============================================================================= ' Folder Demo Programs\Graphic Chars ' File GraphicChars_WebPages.txt ' ============================================================================= ' Fonts supporting all the graphic chars: ' - DejaVu Sans Mono ' - Fira Mono ' Fonts supporting some graphic chars only: ' - Courier New ' - Cousine ' - Lucida Console ' ---------------------------------------------------- ' Graphic chars from web pages ' ---------------------------------------------------- Button 1 Text GraphicChars1 Button 2 Text GraphicChars2 Stop Label GraphicChars1 Load https://bulletpointsymbol.com/alt-codes.html Return Label GraphicChars2 Load https://copypastecharacter.com/graphic-shapes Return ' ============================================================================= ' Folder Demo Programs\Graphic Chars ' File MixedChineseChars.txt ' ============================================================================= ' ╔════════════════════════════════════╗ ' ║ TEST 1 ║ ' ╚════════════════════════════════════╝ ' █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█ ' █ TEST 2 █ ' █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█ ' ╔════════════════════════════════════╗ ██▀██ ' ║ TEST 3 ║ ██ ██ ' ╚════════════════════════════════════╝ ██▄██ ' 灿踩灿踩灿踩 AFTER THESE CHINESE CHARS THE BOXES ARE OK ? ' ╔════════════════════════════════════╗ ' ║ TEST 1 ║ ' ╚════════════════════════════════════╝ ' █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█ ' █ TEST 2 █ ' █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█ ' ╔════════════════════════════════════╗ ██▀██ ' ║ TEST 3 ║ ██ ██ ' ╚════════════════════════════════════╝ ██▄██ ' ============================================================================= ' Folder Demo Programs\Graphic Chars ' File Open CharMap.txt ' ============================================================================= Load c:\Windows\system32\charmap.exe Stop ' ============================================================================= ' Folder Demo Programs\Hilight Running Lines ' File Buttons with colors 8-8.txt ' ============================================================================= Button 1 Text "B1" Button 2 Text "B2" Button 3 Text "B3" Button 4 Text "B4" Button 5 Text "B5" Button 6 Text "B6" Button 7 Text "B7" Button 8 Text "B8" ' Button 17 Text "B17" Button 18 Text "B18" Button 19 Text "B19" Button 20 Text "B20" Button 21 Text "B21" Button 22 Text "B22" Button 23 Text "B23" Button 24 Text "B24" ' Button B1 Color Flashing Yellow9 Red7 Button B2 Color Honeydew Button B3 Color Yellow Button B4 Color Cyan Button B5 Color YellowGreen Button B6 Color LightPink Button B7 Color Orange Button B8 Color LightGray Button B17 Color Lavender Button B18 Color LavenderBlush Button B19 Color LawnGreen Button B20 Color LemonChiffon Button B21 Color LightBlue Button B22 Color LightCoral Button B23 Color LightCyan Button B24 Color LightGoldenrodYellow Stop ' ============================================================================= ' Folder Demo Programs\Hilight Running Lines ' File Demo-WaitButton.txt ' ============================================================================= ' Theremino Automation demo program ' Demonstrating "Partial button names" and "Wait Button" Button 1 Text "sTrAnGe nAmE" Button 2 Text "five" Label Start ' Wait Button Strange Slot(1) = 1000 Slot(1) = 0 ' Wait Button Five Slot(2) = 1000 Slot(2) = 0 ' Goto Start ' ============================================================================= ' Folder Demo Programs\Hilight Running Lines ' File Enable Disable Buttons.txt ' ============================================================================= Button 1 Text "Button1" Button Button1 Color Blue9 Button 2 Text "Button2" Button Button2 Color SlateGray Button 3 Text "Button3" Button Button3 Color IndianRed Button 4 Text "Button4" Button Button4 Color IndianRed Button 7 Text EnableButtons Button EnableButtons Color Tan Button 8 Text DisableButtons Button DisableButtons Text "Disable Buttons" Button DisableButtons Color Tan Gosub DisableButtons Stop ' ===================================================================== ' ENABLE/DISABLE BUTTONS ' ===================================================================== Label EnableButtons For v1 = 1 To 4 Button v1 Enabled Next Return Label DisableButtons For v1 = 1 To 4 Button v1 Disabled Next Return Label Button1 Beep Return Label Button2 Beep Return Label Button3 Beep Return Label Button4 Beep Return ' ============================================================================= ' Folder Demo Programs\Hilight Running Lines ' File REDON Not Hilighted in running.txt ' ============================================================================= Button 1 Text RedOn Button RedOn Color Red Button 2 Text GreenOn Button GreenOn Color Green Button 3 Text YellowOn Button YellowOn Color Yellow Stop Variable Numeric Slot_LedR Variable Numeric Slot_LedG Variable Numeric Slot_LedB ' ==================================================================== ' LED COLORS ' ==================================================================== Label RedOn Slot(Slot_LedR) = 1000 Slot(Slot_LedG) = 0 Slot(Slot_LedB) = 0 Return Label GreenOn Slot(Slot_LedR) = 0 Slot(Slot_LedG) = 1000 Slot(Slot_LedB) = 0 Return Label YellowOn Slot(Slot_LedR) = 600 Slot(Slot_LedG) = 400 Slot(Slot_LedB) = 0 Return ' ============================================================================= ' Folder Demo Programs\Hilight Running Lines ' File Test CPU CHARGE 1.txt ' ============================================================================= ' Try with Scroll enabled and Scroll disabled ' With Speed = 4 the scroll is continue ' With Speed > 4 the scroll is not continue Option Speed 4 ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ Label Loop v1 = v1 + 1 v1 = v1 + 2 v1 = v1 + 3 v1 = v1 + 4 v1 = v1 + 5 v1 = v1 + 6 v1 = v1 + 7 v1 = v1 + 8 v1 = v1 + 9 v1 = v1 + 10 v1 = v1 + 11 v1 = v1 + 12 v1 = v1 + 13 v1 = v1 + 14 v1 = v1 + 15 v1 = v1 + 16 v1 = v1 + 17 v1 = v1 + 18 v1 = v1 + 19 v1 = v1 + 20 v1 = v1 + 21 v1 = v1 + 22 v1 = v1 + 23 v1 = v1 + 24 v1 = v1 + 25 v1 = v1 + 26 v1 = v1 + 27 v1 = v1 + 28 v1 = v1 + 29 v1 = v1 + 30 Goto Loop ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ----- ' ============================================================================= ' Folder Demo Programs\Hilight Running Lines ' File Test CPU CHARGE 2.txt ' ============================================================================= Label Loop v1 = v1 + 1 v1 = v1 + 2 v1 = v1 + 3 v1 = v1 + 4 v1 = v1 + 5 v1 = v1 + 6 v1 = v1 + 7 v1 = v1 + 8 v1 = v1 + 9 v1 = v1 + 10 v1 = v1 + 11 v1 = v1 + 12 v1 = v1 + 13 v1 = v1 + 14 v1 = v1 + 15 v1 = v1 + 16 v1 = v1 + 17 v1 = v1 + 18 v1 = v1 + 19 v1 = v1 + 20 v1 = v1 + 21 v1 = v1 + 22 v1 = v1 + 23 v1 = v1 + 24 v1 = v1 + 25 v1 = v1 + 26 v1 = v1 + 27 v1 = v1 + 28 v1 = v1 + 29 v1 = v1 + 30 Goto Loop ' ============================================================================= ' Folder Demo Programs\Hilight Running Lines ' File Test CPU CHARGE 2b.txt ' ============================================================================= Label Loop v1 = v1 + 1 v1 = v1 + 2 v1 = v1 + 3 v1 = v1 + 4 v1 = v1 + 5 v1 = v1 + 6 v1 = v1 + 7 v1 = v1 + 8 v1 = v1 + 9 v1 = v1 + 10 v1 = v1 + 11 v1 = v1 + 12 v1 = v1 + 13 v1 = v1 + 14 v1 = v1 + 15 v1 = v1 + 16 v1 = v1 + 17 v1 = v1 + 18 v1 = v1 + 19 v1 = v1 + 20 v1 = v1 + 21 v1 = v1 + 22 v1 = v1 + 23 v1 = v1 + 24 v1 = v1 + 25 v1 = v1 + 26 v1 = v1 + 27 v1 = v1 + 28 v1 = v1 + 29 v1 = v1 + 30 v1 = v1 + 1 v1 = v1 + 2 v1 = v1 + 3 v1 = v1 + 4 v1 = v1 + 5 v1 = v1 + 6 v1 = v1 + 7 v1 = v1 + 8 v1 = v1 + 9 v1 = v1 + 10 v1 = v1 + 11 v1 = v1 + 12 v1 = v1 + 13 v1 = v1 + 14 v1 = v1 + 15 v1 = v1 + 16 v1 = v1 + 17 v1 = v1 + 18 v1 = v1 + 19 v1 = v1 + 20 v1 = v1 + 21 v1 = v1 + 22 v1 = v1 + 23 v1 = v1 + 24 v1 = v1 + 25 v1 = v1 + 26 v1 = v1 + 27 v1 = v1 + 28 v1 = v1 + 29 v1 = v1 + 30 v1 = v1 + 1 v1 = v1 + 2 v1 = v1 + 3 v1 = v1 + 4 v1 = v1 + 5 v1 = v1 + 6 v1 = v1 + 7 v1 = v1 + 8 v1 = v1 + 9 v1 = v1 + 10 v1 = v1 + 11 v1 = v1 + 12 v1 = v1 + 13 v1 = v1 + 14 v1 = v1 + 15 v1 = v1 + 16 v1 = v1 + 17 v1 = v1 + 18 v1 = v1 + 19 v1 = v1 + 20 v1 = v1 + 21 v1 = v1 + 22 v1 = v1 + 23 v1 = v1 + 24 v1 = v1 + 25 v1 = v1 + 26 v1 = v1 + 27 v1 = v1 + 28 v1 = v1 + 29 v1 = v1 + 30 v1 = v1 + 1 v1 = v1 + 2 v1 = v1 + 3 v1 = v1 + 4 v1 = v1 + 5 v1 = v1 + 6 v1 = v1 + 7 v1 = v1 + 8 v1 = v1 + 9 v1 = v1 + 10 v1 = v1 + 11 v1 = v1 + 12 v1 = v1 + 13 v1 = v1 + 14 v1 = v1 + 15 v1 = v1 + 16 v1 = v1 + 17 v1 = v1 + 18 v1 = v1 + 19 v1 = v1 + 20 v1 = v1 + 21 v1 = v1 + 22 v1 = v1 + 23 v1 = v1 + 24 v1 = v1 + 25 v1 = v1 + 26 v1 = v1 + 27 v1 = v1 + 28 v1 = v1 + 29 v1 = v1 + 30 v1 = v1 + 1 v1 = v1 + 2 v1 = v1 + 3 v1 = v1 + 4 v1 = v1 + 5 v1 = v1 + 6 v1 = v1 + 7 v1 = v1 + 8 v1 = v1 + 9 v1 = v1 + 10 v1 = v1 + 11 v1 = v1 + 12 v1 = v1 + 13 v1 = v1 + 14 v1 = v1 + 15 v1 = v1 + 16 v1 = v1 + 17 v1 = v1 + 18 v1 = v1 + 19 v1 = v1 + 20 v1 = v1 + 21 v1 = v1 + 22 v1 = v1 + 23 v1 = v1 + 24 v1 = v1 + 25 v1 = v1 + 26 v1 = v1 + 27 v1 = v1 + 28 v1 = v1 + 29 v1 = v1 + 30 Goto Loop ' ============================================================================= ' Folder Demo Programs\Hilight Running Lines ' File Test CPU CHARGE 3.txt ' ============================================================================= 'Label Loop ' v1 = v1 + 1 ' v1 = v1 + 2 ' v1 = v1 + 3 ' v1 = v1 + 4 ' v1 = v1 + 5 ' v1 = v1 + 6 ' v1 = v1 + 7 ' v1 = v1 + 8 ' v1 = v1 + 9 ' v1 = v1 + 10 ' v1 = v1 + 11 ' v1 = v1 + 12 ' v1 = v1 + 13 ' v1 = v1 + 14 ' v1 = v1 + 15 ' v1 = v1 + 16 ' v1 = v1 + 17 ' v1 = v1 + 18 ' v1 = v1 + 19 ' v1 = v1 + 20 ' v1 = v1 + 21 ' v1 = v1 + 22 ' v1 = v1 + 23 ' v1 = v1 + 24 ' v1 = v1 + 25 ' v1 = v1 + 26 ' v1 = v1 + 27 ' v1 = v1 + 28 ' v1 = v1 + 29 ' v1 = v1 + 30 ' Wait Not Key("SHIFT") 'Goto Loop ' =================================================================== ' Name: Control_78_NewHoming.txt Date: 08 Set 2020 ' Autor: Leonardo DE PALO ' Scope: Test COREXY from Wingo ' Hardware: Standard Master. ' ==================================================================== Option Speed 9 COM Open 1 115200 ' -------------------------------------- Options KeyJog_Speed = 100 ' -------------------------------------- Software limits DestxMax = 256 DestxMin = 2 DestyMax = 143 DestyMin = 2 ' ----------------------------------------- MOTORS ASSIGNEMENTS POWER_IN = 363 ' main power plug insert POWER_OUT = 665 ' main power plug out USB3_IN = 212 USB3_OUT = 620 USBC_IN = 384 USBC_OUT = 670 HDMI_IN = 995 HDMI_OUT = 787 USBPWR_IN = 205 USBPWR_OUT = 470 ONOFF_IN = 750 ONOFF_OUT = 295 VOLUME_IN_UP = 697 VOLUME_OUT = 754 VOLUME_IN_DW = 794 MEMORY_IN = 300 MEMORY_OUT = 604 HEARSET_IN = 865 HEARSET_OUT = 565 PEN_DOWN = 560 PEN_UP = 189 ' ----------------------------------------- STEPPER SLOTS Slot_MotorA = 1 '1_TabTesterXY pin 1 STEPPER Slot_MotorB = 3 '1_TabTesterXY pin 3 STEPPER Slot_SensorX = 7 '1_TabTesterXY pin 7 DIG INPU Slot_SensorY = 8 '1_TabTesterXY pin 8 DIG INPU Slot_EnableMotors = 10 '1_TabTesterXY pin 10 DIG OUT ' ----------------------------------------- DIGITAL MOTOR SLOTS SLOT_USB3 = 13 '2_TabTesterMot pin 1 PWM16 SLOT_USBC = 14 '2_TabTesterMot pin 2 PWM16 SLOT_HDMI = 15 '2_TabTesterMot pin 3 PWM16 SLOT_USBPWR = 16 '2_TabTesterMot pin 4 PWM16 SLOT_ONOFF = 17 '2_TabTesterMot pin 5 PWM16 SLOT_POWER = 18 '2_TabTesterMot pin 6 software control SERVO16 SLOT_VOLUME = 25 '3_TabTesterMot pin 1 PWM16 SLOT_MEMORY = 26 '3_TabTesterMot pin 2 PWM16 SLOT_HEARSET = 27 '3_TabTesterMot pin 3 PWM16 SLOT_PEN = 29 '3_TabTesterMot pin 4 PWM16 SLOT_ROTAT = 28 '3_TabTesterMot pin 5 PWM16 ' ----------------------------------------- TABLET POWER SLOT_TabletPower = 9 ' 1000 = Tablet on ' ----------------------------------------- ROTATION H/V Slot_RotHV_Drive = 28 '30 ' slot Slot_RotHV_Current = 60 '31 ' slot Slot_RotHV_MaxCurrent = 6000 'Period for the max current ' ----------------------------------------- SLOTS FOR SOUND TESTS Slot_RunScope = 37 Slot_SoundLevel = 41 Slot_SoundLevel2ndHarm = 43 Slot_SoundLevel3rdHarm = 45 ' ----------------------------------------- JOG WITH MOUSE Jog_RangeX = 256 '288 Jog_RangeY = 144 Jog_Enable_Slot = 34 ' ----------------------------------------- COLOR RECOGNITION Slot_S0 = 24 Slot_S1 = 23 Slot_S2 = 21 Slot_S3 = 20 Slot_Freq = 22 ' ----------------------------------------- FILE SET UP ' Variable String FileName ' FileName = "Test_Results.txt" ' ----------------------------------------- LOAD APPS Load Theremino_HAL\Theremino_HAL.exe Load Theremino_HAL\Theremino_SlotViewer.exe 'Load Theremino_MicroVideo\Theremino_MicroVideo.exe 'Load Theremino_AudioGenerator\Theremino_AudioGenerator.exe 'Load Theremino_AudioInput\Theremino_AudioInput.exe 'Load Theremino_HAL\Theremino_SignalScope.exe ' ----------------------------------------- KEYS Key Right Gosub ExecKeys Key Left Gosub ExecKeys Key Up Gosub ExecKeys Key Down Gosub ExecKeys Key Pageup Gosub PEN UP Key Pagedown Gosub PEN DOWN Key End Gosub PEN SINGLE ' ----------------------------------------- START Load Toc.wav Option Speed 9 Slot Slot_S0 = 1000 Slot Slot_S1 = 1000 'Window MinSize DestX = v1 DestY = v2 Gosub VOLUME OUT Gosub PEN UP Gosub MAIN MENU Stop ' ' ----------------------------------------------------------------- Variable Numeric DestxMax Variable Numeric DestxMin Variable Numeric DestyMax Variable Numeric DestyMin ' ----------------------------------------------------------------- Label CLEAR BUTTONS For v1 = 1 To 32 Button v1 Text "" Button v1 Color Moccasin Next Return Label CLOSE ALL Load CloseApps Return Label EventStop Window Sizable End ' ----------------------------------------------------------------- ' MENU ' ----------------------------------------------------------------- Label MAIN MENU Gosub CLEAR BUTTONS Button 1 Label DISPLAY Button 1 Color SkyBlue Button 2 Label "TOUCH1" Button 2 Color LightSteelBlue Button 3 Label AUDIO Button 3 Color LightGreen Button 4 Label PLUG Button 4 Color MediumAquamarine Button 5 Label Wi-Fi Button 5 Color HotPink Button 6 Label BLUETOOTH Button 6 Color RoyalBlue Button 7 Label "POWER1" Button 7 Color Chocolate Button 8 Label VIRTUAL Key Button 8 Color SlateGray Button 9 Label MECHANICAL Button 9 Color Gainsboro Button 10 Label MISCELLANEA Button 10 Color DarkCyan Button 15 Label CLOSE ALL Button 15 Color Red Return Label DISPLAY Gosub CLEAR BUTTONS Button 1 Label LUMINOSITY Button 1 Color SkyBlue Button 2 Label "RED1" Button 2 Color Red Button 3 Label "GREEN1" Button 3 Color Green Button 4 Label BLU Button 4 Color Blue Button 5 Label "WHITE1" Button 5 Color White Button 6 Label BITMAP Button 6 Color SkyBlue Button 7 Label PHOTO Button 7 Color SkyBlue Button 8 Label VIDEO Button 8 Color SkyBlue Button 9 Label NO Color Button 9 Color SkyBlue Button 10 Label Color TEST Button 10 Color SkyBlue 'Button 11 Text -------- 'Button 11 Color SkyBlue Button 12 Label TOUCH TEST Button 12 Color SkyBlue Button 13 Label Color RECOGNITION Button 13 Color SkyBlue Button 14 Label MAIN MENU Button 14 Color Yellow Button 15 Label CLOSE ALL Button 15 Color Red Return Label TOUCH Gosub CLEAR BUTTONS Button 1 Label PEN UP Button 1 Color LightSteelBlue Button 2 Label PEN DOWN Button 2 Color LightSteelBlue Button 3 Label PEN SINGLE Button 3 Color LightSteelBlue Button 4 Label PEN DOUBLE Button 4 Color LightSteelBlue Button 5 Label "SLIDE1" Button 5 Color LightSteelBlue Button 6 Label SLIDE PSW Button 6 Color LightSteelBlue Button 7 Label TOUCH TEST Button 7 Color LightSteelBlue Button 8 Label JOG with Mouse Button 8 Color LightSteelBlue Button 10 Label Start WXM AppTablet Button 10 Color LightSteelBlue Button 14 Label MAIN MENU Button 14 Color Yellow Button 15 Label CLOSE ALL Button 15 Color Red Return Label AUDIO Gosub CLEAR BUTTONS Button 1 Label HEARSET IN Button 1 Color LightGreen Button 2 Label HEARSET OUT Button 2 Color LightGreen Button 3 Label VOLUME OUT Button 3 Color LightGreen Button 4 Label VOLUME UP Button 4 Color LightGreen Button 5 Label VOLUME DW Button 5 Color LightGreen Button 6 Label VOLUME TEST Button 6 Color LightGreen Button 7 Label Speak.DIST. Button 7 Color LightGreen Button 8 Label TestHearset Button 8 Color LightGreen Button 14 Label MAIN MENU Button 14 Color Yellow Button 15 Label CLOSE ALL Button 15 Color Red Return Label PLUG Gosub CLEAR BUTTONS Button 1 Label POWER IN Button 1 Color MediumAquamarine Button 2 Label POWER OUT Button 2 Color MediumAquamarine Button 3 Label MEMORY IN Button 3 Color MediumAquamarine Button 4 Label MEMORY OUT Button 4 Color MediumAquamarine Button 5 Label USB3 IN Button 5 Color MediumAquamarine Button 6 Label USB3 OUT Button 6 Color MediumAquamarine Button 7 Label USBC IN Button 7 Color MediumAquamarine Button 8 Label USBC OUT Button 8 Color MediumAquamarine Button 9 Label HDMI IN Button 9 Color MediumAquamarine Button 10 Label HDMI OUT Button 10 Color MediumAquamarine Button 11 Label HEARSET IN Button 11 Color MediumAquamarine Button 12 Label HEARSET OUT Button 12 Color MediumAquamarine Button 14 Label MAIN MENU Button 14 Color Yellow Button 15 Label CLOSE ALL Button 15 Color Red Return Label Wi-Fi Gosub CLEAR BUTTONS Button 1 Label EMPTY 1 Button 1 Color HotPink Button 2 Label EMPTY 2 Button 2 Color HotPink Button 3 Label EMPTY 3 Button 3 Color HotPink Button 14 Label MAIN MENU Button 14 Color Yellow Button 15 Label CLOSE ALL Button 15 Color Red Return Label BLUETOOTH Gosub CLEAR BUTTONS Button 1 Label EMPTY 1 Button 1 Color RoyalBlue Button 2 Label EMPTY 2 Button 2 Color RoyalBlue Button 3 Label EMPTY 3 Button 3 Color RoyalBlue Button 14 Label MAIN MENU Button 14 Color Yellow Button 15 Label CLOSE ALL Button 15 Color Red Return Label POWER Gosub CLEAR BUTTONS Button 1 Label POWER IN Button 1 Color Chocolate Button 2 Label POWER OUT Button 2 Color Chocolate Button 4 Label POWER ON Button 4 Color Yellow6 Button 5 Label POWER OFF Button 5 Color Yellow6 Button 14 Label MAIN MENU Button 14 Color Yellow Button 15 Label CLOSE ALL Button 15 Color Red Return Label VIRTUAL KEY Gosub CLEAR BUTTONS Button 1 Label NUMBER Button 1 Color SlateGray Button 2 Label ALPHABET Button 2 Color SlateGray Button 3 Label £$%*°ç&[@)^! Button 3 Color SlateGray Button 5 Label PS SEQUENCES Button 5 Color SlateGray Button 6 Label Get-Service Button 6 Color SlateGray Button 7 Label Win10 update history Button 7 Color SlateGray Button 8 Label "GetSystemInfo1" Button 8 Color SlateGray Button 14 Label MAIN MENU Button 14 Color Yellow Button 15 Label CLOSE ALL Button 15 Color Red Return Label MECHANICAL Gosub CLEAR BUTTONS Button 1 Label ZERO Button 1 Color Gainsboro Button 2 Label ENAB.MOTORS Button 2 Color Gainsboro Button 3 Label DISAB.MOTORS Button 3 Color Gainsboro Button 4 Label ROTATE VERT Button 4 Color Gainsboro Button 5 Label ROTATE HORZ Button 5 Color Gainsboro Button 6 Label ROTATE MIDL Button 6 Color Gainsboro Button 7 Label Button FAST Button 7 Color Gainsboro Button 9 Label BURN IN 7-24 Button 9 Color Gainsboro Button 14 Label MAIN MENU Button 14 Color Yellow Button 15 Label CLOSE ALL Button 15 Color Red Return Label MISCELLANEA Gosub CLEAR BUTTONS Button 1 Label STAND BY Button 1 Color DarkCyan Button 2 Label SAFE REMOVE Button 2 Color DarkCyan Button 3 Label ALL IN Button 3 Color DarkCyan Button 4 Label ALL OUT Button 4 Color DarkCyan Button 5 Label V KEYBOARD Button 5 Color DarkCyan Button 6 Label JOG with Mouse Button 6 Color DarkCyan Button 7 Label Calibrate Button 7 Color DarkCyan Button 8 Label USBPWR IN Button 8 Color DarkCyan Button 9 Label USBPWR OUT Button 9 Color DarkCyan Button 11 Label GetSystemInfo Button 11 Color DarkCyan Button 14 Label MAIN MENU Button 14 Color Yellow Button 15 Label CLOSE ALL Button 15 Color Red Return Label NUMBER PressKeys ALT Tab Wait Seconds 0.5 s1 = "SPACE" PressKeys s1 PressKeys 1 2 3 4 5 6 7 8 9 0 Enter Return Label ALPHABET PressKeys ALT Tab Wait Seconds 0.5 PressKeys A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Enter PressKeys B C C Enter Return Label £$%*°ç&[@)^! 'PressKey Space PressKeys WINDOWS X Wait Seconds 2 Return Label PS SEQUENCES SequenceFileName = "SEQUENCES\Sequence_Dir.seq" Gosub ExecSequence Return Label Get-Service SequenceFileName = "SEQUENCES\Sequence_Get-Service.seq" Gosub ExecSequence Return Label Win10 update history SequenceFileName = "SEQUENCES\Sequence_Win10-update-history.seq" Gosub ExecSequence Return Label GetSystemInfo COM DiscardOutBuffer COM WriteString "SendSystemInfo" + CRLF FileName = "info.csv" Gosub ReceiveFileFromCOM Return Label LUMINOSITY Button 1 Color Flashing8 Black Gray5 Beep Wait Key("Space") SequenceFileName = "SEQUENCES\Sequence_LuminosityBigPen.seq" Gosub ExecSequence Button 1 Color SkyBlue Return Label V KEYBOARD Beep Wait Key("Space") Button 29 Color Flashing8 Blue9 Cyan9 SequenceFileName = "SEQUENCES\Sequence_VirtualKeyboard.seq" Gosub ExecSequence Wait Seconds 2 Button 29 Color MediumBlue Return Label RED COM WriteString "RED" + CRLF Return Label GREEN COM WriteString "GREEN" + CRLF Return Label BLU COM WriteString "BLU" + CRLF Return Label WHITE COM WriteString "WHITE" + CRLF Return Label NO COLOR COM WriteString "NO COLOR" + CRLF Return Label BITMAP COM WriteString "BITMAP" + CRLF Return Label PHOTO COM WriteString "PHOTO" + CRLF Return Label VIDEO COM WriteString "VIDEO" + CRLF Return Label STAND BY Gosub ZERO SequenceFileName = "SEQUENCES\Sequence_SafeRemove.seq" Gosub ExecSequence Gosub POWER IN Gosub USB3 IN Gosub MEMORY IN Gosub USBC OUT Gosub HDMI OUT Gosub USBPWR OUT Gosub HEARSET OUT Gosub ONOFF OUT Gosub VOLUME OUT Gosub DISAB.MOTORS Return Label ALL IN Gosub POWER IN Wait Seconds 0.2 Gosub USB3 IN Wait Seconds 0.2 Gosub USBC IN Wait Seconds 0.2 Gosub HDMI IN Wait Seconds 0.2 Gosub USBPWR IN Wait Seconds 0.2 Gosub HEARSET IN Wait Seconds 0.2 Gosub MEMORY IN Wait Seconds 0.2 'Gosub ONOFF IN 'Gosub VOLUME IN_UP 'Wait Seconds 0.5 Gosub VOLUME OUT Wait Seconds 0.2 Return Label ALL OUT Gosub POWER OUT Wait Seconds 0.2 Gosub USB3 OUT Wait Seconds 0.2 Gosub USBC OUT Wait Seconds 0.2 Gosub HDMI OUT Wait Seconds 0.2 Gosub USBPWR OUT Wait Seconds 0.2 Gosub HEARSET OUT Wait Seconds 0.2 Gosub MEMORY OUT Wait Seconds 0.2 Gosub ONOFF OUT Wait Seconds 0.2 'Gosub VOLUME IN_DW 'Wait Seconds 0.5 Gosub VOLUME OUT Wait Seconds 0.2 Return Label MULTI v2 = Input " How many loops? " If v2 = 0 v2 = 10 EndIf For v1 = 1 To v2 s1 = Now s1 = s1 + " Cycle in progress = " + v1 s1 = s1 + " Cycle to do = " + v2 Print s1 'Gosub RUN TEST Next Return Label SAFE REMOVE Gosub ZERO Gosub POWER OUT Gosub USB3 OUT Gosub USBC OUT Gosub HDMI OUT Gosub USBPWR OUT Gosub HEARSET OUT Gosub ONOFF OUT Gosub VOLUME OUT Gosub MEMORY OUT SequenceFileName = "SEQUENCES\Sequence_SafeRemove.seq" Gosub ExecSequence Return Label BUTTON FAST SequenceFileName = "SEQUENCES\Sequence_ButtonFast.seq" Gosub ExecSequence Return Label BURN IN 7-24 For v9 = 1 To 10000 SequenceFileName = "SEQUENCES\BurnIn7-24.seq" Gosub ExecSequence Print "Cycle number:" + v9 ' Wait Seconds 1.5 Slot(100) = Slot(100) + 1 Beep Next Return Label CALIBRATE 'Beep 'Wait Key("Space") Gosub ZERO 'SequenceFileName = "SEQUENCES\Sequence_Calibrate.seq" SequenceFileName = "SEQUENCES\Sequence_SpeedTest.seq" Gosub ExecSequence Return ' =========================================================== ' AUDIO TESTS ' =========================================================== Variable Numeric Slot_RunScope Variable Numeric Slot_SoundLevel Variable Numeric Slot_SoundLevel2ndHarm Variable Numeric Slot_SoundLevel3rdHarm Variable Numeric SoundLevelMin Variable Numeric SoundNoiseMax Variable Numeric SoundDist2ndHarmMax ' Max level for the 2nd harmonics Variable Numeric SoundDist3rdHarmMax ' Max level for the 3rd harmonics Label SPEAK.DIST. Window MinSize Wait Key("Space") Button 25 Color Flashing8 Gold DarkGreen SoundLevelMin = 650 SoundNoiseMax = 350 SoundDist2ndHarmMax = 400 SoundDist3rdHarmMax = 400 Gosub AudioTest Window Sizable Button 25 Color LightSteelBlue 'Gosub EventStop Return Label TestHearset Window MinSize Button 26 Color Flashing8 Gold DarkGreen SoundLevelMin = 50 SoundNoiseMax = 30 Gosub AudioTest Window Sizable Button 26 Color LightSteelBlue Gosub EventStop Return Label AudioTest 'Gosub "ZERO" Slot 39 = 1000 '<<<<<<<<<<<<<< manual sound start 'Beep 'wait Seconds 2 'Wait Key("Space") s1 = "" '---------------------- test audio left DestX = 014 DestY = 108.8 Gosub CoreXY_MoveToDestXY_AndWait Gosub PEN SINGLE Wait Seconds 0.8 Slot Slot_RunScope = 1000 Wait Seconds 0.5 v1 = Slot(Slot_SoundLevel) If v1 < SoundLevelMin s1 = s1 + "ERROR: Left level too low" + CRLF EndIf v1 = Slot(Slot_SoundLevel2ndHarm) If v1 > SoundDist2ndHarmMax s1 = s1 + "ERROR: Left speaker. Too much distortion on the 2nd harmonics" + CRLF EndIf v1 = Slot(Slot_SoundLevel3rdHarm) If v1 > SoundDist3rdHarmMax s1 = s1 + "ERROR: Left speaker. Too much distortion on the 3rd harmonics" + CRLF EndIf Slot Slot_RunScope = 0 '---------------------- test audio right DestX = 014 DestY = 102.5 Gosub CoreXY_MoveToDestXY_AndWait Gosub PEN SINGLE Wait Seconds 0.8 Slot Slot_RunScope = 1000 Wait Seconds 0.5 v1 = Slot(Slot_SoundLevel) If v1 < SoundLevelMin s1 = s1 + "ERROR: Right level too low" + CRLF EndIf v1 = Slot(Slot_SoundLevel2ndHarm) If v1 > SoundDist2ndHarmMax s1 = s1 + "ERROR: Right speaker. Too much distortion on the 2nd harmonics" + CRLF EndIf v1 = Slot(Slot_SoundLevel3rdHarm) If v1 > SoundDist3rdHarmMax s1 = s1 + "ERROR: Right speaker. Too much distortion on the 3rd harmonics" + CRLF EndIf Slot Slot_RunScope = 0 Slot 39 = 0 '<<<<<<<<<<<<<< manual sound stop '---------------------- test audio no sound left/right DestX = 014 DestY = 096.2 Gosub CoreXY_MoveToDestXY_AndWait Gosub PEN SINGLE Wait Seconds 0.8 Slot Slot_RunScope = 1000 Wait Seconds 0.5 v1 = Slot(Slot_SoundLevel) If v1 > SoundNoiseMax s1 = s1 + "ERROR: Too much noise" + CRLF EndIf Slot Slot_RunScope = 0 If s1 = "" s1 = "TEST PASSED OK" EndIf Print s1 Return Label VOLUME TEST 'Gosub "ZERO" Window MinSize Button 24 Color Flashing8 LightSteelBlue DarkGreen SoundLevelMin = 650 SoundNoiseMax = 350 Gosub VolumeTest Window Sizable Button 24 Color LightSteelBlue 'SequenceFileName = "SEQUENCES\Sequence_SafeRemove.seq" 'Gosub ExecSequence Gosub STAND BY Gosub EventStop Return Label VolumeTest 'Beep 'wait Seconds 2 'Wait Key("Space") s1 = "" '---------------------- test audio volume level high Gosub VOLUME UP Wait Seconds 4 Gosub VOLUME OUT Slot 39 = 1000 '<<<<<<<<<<<<<< manual sound start Wait Seconds 0.8 Slot Slot_RunScope = 1000 Wait Seconds 0.23 v1 = Slot(Slot_SoundLevel) If v1 < SoundLevelMin s1 = s1 + "ERROR: Left level too low" + CRLF EndIf Slot Slot_RunScope = 0 'Slot 39 = 0 '<<<<<<<<<<<<<< manual sound stop '---------------------- test audio no sound left/right Gosub VOLUME DW Wait Seconds 4 Gosub VOLUME OUT 'Slot 39 = 1000 '<<<<<<<<<<<<<< manual sound start Wait Seconds 0.8 Slot Slot_RunScope = 1000 Wait Seconds 0.23 v1 = Slot(Slot_SoundLevel) If v1 > SoundNoiseMax s1 = s1 + "ERROR: Too much noise" + CRLF EndIf Slot Slot_RunScope = 0 Slot 39 = 0 '<<<<<<<<<<<<<< manual sound stop If s1 = "" s1 = "TEST PASSED OK" EndIf Print s1 Return ' ===================================================================== ' COLOR RECOGNITION ' ===================================================================== Variable Numeric Slot_S0 Variable Numeric Slot_S1 Variable Numeric Slot_S2 Variable Numeric Slot_S3 Variable Numeric Slot_Freq Label COLOR TEST FileHeaderTestName = "COLOR TEST" Gosub WriteFileHeader Beep Wait Key("Space") Button 10 Color Flashing8 Red SkyBlue Gosub RED Wait Seconds 1 Gosub COLOR RECOGNITION If s1 = "RED" s1 = "Red color = Passed" Else s1 = "Red color = Fail" EndIf Save StringToFile s1 FileName Gosub GREEN Wait Seconds 1 Gosub COLOR RECOGNITION If s1 = "GREEN" s1 = "Green color = Passed" Else s1 = "Green color = Fail" EndIf Save StringToFile s1 FileName Gosub BLU Wait Seconds 1 Gosub COLOR RECOGNITION If s1 = "BLU" s1 = "Blu color = Passed" Else s1 = "Blu color = Fail" EndIf Save StringToFile s1 FileName Button 10 Color SkyBlue Gosub NO COLOR Return Label COLOR RECOGNITION ' ------------------------- RED filter Slot Slot_S2 = 0 Slot Slot_S3 = 0 Wait Seconds 0.1 v1 = Slot(Slot_Freq) ' ------------------------- GREEN filter Slot Slot_S2 = 1000 Slot Slot_S3 = 1000 Wait Seconds 0.1 v2 = Slot(Slot_Freq) ' ------------------------- BLU filter Slot Slot_S2 = 0 Slot Slot_S3 = 1000 Wait Seconds 0.1 v3 = Slot(Slot_Freq) '' ------------------------- CLEAR filter 'Slot Slot_S2 = 1000 'Slot Slot_S3 = 0 'Wait Seconds 0.2 'v4 = Slot(Slot_Freq) ' ------------------------- RECOGNIZE COLOR If v1 > v2 And v1 > v3 s1 = "RED" Else If v2 > v1 And v2 > v3 s1 = "GREEN" Else If v3 > v1 And v3 > v2 s1 = "BLU" EndIf EndIf EndIf Print v1 + " " + v2 + " " + v3 + " " + s1 Return Label TOUCH TEST Window MinSize Beep Wait Key("Space") SequenceFileName = "SEQUENCES\Sequence_TouchTest.seq" Gosub ExecSequence Return Label Start WXM AppTablet SequenceFileName = "SEQUENCES\StartWXM_AppTablet.seq" Gosub ExecSequence Return Label Slide PSW SequenceFileName = "SEQUENCES\Sequence_SlidePsw.seq" Gosub ExecSequence Return Variable String FileHeaderTestName Label WriteFileHeader s1 = "-------------------------" + CRLF s1 = s1 + FileHeaderTestName + CRLF s1 = s1 + Format(Now, "dd/MMM/yyyy HH:mm:ss") + CRLF s1 = s1 + "-------------------------" Save StringToFile s1 FileName Return ' ===================================================================== ' SEQUENCE LOADING AND EXECUTION ' ===================================================================== Variable String SequenceFileName Variable String Sequence Variable String SequenceCmd Variable Numeric SequenceIndex Variable Numeric SequenceLength Label ExecSequence Load Sequence SequenceFileName If Len(Sequence) = 0 Controls OpenTextBox Print CRLF + " Sequence file not found: " + SequenceFileName Beep Stop EndIf ' ------------------------------------------ Variable Numeric ExecSequenceStartTime ExecSequenceStartTime = ElapsedTime ' ------------------------------------------ SequenceLength = GetSeparatedStringCount(Sequence, CRLF) For SequenceIndex = 0 To SequenceLength-1 SequenceCmd = GetSeparatedString(Sequence, SequenceIndex, CRLF) SequenceCmd = Replace(SequenceCmd, Chr(9), " ") 'TABS to SPACES SequenceCmd = RemoveComments(SequenceCmd) SequenceCmd = Trim(SequenceCmd) ' Print " Executing command: " + SequenceCmd ' Select UCase(SequenceCmd) ' ------------------- exit from the sequence ------------- Case "ENDSEQ" SequenceIndex = SequenceLength-1 ' ------------------- special multiple actions ----------- Case "SLIDE" ' slide before insert PSW Gosub SLIDE Case "ZERO" ' move pen to X=0 and Y=0 position Gosub ZERO Case "ALL OUT" ' all plug out Gosub ALL OUT Case "ALL IN" ' all plug in Gosub ALL IN ' --------------------- single action ---------------------- Case "POWER IN" ' power plug in Gosub POWER IN Case "POWER OUT" ' power plug out Gosub POWER OUT Case "ENABLE MOTORS" 'enable movement motors Gosub ENAB.MOTORS Case "DISABLE MOTORS" ' disable movement motors Gosub DISAB.MOTORS Case "PEN UP" ' move pen up Gosub PEN UP Case "PEN DOWN" ' move pen down Gosub PEN DOWN Case "PEN SINGLE" ' single click Gosub PEN SINGLE Case "PEN DOUBLE" ' double click Gosub PEN DOUBLE Case "POWER CYCLE" ' push power button, wait then release 'Gosub POWER CYCLE Case "ROTATE HORZ" ' rotate the tablet horizontally Gosub ROTATE HORZ Case "ROTATE MIDL" ' rotate the tablet 60 degree Gosub ROTATE MIDL Case "ROTATE VERT" ' rotate the tablet vertically Gosub ROTATE VERT Case "HDMI IN" Gosub HDMI IN Case "HDMI OUT" Gosub HDMI OUT Case "USB3 IN" Gosub USB3 IN Case "USB3 OUT" Gosub USB3 OUT Case "USBC IN" Gosub USBC IN Case "USBC OUT" Gosub USBC OUT Case "USBPWR IN" Gosub USBPWR IN Case "USBPWR OUT" Gosub USBPWR OUT Case "MEMORY IN" Gosub MEMORY IN Case "MEMORY OUT" Gosub MEMORY OUT Case "HEARSET IN" Gosub HEARSET IN Case "HEARSET OUT" Gosub HEARSET OUT Case "CLOSE ALL" Gosub CLOSE ALL ' ------------------- display actions --------------------- Case "BITMAP" Gosub BITMAP Case "PHOTO" Gosub PHOTO Case "VIDEO" Gosub VIDEO Case "RED" Gosub RED Case "GREEN" Gosub GREEN Case "BLU" Gosub BLU Case "NO COLOR" Gosub NO COLOR ' --------------------- WAIT MOTORS ----------------------- Case "WAIT MOTORS" Gosub WaitMotors ' --------------------- GET SYSTEM INFO ------------------- Case "GetSystemInfo" Gosub GetSystemInfo ' --------------------- Istruction with parameters -------- CaseElse s1 = GetSeparatedString(SequenceCmd, 0) Select UCase(s1) Case "MOVE" DestX = GetSeparatedString(SequenceCmd, 1) DestY = GetSeparatedString(SequenceCmd, 2) Gosub CoreXY_MoveToDestXY_AndWait Case "MOVESLOW" MoveSlowXY_DestX = GetSeparatedString(SequenceCmd, 1) MoveSlowXY_DestY = GetSeparatedString(SequenceCmd, 2) MoveSlowXY_Speed = GetSeparatedString(SequenceCmd, 3) Gosub MoveSlowXY Case "DRAWCIRCLE" DrawCircle_X = GetSeparatedString(SequenceCmd, 1) DrawCircle_Y = GetSeparatedString(SequenceCmd, 2) DrawCircle_Radius = GetSeparatedString(SequenceCmd, 3) DrawCircle_Speed = GetSeparatedString(SequenceCmd, 4) Gosub DrawCircle Case "PAUSE" Wait Seconds GetSeparatedString(SequenceCmd, 1) Case "PRESSKEYS" SequenceCmd = Mid(SequenceCmd, 11) PressKeys SequenceCmd Case "SENDKEYS" SequenceCmd = Mid(SequenceCmd, 10) SendKeys SequenceCmd Case "PENTYPING" PEN_TOUCH_TIME = GetSeparatedString(SequenceCmd, 1) Gosub PEN TYPING CaseElse If s1 <> "" Controls OpenTextBox Print CRLF + " Unrecognized command: " + SequenceCmd Beep Stop EndIf EndSelect EndSelect Next SequenceFileName = Replace(SequenceFileName,".seq","") Print SequenceFileName + " executed in " + Format(ElapsedTime - ExecSequenceStartTime, "0.00") + " seconds" Return ' ===================================================================== ' CORE XY ' ===================================================================== Variable Numeric DestX ' destination in mm coords Variable Numeric DestY ' destination in mm coords Variable Numeric Slot_MotorA Variable Numeric Slot_MotorB Variable Numeric Slot_EnableMotors Variable Numeric Slot_SensorX Variable Numeric Slot_SensorY Label CoreXY_MoveToDestXY_AndWait ' move to destX & destY and wait stop motors Gosub CoreXY_MoveToDestXY Gosub WaitMotors Return Label CoreXY_MoveToDestXY ' move to destX & destY (with limits) DestX = Limit(DestX, DestxMin, DestxMax) DestY = Limit(DestY, DestyMin, DestyMax) If LimitReached Load sound\GeigerClick_16.wav EndIf Gosub CoreXY_PrepareCoreAB Slot(Slot_MotorA) = CoreA Slot(Slot_MotorB) = CoreB Return Label CoreXY_MoveToDestXY_NoLimits ' move to destX & destY (without using limits) Gosub CoreXY_PrepareCoreAB Slot(Slot_MotorA) = CoreA Slot(Slot_MotorB) = CoreB Return Label CoreXY_SetNewZero ' ------------------------- Reset axis X and Y Slot(Slot_MotorA) = Reset Slot(Slot_MotorB) = Reset Wait Seconds 0.15 ' ------------------------- Set reset values with CoreXY correction DestX = 0 DestY = 0 Gosub CoreXY_MoveToDestXY_NoLimits Gosub WaitMotors Return Variable Numeric CoreA Variable Numeric CoreB Label CoreXY_PrepareCoreAB CoreA = (DestX - DestY) / 2 CoreB = (DestX + DestY) / 2 Return ' ===================================================================== ' HOME ' ===================================================================== Variable Numeric HomeAxis Variable Numeric SlotSensor Variable Numeric DetachMM Variable Numeric SpeedSearch Variable Numeric SpeedReturn Variable Numeric InitialPosition Label ZERO Gosub CoreXY_SetNewZero Gosub ENAB.MOTORS Gosub PEN UP Gosub HomeX Gosub HomeY Gosub CoreXY_SetNewZero Print Format(DestX, "0.000") + " " + Format(DestY, "0.000") 'Gosub "DISAB.MOTORS" Return Label HomeX HomeAxis = 0 ' 0 = Axis X SlotSensor = Slot_SensorX ' home sensor slot DetachMM = 1 ' initial detach mm (neg or pos) SpeedSearch = -0.6 ' direction and speed SpeedReturn = +0.05 ' Detach direction and speed InitialPosition = 5 ' move to MM Gosub Home Return Label HomeY HomeAxis = 1 ' 1 = Axis Y SlotSensor = Slot_SensorY ' home sensor slot DetachMM = 1 ' initial detach mm (neg or pos) SpeedSearch = -0.6 ' direction and speed SpeedReturn = +0.05 ' Detach direction and speed InitialPosition = 3 ' move to MM Gosub Home Return Label Home ' -------------------------- detach if sensor is active If Slot(SlotSensor) > 500 Or Key("CTRL") If HomeAxis = 0 DestX = DestX + DetachMM Else DestY = DestY + DetachMM EndIf Gosub CoreXY_MoveToDestXY_NoLimits Gosub WaitMotors EndIf ' -------------------------- search the sensor Label SearchHome If HomeAxis = 0 DestX = DestX + SpeedSearch Else DestY = DestY + SpeedSearch EndIf Gosub CoreXY_MoveToDestXY_NoLimits ' Wait Seconds 0.005 If Slot(SlotSensor) > 500 Or Key("CTRL") Gosub CoreXY_SetNewZero Goto DetachSensor EndIf Goto SearchHome ' -------------------------- detach from the sensor Label DetachSensor If HomeAxis = 0 DestX = DestX + SpeedReturn Else DestY = DestY + SpeedReturn EndIf Gosub CoreXY_MoveToDestXY_NoLimits Wait Seconds 0.005 If Slot (SlotSensor) < 500 Or Key("CTRL") Gosub WaitMotors Gosub CoreXY_SetNewZero Goto MoveToInitialPosition EndIf Goto DetachSensor ' -------------------------- move to InitialPosition Label MoveToInitialPosition If HomeAxis = 0 DestX = InitialPosition Else DestY = InitialPosition EndIf Gosub CoreXY_MoveToDestXY_NoLimits Gosub WaitMotors Return ' ===================================================================== ' WAIT until the motors A and B are stopped ' ===================================================================== Label WaitMotors Wait Seconds 0.1 ' this ensures that the motors are running Label WaitMotors1 If Abs(Slot(Slot_MotorA + 1)) < 0.05 If Abs(Slot(Slot_MotorB + 1)) < 0.05 Return EndIf EndIf Wait Seconds 0.005 Goto WaitMotors1 Goto WaitMotors ' ===================================================================== ' SERVO-MOTORS MOVEMENTS ' ===================================================================== Variable Numeric POWER_IN Variable Numeric POWER_OUT Variable Numeric USB3_IN Variable Numeric USB3_OUT Variable Numeric USBC_IN Variable Numeric USBC_OUT Variable Numeric HDMI_IN Variable Numeric HDMI_OUT Variable Numeric USBPWR_IN Variable Numeric USBPWR_OUT Variable Numeric ONOFF_IN Variable Numeric ONOFF_OUT Variable Numeric VOLUME_IN_UP Variable Numeric VOLUME_OUT Variable Numeric VOLUME_IN_DW Variable Numeric MEMORY_IN Variable Numeric MEMORY_OUT Variable Numeric HEARSET_IN Variable Numeric HEARSET_OUT Variable Numeric PEN_DOWN Variable Numeric PEN_UP Variable Numeric PEN_TOUCH_TIME Variable Numeric SLOT_POWER ' digital motor 1 Variable Numeric SLOT_USB3 ' digital motor 2 Variable Numeric SLOT_USBC ' digital motor 3 Variable Numeric SLOT_HDMI ' digital motor 4 Variable Numeric SLOT_USBPWR ' digital motor 5 Variable Numeric SLOT_ONOFF ' digital motor 6 Variable Numeric SLOT_VOLUME ' digital motor 7 Variable Numeric SLOT_MEMORY ' digital motor 8 Variable Numeric SLOT_HEARSET ' digital motor 9 Variable Numeric SLOT_PEN ' digital motor 10 Variable Numeric SLOT_ROTAT ' digital motor 11 Variable Numeric SLOT_TabletPower ' Tabllet power sensing 'Label START LOOP ' v2 = Input "How many loops ?" ' For v1 = 1 To v2 ' Gosub "ALL IN" ' Wait Seconds 0.5 ' Gosub "ALL OUT" ' Wait Seconds 0.5 ' Next 'Return Label POWER OUT Move_Slot = SLOT_POWER Move_Dest = POWER_OUT Move_Speed = 60 Gosub MoveSlow Button 1 Color Chocolate Button 2 Color Red Return Label POWER IN Move_Slot = SLOT_POWER Move_Dest = POWER_IN Move_Speed = 60 Gosub MoveSlow Button 1 Color Lime Button 2 Color Chocolate Return Label USB3 OUT Move_Slot = SLOT_USB3 Move_Dest = USB3_OUT Move_Speed = 60 Gosub MoveSlow Return Label USB3 IN Move_Slot = SLOT_USB3 Move_Dest = USB3_IN Move_Speed = 60 Gosub MoveSlow Return Label USBC IN Move_Slot = SLOT_USBC Move_Dest = USBC_IN Move_Speed = 60 Gosub MoveSlow Return Label USBC OUT Move_Slot = SLOT_USBC Move_Dest = USBC_OUT Move_Speed = 60 Gosub MoveSlow Return Label HDMI OUT Move_Slot = SLOT_HDMI Move_Dest = HDMI_OUT Move_Speed = 60 Gosub MoveSlow Return Label HDMI IN Move_Slot = SLOT_HDMI Move_Dest = HDMI_IN Move_Speed = 60 Gosub MoveSlow Return Label USBPWR OUT Move_Slot = SLOT_USBPWR Move_Dest = USBPWR_OUT Move_Speed = 60 Gosub MoveSlow Return Label USBPWR IN Move_Slot = SLOT_USBPWR Move_Dest = USBPWR_IN Move_Speed = 60 Gosub MoveSlow Return Label ReceiveFileFromCOM Variable String FileName Variable String Str1 ' COM DiscardInBuffer ' Str1 = "" For v1 = 1 To 9e99 s1 = COM_Received If s1 <> "" s1 = Replace(s1, "{{{CRLF}}}", CRLF) Str1 = Str1 + s1 If s1 = "{{{FileEndMarker}}}" Str1 = Replace(Str1, "{{{FileEndMarker}}}", "") Save DeleteFile FileName Save StringToFile Str1 FileName Exit EndIf EndIf Wait Seconds 0.01 Next Return Label ONOFF OUT Move_Slot = SLOT_ONOFF Move_Dest = ONOFF_OUT Move_Speed = 60 Gosub MoveSlow Return Label ONOFF IN Move_Slot = SLOT_ONOFF Move_Dest = ONOFF_IN Move_Speed = 60 Gosub MoveSlow Return Label VOLUME OUT Move_Slot = SLOT_VOLUME Move_Dest = VOLUME_OUT Move_Speed = 60 Gosub MoveSlow Return Label VOLUME UP Move_Slot = SLOT_VOLUME Move_Dest = VOLUME_IN_UP Move_Speed = 60 Gosub MoveSlow Return Label VOLUME DW Move_Slot = SLOT_VOLUME Move_Dest = VOLUME_IN_DW Move_Speed = 60 Gosub MoveSlow Return Label MEMORY OUT Move_Slot = SLOT_MEMORY Move_Dest = MEMORY_OUT Move_Speed = 60 Gosub MoveSlow Return Label MEMORY IN Move_Slot = SLOT_MEMORY Move_Dest = MEMORY_IN Move_Speed = 30 Gosub MoveSlow Return Label HEARSET OUT Move_Slot = SLOT_HEARSET Move_Dest = HEARSET_OUT Move_Speed = 60 Gosub MoveSlow Return Label HEARSET IN Move_Slot = SLOT_HEARSET Move_Dest = HEARSET_IN Move_Speed = 60 Gosub MoveSlow Return Label PEN UP Move_Slot = SLOT_PEN Move_Dest = PEN_UP Slot(Move_Slot) = Move_Dest Wait Seconds 0.1 Return Label PEN DOWN Move_Slot = SLOT_PEN Move_Dest = PEN_DOWN Slot(Move_Slot) = Move_Dest Wait Seconds 0.1 Return Label PEN SINGLE Gosub PEN DOWN Wait Seconds 0.35 Gosub PEN UP Return Label PEN DOUBLE Slot(SLOT_PEN) = PEN_DOWN Wait Seconds 0.09 Slot(SLOT_PEN) = PEN_UP Wait Seconds 0.1 Slot(SLOT_PEN) = PEN_DOWN Wait Seconds 0.09 Slot(SLOT_PEN) = PEN_UP Return Label PEN TYPING Move_Slot = SLOT_PEN Move_Dest = PEN_DOWN Slot(Move_Slot) = Move_Dest Wait Seconds PEN_TOUCH_TIME Move_Slot = SLOT_PEN Move_Dest = PEN_UP Slot(Move_Slot) = Move_Dest 'Button 10 Text PEN UP Return Label POWER ON Gosub USB3 IN Button 4 Color Flashing8 Yellow5 Red5 Gosub ONOFF IN Wait Seconds 3 If Slot(SLOT_TabletPower) > 500 Button 4 Color PaleGreen Button 5 Color Red Else Print "POWER ON FAILURE" EndIf Gosub ONOFF OUT Return Label POWER OFF Gosub USB3 IN Button 4 Color Yellow6 Button 5 Color Flashing8 Yellow5 Red5 Gosub ONOFF IN Wait Seconds 10 If Slot(SLOT_TabletPower) < 500 Button 4 Color Black Button 5 Color Black EndIf Gosub ONOFF OUT Return Label ENAB.MOTORS Gosub WaitMotors Slot(Slot_EnableMotors) = 1000 'If ButtonVisible(2) ' Button 2 Text "DISAB.MOTORS" ' Button 2 Color GreenYellow 'EndIf Return Label DISAB.MOTORS Gosub WaitMotors Slot(Slot_EnableMotors) = 0 Slot Slot_RotHV_Drive = 600 ' If ButtonVisible(3) ' Button 3 Text "ENAB.MOTORS" ' Button 3 Color Red 'EndIf Return ' ===================================================================== ' SERVO-MOTORS MOVE SLOW ' ===================================================================== Variable Numeric Move_Slot Variable Numeric Move_Speed Variable Numeric Move_Dest Variable Numeric Move_Pos Label MoveSlow Move_Pos = Slot(Move_Slot) If Move_Dest > Move_Pos Move_Pos = Move_Pos + Move_Speed If Move_Pos > Move_Dest Move_Pos = Move_Dest EndIf Else Move_Pos = Move_Pos - Move_Speed If Move_Pos < Move_Dest Move_Pos = Move_Dest EndIf EndIf Slot(Move_Slot) = Move_Pos Wait Seconds 0.01 If Move_Pos = Move_Dest Return EndIf Goto MoveSlow ' ===================================================================== ' STEPPER-MOTORS MOVE SLOW ' ===================================================================== Variable Numeric MoveSlowXY_DestX ' destination in mm Variable Numeric MoveSlowXY_DestY ' destination in mm Variable Numeric MoveSlowXY_Speed ' speed in mm/sec Variable Numeric MSV1 Variable Numeric MSV2 Variable Numeric MSV3 Variable Numeric MSV4 Label MoveSlowXY ' ----------------------------------- test for very low speed If MoveSlowXY_Speed < 0.1 MoveSlowXY_Speed = 1 EndIf ' ----------------------------------- calc the movement in mm MSV1 = MoveSlowXY_DestX - DestX MSV2 = MoveSlowXY_DestY - DestY MSV3 = MSV1 * MSV1 MSV3 = MSV3 + MSV2 * MSV2 MSV3 = Sqrt(MSV3) ' ----------------------------------- calc the loops count MSV4 = MSV3 / 0.01 '<<< loop time MSV4 = Int(MSV4 / MoveSlowXY_Speed) ' ----------------------------------- too much speed ? If MSV4 = 0 DestX = MoveSlowXY_DestX DestY = MoveSlowXY_DestY Gosub CoreXY_MoveToDestXY_AndWait Return EndIf ' ----------------------------------- prepare the increments MSV1 = (MoveSlowXY_DestX - DestX) / MSV4 MSV2 = (MoveSlowXY_DestY - DestY) / MSV4 ' ----------------------------------- loop for v4 times For MSV3 = 1 To MSV4 ' ------------------------------- increment, move and wait DestX = DestX + MSV1 DestY = DestY + MSV2 Gosub CoreXY_MoveToDestXY Wait Seconds 0.01 '<<< loop time Next Gosub WaitMotors Return ' ===================================================================== ' STEPPER-MOTORS DRAW CIRCLE ' ===================================================================== Variable Numeric DrawCircle_X ' Center X in mm Variable Numeric DrawCircle_Y ' Center Y in mm Variable Numeric DrawCircle_Radius ' Radius in mm Variable Numeric DrawCircle_Speed ' Speed in mm/sec Variable Numeric DCV1 Variable Numeric DCV2 Variable Numeric DCV3 Variable Numeric DCV4 Label DrawCircle ' ----------------------------------- test for very low speed If DrawCircle_Speed < 0.1 DrawCircle_Speed = 1 EndIf ' ----------------------------------- calc the movement in mm DCV3 = DrawCircle_Radius * Math_PI * 2 ' ----------------------------------- calc the loops count DCV4 = DCV3 / 0.01 '<<< loop time DCV4 = Int(DCV4 / DrawCircle_Speed) ' ----------------------------------- too much speed ? If DCV4 < 16 DCV4 = 16 EndIf ' ----------------------------------- prepare the increments DCV1 = 2 * Math_PI / DCV4 ' ----------------------------------- loop for v4 times For DCV3 = 0 To DCV4 ' ------------------------------- calc circle DCV2 = DCV3 * DCV1 DestX = DrawCircle_X + DrawCircle_Radius * Sin(DCV2) DestY = DrawCircle_Y + DrawCircle_Radius * Cos(DCV2) ' ------------------------------- move and wait Gosub CoreXY_MoveToDestXY Wait Seconds 0.01 '<<< loop time Next Gosub WaitMotors Return ' ===================================================================== ' STEPPER-MOTORS and PEN action SLIDE ' ===================================================================== Variable Numeric Slide_DestX ' destination in mm Variable Numeric Slide_DestY ' destination in mm Variable Numeric Slide_Speed ' speed in mm/sec Variable Numeric Slide_PenUpTime ' pen-up time in mS from start Variable Numeric SLV1 Variable Numeric SLV2 Variable Numeric SLV3 Variable Numeric SLV4 Variable Numeric SLV5 Label SLIDE Gosub CoreXY_MoveToDestXY_AndWait Slide_DestX = 50 '50 Slide_DestY = 130 '130 Slide_Speed = 200 '200 Slide_PenUpTime = 500 '500 ' ----------------------------------- calc the movement in mm SLV1 = Slide_DestX - DestX SLV2 = Slide_DestY - DestY SLV3 = SLV1 * SLV1 SLV3 = SLV3 + SLV2 * SLV2 SLV3 = Sqrt(SLV3) ' ----------------------------------- calc the loops count SLV4 = SLV3 / 0.01 '<<< loop time SLV4 = Int(SLV4 / Slide_Speed) ' ----------------------------------- prepare the increments SLV1 = (Slide_DestX - DestX) / SLV4 SLV2 = (Slide_DestY - DestY) / SLV4 ' ----------------------------------- prepare the pen-up time SLV5 = Slide_PenUpTime / 1000 SLV5 = Int(SLV5 / 0.01) '<<< loop time ' ----------------------------------- pen down Slot(SLOT_PEN) = PEN_DOWN ' ----------------------------------- loop for v4 times For SLV3 = 1 To SLV4 ' ------------------------------- increment, move and wait DestX = DestX + SLV1 DestY = DestY + SLV2 Gosub CoreXY_MoveToDestXY Wait Seconds 0.01 '<<< loop time ' ------------------------------- pen up If SLV3 = SLV5 Slot(SLOT_PEN) = PEN_UP EndIf Next Gosub WaitMotors Return ' ===================================================================== ' ROTATIONS VERTICAL/HORIZZONTAL ' ===================================================================== Variable Numeric Slot_RotHV_Drive Variable Numeric Slot_RotHV_Current Variable Numeric Slot_RotHV_MaxCurrent Label ROTATE VERT Slot 998 = 600 'start Signal Scope Slot Slot_RotHV_Drive = 600 Wait Seconds 0.5 For v1 = 1 To 1300 ' <<< 1000 = 10 sec timeout (approx) Wait Seconds 0.009 If Slot(Slot_RotHV_Current) > Slot_RotHV_MaxCurrent Slot Slot_RotHV_Drive = 600 Slot 998 = 0 'stop Signal Scope Button 12 Label "ROTATE HORZ" Goto ExitRotateVert EndIf Next Slot Slot_RotHV_Drive = 600 Slot 998 = 0 'stop Signal Scope Button 12 Label "ROTATE HORZ" ' Label ExitRotateVert Return Label ROTATE MIDL Slot 998 = 600 'start Signal Scope Slot Slot_RotHV_Drive = 600 Wait Seconds 0.5 For v1 = 1 To 600 ' <<< 1000 = 10 sec timeout (approx) Wait Seconds 0.009 If Slot(Slot_RotHV_Current) > Slot_RotHV_MaxCurrent Slot Slot_RotHV_Drive = 600 Slot 998 = 0 'stop Signal Scope Goto ExitRotateMidl EndIf Next Slot Slot_RotHV_Drive = 600 Slot 998 = 0 'stop Signal Scope ' Label ExitRotateMidl Return Label ROTATE HORZ Slot 998 = 600 'start Signal Scope Slot Slot_RotHV_Drive = 0 Wait Seconds 0.3 For v1 = 1 To 1300 ' <<< 1000 = 10 sec timeout (approx) Wait Seconds 0.009 If Slot(Slot_RotHV_Current) > Slot_RotHV_MaxCurrent Slot Slot_RotHV_Drive = 600 Slot 998 = 0 'stop Signal Scope Button 12 Label ROTATE VERT Goto ExitRotateHorz EndIf Next Slot Slot_RotHV_Drive = 600 Slot 998 = 0 'stop Signal Scope Button 12 Label ROTATE VERT ' Label ExitRotateHorz Return ' ================================================ ' JOG WITH MOUSE ' ================================================ Variable Numeric Jog_Enable_Slot Variable Numeric Jog_RangeX Variable Numeric Jog_RangeY Variable Numeric Jog_Active Label JOG with Mouse Gosub ENAB.MOTORS Button 8 Label "JOG STOP" Jog_Active = 1 Label Jog2 If Slot(Jog_Enable_Slot) > 500 DestX = MouseX * Jog_RangeX DestY = MouseY * Jog_RangeY Gosub CoreXY_MoveToDestXY Print Format(DestX, "0.000") + " " + Format(DestY, "0.000") EndIf If Jog_Active = 0 Return EndIf Goto Jog2 Return Label JOG STOP Button 8 Label "JOG with Mouse" Jog_Active = 0 Return ' ==================================================================== ' JOG with keyboard ' ==================================================================== Label ExecKeys Variable Numeric KeyJog_Speed Variable Numeric JogSpeed JogSpeed = KeyJog_Speed / 100 Select True Case Key("SHIFT") JogSpeed = JogSpeed * 0.1 Case Key("CTRL") JogSpeed = JogSpeed * 0.01 Case Key("ALT") JogSpeed = JogSpeed * 0.001 EndSelect ' If Key("Right") DestX = DestX + JogSpeed EndIf If Key("Left") DestX = DestX - JogSpeed EndIf ' If Key("Up") DestY = DestY + JogSpeed EndIf If Key("Down") DestY = DestY - JogSpeed EndIf ' 'If Key("PageUp") ' Slot Slot_Z = Limit(Slot(Slot_Z) + JogSpeed, Zmin, Zmax) 'EndIf 'If Key("PageDown") ' Slot Slot_Z = Limit(Slot(Slot_Z) - JogSpeed, Zmin, Zmax) 'EndIf ' Gosub CoreXY_MoveToDestXY Gosub PrintValues Return ' ==================================================================== ' PRINT COORDINATES ' ==================================================================== Label PrintValues s1 = "DestX=" + Format(DestX, "0.000") s1 = s1 + " DestY=" + Format(DestY, "0.000") Print CRLF + s1 Return ' ============================================================================= ' Folder Demo Programs\Hilight Running Lines ' File TestSpeed.txt ' ============================================================================= Option Speed 9 v1 = 0 v2 = 0 Label loop1 v2 = v2 + 1 If v2 > 1000 v2 = 0 Print Format((ElapsedTime - v1) * 1000, "0.0") + " uS" v1 = ElapsedTime EndIf Goto loop1 ' ============================================================================= ' Folder Demo Programs\Hilight Running Lines ' File _Hilight_Test_1.txt ' ============================================================================= Variable String ButtonName1 ButtonName1 = "Test1" Button 1 Text ButtonName1 Button 2 Text "Button2" Button 4 Text "Button4" Button 5 Text "Button5" Button 6 Text "Button6" Button 7 Text "Button7" Button 8 Text "Button8" Button 9 Text "Button9" Option Speed 4 For v1 = 1 To 5 Button ButtonName1 Text ButtonName1 + " = " + Format(v1, "0") Button Button2 Text "Test2 = " + Format(v1, "0") Button Button4 Text "" + Format(Rnd * 10, "0.00000") Button Button5 Text "" + Format(Rnd * 10, "0.00000") Button Button6 Text "" + Format(Sin(Rnd) * 10, "0.00000") Button Button7 Text "" + Format(Cos(Rnd) * 10, "0.00000") Button Button8 Text "" + Format(Tan(Rnd) * 10, "0.00000") Button Button9 Text "" + Format(Log(Rnd) * 10, "0.00000") Print v1 Wait Seconds 0.01 Next Option Speed 9 For v1 = 1 To 50 Button ButtonName1 Text ButtonName1 + " = " + Format(v1, "0") Button Button2 Text "Test2 = " + Format(v1, "0") Button Button4 Text "" + Format(Rnd * 10, "0.00000") Button Button5 Text "" + Format(Rnd * 10, "0.00000") Button Button6 Text "" + Format(Sin(Rnd) * 10, "0.00000") Button Button7 Text "" + Format(Cos(Rnd) * 10, "0.00000") Button Button8 Text "" + Format(Tan(Rnd) * 10, "0.00000") Button Button9 Text "" + Format(Log(Rnd) * 10, "0.00000") Print v1 Wait Seconds 0.01 Next ' ============================================================================= ' Folder Demo Programs\Hilight Running Lines ' File _Hilight_Test_2.txt ' ============================================================================= Variable String ButtonName1 ButtonName1 = "Test1" Option Speed 4 For v1 = 0 To Infinity Button 1 Text ButtonName1 + " = " + Format(v1, "0") Button 2 Text "Test2 = " + Format(v1, "0") Button 4 Text Format(Rnd * 10, "0.00000") Button 5 Text Format(Rnd * 10, "0.00000") Button 6 Text Format(Sin(Rnd) * 10, "0.00000") Button 7 Text Format(Cos(Rnd) * 10, "0.00000") Button 8 Text Format(Tan(Rnd) * 10, "0.00000") Button 9 Text Format(Log(Rnd) * 10, "0.00000") Button 11 Text "Test1" + CRLF + "two lines" Button 12 Text "Test2" Print v1 Next Stop Label Test1 Wait Seconds 0.5 Option Speed 9 Return Label Test2 Wait Seconds 0.5 Option Speed 4 Return ' ============================================================================= ' Folder Demo Programs\Hilight Running Lines ' File _Hilight_Test_3.txt ' ============================================================================= ' --------------------------------------------------------------- ' Limit Example ' The V1 value is limited in the range 0 to 50 ' A sound is emitted when limits are reached ' --------------------------------------------------------------- Option Speed 9 Key Up Gosub Increase Key Down Gosub Decrease Label Stop Stop Label Increase v1 = Limit(v1 + 1, 0, 50) If LimitReached Beep Wait Seconds 0.5 EndIf Button 2 Text "Value = " + v1 Return Label Decrease v1 = Limit(v1 - 1, 0, 50) If LimitReached Beep Wait Seconds 0.5 EndIf Button 2 Text "Value = " + v1 Return ' ============================================================================= ' Folder Demo Programs\Homing Examples ' File MotorCalibration_C12_.txt ' ============================================================================= '╔═══════════════════════════════════════════════════════════╗ '║ Name: MotorCalibration_C12 Date: 24 Nov 2022 ║ '║ Author: Leonardo ║ '║ Scope: Test all the functionality of the PVC-150 ║ '╠═══════════════════════════════════════════════════════════╣ '║Hardware: 5 FeeTech STS3215 ║ '╟───────────────────────────────────────────────────────────╢ '║ Note: Vacuum motor and valve at 6V ║ '║ FeeTech at 7.5V ║ '╟───────────────────────────────────────────────────────────╢ '║ISO Culture Gender Age Name ║ '╟───────────────────────────────────────────────────────────╢ '║ENG EN-US Male Adult Microsoft David Desktop ║ '║ENG EN-US Female Adult Microsoft Zira Desktop ║ '║ITA IT-IT Female Adult Microsoft Elsa Desktop ║ '║JPN JA-JP Female Adult Microsoft Haruka Desktop ║ '║ZHO ZH-CN Female Adult Microsoft Huihui Desktop ║ '╚═══════════════════════════════════════════════════════════╝ Option Speed 9 Beep "2500 20, 1500 100" 'Load images\PVCArm_150.jpg TTS SelectVoice "ENG" s1 = TTSvoices TTS SetVolume 100 TTS SetSpeed -2 TTS SelectVoice 3 'TTS Speak "Theremino Automation programming language is running." ' ╔════════════════════════════════════════════╗ ' ║ SLOT TEXT for COMMANDS and RESPONSES ║ ' ╚════════════════════════════════════════════╝ Variable Numeric Slot_CommandsToMotors = 50 Variable Numeric Slot_CommandsToCobot = 51 Variable Numeric Slot_ResponsesFromCobot = 52 Variable Numeric Slot_ExternalCommands = 53 Variable Numeric Slot_ResponsesFromQRDecode = 54 Variable Numeric Slot_WordRecognized = 55 ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █▀▀█ ▀▀█▀▀ ' ║ SLOT INITIALIZATIONS ║ ▀▀▀█ █ █ █ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄ █▄▄█ █ 'Variable Numeric Slot_Vacuum = 1 Variable Numeric Slot_LedR = 7 Variable Numeric Slot_LedG = 8 Variable Numeric Slot_LedB = 9 'Variable Numeric Slot_Pedal = 10 Variable Numeric Slot_Pump = 11 Variable Numeric Slot_SignalScope = 13 Variable Numeric Slot_Slider1 = 2 Variable Numeric Slot_Slider2 = 3 Variable Numeric Slot_Slider3 = 4 Variable Numeric Slot_Slider4 = 5 Variable Numeric Slot_Slider5 = 6 Variable Numeric Slot_Encoder1 = 21 Variable Numeric Slot_Encoder2 = 22 Variable Numeric Slot_Encoder3 = 23 Variable Numeric Slot_Encoder4 = 24 Variable Numeric Slot_Encoder5 = 25 Variable Numeric Slot_EncoderSlow = 31 Variable Numeric Slot_M1 = 101 Variable Numeric Slot_M2 = 201 Variable Numeric Slot_M3 = 301 Variable Numeric Slot_M4 = 401 Variable Numeric Slot_M5 = 501 Variable Numeric Slot_M1pos = 102 Variable Numeric Slot_M2pos = 202 Variable Numeric Slot_M3pos = 302 Variable Numeric Slot_M4pos = 402 Variable Numeric Slot_M5pos = 502 Variable Numeric Slot_M1center = 123 Variable Numeric Slot_MotorsFPS = 56 ' ╔════════════════════════════════════════════╗ █▀▀▄ █ █ ▀▀█▀▀ ' ║ BUTTONS ║ █▀▀█ █ █ █ ' ╚════════════════════════════════════════════╝ █▄▄█ █▄▄█ █ Button 1 Label MotorFPS Button MotorFPS Text "NO MOTORS" Button MotorFPS Color Flashing7 Yellow DarkOrange Button 2 Label "MotorTemp" Button 3 Label CurrentMeter Button 4 Label GoToShow Button GoToShow Text "Go to show" Button GoToShow Color Yellow Button 5 Label GoToZero Button GoToZero Text "Go to Zero" Button GoToZero Color Yellow Button 7 Label CopyPositionsToDestinations Button CopyPositionsToDestinations Text "Copy Positions" + CRLF + "To Destinations" Button CopyPositionsToDestinations Color Orange Button 8 Label ActivateMotors Button ActivateMotors Text "Activate" + CRLF + "Motors" Button ActivateMotors Color Orange Button 9 Label RecognizeEncoder Button RecognizeEncoder Text "Recognize" + CRLF + "Encoder" Button RecognizeEncoder Color LightBlue 'Button 6 Label SetCenterHere 'Button SetCenterHere Text "Set Center Here" 'Button SetCenterHere Color Orange ' 'Button 7 Label CalibrateToZero 'Button CalibrateToZero Text "Calibrate to Zero" 'Button CalibrateToZero Color Orange ' ================================================ 'Button 2 Label JobQrCode 'Button JobQrCode Text "JOB QRcode" 'Button JobQrCode Color Cyan ' 'Button 4 Label Sliders 'Button Sliders Text "Sliders" 'Button Sliders Color Cyan 'Button 6 Label Voice 'Button Voice Text "Voice" 'Button Voice Color PaleTurquoise Button 10 Label TunaCans Button TunaCans Text "Tuna cans" Button TunaCans Color Indigo Button 11 Label WanpyJob Button WanpyJob Text "Wanpy Job" Button WanpyJob Color Indigo Button 12 Label StartPump Button StartPump Text "Start Pump" Button StartPump Color Lime Button 13 Label StopPump Button StopPump Text "Stop Pump" Button StopPump Color Crimson Button 15 Label CloseAll Button CloseAll Text "CLOSE ALL" Button CloseAll Color Red Button 17 Label Homing Button Homing Text "HOMING" Button Homing Color Gold Button 18 Label Homing1 Button Homing1 Text "Homing 1" Button Homing1 Color Yellow Button 19 Label Homing2 Button Homing2 Text "Homing 2" Button Homing2 Color Yellow Button 20 Label Homing3 Button Homing3 Text "Homing 3" Button Homing3 Color Yellow Button 21 Label Homing4 Button Homing4 Text "Homing 4" Button Homing4 Color Yellow Button 22 Label Homing5 Button Homing5 Text "Homing 5" Button Homing5 Color Yellow Button 24 Label SincroMovement Button SincroMovement Text "Sincro" + CRLF + "Movement" Button SincroMovement Color Orange Button 31 Label VoiceLoop Button VoiceLoop Text "VoiceLoop" Button VoiceLoop Color Blue Button 32 Label Say Button Say Text "Say" Button Say Color DeepSkyBlue ' ╔════════════════════════════════════════════╗ █ █▀▀█ █▀▀█ █▀▀▄ ' ║ LOAD APPS ║ █ █ █ █▄▄█ █ █ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄█ █ █ █▄▄█ Load Theremino_Motors.exe WaitApplicationsStarted '' ------------------------------------- ' MOTORS must be active before Cobot ' ------------------------------------- Load Theremino_HAL.exe Load Theremino_SlotViewer.exe Load Theremino_SlotViewer_Motors.exe Load Theremino_SlotViewer_STR.exe Load Theremino_MicroVideo.exe 'Load Theremino_QRdecoder.exe 'Load Theremino_VoiceCommands.exe Load Theremino_SlotViewer_Strings.exe Load Theremino_SignalScope_M1.exe Load Theremino_SignalScope_M2.exe Load Theremino_SignalScope_M3.exe Load Theremino_SignalScope_M4.exe 'Load Theremino_SignalScope_M5.exe Load Theremino_Cobot.exe 'WaitApplicationsStarted Load Hide ' ╔════════════════════════════════════════════╗ █▀▀▀ ▀▀█▀▀ █▀▀▀█ █▀▀▀█ ▀▀█▀▀ ' ║ EXECUTION START FROM HERE ║ ▀▀▀█ █ █▀▀▀█ █▀█▀▀ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █ █ █ ▀▄ █ ResetEncoders YellowOn Slot(Slot_SignalScope) = 1000 'CopyPositionsToDestinations 'DisableHomeButtons ' ------------------------- GOTO Homing - Command to Cobot 'WaitCobotReady 'SendCommand(Slot_CommandsToCobot)(GotoHoming) 'Homing 'Controls OpenTextBox 'Controls ClearTextBox Loop Stop ' ╔════════════════════════════════════════════╗ █ █▀▀█ █▀▀█ █▀▀█ ' ║ LOOP ║ █ █ █ █ █ █▄▄█ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄█ █▄▄█ █ Label Loop CurrentMeter ShowMotorFPS PositionDelta TestTemp 'InterpretateVoiceCommands Encoder If Slot(Slot_MotorsFPS) < 200 TestMotor Else TM1 = 0 EndIf If Slot(0) = -2 Print "Master disconnected." End EndIf Goto Loop Stop Label TestMotor Variable Numeric TM1 TM1 = TM1 + 1 If TM1 > 100 Print "The robot is not in POWER ON or serial port is not correct." TM1 = 0 End EndIf Return Label PositionDelta Slot(109) = Slot(101) - Slot(102) Slot(209) = Slot(201) - Slot(202) Slot(309) = Slot(301) - Slot(302) Slot(409) = Slot(401) - Slot(402) Slot(509) = Slot(501) - Slot(502) Return Label TestTemp Variable Numeric TT1 Variable Numeric TT2 = 0 'TT2 = 0 For TT1 = 1 To 3 '5 TT2 = Max(TT2, Slot(TT1 * 100 + 6)) Next Button MotorTemp Text "MaxT " + TT2 + "°C" Return ' ╔════════════════════════════════════════════╗ ' ║ ENABLE/DISABLE BUTTONS ║ ' ╚════════════════════════════════════════════╝ Label EnableAllButtons For v1 = 1 To 48 Button v1 Enabled Next Return Label DisableAllButtons For v1 = 1 To 48 Button v1 Disabled Next Return ' ╔════════════════════════════════════════════╗ ' ║ WAIT COBOT READY ║ ' ╚════════════════════════════════════════════╝ Label WaitCobotReady Variable Numeric WCR1 For WCR1 = 1 To Infinity Wait Seconds 0.05 If SlotText(Slot_ResponsesFromCobot) = "Ready" Exit EndIf Next Return ' ╔════════════════════════════════════════════╗ ' ║ WAIT APPS STARTED ║ ' ╚════════════════════════════════════════════╝ Label WaitApplicationsStarted Slot(Slot_MotorsFPS) = 0 Wait Slot(Slot_MotorsFPS) > 10 Wait Seconds 0.1 Return ' ╔════════════════════════════════════════════╗ █▀▀▀ ▀▀█▀▀ █▀▀█ █▀▀█ ' ║ STOP EVENT (when pressing stop button) ║ ▀▀▀█ █ █ █ █▄▄█ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █▄▄█ █ Label EventStop StopPump StopCobot Slot(Slot_SignalScope) = 0 ' GoToShow ' StopCobotAndGotoHoming End 'Label StopCobotAndGotoHoming ' 'StopCobot ' WaitMotorsNotMoving ' 'GotoSafePosition 'Return Label GotoSafePosition SendCommand(Slot_CommandsToCobot)(GotoHoming) WaitMotorsNotMoving Return ' ╔════════════════════════════════════════════╗ █▀▀ █ █▀▀█ █▀▀▀ █▀▀▀ ' ║ CLOSE ALL (when pressing X on form) ║ █ █ █ █ ▀▀▀█ █▀▀ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█ ▄▄▄█ █▄▄▄ Label CloseAll StopPump StopCobot Slot(Slot_SignalScope) = 0 ' GoToShow ' StopCobotAndGotoHoming Load CloseAll End ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand '(Destination Slot)(Command String) Variable Numeric SC1 Variable String SC2 Variable Numeric SC3 = 0.5 '<-- The timeout in seconds Variable Numeric SC4 SlotText SC1 = SC2 For SC4 = 0.1 To SC3 Step 0.1 If SlotText(SC1) = "" Exit EndIf Wait Seconds 0.1 Next Return ' ============================================================= ' COMMANDS to Cobot ' ============================================================= Label ExecCobot SendCommand(Slot_CommandsToCobot)(EnableRepeat) SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label StopCobot SendCommand(Slot_CommandsToCobot)(StopExecution) Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █ █▀█ ' ║ S U B R O U T I N E A R E A ║ ▀▀▀█ █ █ █▀▀█ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄█ █▄▄█ Label EnableHomeButtons For v1 = 17 To 22 Button v1 Enabled Next Return Label DisableHomeButtons For v1 = 17 To 22 Button v1 Disabled Next Return Label CurrentMeter Variable Numeric mA mA = Slot(108) + Slot(208) + Slot (308) + Slot (408) + Slot (508) mA = FilterLP(mA, 0.1, 1) '<-- Filter 0.5 seconds / 1 pole Button CurrentMeter Text "Current " + Str(mA, "0 mA") Return Label ShowMotorFPS Variable String MotorsAreEnabled Variable Numeric SMF1 = Slot(Slot_MotorsFPS) If SMF1 > 30 If MotorsAreEnabled <> "TRUE" MotorsAreEnabled = "TRUE" Button MotorFPS Color GreenYellow EndIf Button MotorFPS Text "FPS " + Str(SMF1) Else If MotorsAreEnabled = "TRUE" MotorsAreEnabled = "FALSE" Button MotorFPS Color Flashing7 Yellow DarkOrange Button MotorFPS Text "NO MOTORS" EndIf EndIf Return Label MotorFPS If MotorsAreEnabled = "TRUE" SendCommand(Slot_CommandsToMotors)(DisableConnection) Else SendCommand(Slot_CommandsToMotors)(EnableConnection) EndIf Return Label StartPump BlueOn 'Slot(Slot_SignScope) = 1000 Slot(Slot_Pump) = 1000 Button StartPump Disabled Button StopPump Enabled Wait Seconds 0.4 'If Slot(Slot_Vacuum) > 56 ' 'Beep "500, 300, 0, 300" ' 'SayVacuumProblem ' RedOn ' StopPump ' Print "Vacuum Problem" + CRLF ' 'CobotShowPoint ' Print "Execution stopped" + CRLF ' RedBlink ' End 'Else ' Print "Target picked" 'EndIf Return Label RecognizeEncoder Slot(0) = Recognize Return Label StopPump Slot(Slot_Pump) = 0 Button StopPump Disabled Button StartPump Enabled GreenOn Return Label GoToShow MoveMotorTo(4)(90)(0.1) MoveMotorTo(1) (0)(0.1) MoveMotorTo(3)(37)(0.1) MoveMotorTo(2)(20)(0.1) MoveMotorTo(5) (0)(0.1) Return Label GoToZero MoveMotorTo(4)(90)(0.1) MoveMotorTo(1)(0)(0.1) MoveMotorTo(2)(0)(0.1) MoveMotorTo(3)(0)(0.1) MoveMotorTo(5)(0)(0.1) MoveMotorTo(4)(0)(0.1) Return ' ╔════════════════════════════════════════════╗ █ █▀▀ █▀▄ ' ║ LED COLORS ║ █ █▀ █ █ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█ Label RedOn Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Return Label MagentaOn Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label YellowOn Slot Slot_LedR = 900 Slot Slot_LedG = 400 Slot Slot_LedB = 0 Return Label GreenOn Slot Slot_LedR = 0 Slot Slot_LedG = 1000 Slot Slot_LedB = 0 Return Label BlueOn Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label WhiteOn Slot Slot_LedR = 1000 Slot Slot_LedG = 1000 Slot Slot_LedB = 1000 Return Label RgbOff Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Return Label RedBlink RedOn WhiteOn Return ' ╔═════════════════════════╗ █▀▀▀ █▀▀█ █▄ ▄█ █▀▀ █▀▀▀ █▀▀█ █▀█ ' ║ COMMANDS FROM COBOT ║ █ █ █ █ ▀ █ █▀ █ █ █ █▀▀█ ' ╚═════════════════════════╝ █▄▄▄ █▄▄█ █ █ ▄ █ ▄ █▄▄▄ █▄▄█ █▄▄█ Label Event_ExternalCommands ' ------------------------------------------------------ Do not print lines containing '' 'Print " Exec: " + CommandText + CRLF ' ------------------------------------------------------ Select CommandText ' ---------------------------------------------- ACTIONS Case "RedOn" RedOn ClearCommand Case "GreenOn" GreenOn ClearCommand Case "BlueOn" BlueOn ClearCommand Case "WhiteOn" WhiteOn ClearCommand Case "MagentaOn" MagentaOn ClearCommand Case "YellowOn" YellowOn ClearCommand Case "Beep" Beep 880-100 ClearCommand Case "Pause" Wait Seconds GetSeparatedString(CommandText, 1) ClearCommand Case "StartPump" StartPump ClearCommand Case "StopPump" StopPump ClearCommand Case "Homing1" Homing1 ClearCommand Case "Homing2" Homing2 ClearCommand Case "Homing3" Homing3 ClearCommand Case "Homing4" Homing4 ClearCommand Case "Homing5" Homing5 ClearCommand Case "MemorizeQrCode" Variable Numeric MQR1 For MQR1 = 1 To 5 QrCode = SlotText(Slot_ResponsesFromQRDecode) Print QrCode If QrCode <> "" Exit EndIf If MQR1 = 5 SendCommand(Slot_CommandsToCobot)(StopExecution) EndIf Wait Seconds 1 Next ClearCommand Case "ExecQrCode" ExecQRcode ClearCommand Case "StartFichesPick" StartFichesPick ClearCommand Case "EndOfTask" EndOfTask ClearCommand CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + CommandText + CRLF Beep ClearCommand Stop ' EndSelect Return Label ClearCommand SlotText(Slot_ExternalCommands) = "" Return ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █▄ █ ' ║ WANPY ║ █ █ █▄▄█ █ ▀█ ' ╚════════════════════════════════════════════╝ ▀▄▀ █ █ █ █ Label WanpyJob TTS Speak "Wanpy job started." Controls OpenTextBox Controls ClearTextBox StartTime = ElapsedTime Wanpy_A5toB1 Return Variable String Status = "A5toB1" Label EndOfTask PrintTime StartTimePartial = ElapsedTime Select Status Case "A5toB1" 'Wanpy_B1toA5 Wanpy_A4toB2 Case "A4toB2" Wanpy_A3toB3 Case "A3toB3" Wanpy_A2toB4 Case "A2toB4" Wanpy_A1toB5 Case "A1toB5" Wanpy_B5toA1 Case "B5toA1" Wanpy_B4toA2 Case "B4toA2" Wanpy_B3toA3 Case "B3toA3" Wanpy_B2toA4 Case "B2toA4" Wanpy_B1toA5 Case "B1toA5" StartTime = ElapsedTime Print CRLF Wanpy_A5toB1 EndSelect Return Variable Numeric StartTime Variable Numeric StartTimePartial Variable String Time Label PrintTime Time = "Partial time = " Time = Time + PadLeft(Format(ElapsedTime - StartTimePartial, "0.0"),4) Time = Time + " Total time = " Time = Time + PadLeft(Format(ElapsedTime - StartTime, "0.0"),4) Print Status + " " + Time + CRLF Return Label Wanpy_A5toB1 Status = "A5toB1" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A5toB1.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A4toB2 Status = "A4toB2" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A4toB2.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A3toB3 Status = "A3toB3" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A3toB3.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A2toB4 Status = "A2toB4" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A2toB4.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A1toB5 Status = "A1toB5" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A1toB5.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B5toA1 Status = "B5toA1" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B5toA1.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B4toA2 Status = "B4toA2" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B4toA2.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B3toA3 Status = "B3toA3" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B3toA3.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B2toA4 Status = "B2toA4" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B2toA4.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B1toA5 Status = "B1toA5" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B1toA5.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return ' ╔════════════════════════════════════════════╗ █▀▀█ █▀▀█ █▀▀▀ ' ║ QR CODE ║ █ █ █▄▄█ █ ' ╚════════════════════════════════════════════╝ █▄██▄ █ ▀▄ █▄▄▄ Label JobQrCode TTS Speak "QR code recognition and action related is started." StartFichesPick Return Label StartFichesPick BlueOn SendCommand(Slot_CommandsToCobot)("LoadSequence fiches_pick.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label ExecQRcode Variable String QrCode Select QrCode Case "WHITE" WhiteOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_white.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "RED" RedOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_red.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "GREEN" GreenOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_green.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "BLUE" BlueOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_Place_blue.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "BLACK" RgbOff SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_black.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) CaseElse Controls OpenTextBox Print CRLF + " Unrecognized color command: " + CommandText + CRLF StopPump Beep ClearCommand Stop EndSelect Return ' ╔════════════════════════════════════════════╗ ▀▀█▀▀ █ █ █▄ █ ' ║ TUNA ║ █ █ █ █ ▀█ ' ╚════════════════════════════════════════════╝ █ █▄▄█ █ █ Label TunaCans TTS Speak "Tuna can handling." YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Tuna_Cans.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █ █▀▀▄ ' ║ SLIDERS ║ ▀▀▀█ █ █ █ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄ █ █▄▄█ Variable Numeric SLD Label Sliders BlueOn 'Button Sliders Color Flashing7 Blue White For SLD = 1 To Infinity Slot(Slot_M1) = Slot(Slot_Slider1) Slot(Slot_M2) = Slot(Slot_Slider2) Slot(Slot_M3) = Slot(Slot_Slider3) + Slot(Slot_Slider2) Slot(Slot_M4) = Slot(Slot_Slider4) Slot(Slot_M5) = Slot(Slot_Slider5) Next Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █▀▀█ ▀▄ ▄▀ ' ║ SAY ║ ▀▀▀█ █▄▄█ ▀▄▀ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █ █ Label Say TTS SelectVoice "ENGF" TTS Speak "Today is a beautiful day because we spend time together." Wait TTSready TTS SelectVoice "ITA FEM" TTS Speak "Oggi è una bella giornata perche passeremo del tempo insieme." Wait TTSready TTS SelectVoice "JPN" TTS Speak "私たちは一緒に時間を過ごすので、今日は美しい日です。" Wait TTSready TTS SelectVoice "ZHO" TTS Speak "今天是美好的一天,因为我们共度时光。" Wait TTSready Return ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █ █▀▀▀ █▀▀▀ ' ║ VOICE COMMANDS ║ █ █ █ █ █ █ █▀▀ ' ╚════════════════════════════════════════════╝ █ █▄▄█ █ █▄▄▄ █▄▄▄ Label Voice ClearVoiceCommand If VoiceCommandsStatus = "active" VoiceCommandsStatus = "" 'Button Voice Color PaleTurquoise Else VoiceCommandsStatus = "active" 'Button Voice Color Flashing7 Orange White EndIf Return Variable String Word Variable String VoiceCommandsStatus Label InterpretateVoiceCommands If VoiceCommandsStatus = "active" If SlotText(Slot_WordRecognized) <> "" Word = SlotText(Slot_WordRecognized) Print Word + " " Interpretate ClearVoiceCommand EndIf EndIf Return Variable String ShowingType Label Interpretate Select Word Case "show.fiches" If ShowingType = "" WhiteOn ShowingType = "Fiches" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Fiches.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "show.wanpy" If ShowingType = "" YellowOn ShowingType = "Wanpy" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Wanpy.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "show.tuna" If ShowingType = "" GreenOn ShowingType = "Tuna" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Tuna.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf '------------------------------------------------------------------------- Case "release" Select ShowingType Case "fiches" WhiteOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Fiches.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" Case "wanpy" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Wanpy.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" Case "tuna" GreenOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Tuna.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" CaseElse ' EndSelect '------------------------------------------------------------------------- Case "goto.center" If ShowingType = "" RedOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_goto_Center.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "goto.Homing" If ShowingType = "" MagentaOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_goto_Homing.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf '------------------------------------------------------------------------- CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + Word + CRLF Beep ClearCommand Stop EndSelect Return Label ClearVoiceCommand SlotText(Slot_WordRecognized) = "" Return ' ╔════════════════════════════════════════════╗ ▀▀█▀▀ █▀▀█ █ █▀▀█ █ ' ║ T R I A L S ║ █ █▄▄▀ █ █▄▄█ █ ' ╚════════════════════════════════════════════╝ █ █ ▀▄ █ █ █ █▄▄ Label SincroMovement Slot(Slot_M2) = 0 Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █▄ █ █▀▀▀ ' ║ ENCODERS ║ █▀▀ █ ▀█ █ ' ╚════════════════════════════════════════════╝ █▄▄▄ █ █ █▄▄▄ Variable Numeric EncoderSteps1 Variable Numeric OldEncoderSteps1 Variable Numeric Difference1 Variable Numeric EncoderSteps2 Variable Numeric OldEncoderSteps2 Variable Numeric Difference2 Variable Numeric EncoderSteps3 Variable Numeric OldEncoderSteps3 Variable Numeric Difference3 Variable Numeric EncoderSteps4 Variable Numeric OldEncoderSteps4 Variable Numeric Difference4 Variable Numeric EncoderSteps5 Variable Numeric OldEncoderSteps5 Variable Numeric Difference5 Label Encoder '------------------------------------------------ read encoder1 EncoderSteps1 = Slot(Slot_Encoder1) Difference1 = EncoderSteps1 - OldEncoderSteps1 OldEncoderSteps1 = EncoderSteps1 If Difference1 > 32000 Difference1 = Difference1 - 65536 EndIf If Difference1 < -32000 Difference1 = Difference1 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference1 = Difference1 * 0.1 EndIf Slot(Slot_M1) = Limit(Slot (Slot_M1) + Difference1, -73, +73) '------------------------------------------------ read encoder2 EncoderSteps2 = Slot(Slot_Encoder2) Difference2 = EncoderSteps2 - OldEncoderSteps2 OldEncoderSteps2 = EncoderSteps2 If Difference2 > 32000 Difference2 = Difference2 - 65536 EndIf If Difference2 < -32000 Difference2 = Difference2 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference2 = Difference2 * 0.1 EndIf Slot(Slot_M2) = Limit(Slot (Slot_M2) + Difference2, -41, +38) '------------------------------------------------ read encoder3 EncoderSteps3 = Slot(Slot_Encoder3) Difference3 = EncoderSteps3 - OldEncoderSteps3 OldEncoderSteps3 = EncoderSteps3 If Difference3 > 32000 Difference3 = Difference3 - 65536 EndIf If Difference3 < -32000 Difference3 = Difference3 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference3 = Difference3 * 0.1 EndIf Slot(Slot_M3) = Limit(Slot (Slot_M3) + Difference3, -66, 56) '------------------------------------------------ read encoder4 EncoderSteps4 = Slot(Slot_Encoder4) Difference4 = EncoderSteps4 - OldEncoderSteps4 OldEncoderSteps4 = EncoderSteps4 If Difference4 > 32000 Difference4 = Difference4 - 65536 EndIf If Difference4 < -32000 Difference4 = Difference4 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference4 = Difference4 * 0.1 EndIf Slot(Slot_M4) = Limit(Slot (Slot_M4) + Difference4, -110, +114) '------------------------------------------------ read encoder5 EncoderSteps5 = Slot(Slot_Encoder5) Difference5 = EncoderSteps5 - OldEncoderSteps5 OldEncoderSteps5 = EncoderSteps5 If Difference5 > 32000 Difference5 = Difference5 - 65536 EndIf If Difference5 < -32000 Difference5 = Difference5 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference5 = Difference5 * 0.1 EndIf Slot(Slot_M5) = Limit(Slot (Slot_M5) + Difference5, -105, +124) Return Label ResetEncoders OldEncoderSteps1 = Slot(Slot_Encoder1) OldEncoderSteps2 = Slot(Slot_Encoder2) OldEncoderSteps3 = Slot(Slot_Encoder3) OldEncoderSteps4 = Slot(Slot_Encoder4) OldEncoderSteps5 = Slot(Slot_Encoder5) Return ' ╔════════════════════════════════════════════╗ █▀▀█ █▀▀█ █ ' ║ CALIBRATIONS ║ █ █▄▄█ █ ' ╚════════════════════════════════════════════╝ █▄▄█ █ █ █▄▄▄ Label ResetAllMultiturnValues SendCommand(Slot_CommandsToMotors)("ResetAllMultiturnValues") Return Label CopyPositionsToDestinations Slot Slot_M1 = Slot(Slot_M1pos) Slot Slot_M2 = Slot(Slot_M2pos) Slot Slot_M3 = Slot(Slot_M3pos) Slot Slot_M4 = Slot(Slot_M4pos) Slot Slot_M5 = Slot(Slot_M5pos) Return Label ActivateMotors Variable Numeric AM1 For AM1 = 1 To 5 SetMotor_ON(AM1) Next SendCommand(Slot_CommandsToCobot)("SetTorque 550" ) SendCommand(Slot_CommandsToCobot)("SetAcceleration 100") SendCommand(Slot_CommandsToCobot)("SetSpeed 1000") SendCommand(Slot_CommandsToMotors)(ShowWindow) Return Label CalibrateMotorToZero '(Motor Number) Variable Numeric CMTZ1 SendCommand(Slot_CommandsToMotors)("Calibrate Motor " + CMTZ1 + " To 0") CMTZ1 = (CMTZ1*100-100) Slot(Slot_M1 + CMTZ1) = Slot(Slot_M1pos + CMTZ1) Return Label SetMotorCenterHere '(Motor Number) Variable Numeric SMC1 SMC1 = Slot_M1center + (SMC1*100-100) Slot SMC1 = 128 Wait Seconds 0.1 Slot SMC1 = 1 Wait Seconds 0.1 Return Label SetMotor_ON '(Motor Number) Variable Numeric SMON1 SMON1 = Slot_M1center + (SMON1*100-100) Slot SMON1 = 0 Wait Seconds 0.1 Slot SMON1 = 1 Wait Seconds 0.1 Return Label SetMotor_OFF '(Motor Number) Variable Numeric SMOFF1 SMOFF1 = Slot_M1center + (SMOFF1*100-100) Slot SMOFF1 = 0 Wait Seconds 0.1 Slot SMOFF1 = 1 Wait Seconds 0.1 Return Label WaitMotorsNotMoving Variable Numeric WMN1 For WMN1 = 1 To 5 WaitMotor(WMN1)(0.1) Next Return ' ------------------------------------------------------- ' The "Wait seconds" parameter is a initial delay ' If this delay is short and the motor starts slowly ' then the "WaitMotor" functions could exit immediately ' ------------------------------------------------------- Label WaitMotor '(Motor Number)(Wait seconds) Variable Numeric WM1 Variable Numeric WM2 WM1 = (WM1*100-100) Wait Seconds WM2 Variable Numeric WM3 For WM3 = 0 To Infinity 'If Slot(Slot_M1 + 2 + WM1) = 0 Or Key("CTRL") ' test Velocity ' Exit For 'EndIf If Slot(Slot_M1 + 6 + WM1) = 0 Or Key("CTRL") ' test Moving Exit For EndIf Next Return Label MoveMotorTo '(Motor Number)(Destination)(Wait seconds) Variable Numeric MMT1 Variable Numeric MMT2 Variable Numeric MMT3 Slot(Slot_M1 + MMT1*100-100) = MMT2 WaitMotor(MMT1)(MMT3) Return ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █▄ ▄█ █▀▀▀ ' ║ H O M I N G ║ █▀▀█ █ █ █ ▀ █ █▀▀ ' ╚════════════════════════════════════════════╝ █ █ █▄▄█ █ █ █▄▄▄ Label Homing WhiteOn Homing4 WhiteOn Homing5 WhiteOn Homing2 WhiteOn Homing3 WhiteOn Homing1 GreenOn Return Label GotoFinalPositions Slot(Slot_M1) = 0 Slot(Slot_M2) = 0 Slot(Slot_M3) = 0 Slot(Slot_M4) = 90 Slot(Slot_M5) = 0 Return Label Homing1 HomingMotor(1)(-0.3)(300)( +81)( 0)(400)(100)(1000) Return Label Homing2 HomingMotor(2)(+0.2)(300)( -42)( +26)(450)(100)(1000) Return Label Homing3 HomingMotor(3)(+0.2)(350)( -130)( 40)(400)(100)(1000) '-90 Return Label Homing4 HomingMotor(4)(+0.4)(300)(-115)(90)(350)(100)(1000) Return Label Homing5 HomingMotor(5)(+0.8)(300)(-127)( 0)(400)(100)(1000) Return Label HomingMotor ' ----------------------------------- Parameters Variable Numeric HM_MotNum Variable Numeric HM_SearchSpeed Variable Numeric HM_SearchTorque Variable Numeric HM_MoveToCenter Variable Numeric HM_MoveToFinal Variable Numeric HM_MotorTorque Variable Numeric HM_MotorAcc Variable Numeric HM_MotorSpeed ' ----------------------------------- Local Variables Variable Numeric HM_MotSlot HM_MotSlot = Slot_M1 + HM_MotNum * 100 - 100 Variable Numeric HM1 ' ----------------------------------- DisableAllButtons BlueOn FlashHomingButton(HM_MotNum) Slot(Slot_SignalScope) = 1000 SendCommand(Slot_CommandsToCobot)(StopExecution) SendCommand(Slot_CommandsToCobot)("SetTorque " + HM_MotorTorque) SendCommand(Slot_CommandsToCobot)("SetAcceleration " + HM_MotorAcc) SendCommand(Slot_CommandsToCobot)("SetSpeed " + HM_MotorSpeed) ResetAllMultiturnValues CalibrateMotorToZero(HM_MotNum) ' Calibrate To Zero For HM1 = 1 To Infinity Slot(HM_MotSlot) = Slot(HM_MotSlot) + HM_SearchSpeed If Abs(Slot(HM_MotSlot + 7)) > HM_SearchTorque ' +7=current Beep 2200 50 Exit EndIf If Abs(Slot(HM_MotSlot) - Slot(HM_MotSlot + 1)) > 30 Beep 800 100 SetMotorCenterHere(1) ' Set Center here CopyPositionsToDestinations EndIf Wait Seconds 0.01 Next ' ----------------------------------- Beep 2500 50 CalibrateMotorToZero(HM_MotNum) ' Calibrate To Zero MoveMotorTo(HM_MotNum)(HM_MoveToCenter)(1.5)' Move to Center CalibrateMotorToZero(HM_MotNum) ' Calibrate to Zero SetMotorCenterHere(HM_MotNum) ' Set Center here CalibrateMotorToZero(HM_MotNum) ' Calibrate to Zero MoveMotorTo(HM_MotNum)(HM_MoveToFinal)(0.1) ' Move to Final position Beep 2800 200 ' ----------------------------------- EnableAllButtons Slot(Slot_SignalScope) = 0 UnFlashHomingButtons Return Label FlashHomingButton Variable Numeric FHB1 ' First Param = Motor Number Select FHB1 Case 1 Button Homing1 Color Flashing6 Blue White Case 2 Button Homing2 Color Flashing6 Blue White Case 3 Button Homing3 Color Flashing6 Blue White Case 4 Button Homing4 Color Flashing6 Blue White Case 5 Button Homing5 Color Flashing6 Blue White 'Case 6 ' Button Homing6 Color Flashing6 Blue White 'Case 7 ' Button Homing7 Color Flashing6 Blue White EndSelect Return Label UnFlashHomingButtons Button Homing1 Color Yellow Button Homing2 Color Yellow Button Homing3 Color Yellow Button Homing4 Color Yellow Button Homing5 Color Yellow 'Button Homing6 Color Yellow 'Button Homing7 Color Yellow Return ' ============================================================================= ' Folder Demo Programs\Homing Examples ' File MotorCalib_Exibit_05.txt ' ============================================================================= '╔═══════════════════════════════════════════════════════════╗ '║ Name: MotorCalib_Exibit_04.txt Date: 09 Dic 2022 ║ '║ Author: Leonardo ║ '║ Scope: Test all the functionality of the PVC-150 ║ '╠═══════════════════════════════════════════════════════════╣ '║Hardware: 5 FeeTech STS3215 new MOTOR ║ '╟───────────────────────────────────────────────────────────╢ '║ Note: Vacuum motor and valve at 6V ║ '║ FeeTech at 7.5V ║ '╟───────────────────────────────────────────────────────────╢ '║ISO Culture Gender Age Name ║ '╟───────────────────────────────────────────────────────────╢ '║ENG EN-US Male Adult Microsoft David Desktop ║ '║ENG EN-US Female Adult Microsoft Zira Desktop ║ '║ITA IT-IT Female Adult Microsoft Elsa Desktop ║ '║JPN JA-JP Female Adult Microsoft Haruka Desktop ║ '║ZHO ZH-CN Female Adult Microsoft Huihui Desktop ║ '╚═══════════════════════════════════════════════════════════╝ Option Speed 9 Beep "2500 20, 1500 100" 'Load images\PVCArm_150.jpg TTS SelectVoice "ENG" s1 = TTSvoices TTS SetVolume 100 TTS SetSpeed -2 TTS SelectVoice 3 'TTS Speak "Theremino Automation programming language is running." ' ╔════════════════════════════════════════════╗ ' ║ SLOT TEXT for COMMANDS and RESPONSES ║ ' ╚════════════════════════════════════════════╝ Variable Numeric Slot_CommandsToMotors = 50 Variable Numeric Slot_CommandsToCobot = 51 Variable Numeric Slot_ResponsesFromCobot = 52 Variable Numeric Slot_ExternalCommands = 53 Variable Numeric Slot_ResponsesFromQRDecode = 54 Variable Numeric Slot_WordRecognized = 55 ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █▀▀█ ▀▀█▀▀ ' ║ SLOT INITIALIZATIONS ║ ▀▀▀█ █ █ █ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄ █▄▄█ █ 'Variable Numeric Slot_Vacuum = 1 Variable Numeric Slot_FiveButton = 26 Variable Numeric Slot_LedR = 7 Variable Numeric Slot_LedG = 8 Variable Numeric Slot_LedB = 9 'Variable Numeric Slot_Pedal = 10 Variable Numeric Slot_Pump = 11 Variable Numeric Slot_SignalScope = 13 Variable Numeric Slot_Slider1 = 2 Variable Numeric Slot_Slider2 = 3 Variable Numeric Slot_Slider3 = 4 Variable Numeric Slot_Slider4 = 5 Variable Numeric Slot_Slider5 = 6 Variable Numeric Slot_Encoder1 = 21 Variable Numeric Slot_Encoder2 = 22 Variable Numeric Slot_Encoder3 = 23 Variable Numeric Slot_Encoder4 = 24 Variable Numeric Slot_Encoder5 = 25 Variable Numeric Slot_EncoderSlow = 31 Variable Numeric Slot_M1 = 101 Variable Numeric Slot_M2 = 201 Variable Numeric Slot_M3 = 301 Variable Numeric Slot_M4 = 401 Variable Numeric Slot_M5 = 501 Variable Numeric Slot_M1pos = 102 Variable Numeric Slot_M2pos = 202 Variable Numeric Slot_M3pos = 302 Variable Numeric Slot_M4pos = 402 Variable Numeric Slot_M5pos = 502 Variable Numeric Slot_M1center = 123 Variable Numeric Slot_MotorsFPS = 56 ' ╔════════════════════════════════════════════╗ █▀▀▄ █ █ ▀▀█▀▀ ' ║ BUTTONS ║ █▀▀█ █ █ █ ' ╚════════════════════════════════════════════╝ █▄▄█ █▄▄█ █ Button 1 Label MotorFPS Button MotorFPS Text "NO MOTORS" Button MotorFPS Color Flashing7 Yellow DarkOrange Button 2 Label "MotorTemp" Button 3 Label CurrentMeter Button 4 Label GoToShow Button GoToShow Text "Go to show" Button GoToShow Color Yellow Button 5 Label GoToZero Button GoToZero Text "Go to Zero" Button GoToZero Color Yellow Button 6 Label Crouch Button Crouch Text "Go Crouch" Button Crouch Color Gold Button 7 Label CopyPositionsToDestinations Button CopyPositionsToDestinations Text "Copy Positions" + CRLF + "To Destinations" Button CopyPositionsToDestinations Color Orange 'Button 8 Label ActivateMotors 'Button ActivateMotors Text "Activate" + CRLF + "Motors" 'Button ActivateMotors Color Orange Button 9 Label RecognizeEncoder Button RecognizeEncoder Text "Recognize" + CRLF + "Encoder" Button RecognizeEncoder Color LightBlue 'Button 6 Label SetCenterHere 'Button SetCenterHere Text "Set Center Here" 'Button SetCenterHere Color Orange ' 'Button 7 Label CalibrateToZero 'Button CalibrateToZero Text "Calibrate to Zero" 'Button CalibrateToZero Color Orange ' ================================================ 'Button 2 Label JobQrCode 'Button JobQrCode Text "JOB QRcode" 'Button JobQrCode Color Cyan ' 'Button 4 Label Sliders 'Button Sliders Text "Sliders" 'Button Sliders Color Cyan 'Button 6 Label Voice 'Button Voice Text "Voice" 'Button Voice Color PaleTurquoise Button 10 Label TunaCans Button TunaCans Text "Tuna cans" Button TunaCans Color Indigo Button 11 Label WanpyJob5 Button WanpyJob5 Text "Wanpy Job 5" Button WanpyJob5 Color Indigo Button 12 Label StartPump Button StartPump Text "Start Pump" Button StartPump Color Lime Button 13 Label StopPump Button StopPump Text "Stop Pump" Button StopPump Color Crimson Button 15 Label CloseAll Button CloseAll Text "CLOSE ALL" Button CloseAll Color Red Button 17 Label Homing Button Homing Text "HOMING" Button Homing Color Gold Button 18 Label Homing1 Button Homing1 Text "Homing 1" Button Homing1 Color Yellow Button 19 Label Homing2 Button Homing2 Text "Homing 2" Button Homing2 Color Yellow Button 20 Label Homing3 Button Homing3 Text "Homing 3" Button Homing3 Color Yellow Button 21 Label Homing4 Button Homing4 Text "Homing 4" Button Homing4 Color Yellow Button 22 Label Homing5 Button Homing5 Text "Homing 5" Button Homing5 Color Yellow Button 24 Label CloseScopes Button CloseScopes Text "Close Scopes" Button CloseScopes Color SkyBlue Button 25 Label OpenScope_1 Button OpenScope_1 Text "Open Scope 1" Button OpenScope_1 Color PaleTurquoise Button 26 Label OpenScope_2 Button OpenScope_2 Text "Open Scope 2" Button OpenScope_2 Color PaleTurquoise Button 27 Label OpenScope_3 Button OpenScope_3 Text "Open Scope 3" Button OpenScope_3 Color PaleTurquoise Button 28 Label OpenScope_4 Button OpenScope_4 Text "Open Scope 4" Button OpenScope_4 Color PaleTurquoise Button 29 Label OpenScope_5 Button OpenScope_5 Text "Open Scope 5" Button OpenScope_5 Color PaleTurquoise Button 30 Label OpenFPS Button OpenFPS Text "Open FPS" Button OpenFPS Color PaleTurquoise Button 31 Label VoiceLoop Button VoiceLoop Text "VoiceLoop" Button VoiceLoop Color Blue Button 32 Label Say Button Say Text "Say" Button Say Color DeepSkyBlue ' ╔════════════════════════════════════════════╗ █ █▀▀█ █▀▀█ █▀▀▄ ' ║ LOAD APPS ║ █ █ █ █▄▄█ █ █ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄█ █ █ █▄▄█ Load Theremino_Motors.exe WaitApplicationsStarted '' ------------------------------------- ' MOTORS must be active before Cobot ' ------------------------------------- Load Theremino_HAL.exe Load Theremino_SlotViewer.exe Load Theremino_SlotViewer_Motors.exe Load Theremino_SlotViewer_STR.exe 'Load Theremino_MicroVideo.exe 'Load Theremino_QRdecoder.exe 'Load Theremino_VoiceCommands.exe Load Theremino_SlotViewer_Strings.exe Load Theremino_Cobot.exe 'WaitApplicationsStarted Load Hide ' ╔════════════════════════════════════════════╗ █▀▀▀ ▀▀█▀▀ █▀▀▀█ █▀▀▀█ ▀▀█▀▀ ' ║ EXECUTION START FROM HERE ║ ▀▀▀█ █ █▀▀▀█ █▀█▀▀ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █ █ █ ▀▄ █ ResetEncoders YellowOn Slot(Slot_SignalScope) = 1000 'CopyPositionsToDestinations 'DisableHomeButtons ' ------------------------- GOTO Homing - Command to Cobot 'WaitCobotReady 'SendCommand(Slot_CommandsToCobot)(GotoHoming) 'Homing 'Controls OpenTextBox 'Controls ClearTextBox Loop Stop ' ╔════════════════════════════════════════════╗ █ █▀▀█ █▀▀█ █▀▀█ ' ║ LOOP ║ █ █ █ █ █ █▄▄█ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄█ █▄▄█ █ Label Loop CurrentMeter ShowMotorFPS PositionDelta TestTemp InterpretateVoiceCommands Encoder FiveButton If Slot(Slot_MotorsFPS) < 5 Print "The robot is not in POWER ON or serial port is not correct." End EndIf If Slot(0) = -2 Print "Master disconnected." End EndIf Goto Loop Label PositionDelta Slot(109) = Slot(101) - Slot(102) Slot(209) = Slot(201) - Slot(202) Slot(309) = Slot(301) - Slot(302) Slot(409) = Slot(401) - Slot(402) Slot(509) = Slot(501) - Slot(502) Return Label TestTemp Variable Numeric TT1 Variable Numeric TT2 = 0 'TT2 = 0 For TT1 = 1 To 3 '5 TT2 = Max(TT2, Slot(TT1 * 100 + 6)) Next Button MotorTemp Text "MaxT " + TT2 + "°C" Return ' ╔════════════════════════════════════════════╗ ' ║ ENABLE/DISABLE BUTTONS ║ ' ╚════════════════════════════════════════════╝ Label EnableAllButtons For v1 = 1 To 48 Button v1 Enabled Next Return Label DisableAllButtons For v1 = 1 To 48 Button v1 Disabled Next Return ' ╔════════════════════════════════════════════╗ ' ║ WAIT COBOT READY ║ ' ╚════════════════════════════════════════════╝ Label WaitCobotReady Variable Numeric WCR1 For WCR1 = 1 To Infinity Wait Seconds 0.05 If SlotText(Slot_ResponsesFromCobot) = "Ready" Exit EndIf Next Return ' ╔════════════════════════════════════════════╗ ' ║ WAIT APPS STARTED ║ ' ╚════════════════════════════════════════════╝ Label WaitApplicationsStarted Slot(Slot_MotorsFPS) = 0 Wait Slot(Slot_MotorsFPS) > 10 Wait Seconds 0.1 Return ' ╔════════════════════════════════════════════╗ █▀▀▀ ▀▀█▀▀ █▀▀█ █▀▀█ ' ║ STOP EVENT (when pressing stop button) ║ ▀▀▀█ █ █ █ █▄▄█ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █▄▄█ █ Label EventStop StopPump StopCobot Slot(Slot_SignalScope) = 0 ' GoToShow ' StopCobotAndGotoHoming End 'Label StopCobotAndGotoHoming ' 'StopCobot ' WaitMotorsNotMoving ' 'GotoSafePosition 'Return Label GotoSafePosition SendCommand(Slot_CommandsToCobot)(GotoHoming) WaitMotorsNotMoving Return ' ╔════════════════════════════════════════════╗ █▀▀ █ █▀▀█ █▀▀▀ █▀▀▀ ' ║ CLOSE ALL (when pressing X on form) ║ █ █ █ █ ▀▀▀█ █▀▀ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█ ▄▄▄█ █▄▄▄ Label CloseAll StopPump StopCobot Slot(Slot_SignalScope) = 0 ' GoToShow ' StopCobotAndGotoHoming Load CloseAll End ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand '(Destination Slot)(Command String) Variable Numeric SC1 Variable String SC2 Variable Numeric SC3 = 0.5 '<-- The timeout in seconds Variable Numeric SC4 SlotText SC1 = SC2 For SC4 = 0.1 To SC3 Step 0.1 If SlotText(SC1) = "" Exit EndIf Wait Seconds 0.1 Next Return ' ============================================================= ' COMMANDS to Cobot ' ============================================================= Label ExecCobot SendCommand(Slot_CommandsToCobot)(EnableRepeat) SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label StopCobot SendCommand(Slot_CommandsToCobot)(StopExecution) Return Label ArrowUpCobot SendCommand(Slot_CommandsToCobot)(ArrowUp) Return Label ArrowDownCobot SendCommand(Slot_CommandsToCobot)(ArrowDown) Return Label ExecuteCobotFromSelectedLine SendCommand(Slot_CommandsToCobot)(StartExecution) Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █ █▀█ ' ║ S U B R O U T I N E A R E A ║ ▀▀▀█ █ █ █▀▀█ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄█ █▄▄█ Label EnableHomeButtons For v1 = 17 To 22 Button v1 Enabled Next Return Label DisableHomeButtons For v1 = 17 To 22 Button v1 Disabled Next Return Label CurrentMeter Variable Numeric mA mA = Slot(108) + Slot(208) + Slot (308) + Slot (408) + Slot (508) mA = FilterLP(mA, 0.1, 1) '<-- Filter 0.5 seconds / 1 pole Button CurrentMeter Text "Current " + Str(mA, "0 mA") Return Label ShowMotorFPS Variable String MotorsAreEnabled Variable Numeric SMF1 = Slot(Slot_MotorsFPS) If SMF1 > 30 If MotorsAreEnabled <> "TRUE" MotorsAreEnabled = "TRUE" Button MotorFPS Color GreenYellow EndIf Button MotorFPS Text "FPS " + Str(SMF1) Else If MotorsAreEnabled = "TRUE" MotorsAreEnabled = "FALSE" Button MotorFPS Color Flashing7 Yellow DarkOrange Button MotorFPS Text "NO MOTORS" EndIf EndIf Return Label MotorFPS If MotorsAreEnabled = "TRUE" SendCommand(Slot_CommandsToMotors)(DisableConnection) Else SendCommand(Slot_CommandsToMotors)(EnableConnection) EndIf Return Label StartPump BlueOn 'Slot(Slot_SignScope) = 1000 Slot(Slot_Pump) = 1000 Button StartPump Disabled Button StopPump Enabled Wait Seconds 0.4 'If Slot(Slot_Vacuum) > 56 ' 'Beep "500, 300, 0, 300" ' 'SayVacuumProblem ' RedOn ' StopPump ' Print "Vacuum Problem" + CRLF ' 'CobotShowPoint ' Print "Execution stopped" + CRLF ' RedBlink ' End 'Else ' Print "Target picked" 'EndIf Return Label RecognizeEncoder Slot(0) = Recognize Return Label StopPump Slot(Slot_Pump) = 0 Button StopPump Disabled Button StartPump Enabled GreenOn Return Label GoToShow MoveMotorTo(4)(50)(0.1) MoveMotorTo(1) (0)(0.1) MoveMotorTo(3)(-53)(0.1) MoveMotorTo(2)(16)(0.1) MoveMotorTo(5) (90)(0.1) Return Label GoToZero MoveMotorTo(4)(90)(0.1) MoveMotorTo(1)(0)(0.1) MoveMotorTo(2)(0)(0.1) MoveMotorTo(3)(0)(0.1) MoveMotorTo(5)(0)(0.1) MoveMotorTo(4)(0)(0.1) Return Label Crouch MoveMotorTo(4)(90)(0.1) MoveMotorTo(1)(-78)(0.1) MoveMotorTo(2)(36)(0.1) MoveMotorTo(3)(-53)(0.1) MoveMotorTo(5)(90)(0.1) MoveMotorTo(4)(4)(0.1) Return ' ╔════════════════════════════════════════════╗ █▀▀ █▀█ █ █ ▀▀█▀▀ ' ║ FIVE PUSH BUTTONS ║ ▀▀█ █▀▀█ █ █ █ ' ╚════════════════════════════════════════════╝ ▄▄█ █▄▄█ █▄▄█ █ Variable String PressedButton Label FiveButton Variable Numeric FB0 Variable Numeric FB1 FB1 = Slot(Slot_FiveButton) ' ------------------------------ Test buttons If FB0 = 0 FB0 = 1 Select True Case FB1 > 500 Print "" PressedButton = "" Case FB1 > 250 Print "red" PressedButton = "red" ExecuteCobotFromSelectedLine Case FB1 > 120 Print "white" PressedButton = "white" ExecCobot Case FB1 > 56 Print "green" PressedButton = "green" ArrowDownCobot Case FB1 > 15 Print "blue" PressedButton = "blue" ArrowUpCobot CaseElse Print "yellow" PressedButton = "yellow" EndSelect EndIf ' ------------------------------ Rearm buttons If FB1 > 500 FB0 = 0 EndIf Return Label CloseScopes Load CloseApps Theremino_SignalScope_M1.exe Load CloseApps Theremino_SignalScope_M2.exe Load CloseApps Theremino_SignalScope_M3.exe Load CloseApps Theremino_SignalScope_M4.exe Load CloseApps Theremino_SignalScope_M5.exe Load CloseApps Theremino_SignalScope_FPS.exe Return Label OpenScope_1 Load Theremino_SignalScope_M1.exe Return Label OpenScope_2 Load Theremino_SignalScope_M2.exe Return Label OpenScope_3 Load Theremino_SignalScope_M3.exe Return Label OpenScope_4 Load Theremino_SignalScope_M4.exe Return Label OpenScope_5 Load Theremino_SignalScope_M5.exe Return Label OpenFPS Load Theremino_SignalScope_FPS.exe Return ' ╔════════════════════════════════════════════╗ █ █▀▀ █▀▄ ' ║ LED COLORS ║ █ █▀ █ █ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█ Label RedOn Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Return Label MagentaOn Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label YellowOn Slot Slot_LedR = 900 Slot Slot_LedG = 400 Slot Slot_LedB = 0 Return Label GreenOn Slot Slot_LedR = 0 Slot Slot_LedG = 1000 Slot Slot_LedB = 0 Return Label BlueOn Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label WhiteOn Slot Slot_LedR = 1000 Slot Slot_LedG = 1000 Slot Slot_LedB = 1000 Return Label RgbOff Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Return Label RedBlink RedOn WhiteOn Return ' ╔═════════════════════════╗ █▀▀▀ █▀▀█ █▄ ▄█ █▀▀ █▀▀▀ █▀▀█ █▀█ ' ║ COMMANDS FROM COBOT ║ █ █ █ █ ▀ █ █▀ █ █ █ █▀▀█ ' ╚═════════════════════════╝ █▄▄▄ █▄▄█ █ █ ▄ █ ▄ █▄▄▄ █▄▄█ █▄▄█ Label Event_ExternalCommands ' ------------------------------------------------------ Do not print lines containing '' 'Print " Exec: " + CommandText + CRLF ' ------------------------------------------------------ Select CommandText ' ---------------------------------------------- ACTIONS Case "RedOn" RedOn ClearCommand Case "GreenOn" GreenOn ClearCommand Case "BlueOn" BlueOn ClearCommand Case "WhiteOn" WhiteOn ClearCommand Case "MagentaOn" MagentaOn ClearCommand Case "YellowOn" YellowOn ClearCommand Case "Beep" Beep 880-100 ClearCommand Case "Pause" Wait Seconds GetSeparatedString(CommandText, 1) ClearCommand Case "StartPump" StartPump ClearCommand Case "StopPump" StopPump ClearCommand Case "Homing1" Homing1 ClearCommand Case "Homing2" Homing2 ClearCommand Case "Homing3" Homing3 ClearCommand Case "Homing4" Homing4 ClearCommand Case "Homing5" Homing5 ClearCommand Case "MemorizeQrCode" Variable Numeric MQR1 For MQR1 = 1 To 5 QrCode = SlotText(Slot_ResponsesFromQRDecode) Print QrCode If QrCode <> "" Exit EndIf If MQR1 = 5 SendCommand(Slot_CommandsToCobot)(StopExecution) EndIf Wait Seconds 1 Next ClearCommand Case "ExecQrCode" ExecQRcode ClearCommand Case "StartFichesPick" StartFichesPick ClearCommand Case "EndOfTask" EndOfTask ClearCommand Case "Executing" ClearCommand CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + CommandText + CRLF Beep ClearCommand Stop ' EndSelect Return Label ClearCommand SlotText(Slot_ExternalCommands) = "" Return ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █▄ █ █▀▀▀ ' ║ WANPY 5 ║ █ █ █▄▄█ █ ▀█ ▀▀▀█ ' ╚════════════════════════════════════════════╝ ▀▄▀ █ █ █ █ ▄▄▄█ Label WanpyJob5 TTS Speak "Wanpy job started." Controls OpenTextBox Controls ClearTextBox StartTime = ElapsedTime Wanpy_A5toB1 Return Variable String Status = "A5toB1" Label EndOfTask PrintTime StartTimePartial = ElapsedTime Select Status Case "A5toB1" 'Wanpy_B1toA5 Wanpy_A4toB2 Case "A4toB2" Wanpy_A3toB3 Case "A3toB3" Wanpy_A2toB4 Case "A2toB4" Wanpy_A1toB5 Case "A1toB5" Wanpy_B5toA1 Case "B5toA1" Wanpy_B4toA2 Case "B4toA2" Wanpy_B3toA3 Case "B3toA3" Wanpy_B2toA4 Case "B2toA4" Wanpy_B1toA5 Case "B1toA5" StartTime = ElapsedTime Print CRLF Wanpy_A5toB1 EndSelect Return Variable Numeric StartTime Variable Numeric StartTimePartial Variable String Time Label PrintTime Time = "Partial time = " Time = Time + PadLeft(Format(ElapsedTime - StartTimePartial, "0.0"),4) Time = Time + " Total time = " Time = Time + PadLeft(Format(ElapsedTime - StartTime, "0.0"),4) Print Status + " " + Time + CRLF Return Label Wanpy_A5toB1 Status = "A5toB1" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A5toB1.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A4toB2 Status = "A4toB2" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A4toB2.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A3toB3 Status = "A3toB3" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A3toB3.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A2toB4 Status = "A2toB4" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A2toB4.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A1toB5 Status = "A1toB5" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A1toB5.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B5toA1 Status = "B5toA1" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B5toA1.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B4toA2 Status = "B4toA2" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B4toA2.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B3toA3 Status = "B3toA3" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B3toA3.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B2toA4 Status = "B2toA4" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B2toA4.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B1toA5 Status = "B1toA5" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B1toA5.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return ' ╔════════════════════════════════════════════╗ █▀▀█ █▀▀█ █▀▀▀ ' ║ QR CODE ║ █ █ █▄▄█ █ ' ╚════════════════════════════════════════════╝ █▄██▄ █ ▀▄ █▄▄▄ Label JobQrCode TTS Speak "QR code recognition and action related is started." StartFichesPick Return Label StartFichesPick BlueOn SendCommand(Slot_CommandsToCobot)("LoadSequence fiches_pick.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label ExecQRcode Variable String QrCode Select QrCode Case "WHITE" WhiteOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_white.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "RED" RedOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_red.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "GREEN" GreenOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_green.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "BLUE" BlueOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_Place_blue.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "BLACK" RgbOff SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_black.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) CaseElse Controls OpenTextBox Print CRLF + " Unrecognized color command: " + CommandText + CRLF StopPump Beep ClearCommand Stop EndSelect Return ' ╔════════════════════════════════════════════╗ ▀▀█▀▀ █ █ █▄ █ ' ║ TUNA ║ █ █ █ █ ▀█ ' ╚════════════════════════════════════════════╝ █ █▄▄█ █ █ Label TunaCans TTS Speak "Tuna can handling." YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Tuna_Cans.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █ █▀▀▄ ' ║ SLIDERS ║ ▀▀▀█ █ █ █ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄ █ █▄▄█ Variable Numeric SLD Label Sliders BlueOn 'Button Sliders Color Flashing7 Blue White For SLD = 1 To Infinity Slot(Slot_M1) = Slot(Slot_Slider1) Slot(Slot_M2) = Slot(Slot_Slider2) Slot(Slot_M3) = Slot(Slot_Slider3) + Slot(Slot_Slider2) Slot(Slot_M4) = Slot(Slot_Slider4) Slot(Slot_M5) = Slot(Slot_Slider5) Next Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █▀▀█ ▀▄ ▄▀ ' ║ SAY ║ ▀▀▀█ █▄▄█ ▀▄▀ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █ █ Label Say TTS SelectVoice "ENGF" TTS Speak "Today is a beautiful day because we spend time together." Wait TTSready TTS SelectVoice "ITA FEM" TTS Speak "Oggi è una bella giornata perche passeremo del tempo insieme." Wait TTSready TTS SelectVoice "JPN" TTS Speak "私たちは一緒に時間を過ごすので、今日は美しい日です。" Wait TTSready TTS SelectVoice "ZHO" TTS Speak "今天是美好的一天,因为我们共度时光。" Wait TTSready Return ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █ █▀▀▀ █▀▀▀ ' ║ VOICE COMMANDS ║ █ █ █ █ █ █ █▀▀ ' ╚════════════════════════════════════════════╝ █ █▄▄█ █ █▄▄▄ █▄▄▄ Label Voice ClearVoiceCommand If VoiceCommandsStatus = "active" VoiceCommandsStatus = "" 'Button Voice Color PaleTurquoise Else VoiceCommandsStatus = "active" 'Button Voice Color Flashing7 Orange White EndIf Return Variable String Word Variable String VoiceCommandsStatus Label InterpretateVoiceCommands If VoiceCommandsStatus = "active" If SlotText(Slot_WordRecognized) <> "" Word = SlotText(Slot_WordRecognized) Print Word + " " Interpretate ClearVoiceCommand EndIf EndIf Return Variable String ShowingType Label Interpretate Select Word Case "show.fiches" If ShowingType = "" WhiteOn ShowingType = "Fiches" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Fiches.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "show.wanpy" If ShowingType = "" YellowOn ShowingType = "Wanpy" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Wanpy.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "show.tuna" If ShowingType = "" GreenOn ShowingType = "Tuna" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Tuna.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf '------------------------------------------------------------------------- Case "release" Select ShowingType Case "fiches" WhiteOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Fiches.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" Case "wanpy" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Wanpy.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" Case "tuna" GreenOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Tuna.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" CaseElse ' EndSelect '------------------------------------------------------------------------- Case "goto.center" If ShowingType = "" RedOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_goto_Center.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "goto.Homing" If ShowingType = "" MagentaOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_goto_Homing.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf '------------------------------------------------------------------------- CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + Word + CRLF Beep ClearCommand Stop EndSelect Return Label ClearVoiceCommand SlotText(Slot_WordRecognized) = "" Return ' ╔════════════════════════════════════════════╗ ▀▀█▀▀ █▀▀█ █ █▀▀█ █ ' ║ T R I A L S ║ █ █▄▄▀ █ █▄▄█ █ ' ╚════════════════════════════════════════════╝ █ █ ▀▄ █ █ █ █▄▄ ' ╔════════════════════════════════════════════╗ █▀▀▀ █▄ █ █▀▀▀ ' ║ ENCODERS ║ █▀▀ █ ▀█ █ ' ╚════════════════════════════════════════════╝ █▄▄▄ █ █ █▄▄▄ Variable Numeric EncoderSteps1 Variable Numeric OldEncoderSteps1 Variable Numeric Difference1 Variable Numeric EncoderSteps2 Variable Numeric OldEncoderSteps2 Variable Numeric Difference2 Variable Numeric EncoderSteps3 Variable Numeric OldEncoderSteps3 Variable Numeric Difference3 Variable Numeric EncoderSteps4 Variable Numeric OldEncoderSteps4 Variable Numeric Difference4 Variable Numeric EncoderSteps5 Variable Numeric OldEncoderSteps5 Variable Numeric Difference5 Label Encoder '------------------------------------------------ encoder1 to mot 1 or 6 EncoderSteps1 = Slot(Slot_Encoder1) Difference1 = EncoderSteps1 - OldEncoderSteps1 OldEncoderSteps1 = EncoderSteps1 If Difference1 > 32000 Difference1 = Difference1 - 65536 EndIf If Difference1 < -32000 Difference1 = Difference1 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference1 = Difference1 * 0.1 EndIf If PressedButton <> "yellow" Slot(Slot_M1) = Limit(Slot (Slot_M1) + Difference1, -130, +130) Else 'Slot(Slot_M6) = Limit(Slot (Slot_M6) + Difference1, -130, +130) EndIf '------------------------------------------------ read encoder2 EncoderSteps2 = Slot(Slot_Encoder2) Difference2 = EncoderSteps2 - OldEncoderSteps2 OldEncoderSteps2 = EncoderSteps2 If Difference2 > 32000 Difference2 = Difference2 - 65536 EndIf If Difference2 < -32000 Difference2 = Difference2 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference2 = Difference2 * 0.1 EndIf Slot(Slot_M2) = Limit(Slot (Slot_M2) + Difference2, -130, +130) '------------------------------------------------ read encoder3 EncoderSteps3 = Slot(Slot_Encoder3) Difference3 = EncoderSteps3 - OldEncoderSteps3 OldEncoderSteps3 = EncoderSteps3 If Difference3 > 32000 Difference3 = Difference3 - 65536 EndIf If Difference3 < -32000 Difference3 = Difference3 + 65536 EndIf Difference3 = Difference3 * 0.5 If Slot(Slot_EncoderSlow) < 500 Difference3 = Difference3 * 0.1 EndIf Slot(Slot_M3) = Limit(Slot (Slot_M3) + Difference3, -130, +130) '------------------------------------------------ read encoder4 EncoderSteps4 = Slot(Slot_Encoder4) Difference4 = EncoderSteps4 - OldEncoderSteps4 OldEncoderSteps4 = EncoderSteps4 If Difference4 > 32000 Difference4 = Difference4 - 65536 EndIf If Difference4 < -32000 Difference4 = Difference4 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference4 = Difference4 * 0.01 EndIf Slot(Slot_M4) = Limit(Slot (Slot_M4) + Difference4, -170, +170) '------------------------------------------------ read encoder5 EncoderSteps5 = Slot(Slot_Encoder5) Difference5 = EncoderSteps5 - OldEncoderSteps5 OldEncoderSteps5 = EncoderSteps5 If Difference5 > 32000 Difference5 = Difference5 - 65536 EndIf If Difference5 < -32000 Difference5 = Difference5 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference5 = Difference5 * 0.1 EndIf Slot(Slot_M5) = Limit(Slot (Slot_M5) + Difference5, -130, +130) Return Label ResetEncoders OldEncoderSteps1 = Slot(Slot_Encoder1) OldEncoderSteps2 = Slot(Slot_Encoder2) OldEncoderSteps3 = Slot(Slot_Encoder3) OldEncoderSteps4 = Slot(Slot_Encoder4) OldEncoderSteps5 = Slot(Slot_Encoder5) Return ' ╔════════════════════════════════════════════╗ █▀▀█ █▀▀█ █ ' ║ CALIBRATIONS ║ █ █▄▄█ █ ' ╚════════════════════════════════════════════╝ █▄▄█ █ █ █▄▄▄ Label ResetAllMultiturnValues SendCommand(Slot_CommandsToMotors)("ResetAllMultiturnValues") Return Label CopyPositionsToDestinations Slot Slot_M1 = Slot(Slot_M1pos) Slot Slot_M2 = Slot(Slot_M2pos) Slot Slot_M3 = Slot(Slot_M3pos) Slot Slot_M4 = Slot(Slot_M4pos) Slot Slot_M5 = Slot(Slot_M5pos) Return Label ActivateMotors Variable Numeric AM1 For AM1 = 1 To 5 SetMotor_ON(AM1) Next SendCommand(Slot_CommandsToCobot)("SetTorque 550" ) SendCommand(Slot_CommandsToCobot)("SetAcceleration 100") SendCommand(Slot_CommandsToCobot)("SetSpeed 1000") SendCommand(Slot_CommandsToMotors)(ShowWindow) Return Label CalibrateMotorToZero '(Motor Number) Variable Numeric CMTZ1 SendCommand(Slot_CommandsToMotors)("Calibrate Motor " + CMTZ1 + " To 0") CMTZ1 = (CMTZ1*100-100) Slot(Slot_M1 + CMTZ1) = Slot(Slot_M1pos + CMTZ1) Return Label SetMotorCenterHere '(Motor Number) Variable Numeric SMC1 SMC1 = Slot_M1center + (SMC1*100-100) Slot SMC1 = 128 Wait Seconds 0.1 Slot SMC1 = 1 Wait Seconds 0.1 Return Label SetMotor_ON '(Motor Number) Variable Numeric SMON1 SMON1 = Slot_M1center + (SMON1*100-100) Slot SMON1 = 0 Wait Seconds 0.1 Slot SMON1 = 1 Wait Seconds 0.1 Return Label SetMotor_OFF '(Motor Number) Variable Numeric SMOFF1 SMOFF1 = Slot_M1center + (SMOFF1*100-100) Slot SMOFF1 = 0 Wait Seconds 0.1 Slot SMOFF1 = 1 Wait Seconds 0.1 Return Label WaitMotorsNotMoving Variable Numeric WMN1 For WMN1 = 1 To 5 WaitMotor(WMN1)(0.1) Next Return ' ------------------------------------------------------- ' The "Wait seconds" parameter is a initial delay ' If this delay is short and the motor starts slowly ' then the "WaitMotor" functions could exit immediately ' ------------------------------------------------------- Label WaitMotor '(Motor Number)(Wait seconds) Variable Numeric WM1 Variable Numeric WM2 WM1 = (WM1*100-100) Wait Seconds WM2 Variable Numeric WM3 For WM3 = 0 To Infinity If Slot(Slot_M1 + 2 + WM1) = 0 Or Key("CTRL") ' test Velocity Exit For EndIf 'If Slot(Slot_M1 + 6 + WM1) = 0 Or Key("CTRL") ' test Moving ' Exit For 'EndIf Next Return Label MoveMotorTo '(Motor Number)(Destination)(Wait seconds) Variable Numeric MMT1 Variable Numeric MMT2 Variable Numeric MMT3 Slot(Slot_M1 + MMT1*100-100) = MMT2 WaitMotor(MMT1)(MMT3) Return ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █▄ ▄█ █▀▀▀ ' ║ H O M I N G ║ █▀▀█ █ █ █ ▀ █ █▀▀ ' ╚════════════════════════════════════════════╝ █ █ █▄▄█ █ █ █▄▄▄ Label Homing WhiteOn Homing4 WhiteOn Homing5 WhiteOn Homing2 WhiteOn Homing3 WhiteOn Homing1 GreenOn Return Label GotoFinalPositions Slot(Slot_M1) = 0 Slot(Slot_M2) = 0 Slot(Slot_M3) = 0 Slot(Slot_M4) = 90 Slot(Slot_M5) = 0 Return Label Homing1 OpenScope_1 HomingMotor(1)(-0.3)(300)( +81)( 0)(400)(100)(1000) CloseScopes Return Label Homing2 OpenScope_2 HomingMotor(2)(+0.2)(200)( -38)(+22)(250)(100)(1000) CloseScopes Return Label Homing3 OpenScope_3 HomingMotor(3)(+0.2)(350)( -50)( 0)(400)(100)(1000) CloseScopes Return Label Homing4 OpenScope_4 HomingMotor(4)(+0.4)(300)(-93.5)(90)(350)(100)(1000) CloseScopes Return Label Homing5 OpenScope_5 HomingMotor(5)(+0.8)(300)(-127)( 0)(400)(100)(1000) CloseScopes Return Label HomingMotor ' ----------------------------------- Parameters Variable Numeric HM_MotNum Variable Numeric HM_SearchSpeed Variable Numeric HM_SearchTorque Variable Numeric HM_MoveToCenter Variable Numeric HM_MoveToFinal Variable Numeric HM_MotorTorque Variable Numeric HM_MotorAcc Variable Numeric HM_MotorSpeed ' ----------------------------------- Local Variables Variable Numeric HM_MotSlot HM_MotSlot = Slot_M1 + HM_MotNum * 100 - 100 Variable Numeric HM1 ' ----------------------------------- DisableAllButtons BlueOn FlashHomingButton(HM_MotNum) Slot(Slot_SignalScope) = 1000 SendCommand(Slot_CommandsToCobot)(StopExecution) SendCommand(Slot_CommandsToCobot)("SetTorque " + HM_MotorTorque) SendCommand(Slot_CommandsToCobot)("SetAcceleration " + HM_MotorAcc) SendCommand(Slot_CommandsToCobot)("SetSpeed " + HM_MotorSpeed) ResetAllMultiturnValues CalibrateMotorToZero(HM_MotNum) ' Calibrate To Zero For HM1 = 1 To Infinity Slot(HM_MotSlot) = Slot(HM_MotSlot) + HM_SearchSpeed If Abs(Slot(HM_MotSlot + 7)) > HM_SearchTorque ' +7=current Beep 2200 50 Exit EndIf If Abs(Slot(HM_MotSlot) - Slot(HM_MotSlot + 1)) > 30 Beep 800 100 SetMotorCenterHere(1) ' Set Center here CopyPositionsToDestinations EndIf Wait Seconds 0.01 Next ' ----------------------------------- Beep 2500 50 CalibrateMotorToZero(HM_MotNum) ' Calibrate To Zero MoveMotorTo(HM_MotNum)(HM_MoveToCenter)(1.5)' Move to Center CalibrateMotorToZero(HM_MotNum) ' Calibrate to Zero SetMotorCenterHere(HM_MotNum) ' Set Center here CalibrateMotorToZero(HM_MotNum) ' Calibrate to Zero MoveMotorTo(HM_MotNum)(HM_MoveToFinal)(0.1) ' Move to Final position Beep 2800 200 ' ----------------------------------- EnableAllButtons Slot(Slot_SignalScope) = 0 UnFlashHomingButtons Return Label FlashHomingButton Variable Numeric FHB1 ' First Param = Motor Number Select FHB1 Case 1 Button Homing1 Color Flashing6 Blue White Case 2 Button Homing2 Color Flashing6 Blue White Case 3 Button Homing3 Color Flashing6 Blue White Case 4 Button Homing4 Color Flashing6 Blue White Case 5 Button Homing5 Color Flashing6 Blue White 'Case 6 ' Button Homing6 Color Flashing6 Blue White 'Case 7 ' Button Homing7 Color Flashing6 Blue White EndSelect Return Label UnFlashHomingButtons Button Homing1 Color Yellow Button Homing2 Color Yellow Button Homing3 Color Yellow Button Homing4 Color Yellow Button Homing5 Color Yellow 'Button Homing6 Color Yellow 'Button Homing7 Color Yellow Return ' ============================================================================= ' Folder Demo Programs\Homing Examples ' File PVCArm_140_26.txt ' ============================================================================= '╔═══════════════════════════════════════════════════════════╗ '║ Name: PVCArm140Voice_26.txt Date: 21 Oct 2022 ║ '║ Author: Leonardo ║ '║ Scope: Test all the functionality of the PVC-140 COBOT ║ '╠═══════════════════════════════════════════════════════════╣ '║Hardware: 5 FeeTech STS3215 ║ '╟───────────────────────────────────────────────────────────╢ '║ Note: Vacuum motor and valvle at 6V ║ '║ FeeTech at 7.5V ║ '╟───────────────────────────────────────────────────────────╢ '║ISO Culture Gender Age Name ║ '╟───────────────────────────────────────────────────────────╢ '║ENG EN-US Male Adult Microsoft David Desktop ║ '║ENG EN-US Female Adult Microsoft Zira Desktop ║ '║ITA IT-IT Female Adult Microsoft Elsa Desktop ║ '║JPN JA-JP Female Adult Microsoft Haruka Desktop ║ '║ZHO ZH-CN Female Adult Microsoft Huihui Desktop ║ '╚═══════════════════════════════════════════════════════════╝ Option Speed 9 Beep "2500 20, 1500 100" 'Load images\PVCArm_140.jpg TTS SelectVoice "ENG" s1 = TTSvoices TTS SetVolume 100 TTS SetSpeed -2 TTS SelectVoice 3 'TTS Speak "Theremino Automation programming language is running." ' ╔════════════════════════════════════════════╗ ' ║ SLOT TEXT for COMMANDS and RESPONSES ║ ' ╚════════════════════════════════════════════╝ Variable Numeric Slot_CommandsToMotors = 50 Variable Numeric Slot_CommandsToCobot = 51 Variable Numeric Slot_ResponsesFromCobot = 52 Variable Numeric Slot_ExternalCommands = 53 Variable Numeric Slot_ResponsesFromQRDecode = 54 Variable Numeric Slot_WordRecognized = 55 ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █▀▀█ ▀▀█▀▀ ' ║ SLOT INITIALIZATIONS ║ ▀▀▀█ █ █ █ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄ █▄▄█ █ Variable Numeric Slot_Vacuum = 1 Variable Numeric Slot_LedR = 7 Variable Numeric Slot_LedG = 8 Variable Numeric Slot_LedB = 9 Variable Numeric Slot_Pedal = 10 Variable Numeric Slot_Pump = 11 Variable Numeric Slot_SignalScope = 13 Variable Numeric Slot_Slider1 = 2 Variable Numeric Slot_Slider2 = 3 Variable Numeric Slot_Slider3 = 4 Variable Numeric Slot_Slider4 = 5 Variable Numeric Slot_Slider5 = 6 Variable Numeric Slot_Encoder1 = 21 Variable Numeric Slot_Encoder2 = 22 Variable Numeric Slot_Encoder3 = 23 Variable Numeric Slot_Encoder4 = 24 Variable Numeric Slot_Encoder5 = 25 Variable Numeric Slot_EncoderSlow = 31 Variable Numeric Slot_M1 = 101 Variable Numeric Slot_M2 = 201 Variable Numeric Slot_M3 = 301 Variable Numeric Slot_M4 = 401 Variable Numeric Slot_M5 = 501 Variable Numeric Slot_RS485_FPS = 56 ' ╔════════════════════════════════════════════╗ █▀▀▄ █ █ ▀▀█▀▀ ' ║ BUTTONS ║ █▀▀█ █ █ █ ' ╚════════════════════════════════════════════╝ █▄▄█ █▄▄█ █ Button 1 Label WanpyJob Button WanpyJob Text "Wanpy Job" Button WanpyJob Color Cyan Button 2 Label JobQrCode Button JobQrCode Text "JOB QRcode" Button JobQrCode Color Cyan Button 3 Label TunaCans Button TunaCans Text "Tuna cans" Button TunaCans Color Cyan Button 4 Label Sliders Button Sliders Text "Sliders" Button Sliders Color Cyan Button 5 Label Encoder Button Encoder Text "Encoder" Button Encoder Color Cyan Button 6 Label Voice Button Voice Text "Voice" Button Voice Color PaleTurquoise Button 7 Label GoHome Button GoHome Text "Go Home" Button GoHome Color Yellow ' Button 8 Label GoCenter Button GoCenter Text "Go Center" Button GoCenter Color Yellow 'Button 6 Label SetCenterHere 'Button SetCenterHere Text "Set Center Here" 'Button SetCenterHere Color Orange ' 'Button 7 Label CalibrateToZero 'Button CalibrateToZero Text "Calibrate to Zero" 'Button CalibrateToZero Color Orange Button 9 Label StartPump Button StartPump Text "Start Pump" Button StartPump Color Lime Button 10 Label StopPump Button StopPump Text "Stop Pump" Button StopPump Color Crimson Button 11 Label CurrentMeter Button 12 Label MotorFPS 'Button MotorFPS Text FPS Button 14 Label "MotorTemp" Button MotorTemp Color Salmon Button 15 Label CloseAll Button CloseAll Text "CLOSE ALL" Button CloseAll Color Red Button 17 Label Home Button Home Text "HOME" Button Home Color Yellow Button 18 Label Home1 Button Home1 Text "Home 1" Button Home1 Color Yellow Button 19 Label Home2 Button Home2 Text "Home 2" Button Home2 Color Yellow Button 20 Label Home3 Button Home3 Text "Home 3" Button Home3 Color Yellow Button 21 Label Home4 Button Home4 Text "Home 4" Button Home4 Color Yellow Button 22 Label Home5 Button Home5 Text "Home 5" Button Home5 Color Yellow Button 24 Label ShowFiches Button ShowFiches Text "ShowFiches" Button ShowFiches Color SteelBlue Button 25 Label ReleaseFiches Button ReleaseFiches Text "ReleaseFiches" Button ReleaseFiches Color SteelBlue Button 26 Label ShowTuna Button ShowTuna Text "ShowTuna" Button ShowTuna Color SteelBlue Button 27 Label ReleaseTuna Button ReleaseTuna Text "ReleaseTuna" Button ReleaseTuna Color SteelBlue Button 28 Label ShowWanpy Button ShowWanpy Text "ShowWanpy" Button ShowWanpy Color SteelBlue Button 29 Label ReleaseWanpy Button ReleaseWanpy Text "ReleaseWanpy" Button ReleaseWanpy Color SteelBlue Button 30 Label VoiceLoop Button VoiceLoop Text "VoiceLoop" Button VoiceLoop Color Blue Button 32 Label Say Button Say Text "Say" Button Say Color DeepSkyBlue ' ╔════════════════════════════════════════════╗ █ █▀▀█ █▀▀█ █▀▀▄ ' ║ LOAD APPS ║ █ █ █ █▄▄█ █ █ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄█ █ █ █▄▄█ Load Theremino_Motors.exe WaitApplicationsStarted '' ------------------------------------- ' MOTORS must be active before Cobot ' ------------------------------------- Load Theremino_HAL.exe Load Theremino_SlotViewer.exe Load Theremino_SlotViewer_M1.exe Load Theremino_SlotViewer_M2.exe Load Theremino_SlotViewer_M3.exe Load Theremino_SlotViewer_M4.exe Load Theremino_SlotViewer_M5.exe Load Theremino_SlotViewer_Enc.exe Load Theremino_SlotViewer_STR.exe 'Load Theremino_MicroVideo.exe Load Theremino_QRdecoder.exe Load Theremino_VoiceCommands.exe Load Theremino_SlotViewer_Strings.exe Load Theremino_SignalScope_M1.exe Load Theremino_SignalScope_M2.exe Load Theremino_SignalScope_M3.exe Load Theremino_SignalScope_M4.exe Load Theremino_SignalScope_M5.exe Load Theremino_Cobot.exe WaitApplicationsStarted Load Hide ' ╔════════════════════════════════════════════╗ █▀▀▀ ▀▀█▀▀ █▀▀▀█ █▀▀▀█ ▀▀█▀▀ ' ║ EXECUTION START FROM HERE ║ ▀▀▀█ █ █▀▀▀█ █▀█▀▀ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █ █ █ ▀▄ █ ResetEncoders YellowOn Slot(Slot_SignalScope) = 1000 ' ------------------------- GOTO HOME - Command to Cobot 'WaitCobotReady 'SendCommand(Slot_CommandsToCobot)(GotoHome) 'Home Controls OpenTextBox Controls ClearTextBox ' ╔════════════════════════════════════════════╗ █ █▀▀█ █▀▀█ █▀▀█ ' ║ LOOP ║ █ █ █ █ █ █▄▄█ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄█ █▄▄█ █ Label Loop CurrentMeter MotorFPS PositionDelta TestTemp InterpretateVoiceCommands Encoder Goto Loop Stop Label PositionDelta Slot(109) = Slot(101) - Slot(102) Slot(209) = Slot(201) - Slot(202) Slot(309) = Slot(301) - Slot(302) Slot(409) = Slot(401) - Slot(402) Slot(509) = Slot(501) - Slot(502) Return Label TestTemp Variable Numeric TT1 Variable Numeric TT2 = 0 'TT2 = 0 For TT1 = 1 To 5 TT2 = Max(TT2, Slot(TT1 * 100 + 6)) Next Button MotorTemp Text "MaxT=" + TT2 + "°C" Return ' ╔════════════════════════════════════════════╗ ' ║ ENABLE/DISABLE BUTTONS ║ ' ╚════════════════════════════════════════════╝ Label EnableAllButtons For v1 = 1 To 48 Button v1 Enabled Next Return Label DisableAllButtons For v1 = 1 To 48 Button v1 Disabled Next Return ' ╔════════════════════════════════════════════╗ ' ║ WAIT COBOT READY ║ ' ╚════════════════════════════════════════════╝ Label WaitCobotReady Variable Numeric WCR1 For WCR1 = 1 To Infinity Wait Seconds 0.05 If SlotText(Slot_ResponsesFromCobot) = "Ready" Exit EndIf Next Return ' ╔════════════════════════════════════════════╗ ' ║ WAIT APPS STARTED ║ ' ╚════════════════════════════════════════════╝ Label WaitApplicationsStarted Slot(Slot_RS485_FPS) = 0 Wait Slot(Slot_RS485_FPS) > 10 Wait Seconds 0.1 Return ' ╔════════════════════════════════════════════╗ █▀▀▀ ▀▀█▀▀ █▀▀█ █▀▀█ ' ║ STOP EVENT (when pressing stop button) ║ ▀▀▀█ █ █ █ █▄▄█ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █▄▄█ █ Label EventStop StopPump GoHome StopCobotAndGotoHome End Label StopCobotAndGotoHome StopCobot WaitMotorsNotMoving GotoSafePosition Return Label GotoSafePosition SendCommand(Slot_CommandsToCobot)(GotoHome) WaitMotorsNotMoving Return Label WaitMotorsNotMoving Variable Numeric WMN1 Variable Numeric WMN2 Wait Seconds 0.1 For WMN1 = 0 To Infinity WMN2 = Slot(Slot_M1 + 6) WMN2 = WMN2 + Slot(Slot_M2 + 6) WMN2 = WMN2 + Slot(Slot_M3 + 6) WMN2 = WMN2 + Slot(Slot_M4 + 6) WMN2 = WMN2 + Slot(Slot_M5 + 6) If WMN2 = 0 Exit For EndIf Next Return ' ╔════════════════════════════════════════════╗ █▀▀ █ █▀▀█ █▀▀▀ █▀▀▀ ' ║ CLOSE ALL (when pressing X on form) ║ █ █ █ █ ▀▀▀█ █▀▀ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█ ▄▄▄█ █▄▄▄ Label CloseAll StopPump GoHome StopCobotAndGotoHome Load CloseAll End ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand Variable Numeric SC1 '<-- Parameter Destinat.-Slot Variable String SC2 '<-- Parameter Command-String Variable Numeric SC3 = 0.5 '<-- The timeout in seconds Variable Numeric SC4 SlotText SC1 = SC2 For SC4 = 0.1 To SC3 Step 0.1 If SlotText(SC1) = "" Exit EndIf Wait Seconds 0.1 Next Return ' ============================================================= ' COMMANDS to Cobot ' ============================================================= Label ExecCobot SendCommand(Slot_CommandsToCobot)(EnableRepeat) SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label StopCobot SendCommand(Slot_CommandsToCobot)(StopExecution) Return ' ============================================================= ' CALIBRATION COMMANDS to Motors and Cobot ' ============================================================= Label SetCenterHere SendCommand(Slot_CommandsToMotors)("ResetAllCalibrationValues") 'Wait Seconds 0.1 SendCommand(Slot_CommandsToMotors)("ResetAllMultiturnValues") 'Wait Seconds 0.1 SendCommand(Slot_CommandsToCobot) ("SetAllMotorsCenterHere") 'Wait Seconds 0.1 SendCommand(Slot_CommandsToCobot) ("CopyPositionsToDestinations") 'Wait Seconds 0.1 Return Label CalibrateToZero SendCommand(Slot_CommandsToMotors)("Calibrate Motor 1 To 0") SendCommand(Slot_CommandsToMotors)("Calibrate Motor 2 To 0") SendCommand(Slot_CommandsToMotors)("Calibrate Motor 3 To 0") SendCommand(Slot_CommandsToMotors)("Calibrate Motor 4 To 0") SendCommand(Slot_CommandsToMotors)("Calibrate Motor 5 To 0") SendCommand(Slot_CommandsToCobot) ("CopyPositionsToDestinations") Return Label CalibrateMotor1To180 SendCommand(Slot_CommandsToMotors)("Calibrate Motor 1 To 180") SendCommand(Slot_CommandsToCobot)("CopyPositionsToDestinations") Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █ █▀█ ' ║ S U B R O U T I N E A R E A ║ ▀▀▀█ █ █ █▀▀█ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄█ █▄▄█ Label CurrentMeter Variable Numeric mA mA = Slot(108) + Slot(208) + Slot (308) ' <-- Motors slots mA = FilterLP(mA, 0.1, 1) '<-- Filter 0.5 seconds / 1 pole Button CurrentMeter Text "Current= " + Str(mA, "0 mA") Return Label MotorFPS Button MotorFPS Text "FPS=" + Str(Slot(Slot_RS485_FPS)) Return Label StartPump RedOn 'Slot(Slot_SignScope) = 1000 Slot(Slot_Pump) = 1000 Button StartPump Disabled Button StopPump Enabled Wait Seconds 0.4 'If Slot(Slot_Vacuum) > 56 ' 'Beep "500, 300, 0, 300" ' 'SayVacuumProblem ' RedOn ' StopPump ' Print "Vacuum Problem" + CRLF ' 'CobotShowPoint ' Print "Execution stopped" + CRLF ' RedBlink ' End 'Else ' Print "Target picked" 'EndIf Return Label StopPump Slot(Slot_Pump) = 0 Button StopPump Disabled Button StartPump Enabled GreenOn Return ' ╔════════════════════════════════════════════╗ █ █▀▀ █▀▄ ' ║ LED COLORS ║ █ █▀ █ █ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█ Label RedOn Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Return Label MagentaOn Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label YellowOn Slot Slot_LedR = 900 Slot Slot_LedG = 400 Slot Slot_LedB = 0 Return Label GreenOn Slot Slot_LedR = 0 Slot Slot_LedG = 1000 Slot Slot_LedB = 0 Return Label BlueOn Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label WhiteOn Slot Slot_LedR = 1000 Slot Slot_LedG = 1000 Slot Slot_LedB = 1000 Return Label RgbOff Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Return Label RedBlink RedOn WhiteOn Return ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █▄ ▄█ █▀▀▀ ' ║ HOME ║ █▀▀█ █ █ █ ▀ █ █▀▀ ' ╚════════════════════════════════════════════╝ █ █ █▄▄█ █ █ █▄▄▄ Label Home BlueOn 'GoHome WaitMotorsNotMoving Home4 Home5 Home1 Home2 Home3 GoCenter Return Variable Numeric HM Label Home1 'DisableAllButtons Button Home1 Color Flashing6 Blue White Slot(Slot_SignalScope) = 1000 Slot(Slot_M1) = Slot(Slot_M1) - 5 WaitMotorsNotMoving SetCenterHere CalibrateToZero '===============================CalibrateM1ToZero For HM = 1 To Infinity Slot(Slot_M1) = Slot(Slot_M1) + 0.05 ' do not change If Abs(Slot(Slot_M1 + 3)) > 300 Exit EndIf Wait Seconds 0.01 Next WaitMotorsNotMoving Slot(Slot_M1) = Slot(Slot_M1) - 5 WaitMotorsNotMoving CalibrateToZero '===============================CalibrateM1ToZero EnableAllButtons Slot(Slot_SignalScope) = 0 Button Home1 Color Yellow Return Label Home2 'DisableAllButtons Button Home2 Color Flashing6 Blue White Slot(Slot_SignalScope) = 1000 Slot(Slot_M3) = Slot(Slot_M3) + 5 Slot(Slot_M2) = Slot(Slot_M2) - 5 WaitMotorsNotMoving SetCenterHere CalibrateToZero For HM = 1 To Infinity Slot(Slot_M2) = Slot(Slot_M2) + 0.08 If Abs(Slot(Slot_M2 + 3)) > 400 Exit EndIf Wait Seconds 0.01 Next WaitMotorsNotMoving Slot(Slot_M2) = Slot(Slot_M2) - 5 WaitMotorsNotMoving CalibrateToZero Slot(Slot_SignalScope) = 0 EnableAllButtons Button Home2 Color Yellow Return Label Home3 'DisableAllButtons Button Home3 Color Flashing6 Blue White Slot(Slot_SignalScope) = 1000 Slot(Slot_M3) = Slot(Slot_M3) + 5 WaitMotorsNotMoving SetCenterHere CalibrateToZero For HM = 1 To Infinity Slot(Slot_M3) = Slot(Slot_M3) - 0.08 If Abs(Slot(Slot_M3 + 3)) > 300 Exit EndIf Wait Seconds 0.01 Next WaitMotorsNotMoving Slot(Slot_M3) = Slot(Slot_M3) + 5 WaitMotorsNotMoving CalibrateToZero Slot(Slot_SignalScope) = 0 EnableAllButtons Button Home3 Color Yellow Return Label Home4 'DisableAllButtons Button Home4 Color Flashing6 Blue White Slot(Slot_SignalScope) = 1000 Slot(Slot_M4) = Slot(Slot_M4) - 5 WaitMotorsNotMoving SetCenterHere CalibrateToZero For HM = 1 To Infinity Slot(Slot_M4) = Slot(Slot_M4) + 0.2 If Abs(Slot(Slot_M4 + 3)) > 300 Exit EndIf Wait Seconds 0.01 Next WaitMotorsNotMoving Slot(Slot_M4) = Slot(Slot_M4) - 5 WaitMotorsNotMoving SetCenterHere CalibrateToZero Slot(Slot_SignalScope) = 0 EnableAllButtons Button Home4 Color Yellow Return Label Home5 'DisableAllButtons Button Home5 Color Flashing6 Blue White Slot(Slot_SignalScope) = 1000 Slot(Slot_M5) = Slot(Slot_M5) - 5 WaitMotorsNotMoving SetCenterHere CalibrateToZero For HM = 1 To Infinity Slot(Slot_M5) = Slot(Slot_M5) + 0.2 If Abs(Slot(Slot_M5 + 3)) > 300 Exit EndIf Wait Seconds 0.01 Next WaitMotorsNotMoving Slot(Slot_M5) = Slot(Slot_M5) - 5 WaitMotorsNotMoving SetCenterHere CalibrateToZero Slot(Slot_SignalScope) = 0 EnableAllButtons Button Home5 Color Yellow Return Label GoHome Slot(Slot_M4) = 0 Slot(Slot_M5) = 0 Slot(Slot_M2) = 0 Slot(Slot_M3) = 0 Slot(Slot_M2) = 0 Slot(Slot_M1) = 0 Return Label GoCenter Slot(Slot_M1) = -026 Slot(Slot_M2) = -039 Slot(Slot_M3) = +018 Slot(Slot_M4) = -110 Slot(Slot_M5) = -153 Return ' ╔═════════════════════════╗ █▀▀▀ █▀▀█ █▄ ▄█ █▀▀ █▀▀▀ █▀▀█ █▀█ ' ║ COMMANDS FROM COBOT ║ █ █ █ █ ▀ █ █▀ █ █ █ █▀▀█ ' ╚═════════════════════════╝ █▄▄▄ █▄▄█ █ █ ▄ █ ▄ █▄▄▄ █▄▄█ █▄▄█ Label Event_ExternalCommands ' ------------------------------------------------------ Do not print lines containing '' 'Print " Exec: " + CommandText + CRLF ' ------------------------------------------------------ Select CommandText ' ---------------------------------------------- ACTIONS Case "Beep" Beep 880-100 ClearCommand Case "Pause" Wait Seconds GetSeparatedString(CommandText, 1) ClearCommand Case "StartPump" StartPump ClearCommand Case "StopPump" StopPump ClearCommand Case "MemorizeQrCode" Variable Numeric MQR1 For MQR1 = 1 To 5 QrCode = SlotText(Slot_ResponsesFromQRDecode) Print QrCode If QrCode <> "" Exit EndIf If MQR1 = 5 SendCommand(Slot_CommandsToCobot)(StopExecution) EndIf Wait Seconds 1 Next ClearCommand Case "ExecQrCode" ExecQRcode ClearCommand Case "StartFichesPick" StartFichesPick ClearCommand Case "EndOfTask" EndOfTask ClearCommand CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + CommandText + CRLF Beep ClearCommand Stop ' EndSelect Return Label ClearCommand SlotText(Slot_ExternalCommands) = "" Return ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █▄ █ ' ║ WANPY ║ █ █ █▄▄█ █ ▀█ ' ╚════════════════════════════════════════════╝ ▀▄▀ █ █ █ █ Label WanpyJob TTS Speak "Wanpy job started." Controls OpenTextBox Controls ClearTextBox StartTime = ElapsedTime RedOn Wanpy_A5toB1 Return Variable String Status = "A5toB1" Label EndOfTask PrintTime StartTimePartial = ElapsedTime Select Status Case "A5toB1" 'Wanpy_B1toA5 Wanpy_A4toB2 Case "A4toB2" Wanpy_A3toB3 Case "A3toB3" Wanpy_A2toB4 Case "A2toB4" Wanpy_A1toB5 Case "A1toB5" Wanpy_B5toA1 Case "B5toA1" Wanpy_B4toA2 Case "B4toA2" Wanpy_B3toA3 Case "B3toA3" Wanpy_B2toA4 Case "B2toA4" Wanpy_B1toA5 Case "B1toA5" StartTime = ElapsedTime Print CRLF Wanpy_A5toB1 EndSelect Return Variable Numeric StartTime Variable Numeric StartTimePartial Variable String Time Label PrintTime Time = "Partial time = " Time = Time + PadLeft(Format(ElapsedTime - StartTimePartial, "0.0"),4) Time = Time + " Total time = " Time = Time + PadLeft(Format(ElapsedTime - StartTime, "0.0"),4) Print Status + " " + Time + CRLF Return Label Wanpy_A5toB1 Status = "A5toB1" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A5toB1.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A4toB2 Status = "A4toB2" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A4toB2.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A3toB3 Status = "A3toB3" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A3toB3.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A2toB4 Status = "A2toB4" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A2toB4.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A1toB5 Status = "A1toB5" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A1toB5.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B5toA1 Status = "B5toA1" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B5toA1.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B4toA2 Status = "B4toA2" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B4toA2.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B3toA3 Status = "B3toA3" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B3toA3.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B2toA4 Status = "B2toA4" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B2toA4.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B1toA5 Status = "B1toA5" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B1toA5.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return ' ╔════════════════════════════════════════════╗ █▀▀█ █▀▀█ █▀▀▀ ' ║ QR CODE ║ █ █ █▄▄█ █ ' ╚════════════════════════════════════════════╝ █▄██▄ █ ▀▄ █▄▄▄ Label JobQrCode TTS Speak "QR code recognition and action related is started." StartFichesPick Return Label StartFichesPick BlueOn SendCommand(Slot_CommandsToCobot)("LoadSequence fiches_pick.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label ExecQRcode Variable String QrCode Select QrCode Case "WHITE" WhiteOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_white.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "RED" RedOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_red.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "GREEN" GreenOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_green.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "BLUE" BlueOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_Place_blue.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "BLACK" RgbOff SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_black.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) CaseElse Controls OpenTextBox Print CRLF + " Unrecognized color command: " + CommandText + CRLF StopPump Beep ClearCommand Stop EndSelect Return ' ╔════════════════════════════════════════════╗ ▀▀█▀▀ █ █ █▄ █ ' ║ TUNA ║ █ █ █ █ ▀█ ' ╚════════════════════════════════════════════╝ █ █▄▄█ █ █ Label TunaCans TTS Speak "Tuna can handling." YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Tuna_Cans.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █ █▀▀▄ ' ║ SLIDERS ║ ▀▀▀█ █ █ █ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄ █ █▄▄█ Variable Numeric SLD Label Sliders BlueOn Button Sliders Color Flashing7 Blue White For SLD = 1 To Infinity Slot(Slot_M1) = Slot(Slot_Slider1) Slot(Slot_M2) = Slot(Slot_Slider2) Slot(Slot_M3) = Slot(Slot_Slider3) + Slot(Slot_Slider2) Slot(Slot_M4) = Slot(Slot_Slider4) Slot(Slot_M5) = Slot(Slot_Slider5) Next Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █▀▀█ ▀▄ ▄▀ ' ║ SAY ║ ▀▀▀█ █▄▄█ ▀▄▀ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █ █ Label Say TTS SelectVoice "ENGF" TTS Speak "Today is a beautiful day because we spend time together." Wait TTSready TTS SelectVoice "ITA FEM" TTS Speak "Oggi è una bella giornata perche passeremo del tempo insieme." Wait TTSready TTS SelectVoice "JPN" TTS Speak "私たちは一緒に時間を過ごすので、今日は美しい日です。" Wait TTSready TTS SelectVoice "ZHO" TTS Speak "今天是美好的一天,因为我们共度时光。" Wait TTSready Return ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █ █▀▀▀ █▀▀▀ ' ║ VOICE COMMANDS ║ █ █ █ █ █ █ █▀▀ ' ╚════════════════════════════════════════════╝ █ █▄▄█ █ █▄▄▄ █▄▄▄ Label Voice ClearVoiceCommand If VoiceCommandsStatus = "active" VoiceCommandsStatus = "" Button Voice Color PaleTurquoise Else VoiceCommandsStatus = "active" Button Voice Color Flashing7 Orange White EndIf Return Variable String Word Variable String VoiceCommandsStatus Label InterpretateVoiceCommands If VoiceCommandsStatus = "active" If SlotText(Slot_WordRecognized) <> "" Word = SlotText(Slot_WordRecognized) Print Word + " " Interpretate ClearVoiceCommand EndIf EndIf Return Variable String ShowingType Label Interpretate Select Word Case "show.fiches" If ShowingType = "" WhiteOn ShowingType = "Fiches" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Fiches.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "show.wanpy" If ShowingType = "" YellowOn ShowingType = "Wanpy" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Wanpy.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "show.tuna" If ShowingType = "" GreenOn ShowingType = "Tuna" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Tuna.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf '------------------------------------------------------------------------- Case "release" Select ShowingType Case "fiches" WhiteOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Fiches.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" Case "wanpy" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Wanpy.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" Case "tuna" GreenOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Tuna.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" CaseElse ' EndSelect '------------------------------------------------------------------------- Case "goto.center" If ShowingType = "" RedOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_goto_Center.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "goto.home" If ShowingType = "" MagentaOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_goto_Home.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf '------------------------------------------------------------------------- CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + Word + CRLF Beep ClearCommand Stop EndSelect Return Label ClearVoiceCommand SlotText(Slot_WordRecognized) = "" Return '============================= TRIALS ==================== Label ShowFiches YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Fiches.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label ReleaseFiches YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Fiches.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label ShowTuna YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Tuna.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label ReleaseTuna YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Tuna.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label ShowWanpy YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Wanpy.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label ReleaseWanpy YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Wanpy.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Variable Numeric VOL Label VoiceLoop For VOL = 1 To Infinity ShowFiches Wait Seconds 1 ReleaseFiches Wait Seconds 1 ShowTuna Wait Seconds 1 ReleaseTuna Wait Seconds 1 ShowWanpy Wait Seconds 1 ReleaseWanpy Wait Seconds 1 Next Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █▄ █ █▀▀▀ ' ║ ENCODERS ║ █▀▀ █ ▀█ █ ' ╚════════════════════════════════════════════╝ █▄▄▄ █ █ █▄▄▄ Variable Numeric EncoderSteps1 Variable Numeric OldEncoderSteps1 Variable Numeric Difference1 Variable Numeric EncoderSteps2 Variable Numeric OldEncoderSteps2 Variable Numeric Difference2 Variable Numeric EncoderSteps3 Variable Numeric OldEncoderSteps3 Variable Numeric Difference3 Variable Numeric EncoderSteps4 Variable Numeric OldEncoderSteps4 Variable Numeric Difference4 Variable Numeric EncoderSteps5 Variable Numeric OldEncoderSteps5 Variable Numeric Difference5 Label Encoder '------------------------------------------------ read encoder1 EncoderSteps1 = Slot(Slot_Encoder1) Difference1 = EncoderSteps1 - OldEncoderSteps1 OldEncoderSteps1 = EncoderSteps1 If Difference1 > 32000 Difference1 = Difference1 - 65536 EndIf If Difference1 < -32000 Difference1 = Difference1 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference1 = Difference1 * 0.1 EndIf Slot(Slot_M1) = Limit(Slot (Slot_M1) + Difference1, -70, 0) '------------------------------------------------ read encoder2 EncoderSteps2 = Slot(Slot_Encoder2) Difference2 = EncoderSteps2 - OldEncoderSteps2 OldEncoderSteps2 = EncoderSteps2 If Difference2 > 32000 Difference2 = Difference2 - 65536 EndIf If Difference2 < -32000 Difference2 = Difference2 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference2 = Difference2 * 0.1 EndIf Slot(Slot_M2) = Limit(Slot (Slot_M2) + Difference2, -160, 0) '------------------------------------------------ read encoder3 EncoderSteps3 = Slot(Slot_Encoder3) Difference3 = EncoderSteps3 - OldEncoderSteps3 OldEncoderSteps3 = EncoderSteps3 If Difference3 > 32000 Difference3 = Difference3 - 65536 EndIf If Difference3 < -32000 Difference3 = Difference3 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference3 = Difference3 * 0.1 EndIf Slot(Slot_M3) = Limit(Slot (Slot_M3) + Difference3, -100, 100) '------------------------------------------------ read encoder4 EncoderSteps4 = Slot(Slot_Encoder4) Difference4 = EncoderSteps4 - OldEncoderSteps4 OldEncoderSteps4 = EncoderSteps4 If Difference4 > 32000 Difference4 = Difference4 - 65536 EndIf If Difference4 < -32000 Difference4 = Difference4 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference4 = Difference4 * 0.1 EndIf Slot(Slot_M4) = Limit(Slot (Slot_M4) + Difference4, -180, 0) '------------------------------------------------ read encoder5 EncoderSteps5 = Slot(Slot_Encoder5) Difference5 = EncoderSteps5 - OldEncoderSteps5 OldEncoderSteps5 = EncoderSteps5 If Difference5 > 32000 Difference5 = Difference5 - 65536 EndIf If Difference5 < -32000 Difference5 = Difference5 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference5 = Difference5 * 0.1 EndIf Slot(Slot_M5) = Limit(Slot (Slot_M5) + Difference5, -240, 0) Return Label ResetEncoders OldEncoderSteps1 = Slot(Slot_Encoder1) OldEncoderSteps2 = Slot(Slot_Encoder2) OldEncoderSteps3 = Slot(Slot_Encoder3) OldEncoderSteps4 = Slot(Slot_Encoder4) OldEncoderSteps5 = Slot(Slot_Encoder5) Return ' ============================================================================= ' Folder Demo Programs\IF ELSE ENDIF ' File Demo-IF_ELSE_ENDIF.txt ' ============================================================================= ' Theremino Automation demo program ' Demonstrating IF, ELSE, ENDIF and system Beep v1 = Slot(1) v2 = Slot(2) If v1 < 500 Print "V1 is less than 500" Else If v1 = 500 Print "V1 is equal to 500" Else Print "V1 is more than 500" EndIf EndIf If v1 = v2 Print "V1 is equal to V2" Beep EndIf ' ============================================================================= ' Folder Demo Programs\IF ELSE ENDIF ' File Demo-MultipleIF.txt ' ============================================================================= ' Theremino Automation demo program ' Demonstrating AND and OR with MULTIPLE IF Button 1 Text Test1 Button 2 Text Test2 '------------- Beep if all the slots are more than 500 Label test1 If Slot(1) > 500 If Slot(2) > 500 If Slot(3) > 500 Beep EndIf EndIf EndIf Goto test1 '------------- Beep if one slots is more than 500 Label test2 If Slot(1) < 500 If Slot(2) < 500 If Slot(3) < 500 Goto test2 EndIf EndIf EndIf Beep Goto test2 ' ============================================================================= ' Folder Demo Programs\IF ELSE ENDIF ' File Demo-NESTED COMPARATIONS.txt ' ============================================================================= ' Theremino Automation demo program ' Demonstrating NESTED COMPARATIONS v1 = Slot(1) v2 = Slot(2) If v1 > v2 Print "V1 is greater than V2" Else If v1 < v2 Print "V1 is less than V2" Else Print "V1 is equal to V2" EndIf EndIf ' ============================================================================= ' Folder Demo Programs\IF ELSE ENDIF ' File Demo-SIMPLE COMPARATIONS.txt ' ============================================================================= ' Theremino Automation demo program ' Demonstrating SIMPLE COMPARATIONS v1 = Slot(1) v2 = Slot(2) If v1 > v2 Print "V1 is greater than V2" EndIf If v1 < v2 Print "V1 is less than V2" EndIf If v1 = v2 Print "V1 is equal than V2" EndIf ' ============================================================================= ' Folder Demo Programs\Immediate Vars ' File Immediate Vars Assignements 1.txt ' ============================================================================= ' ==================================================================== ' Name: WXM_CNC_Vslot_Automation_16_2.txt Date: 17 Jun 2021 ' Autor: Leonardo DE PALO ' Scope: Two gripper PWM, rotating with Protocol1 of FeeTech. ' Hardware: Standard Master e SM29. ' note: ' ==================================================================== Option Speed 9 Gosub RestoreVars Gosub SetButtonsAndKeys Gosub ShowSequenceName Stop ' Label EventStop Gosub SaveVars End ' ==================================================================== ' SAVE LOAD VARS ' ==================================================================== Label SaveVars S1 = SequenceName Save Vars Return Label RestoreVars Load Vars SequenceName = S1 Return ' ==================================================================== ' BUTTONS ' ==================================================================== Label SetButtonsAndKeys Button 5 Text EditSequence Button EditSequence Text "Edit sequence" Button EditSequence Color PaleGreen Button 6 Text RunSequence Button RunSequence Text "RUN SEQUENCE" Button RunSequence Color Aqua Button 7 Text SelectSequence Button SelectSequence Text "Select Sequence" Button SelectSequence Color PowderBlue Return ' ===================================================================== ' SEQUENCES ' ===================================================================== 'Label InitSequencePaths ' Variable String EditorFolder ' Variable String EditorApp ' Variable String SequencePathAndName ' Variable String SequenceName ' ' ' EditorFolder = ".\Theremino_HAL\Theremino_Editor\" ' ' ' EditorApp = EditorFolder + "Theremino_Editor.exe" ' ' ' SequencePathAndName = EditorFolder + "Sequences\" + SequenceName 'Return Label InitSequencePaths Variable String SequenceName Variable String EditorFolder = ".\Theremino_HAL\Theremino_Editor\" Variable String EditorApp = EditorFolder + "Theremino_Editor.exe" Variable String SequencePathAndName = EditorFolder + "Sequences\" + SequenceName Return Label EditSequence Gosub InitSequencePaths If FileExists(SequencePathAndName) Load EditorApp + " " + SequencePathAndName EndIf Return Label SelectSequence Gosub InitSequencePaths s1 = SelectFile(EditorFolder + "Sequences\") If s1 <> "" SequenceName = s1 Gosub ShowSequenceName Gosub EditSequence EndIf Return Label ShowSequenceName Button SelectSequence Text "Sequence" + CRLF + SequenceName Return ' ==================================================================== ' RUN sequence ' ==================================================================== Label RunSequence Variable Numeric ExitFromSequenceLoop Variable Numeric NumCycle ' Controls OpenTextBox Gosub InitSequencePaths ' ExitFromSequenceLoop = 0 SequenceToExecute = SequencePathAndName For NumCycle = NumCycle To Infinity Gosub ExecSequence Wait Seconds 0.5 If ExitFromSequenceLoop > 0 Exit EndIf Next Return ' ==================================================================== ' SEQUENCE LOADING AND EXECUTION ' ==================================================================== Variable String SequenceToExecute Variable String Sequence Variable String SequenceCmd Variable Numeric SequenceIndex Variable Numeric SequenceLength Label ExecSequence Load Sequence SequenceToExecute If Len(Sequence) = 0 Controls OpenTextBox Print CRLF + " Sequence file not found: " + SequenceToExecute Beep Stop EndIf ' Print "Sequence " + GetFileNameWithoutPath(SequenceToExecute) + " started at " + Format(Now, "HH:mm:ss") + CRLF Print Chars("-", 50) + CRLF Variable Numeric ExecSequenceStartTime ExecSequenceStartTime = ElapsedTime ' ------------------------------------------ SequenceLength = GetSeparatedStringCount(Sequence, CRLF) For SequenceIndex = 0 To SequenceLength-1 ' SequenceCmd = GetSeparatedString(Sequence, SequenceIndex, CRLF) SequenceCmd = Replace(SequenceCmd, Chr(9), " ") 'TABS to SPACES ' Print " Exec: " + SequenceCmd + CRLF ' SequenceCmd = RemoveComments(SequenceCmd) SequenceCmd = Trim(SequenceCmd) ' If SequenceCmd <> "" ' Select SequenceCmd ' ---------------------------------------------- End sequence Case "EndSeq" SequenceIndex = SequenceLength-1 ' ---------------------------------------------- Event STOPd sequence ' ---------------------------------------------- With parameters CaseElse Select GetSeparatedString(SequenceCmd, 0) CaseElse If SequenceCmd <> "" Controls OpenTextBox Print CRLF + " Unrecognized command: " + SequenceCmd + CRLF Beep Stop EndIf EndSelect EndSelect EndIf Next Print Chars("-", 50) + CRLF Print "Sequence " + GetFileNameWithoutPath(SequenceToExecute) + " executed in " + Format(ElapsedTime - ExecSequenceStartTime, "0.00") + " seconds" + CRLF Return ' ============================================================================= ' Folder Demo Programs\Immediate Vars ' File Immediate Vars Assignements 2.txt ' ============================================================================= ' ==================================================================== ' IMMEDIATE ASSIGNEMENTS TO VARIABLES ' ==================================================================== ' -------------------------------------- Set slots Variable Numeric Slot_LedR = 907 * 22 Variable Numeric Slot_LedG = 908 Variable Numeric Slot_LedB = 909 Variable Numeric Slot_Air = 1911 Variable Numeric Slot_WhiteLight = 912 + 6 Variable String Str1 = "This is a string" Print Slot_LedR Print Slot_LedG Print Slot_LedB Print Slot_Air Print Slot_WhiteLight Print Str1 Str1 = Str1 + " very long" Stop ' ============================================================================= ' Folder Demo Programs\Immediate Vars ' File Immediate Vars Assignements 3.txt ' ============================================================================= ' ==================================================================== ' IMMEDIATE ASSIGNEMENTS TO VARIABLES ' ==================================================================== ' -------------------------------------- Set slots Variable Numeric Slot_LedR = 907 * 22 Variable Numeric Slot_LedG = 908 Variable String Str1 = "This is a String" Print Slot_LedR Print Slot_LedG Print Str1 'Str1 = "rtrtr" Stop ' ============================================================================= ' Folder Demo Programs\INDENT ' File Auto Indent - Multiple functions.txt ' ============================================================================= ' Theremino Automation ' Demo program for auto-indent Label Loop1 Gosub loop2 Goto loop1 Label Loop2 v1 = Slot(1) v2 = Slot(2) Gosub loop3 Return Label Loop3 Beep Return Label 1 If Slot(1) < 500 Gosub 2 Else Gosub 3 EndIf Goto 1 Label 2 Return Label 3 Return ' ============================================================================= ' Folder Demo Programs\INDENT ' File Auto Indent.txt ' ============================================================================= ' Theremino Automation ' Demo program for INDENT Label Loop2 ' ------------------------------- If Slot(1) = 0 Beep Else Beep EndIf ' ------------------------------- v1 = Slot(1) v2 = Slot(2) Select v1 Case 1 Beep Select v2 Case 1 Beep Case 2 Beep Beep EndSelect Case 2 Beep Beep EndSelect GoTo Loop2 ' ============================================================================= ' Folder Demo Programs\INDENT ' File Test - Indent1.txt ' ============================================================================= Label 1 Beep Goto 1 Label 2 Beep Stop Label 3 Beep Goto 3 Label 4 Beep Stop ' ============================================================================= ' Folder Demo Programs\INDENT ' File Test - Indent2.txt ' ============================================================================= Label 1 If v1 = 3 If v2 = 6 EndIf Else EndIf If v3 = 4 EndIf Return Label 2 If v3 = 4 EndIf Return ' ============================================================================= ' Folder Demo Programs\INDENT ' File Test - Indent3.txt ' ============================================================================= Label testAllSounds Wait Seconds 0.01 If Slot(11) < 100 If Slot(12) < 100 If Slot(13) < 100 If Slot(14) < 100 If Slot(15) < 100 If Slot(16) < 100 If Slot(17) < 100 If Slot(18) < 100 Goto EndProgram EndIf EndIf EndIf EndIf EndIf EndIf EndIf EndIf Goto testAllSounds Label EndProgram End ' ============================================================================= ' Folder Demo Programs\Input and Message ' File Demo - Input.txt ' ============================================================================= ' Example for Text and Numeric Input S1 = Input "Write your input here" Print s1 V1 = Input "Write a number" Print v1 ' It works also without the double quotes V1 = Input Write a number Print v1 Stop ' ============================================================================= ' Folder Demo Programs\Input and Message ' File Demo - Input2.txt ' ============================================================================= Print "Resonance frequency calculation" ' ----------------------------------- V1 = Input "Capacitance in pF ?" V1 = V1 / 1000000000000 V2 = Input "Inductance in uH ?" V2 = V2 / 1000000 V3 = 1 / Sqrt(V1 * V2) V4 = V3 / (2 * Math_PI) If v4 >= 1000000 S1 = V4 / 1000000 + " MHz" Else S1 = V4 + " Hz" EndIf Print "Resonance frequency is: " + S1 Stop ' ============================================================================= ' Folder Demo Programs\Input and Message ' File Demo - Inputs and Messages.txt ' ============================================================================= v1 = Input Please Input a number Print v1 s1 = Input Please Input a string Print s1 s1 = "First message line" + CRLF s1 = s1 + "Second message line" + CRLF s1 = s1 + "Please select YES or NO" s1 = Message s1 Print s1 v1 = Message Do you confirm this? Print v1 If v1 = 1 Beep EndIf s1 = Message Do you confirm this? Print s1 If s1 = "YES" Beep EndIf Stop ' ============================================================================= ' Folder Demo Programs\Input and Message ' File Demo - Messages.txt ' ============================================================================= s1 = "First message line" + CRLF s1 = s1 + "Second message line" + CRLF s1 = s1 + "Please select YES or NO" s1 = Message s1 Print s1 v1 = Message Do you confirm this? Print v1 If v1 = 1 Beep EndIf s1 = Message Do you confirm this? Print s1 If s1 = "YES" Beep EndIf Stop ' ============================================================================= ' Folder Demo Programs\Keys ' File Demo Keys.txt ' ============================================================================= ' Demo Keys with Goto and Gosub Key 1 Goto Start Key 2 Goto Stop Key 3 Gosub 3 Stop Label Start Stop Label Stop Stop Label 3 Beep Return ' ============================================================================= ' Folder Demo Programs\Keys ' File Demo XY with Keys.txt ' ============================================================================= Option GlobalKeys Enabled Option Speed 9 ' -------------------------------------- Slots Variable Numeric Slot_MotorX = 1 Variable Numeric Slot_MotorY = 2 Variable Numeric Slot_MotorZ = 3 ' -------------------------------------- X limits Variable Numeric Xmin = 0 Variable Numeric Xmax = 999 Variable Numeric Ymin = 0 Variable Numeric Ymax = 999 Variable Numeric Zmin = 0 Variable Numeric Zmax = 999 ' -------------------------------------- Key Jog Speed Variable Numeric KeyJog_Speed = 100 ' ----------------------------------------- KEYS Key Up Gosub ExecKeys Key Down Gosub ExecKeys Key Left Gosub ExecKeys Key Right Gosub ExecKeys Key Pageup Gosub ExecKeys Key Pagedown Gosub ExecKeys Controls OpenTextBox Controls ClearTextBox Print CRLF + " PRESS KEYBOARD ARROWS" + CRLF Stop ' ==================================================================== ' JOG with keyboard ' ==================================================================== Label ExecKeys Variable Numeric JogSpeed JogSpeed = KeyJog_Speed / 100 Select True Case Key("SHIFT") JogSpeed = JogSpeed * 0.1 Case Key("CTRL") JogSpeed = JogSpeed * 0.01 Case Key("ALT") JogSpeed = JogSpeed * 0.001 EndSelect ' If Key("Up") Slot(Slot_MotorY) = Limit(Slot(Slot_MotorY) + JogSpeed, Ymin, Ymax) EndIf If Key("Down") Slot(Slot_MotorY) = Limit(Slot(Slot_MotorY) - JogSpeed, Ymin, Ymax) EndIf ' If Key("Left") Slot(Slot_MotorX) = Limit(Slot(Slot_MotorX) - JogSpeed, Xmin, Xmax) EndIf If Key("Right") Slot(Slot_MotorX) = Limit(Slot(Slot_MotorX) + JogSpeed, Xmin, Xmax) EndIf ' If Key("PageUp") Slot(Slot_MotorZ) = Limit(Slot(Slot_MotorZ) + JogSpeed, Zmin, Zmax) EndIf If Key("PageDown") Slot(Slot_MotorZ) = Limit(Slot(Slot_MotorZ) - JogSpeed, Zmin, Zmax) EndIf ' If LimitReached Load "Sound\ButtonClick3.wav" EndIf ' Gosub PrintValues Return ' ==================================================================== ' PRINT COORDINATES ' ==================================================================== Label PrintValues Controls OpenTextBox s1 = " " + PadRight("X=" + Format(Slot(Slot_MotorX), "0.000"), 11) s1 = s1 + PadRight("Y=" + Format(Slot(Slot_MotorY), "0.000"), 11) s1 = s1 + PadRight("Z=" + Format(Slot(Slot_MotorZ), "0.000"), 11) Print CRLF + s1 Return ' ============================================================================= ' Folder Demo Programs\Keys ' File Key function Modifiers.txt ' ============================================================================= ' ----------------------------------------- ' Valid key names (uppercase or lowercase) ' ----------------------------------------- ' Canc Back Enter Ins Shift Ctrl Alt ' Print Scroll Pause ' Left Right Up Down PageUp PageDown ' Space Esc Home End ' 0 1 2 3 4 5 6 7 8 9 ' a b c d e f g h i j k l m n ' o p q r s t u v w x y z ' f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 ' ----------------------------------------- If Key("Shift") Beep EndIf If Key("Ctrl") Beep EndIf If Key("Alt") Beep EndIf ' ============================================================================= ' Folder Demo Programs\Keys ' File Key function.txt ' ============================================================================= ' ----------------------------------------- ' Valid key names (uppercase or lowercase) ' ----------------------------------------- ' Canc Back Enter Ins ' Printscreen Scroll Pause ' Left Right Up Down PageUp PageDown ' Space Esc Home End ' 0 1 2 3 4 5 6 7 8 9 ' a b c d e f g h i j k l m n ' o p q r s t u v w x y z ' f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 ' ----------------------------------------- If Key("Space") Beep EndIf If Key("X") Beep EndIf If Key("Ctrl") Beep EndIf If Key("Alt") Beep EndIf ' ============================================================================= ' Folder Demo Programs\Keys ' File KeyboardKeys.txt ' ============================================================================= ' Theremino Automation demo program ' TEST Keyboard Keys Button 1 Text "1" Key 1 Goto 1 Key 2 Goto 2 Key 3 Goto 3 Key 4 Goto 4 Key A Gosub 5 Key B Gosub 6 Label 1 Beep Load Stop Load Hide Stop Label 2 Load "Science Picnic 2014.mp3" Stop Label 3 Load Stop Load Image1.jpg Stop Label 4 Load Stop Load Image2.jpg Stop Label 5 Load video5.mov Stop Label 6 Wait Seconds 1 Return ' ============================================================================= ' Folder Demo Programs\Keys ' File Keys Autorepeat Test 1.txt ' ============================================================================= Key Left Gosub Move1 Key Right Gosub Move2 Stop Label Move1 Slot 1 = Slot(1) + 10 Gosub Move2 Wait Seconds 0.3 Gosub Move2 Slot 1 = Slot(1) + 1 Return Label Move2 Beep Return ' ============================================================================= ' Folder Demo Programs\Keys ' File Keys Autorepeat Test 2.txt ' ============================================================================= Button 1 Text Left Button 2 Text Right Key Left Gosub Left Key Right Gosub Right Stop Label Left v1 = v1 - 1 Slot 1 = v1 Print v1 Beep 5000 1 Return Label Right v1 = v1 + 1 Slot 1 = v1 Print v1 Beep 5000 1 Return ' ============================================================================= ' Folder Demo Programs\Keys ' File Keys Autorepeat Test 3.txt ' ============================================================================= Key Left Gosub Left Key Right Gosub Right Stop Label Left v1 = v1 - 1 Print v1 Return Label Right v1 = v1 + 1 Print v1 Return ' ============================================================================= ' Folder Demo Programs\Keys ' File Keys-Repetition.txt ' ============================================================================= ' TEST Keys Repetition Button 1 Text "1" Key 1 Gosub 1 Stop Label 1 Wait Seconds 1 Beep Return ' ============================================================================= ' Folder Demo Programs\Keys ' File Option GlobalKeys.txt ' ============================================================================= ' --------------------------------------------------------------- ' By default the instruction "Key" and the function "Key()" ' are active only if this application is focused (selected) ' --------------------------------------------------------------- ' This instruction enables keys also when the app is not focused Option GlobalKeys Enabled ' This instruction disables keys when the app is not focused 'Option GlobalKeys Disabled Key A Goto Test Key S Goto Stop Label Stop Stop Label Test If Key("B") Beep EndIf Goto Test ' ============================================================================= ' Folder Demo Programs\Keys ' File Test-Keys.txt ' ============================================================================= Option Speed 3 Key Left Gosub KLeft Key Right Gosub KRight Key Up Gosub KUp Key Down Gosub KDown Key 1 Gosub K1 Key 2 Gosub K2 Stop Label KLeft Beep Return Label KRight Beep Return Label KUp Beep Return Label KDown Beep Return Label K1 Beep Return Label K2 Beep Return ' ============================================================================= ' Folder Demo Programs\Keys ' File Wait_Key.txt ' ============================================================================= ' ----------------------------------------- ' Valid key names (uppercase or lowercase) ' ----------------------------------------- ' Canc Back Enter Ins Shift Ctrl Alt ' Print Scroll Pause ' Left Right Up Down PageUp PageDown ' Space Esc Home End ' 0 1 2 3 4 5 6 7 8 9 ' a b c d e f g h i j k l m n ' o p q r s t u v w x y z ' f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 ' ----------------------------------------- Wait Key("Space") Beep Wait Key("X") Beep Wait Not Key("X") Beep Wait Key("x") Beep Wait Not Key("x") Beep Wait Key("Left") Beep Wait Key("Right") Beep Wait Seconds 1 Beep Wait Key("'") Beep Wait Key("Print") Beep Wait Key("Scroll") Beep Wait Key("Pause") Beep Wait Key("Canc") Beep Wait Key("Back") Beep Wait Key("End") Beep Wait Key("Enter") Beep Wait Key("Ins") Beep ' ============================================================================= ' Folder Demo Programs\Keys ' File Window SetFocus.txt ' ============================================================================= ' Try to focus another Window and then press CTRL Label Test Window SetFocus If Key("CTRL") Beep Wait Seconds 0.5 EndIf Goto Test ' ============================================================================= ' Folder Demo Programs\LOAD and MEDIA functions ' File Load Video Images and WEB.txt ' ============================================================================= Button 1 Label Video Button 2 Label Image Button 3 Label WEB Button 4 Label Program Button 6 Label FullScreen Button 7 Label Maximized Button 8 Label Sizable Key 1 Gosub Video Key 2 Gosub Image Key 3 Gosub WEB Key 4 Gosub Program Key 5 Gosub FullScreen Key 6 Gosub Maximized Key 7 Gosub Sizable Stop Label Video Load "Video1.avi" Stop Label Image Load "BM_Foundation0.JPG" Stop Label WEB Load https://www.theremino.com Stop Label Program Load Hide Stop Label FullScreen Window FullScreen Stop Label Maximized Window Maximized Stop Label Sizable Window Sizable Stop ' ============================================================================= ' Folder Demo Programs\LOAD and MEDIA functions ' File TestSound position.txt ' ============================================================================= Button 1 Label Sound_START Button 2 Label Sound_45sec Button 3 Label Sound_90sec Button 4 Label Sound_END Load volume 10 Stop Label Sound_START Load "Sound\Blues.mid" Return Label Sound_45sec Load Position 45 Return Label Sound_90sec Load Position 90 Return Label Sound_END Load Position 99999 Return ' ============================================================================= ' Folder Demo Programs\LOAD and MEDIA functions ' File TestSound.txt ' ============================================================================= Load "Sound\Laser.wav" Wait Not MediaPlaying Load "Sound\Ringer.mp3" Wait Not MediaPlaying Load "Sound\PleaseInsertMushroom.m4a" Wait Not MediaPlaying Load "Sound\PleaseInsertMushroom.wav" Wait Not MediaPlaying Load "Sound\Blues.mid" Wait Not MediaPlaying Stop ' ============================================================================= ' Folder Demo Programs\LOAD and MEDIA functions ' File TestSoundsVolume.txt ' ============================================================================= Load Volume 10 Load "Sound\Ringer.mp3" Wait Not MediaPlaying ' THE MIDI VOLUME IS ALWAYS 100 Load "Sound\Blues.mid" Wait Not MediaPlaying Stop ' ============================================================================= ' Folder Demo Programs\LOAD and MEDIA functions ' File TestSound_Mp3_MID.txt ' ============================================================================= Load Volume 10 Load "Sound\Ringer.mp3" Wait Not MediaPlaying Load "Sound\Blues.mid" Wait Not MediaPlaying Stop ' ============================================================================= ' Folder Demo Programs\LOAD and MEDIA functions ' File Video Pause.txt ' ============================================================================= ' =================================================================== ' This example demonstrates how to pause, play and restart a video ' =================================================================== Load Video1.avi Wait Seconds 1 Load Pause Wait Seconds 1 Load Play Wait Seconds 1 Load Pause Wait Seconds 1 Load Position 1 Wait Seconds 1 Load Play Wait Seconds 3.5 Load Pause Stop ' ============================================================================= ' Folder Demo Programs\LOAD and MEDIA functions ' File Video Position.txt ' ============================================================================= ' =================================================================== ' This example demonstrates playing a video in reverse order ' ------------------------------------------------------------------- ' You can do this whith some video formats only ' (for example some AVI and Indeo5 with all the keyframes) ' =================================================================== Load Video3.avi Load Pause For v1 = 4 To 0 Step -0.1 Load Position v1 Wait Seconds 0.05 Print v1 Next Load Hide Stop ' ============================================================================= ' Folder Demo Programs\LOAD APPS ' File LOAD - Open and Close Apps.txt ' ============================================================================= ' Demo - Load and close apps Button 1 Text "Close all the apps" Button 2 Text "Close all" Load Theremino_SlotViewer.exe Stop Label Close all the apps ' ------------------------------------------------ ' This statement closes all the Theremino Apps ' ------------------------------------------------ Load CloseApps End Label Close all ' ------------------------------------------------ ' This statement closes all the Theremino Apps ' and closes Automation too ' ------------------------------------------------ Load CloseAll End ' ============================================================================= ' Folder Demo Programs\LOAD APPS ' File LOAD OpenApps.txt ' ============================================================================= ' ------------------------------------------------------------- ' "Load OpenApps" example ' ------------------------------------------------------------- Load OpenApps Beep Stop ' ============================================================================= ' Folder Demo Programs\LOAD APPS ' File LOAD SlotViewer.txt ' ============================================================================= ' ------------------------------------------------------------- ' "Load" and "Wait Application" example ' ------------------------------------------------------------- ' The "Load" waits until the application is opened ' The "Wait Application" waits until the application is closed ' ------------------------------------------------------------- Load "Theremino_SlotViewer.exe" Wait Application "Theremino_SlotViewer.exe" Beep Stop ' ============================================================================= ' Folder Demo Programs\LOAD APPS ' File LOAD TextFile.txt ' ============================================================================= Load Files\ExampleFile.txt Stop ' ============================================================================= ' Folder Demo Programs\LOAD APPS ' File Open_MicrosoftApps.txt ' ============================================================================= Load c:\Windows\system32\CharMap.exe ' ============================================================================== ' SYSTEM UTILITIES ' ============================================================================== 'Load c:\Windows\system32\CharMap.exe ' Character Map 'Load c:\Windows\system32\Calc.exe ' Calculator 'Load c:\Windows\system32\SndVol.exe ' Sound Mixer 'Load c:\Windows\system32\MsInfo32.exe ' System Informations 'Load c:\Windows\system32\WinVer.exe ' Window System Version 'Load c:\Windows\system32\SnippingTool.exe ' Snipping Tool 'Load c:\Windows\system32\MsPaint.exe ' Image Editor 'Load c:\Windows\system32\Notepad.exe ' Text Editor 'Load c:\Windows\system32\Cmd.exe ' Commands window 'Load c:\Windows\system32\Control.exe ' Control Panel 'Load c:\Windows\system32\PerfMon.exe ' Performance monitor 'Load c:\Windows\system32\ResMon.exe ' Resource monitor 'Load c:\Windows\system32\Magnify.exe ' Magnify 'Load c:\Windows\system32\Narrator.exe ' TextToSpeech utility ' ============================================================================== ' USE THE FOLLOWING ONLY IF YOU KNOW WHAT YOU ARE DOING !!! ' ============================================================================== 'Load c:\Windows\system32\msconfig.exe ' System Configuration 'Load c:\Windows\system32\optionalfeatures.exe ' Optional Features ON or OFF 'Load c:\Windows\system32\prs.exe ' Step recorder 'Load c:\Windows\system32\regedit32.exe ' Registry Editor 'Load c:\Windows\system32\mrt.exe ' Malicious software removal tool Stop ' ============================================================================= ' Folder Demo Programs\LOAD APPS ' File Wait Application 1.txt ' ============================================================================= ' ------------------------------------------------------------- ' "Load" and "Wait Application" example ' ------------------------------------------------------------- ' The "Load" waits until the application is opened ' The "Wait Application" waits until the application is closed ' ------------------------------------------------------------- s1 = "Theremino_SlotViewer.exe" Load s1 Wait Application s1 Beep Stop ' ============================================================================= ' Folder Demo Programs\LOAD APPS ' File Wait Application 2.txt ' ============================================================================= ' ------------------------------------------------------------- ' "Load" and "Wait Application" example ' ------------------------------------------------------------- ' The "Load" waits until the application is opened ' The "Wait Application" waits until the application is closed ' ------------------------------------------------------------- Load "Theremino_SlotViewer.exe" Wait Application "Theremino_SlotViewer.exe" Beep Stop ' ============================================================================= ' Folder Demo Programs\LOAD APPS ' File Wait Applications Open-Close.txt ' ============================================================================= ' AppRunning is explained in the help-file at page 61 and 77 Load Theremino_SlotViewer.exe Wait AppRunning("Theremino_SlotViewer.exe") Beep Load CloseApps Theremino_SlotViewer.exe Wait Not AppRunning("Theremino_SlotViewer.exe") Beep Stop ' ============================================================================= ' Folder Demo Programs\LOAD APPS\Command Line Examples ' File SendCommandLine.txt ' ============================================================================= 'Load c:\Windows\System32\notepad.exe TestFile.txt ''s1 = "c:\Windows\System32\notepad.exe" ''s2 = "FileName TestFile.txt" ''Load s1 s2 's1 = "PSG9080_ARB.exe" 's2 = "COM3 -read16 1 wave01.txt" 'Load s1 s2 ''s1 = "C:\Windows\System32\cmd.exe" 's1 = "Apps\PSG9080_ARB.exe" 's2 = "COM3 -read16 1 waveXX.txt" 'Load s1 s2 ' 's1 = "Apps\PSG9080_ARB.exe" ''s2 = """COM3 -read16 1 waveXX.txt""" 'Load s1 """COM3"" ""-read16"" ""1"" ""waveXX.txt""" 's1 = "c:\Windows\System32\cmd.exe" 's2 = "ipconfig /all" 'Load s1 s2 ' ' 's1 = "c:\Windows\System32\cmd.exe" 's2 = " ipconfig /all" 'Load s1 + s2 'Load "c:\Windows\System32\cmd.exe" "pause" Load "c:\Windows\System32\cmd.exe" Stop ' ============================================================================= ' Folder Demo Programs\LOAD PROGRAM ' File LoadProgram_1.txt ' ============================================================================= ' Demo LoadProgram ' THIS IS PROGRAM 1 Slot 1 = 1000 Wait Seconds 0.2 Slot 1 = 0 Wait Seconds 0.2 Slot 2 = 1000 Wait Seconds 0.2 Slot 2 = 0 Wait Seconds 0.2 Slot 3 = 1000 Wait Seconds 0.2 Slot 3 = 0 Wait Seconds 0.2 Slot 4 = 1000 Wait Seconds 0.2 Slot 4 = 0 Wait Seconds 0.2 Load "Programs\Demo Programs\LOAD PROGRAM\LoadProgram_2.txt" ' ============================================================================= ' Folder Demo Programs\LOAD PROGRAM ' File LoadProgram_2.txt ' ============================================================================= ' Demo LoadProgram ' THIS IS PROGRAM 2 Slot 1 = 1000 Wait Seconds 0.4 Slot 2 = 1000 Wait Seconds 0.4 Slot 2 = 0 Wait Seconds 0.4 Slot 1 = 0 Wait Seconds 0.4 Load "Programs\Demo Programs\LOAD PROGRAM\LoadProgram_1.txt" ' ============================================================================= ' Folder Demo Programs\LOAD SAVE - Slots and Vars ' File Demo - LoadSlots.txt ' ============================================================================= ' Load Slots demo ' Slots are always saved closing the App ' Or you can save them with "Save Slots" ' It is possible to load all the Slots with: 'Load Slots ' Or it is possible to load a range: Load Slots 20 30 '<-- Slots 20 to 30 included ' It is also possible to use complex formula ' (but do not enter spaces in the formula) v1 = 1 Load Slots v1 Sqrt(256)+3 '<-- Sqrt(256)+3 = 19 Stop ' ============================================================================= ' Folder Demo Programs\LOAD SAVE - Slots and Vars ' File Demo - Save-Load Slots-Vars.txt ' ============================================================================= Save Slots Save Vars End Load Slots Load Vars End ' ============================================================================= ' Folder Demo Programs\LOAD SAVE - Slots and Vars ' File Demo - SaveSlots_LoadSlots.txt ' ============================================================================= ' Theremino Automation demo program ' Demonstrating load and save of the Slot and Vars values Button 1 Text Load the slots Button 2 Text Save the Slots Button 3 Text Load the Vars Button 4 Text Save the Vars ' Load all the slots (0 to 999) from the file "_Slots.txt" ' The total load time is about 500 uS Label Load the slots Load Slots Stop ' Save all the slots (0 to 999) to the file "_Slots.txt" ' The total save time is about 2 mS Label Save the Slots Save Slots Stop ' Load all the vars (V0 to V9) from the file "_Vars.txt" ' The total load time is about 5 uS Label Load the Vars Load Vars Stop ' Save all the vars (V0 to V9) to the file "_Vars.txt" ' The total save time is about 20 uS Label Save the Vars Save Vars Stop ' ============================================================================= ' Folder Demo Programs\LOAD TXT files ' File Demo - LOAD file and DECODE by NAMES.txt ' ============================================================================= ' Demo - Load file / Decode to vars / Print vars Variable String Option1 Variable String Option2 Variable String Option3 Variable Numeric Velocity Variable Numeric Delay Gosub DecodeOptionFile Gosub PrintOptions Stop Label DecodeOptionFile ' ---------------------------------------- load the file Load s1 "SetupFile.txt" ' ---------------------------------------- get number of lines v1 = GetSeparatedStringCount(s1, CRLF) ' ---------------------------------------- for each line... For v2 = 0 To v1 ' ------------------------------------ get the line to s2 s2 = GetSeparatedString(s1, v2, CRLF) ' ------------------------------------ get the name to s3 s3 = GetSeparatedString(s2, 0) ' ------------------------------------ get the value to s4 s4 = GetSeparatedString(s2, 2) ' ------------------------------------ decode option names Select s3 Case "Option1" Option1 = s4 Case "Option2" Option2 = s4 Case "Option3" Option3 = s4 Case "Velocity" Velocity = s4 Case "Delay" Delay = s4 EndSelect Next Return Label PrintOptions ' -------------------------------- open the TextBox Controls OpenTextBox Controls ClearTextBox Print CRLF ' -------------------------------- print the options Print Option1 + CRLF Print Option2 + CRLF Print Option3 + CRLF Print Velocity + CRLF Print Delay + CRLF Return ' ============================================================================= ' Folder Demo Programs\LOAD TXT files ' File Demo - LOAD file and DECODE by position.txt ' ============================================================================= ' Demo Load TXT File Load s1 SetupFile.txt Controls OpenTextBox Controls ClearTextBox Print CRLF ' ---------------------------------------- get number of lines v1 = GetSeparatedStringCount(s1, CRLF) ' ---------------------------------------- for each line... For v2 = 0 To v1 ' ------------------------------------ get the line to s2 s2 = GetSeparatedString(s1, v2, CRLF) ' ------------------------------------ if the line is not empty If s2 <> "" ' -------------------------------- print the line Print s2 + CRLF ' -------------------------------- get the value to s2 s2 = GetSeparatedString(s2, 2) ' -------------------------------- print the value Print s2 + CRLF + CRLF EndIf Next Stop ' ============================================================================= ' Folder Demo Programs\LOAD TXT files ' File Demo - LOAD TXT file from var.txt ' ============================================================================= ' Demo - Load TXT File with a variable containing the FileName Variable String Str1 Variable String FileName FileName = "SetupFile.txt" Load Str1 FileName Controls OpenTextBox Controls ClearTextBox Print Str1 Stop ' ============================================================================= ' Folder Demo Programs\LOAD TXT files ' File Demo - LOAD TXT file.txt ' ============================================================================= ' Demo Load TXT File Variable String Str1 Load Str1 SetupFile.txt Controls OpenTextBox Controls ClearTextBox Print Str1 Stop ' ============================================================================= ' Folder Demo Programs\Math Functions ' File Find Prime Numbers V1.txt ' ============================================================================= Controls OpenTextBox Controls ClearTextBox FindPrimeNumbers Stop Variable Numeric number Label FindPrimeNumbers Print "2 " For number = 3 To Infinity Step 2 For v1 = 2 To Sqrt(number) If Mod(number, v1) = 0 v1 = 0 Exit EndIf Next If v1 <> 0 Print number + " " EndIf Next Return ' ============================================================================= ' Folder Demo Programs\Math Functions ' File Find Prime Numbers V2.txt ' ============================================================================= Controls OpenTextBox Controls ClearTextBox FindPrimeNumbers Variable Numeric number = 2 Variable Numeric ii Label FindPrimeNumbers ii = 2 Label loop If ii >= number Print number + " " number = number + 1 Goto FindPrimeNumbers EndIf If Mod(number, ii) = 0 number = number + 1 Goto FindPrimeNumbers EndIf ii = ii + 1 Goto loop Return ' ============================================================================= ' Folder Demo Programs\Math Functions ' File Find Prime Numbers V3.txt ' ============================================================================= Controls OpenTextBox Controls ClearTextBox FindPrimeNumbers Stop Variable Numeric number = 2 Variable Numeric divider Variable Numeric isPrime Label FindPrimeNumbers isPrime = 1 For divider = 2 To Sqrt(number) If Mod(number, divider) = 0 isPrime = 0 Exit EndIf Next If number = 2 Or isPrime = 1 Print number + " " EndIf number = number + 1 Goto FindPrimeNumbers ' ============================================================================= ' Folder Demo Programs\Math Functions ' File Limit Function.txt ' ============================================================================= ' --------------------------------------------------------------- ' Limit Example ' The V1 value is limited in the range 0 to 100 ' A sound is emitted when limits are reached ' --------------------------------------------------------------- Key Up Gosub Increase Key Down Gosub Decrease Label Stop Stop Label Increase v1 = Limit(v1 + 1, 0, 100) If LimitReached Beep Wait seconds 0.5 EndIf Button 2 Text "Value = " + v1 Return Label Decrease v1 = Limit(v1 - 1, 0, 100) If LimitReached Beep Wait seconds 0.5 EndIf Button 2 Text "Value = " + v1 Return ' ============================================================================= ' Folder Demo Programs\Math Functions ' File Math Functions - POW EXP LOG.txt ' ============================================================================= Controls OpenTextBox Print "Pow(E, 10) " + Pow(Math_E, 10) + CRLF Print "Pow(2, 10) " + Pow(2, 10) + CRLF Print "Pow(10, 10) " + Pow(10, 10) + CRLF Print CRLF Print "Exp(10) " + Exp(10) + CRLF Print "Exp2(10) " + Exp2(10) + CRLF Print "Exp10(10) " + Exp10(10) + CRLF Print CRLF Print "Log(E) " + Log(Math_E) + CRLF Print "Log2(2) " + Log2(2) + CRLF Print "Log10(10) " + Log10(10) + CRLF Print CRLF Stop ' ============================================================================= ' Folder Demo Programs\Math Functions ' File Modulus.txt ' ============================================================================= Controls ClearTextBox Controls OpenTextBox For v1 = -30 To 30 Print mod(v1, 10) + " " Next Stop ' ============================================================================= ' Folder Demo Programs\Mixed demo ' File Comment_Indent.txt ' ============================================================================= ' Theremino Automation demo program ' Multiple selected lines can be Commented and Indented ' Use right mouse button or TAB and SHIFT-TAB Label Loop1 'Slot 1 = 1000 'Slot 1 = 0 'Slot 2 = 1000 'Slot 2 = 0 'Slot 3 = 1000 'Slot 3 = 0 'Slot 4 = 1000 'Slot 4 = 0 Goto Loop1 ' ============================================================================= ' Folder Demo Programs\Mixed demo ' File Demo - Print.txt ' ============================================================================= ' To test single lines open the Debug window ' and use the "Single Step" button ' To test the debug Watches ' press "Exec" to initialize S1 and S2 Option Speed 1 Print "Donald Duck" ' --> Donald Duck Print "Duck" + " Donald" ' --> Duck Donald S1 = "PI = " S2 = Format(Math_PI, "") Print S1 + S2 ' --> PI = 3.14159265358979 Print "Duck" = "Cat" ' --> False Print Mid("Duck", 4, 1) = "k" ' --> True Print Math_PI * 2 ' --> 6.28318530717959 Print 2 * 3 + 4 * Sqrt(16) ' --> 22 Print Sin(1) + Cos(2) ' --> 0.425324148260754 ' ============================================================================= ' Folder Demo Programs\Mixed demo ' File Demo - Random.txt ' ============================================================================= ' FILE : Demo Random ' Slot 10 = Input on/off ' Slot 11 = Output random Label Loop If Slot(10) > 500 Slot 11 = 1000 * Rnd() Else Slot 11 = 0 EndIf Goto Loop ' ============================================================================= ' Folder Demo Programs\Mixed demo ' File Demo - Simple_Loop.txt ' ============================================================================= ' Theremino Automation demo program ' This is a simple loop (use Theremino slot Viewer to see the effect on the slots) Label Loop Slot 1 = 1000 Slot 2 = 1000 Slot 3 = 1000 Slot 4 = 1000 Slot 5 = 1000 Slot 6 = 1000 Slot 7 = 1000 Slot 8 = 1000 Slot 1 = 0 Slot 2 = 0 Slot 3 = 0 Slot 4 = 0 Slot 5 = 0 Slot 6 = 0 Slot 7 = 0 Slot 8 = 0 GoTo Loop ' ============================================================================= ' Folder Demo Programs\Mixed demo ' File Demo - Slot_ReadWrte.txt ' ============================================================================= ' Theremino Automation demo program ' Demonstrating read and write of Slot values Button 1 Text F1 Button 2 Text F2 Stop ' A variable is incremented and written to the slot 1 Label F1 Option Speed 7 ' 7 means 1000 instructions per second) v1 = 0 Label F1b Slot(1) = v1 v1 = v1 + 1 If v1 > 1000 ' if more than 1000 v1 = 0 ' reset to zero EndIf Goto F1b Return ' The same, but using directly the slot value ' This demonstrates also how to use the "Speed 9" ' while reducing the CPU charge with "Wait Seconds 0.001" Label F2 Option Speed 9 Slot(1) = 0 Label F2b Slot(1) = Slot(1) + 1 If Slot(1) > 1000 ' if more than 1000 Slot(1) = 0 ' reset to zero EndIf Wait Seconds 0.001 Goto F2b Return ' ============================================================================= ' Folder Demo Programs\Mixed demo ' File Demo-Simple_Loop.txt ' ============================================================================= ' Theremino Automation demo program ' This is a simple loop (use Theremino slot Viewer to see the effect on the slots) Label Loop Slot 1 = 1000 Slot 2 = 1000 Slot 3 = 1000 Slot 4 = 1000 Slot 5 = 1000 Slot 6 = 1000 Slot 7 = 1000 Slot 8 = 1000 Slot 1 = 0 Slot 2 = 0 Slot 3 = 0 Slot 4 = 0 Slot 5 = 0 Slot 6 = 0 Slot 7 = 0 Slot 8 = 0 GoTo Loop ' ============================================================================= ' Folder Demo Programs\Mixed demo ' File FourSlots-Activation.txt ' ============================================================================= ' FILE : Quattro_slot_attivati_da_zero_a_mille ' Slot 1 = Ingresso ' Slot 2 = Video 1 - trigger ' Slot 3 = Video 2 - trigger ' Slot 4 = Video 3 - trigger ' Slot 5 = Video 4 - trigger v1 = 250 v2 = 500 v3 = 750 v4 = 950 Label Loop If Slot(1) < v1 Slot 2 = 1000 Slot 3 = 0 Slot 4 = 0 Slot 5 = 0 Else If Slot(1) < v2 Slot 2 = 0 Slot 3 = 1000 Slot 4 = 0 Slot 5 = 0 Else If Slot(1) < v3 Slot 2 = 0 Slot 3 = 0 Slot 4 = 1000 Slot 5 = 0 Else If Slot(1) < v4 Slot 2 = 0 Slot 3 = 0 Slot 4 = 0 Slot 5 = 1000 Else Slot 2 = 0 Slot 3 = 0 Slot 4 = 0 Slot 5 = 0 EndIf EndIf EndIf EndIf GoTo Loop ' ============================================================================= ' Folder Demo Programs\Mixed demo ' File LegoHouseController.txt ' ============================================================================= ' FILE : Lego House Controller ' ENG ITA ' Slot 1 = Door Porta ' Slot 2 = Fireplace Camino ' Slot 3 = Attic Mansarda ' Slot 4 = Shop Negozio ' Slot 5 = Signboard Insegna ' Slot 6 = StreetLamp Lampione ' Slot 7 = Tree Albero ' Slot 8 = GreenH.Lamp Serra luce ' Slot 9 = GreenH.Lamp Serra temperatura ' Slot 10 = Free1 ' Slot 11 = Free2 ' Slot 12 = Free3 ' Slot 15 = Light cycle ' Slot 16 = Fireplace cycle Option Speed 7 Label Loop ' -------------------------------------- lights cycle speed controller v1 = v1 + Slot(15) If v1 > 100000 v1 = v1 - 100000 EndIf If v1 < 50000 Slot 3 = v1 / 50 Else Slot 3 = 2000 - v1 / 50 EndIf Slot 4 = Slot(3) Slot 5 = Slot(3) Slot 6 = Slot(3) Slot 7 = Slot(3) ' -------------------------------------- fireplace random speed controller v2 = v2 + Slot(16) If v2 > 1000 v2 = v2 - 1000 Slot 2 = 1000 * Rnd() EndIf ' -------------------------------------- loop time Wait Seconds 0.001 GoTo Loop ' ============================================================================= ' Folder Demo Programs\Mixed demo ' File PhoneDial.txt ' ============================================================================= ' =================================================== ' This program read the pulses of a telephone dial ' The thelephone dial is connected from Signal to GND ' Signal is normally down (Up=70ms / Down=40ms) ' =================================================== Option Speed 9 Variable String Status = "WaitingStart" Variable Numeric Count Variable Numeric IN Variable Numeric StartTime Label Decode IN = Slot(1) Select Status Case "WaitingStart" If IN > 800 Count = 0 Status = "WaitingDown" EndIf Case "WaitingDown" If IN < 200 Count = Count + 1 StartTime = ElapsedTime Status = "WaitingUp" EndIf Case "WaitingUp" If IN > 800 Status = "WaitingDown" EndIf If ElapsedTime - StartTime > 0.2 Gosub Execute Status = "WaitingStart" EndIf EndSelect Goto Decode Label Execute Print "Dial counts = " + Count Select Count Case 1 Case 2 Case 3 Case 4 Case 5 Case 6 Case 7 Case 8 Case 9 Case 10 ' the dial 0 has 10 pulses Beep EndSelect Return ' ============================================================================= ' Folder Demo Programs\Mixed demo ' File QuestionsGame.txt ' ============================================================================= Option Speed 9 v1 = 0 Label Loop Key 1 Gosub Sub1 Key 2 Gosub Sub2 Key 3 Gosub Sub3 Key 4 Gosub Sub4 Key 5 Gosub Sub5 Key 6 Gosub Sub6 Key 7 Gosub Sub7 Goto Loop Label Sub1 If v1 = 0 Load Image1.jpg ' First question v1 = 1 EndIf Return Label Sub2 If v1 = 1 Load Image2.jpg ' Wrong v1 = 0 EndIf Return Label Sub3 If v1 = 1 Load Image3.jpg ' OK v1 = 2 EndIf Return Label Sub4 If v1 = 2 Load Image4.jpg ' OK v1 = 3 EndIf Return Label Sub5 If v1 = 2 Load Image5.jpg ' Wrong v1 = 0 EndIf Return Label Sub6 If v1 = 3 Load Image6.jpg ' Wrong v1 = 0 EndIf Return Label Sub7 If v1 = 3 Load Image7.jpg ' Final OK v1 = 0 EndIf Return ' ============================================================================= ' Folder Demo Programs\Mixed demo ' File SlotZeroCommandsToMaster.txt ' ============================================================================= Slot 1 = Reset wait Seconds 0.1 Slot 1 = 100 Stop ' ============================================================================= ' Folder Demo Programs\Mixed demo ' File Test - DateTime.txt ' ============================================================================= V1 = 6 + Now + 6 Print Now ' ============================================================================= ' Folder Demo Programs\Mixed demo ' File The final Stop.txt ' ============================================================================= ' Theremino Automation demo program ' Test 1 Print Format(Math_PI, "0.00") + " " + Format(Cos(2), "0.00") + " " + Format(Atan2(3,0), "") ' This stop is important to reduce the CPU work ' Without the Stop the program restarts automatically ' and produces a continuous reprint Stop ' ============================================================================= ' Folder Demo Programs\Mixed demo\Sequential ON OFF ' File SequentialOnOff_Multiple.txt ' ============================================================================= Button 1 Text L1 Button L1 Slot 1 Button 2 Text L2 Button L2 Slot 2 Button 3 Text L3 Button L3 Slot 3 Stop ' ------------------ Set Slot(1) ON or OFF Label L1 If Slot(11) < 500 Slot(11) = 1000 Else Slot(11) = 0 EndIf Stop ' ------------------ Set Slot(2) ON or OFF Label L2 If Slot(12) < 500 Slot(12) = 1000 Else Slot(12) = 0 EndIf Stop ' ------------------ Set Slot(3) ON or OFF Label L3 If Slot(13) < 500 Slot(13) = 1000 Else Slot(13) = 0 EndIf Stop ' ============================================================================= ' Folder Demo Programs\Mixed demo\Sequential ON OFF ' File SequentialOnOff_SelectCase.txt ' ============================================================================= v1 = 0 Label Loop Select v1 ' ---------------------- Wait Slot(1) OFF Case 0 If Slot(1) < 500 v1 = 1 EndIf ' ---------------------- Wait Slot(1) ON Case 1 If Slot(1) > 500 v1 = 2 EndIf ' ---------------------- Pulse has been pressed Case 2 v1 = 0 ' ------------------ Set Slot(2) ON or OFF If Slot(2) < 500 Slot(2) = 1000 Else Slot(2) = 0 EndIf EndSelect Goto Loop ' ============================================================================= ' Folder Demo Programs\Mixed demo\Sequential ON OFF ' File SequentialOnOff_Simple.txt ' ============================================================================= ' ------------------ Wait pulse transition LOW to HIGH Wait Slot(1) < 500 Wait Slot(1) > 500 ' ------------------ Set Slot(2) ON or OFF If Slot(2) < 500 Slot(2) = 1000 Else Slot(2) = 0 EndIf ' ============================================================================= ' Folder Demo Programs\Mixed demo\Sequential ON OFF ' File SequentialOnOff_Subroutine.txt ' ============================================================================= Label Loop v1 = 1 ' Command Slot v2 = 2 ' Old-value Slot v3 = 3 ' Output Slot Gosub TestSlotsV1V2_And_ToggleSlotV3 v1 = 4 ' Command Slot v2 = 5 ' Old-value Slot v3 = 6 ' Output Slot Gosub TestSlotsV1V2_And_ToggleSlotV3 v1 = 7 ' Command Slot v2 = 8 ' Old-value Slot v3 = 9 ' Output Slot Gosub TestSlotsV1V2_And_ToggleSlotV3 Goto Loop Label TestSlotsV1V2_And_ToggleSlotV3 If Slot(v1) >= 500 And Slot(v2) < 500 If Slot(v3) < 500 Slot(v3) = 1000 Else Slot(v3) = 0 EndIf EndIf Slot(v2) = Slot(v1) Return ' ============================================================================= ' Folder Demo Programs\Mixed demo\Servo Controller ' File ServoController1.txt ' ============================================================================= v1 = 1 ' Slot to move (from 1 to 999) v2 = 50 ' Speed (from 1 to 1000) v3 = 1000 ' Destination (from 0 to 1000) Gosub MoveServo v1 = 1 ' Slot to move (from 1 to 999) v2 = 1000 ' Speed (from 1 to 1000) v3 = 0 ' Destination (from 0 to 1000) Gosub MoveServo v1 = 1 ' Slot to move (from 1 to 999) v2 = 10 ' Speed (from 1 to 1000) v3 = 200 ' Destination (from 0 to 1000) Gosub MoveServo Stop ' ------------------------------------- Label MoveServo v9 = Slot(v1) v8 = Sign(v3 - v9) v7 = v8 * v2 * 0.1 Wait Seconds 0.1 Label MoveServo2 If Abs(Slot(v1) - v3) <= Abs(v7) Slot(v1) = v3 Return EndIf Slot(v1) = Slot(v1) + v7 Wait Seconds 0.01 Goto MoveServo2 Return ' ------------------------------------- ' ============================================================================= ' Folder Demo Programs\Mouse ' File Controls_SetCursorPos.txt ' ============================================================================= Variable Numeric xOld Variable Numeric yOld Variable Numeric x1 Variable Numeric y1 ' Read the old cursor position xOld = MouseXP yOld = MouseYP ' Set cursor to 1000 500 and test it x1 = 1000 y1 = 500 Controls SetCursorPos x1 y1 Print MouseXP + " " + MouseYP ' Restore the old cursor position Controls SetCursorPos xold yold Stop ' ============================================================================= ' Folder Demo Programs\Mouse ' File Demo MouseX and MouseXP.txt ' ============================================================================= s1 = " MouseX=" + Format(MouseX(), "0.0") + " " s1 = s1 + " MouseY=" + Format(MouseY(), "0.0") s1 = s1 + CRLF s1 = s1 + "MouseXP=" + MouseXP() + " " s1 = s1 + "MouseYP=" + MouseYP() Print s1 ' ============================================================================= ' Folder Demo Programs\Mouse ' File JOG_Relative.txt ' ============================================================================= ' ================================================ ' This example demonstrates MouseX, MouseY ' and the KeyPressed events and conditions ' ------------------------------------------------ ' Start and reset the zero position with key "X" ' Stop with key "Z" ' ================================================ Key X Gosub JOG Stop Variable Numeric Jog_X Variable Numeric Jog_Y Variable Numeric Jog_MouseStartX Variable Numeric Jog_MouseStartY Label JOG Jog_MouseStartX = MouseX Jog_MouseStartY = MouseY Label Jog2 Jog_X = MouseX - Jog_MouseStartX Jog_Y = MouseY - Jog_MouseStartY Print Format(Jog_X, "0.000") + " " + Format(Jog_Y, "0.000") If Key("Z") Wait Not Key("Z") Return EndIf Goto Jog2 Return ' ============================================================================= ' Folder Demo Programs\Mouse ' File MouseButtons.txt ' ============================================================================= ' ======================================================= ' This example demonstrates the MouseButtons function ' ======================================================= Print MouseButtons ' ------------------------------------------------------- ' Running this program the value appears in the lower bar ' ------------------------------------------------------- ' No buttons = 0 ' Left button = 1 ' Right button = 2 ' Central button = 4 ' ------------------------------------------------------- ' ============================================================================= ' Folder Demo Programs\Mouse ' File Print Mouse Pixel Position.txt ' ============================================================================= ' ================================================ ' This example demonstrates MouseXP and MouseYP ' ------------------------------------------------ ' Values are ranging from 0 to width and height ' relative to all the connected screens ' ================================================ Print MouseXP + " " + MouseYP ' ============================================================================= ' Folder Demo Programs\Mouse ' File Print Mouse Position.txt ' ============================================================================= ' ================================================ ' This example demonstrates MouseX and MouseY ' ------------------------------------------------ ' Values are ranging from 0.000 to 1.000 ' and relative to the automation screen ' ================================================ v1 = MouseX v2 = MouseY s1 = Format(v1, "0.000") + " " s1 = s1 + Format(v2, "0.000") Print s1 ' ============================================================================= ' Folder Demo Programs\Mouse ' File Test_MouseWheel.txt ' ============================================================================= ' -------------------------------- ' Please rotate the Mouse Wheel ' on the "Controls" panel ' -------------------------------- Loop Stop Label Loop v1 = v1 + MouseWheel v1 = Limit(v1, -19, +19) Print v1 Wait Seconds 0.1 Goto Loop ' ============================================================================= ' Folder Demo Programs\OPEN CLOSE APPS ' File Test OpenClose Apps 1.txt ' ============================================================================= Gosub LoadApps Load OpenApps Button 1 Text CloseApps Button 2 Text CloseAll Stop Label LoadApps 'Load "..\..\Theremino_Automation_V6.6.25.exe" 'Load "Theremino_RS485\Theremino_RS485.exe" ' 'Load "Theremino_HAL\Theremino_HAL.exe" 'Load "Theremino_HAL\Theremino_SlotViewer.exe" 'Load "Theremino_HAL\Theremino_SlotViewer1.exe" 'Load "Theremino_HAL\Theremino_SlotViewer2.exe" 'Load "Theremino_HAL\Theremino_SlotViewer3.exe" ''Load "Theremino_HAL\Theremino_SlotViewer4.exe" 'Load "Theremino_HAL\Theremino_SignalScope_MOTOR_TORQUE.exe" 'Load "Theremino_HAL\Theremino_SignalScope_BLUETOOTH_SOLENOID.exe" Return Label CloseApps Load CloseApps Return Label CloseAll Load CloseAll Return ' ============================================================================= ' Folder Demo Programs\OPEN CLOSE APPS ' File Test OpenClose Apps 2.txt ' ============================================================================= Button 1 Label OpenNotepad Button 2 Label CloseNotepad Button 3 Label OpenCharmap Button 4 Label CloseCharmap Stop Label OpenNotepad Load "c:\windows\system32\notepad.exe" Return Label CloseNotepad Load CloseApps "c:\windows\system32\notepad.exe" Return Label OpenCharmap Load "c:\windows\system32\charmap.exe" Return Label CloseCharmap Load CloseApps "c:\windows\system32\charmap.exe" Return ' ============================================================================= ' Folder Demo Programs\Option ' File Option GlobalKeys.txt ' ============================================================================= ' --------------------------------------------------------------- ' By default the instruction "Key" and the function "Key()" ' are active only if this application is focused (selected) ' --------------------------------------------------------------- ' This instruction enables keys also when the app is not focused Option GlobalKeys Enabled ' This instruction disables keys when the app is not focused 'Option GlobalKeys Disabled Key A Goto Test Key S Goto Stop Label Stop Stop Label Test If Key("B") Beep EndIf Goto Test ' ============================================================================= ' Folder Demo Programs\Option ' File Option Speed.txt ' ============================================================================= Option Speed 3 Wait Seconds 0.3 Option Speed 5 Wait Seconds 0.3 Option Speed 7 Wait Seconds 0.3 Option Speed 9 Wait Seconds 0.3 ' ============================================================================= ' Folder Demo Programs\Option ' File Option Transparency.txt ' ============================================================================= Label Loop Option Transparency 0 Wait Seconds 0.3 Option Transparency 3 Wait Seconds 0.3 Option Transparency 5 Wait Seconds 0.3 Option Transparency 9 Wait Seconds 0.3 Goto Loop Label EventStop Option Transparency 0 End ' ============================================================================= ' Folder Demo Programs\Program Structures ' File Demo - Program Structure 1.txt ' ============================================================================= Button 1 Text "Button1" Button Button1 Color Yellow7 Button 2 Text "Button2" Button Button2 Color Yellow8 Stop Label Button1 Beep Return Label Button2 Beep Return ' ============================================================================= ' Folder Demo Programs\Program Structures ' File Demo - Program Structure 2.txt ' ============================================================================= Button 1 Text "Button1" Button Button1 Color Yellow7 Label MainLoop Gosub CheckMotorTemperature ' --------------------------------------------------------- Wait Seconds 0.1 ' <<< 0.02 sec. or more ' --------------------------------------------------------- Goto MainLoop Stop Label Button1 Beep Return Label CheckMotorTemperature ... ... Return ' ============================================================================= ' Folder Demo Programs\ReadButtonsWithADC ' File ReadButtonsWithADC.txt ' ============================================================================= Variable Numeric Slot_AnalogBut = 1 Label ReadButtonsWithADC Variable Numeric CB1 For v1 = 1 To Infinity '------------------------------------- Double check CB1 = Slot(Slot_AnalogBut) Wait Seconds 0.01 If Abs(Slot(Slot_AnalogBut) - CB1) > 10 CB1 = 99999 EndIf '------------------------------------- Test values Select True Case CB1 < 16 Yellow Case CB1 < 55 Blue Case CB1 < 120 Green Case CB1 < 190 Red Case CB1 < 500 White EndSelect Next Return Label Yellow Print "Yellow" Beep 440 50 Return Label Blue Print "Blue" Beep 660 50 Return Label Green Print "Green" Beep 880 50 Return Label Red Print "Red" Beep 1320 50 Return Label White Print "White" Beep 1660 50 Return ' ============================================================================= ' Folder Demo Programs\Scroll ' File Demo - Scroll with three functions.txt ' ============================================================================= Label Loop1 Print "Loop 1" Slot(1) = 1000 Slot(1) = 0 Slot(2) = 1000 Slot(2) = 0 Wait Seconds 1 Gosub sub1 Beep Wait Seconds 1 Slot(3) = 1000 Slot(3) = 0 Slot(4) = 1000 Slot(4) = 0 Goto Loop1 Label sub1 Print "Sub 1" Wait Seconds 1 Gosub sub2 Beep Wait Seconds 1 Return Label Sub2 Print "Sub 2" Wait Seconds 1 Return ' ============================================================================= ' Folder Demo Programs\Scroll ' File Demo - Scroll.txt ' ============================================================================= ' Try with Scroll enabled and Scroll disabled ' With Speed = 4 the scroll is continue ' With Speed > 4 the scroll is not continue Option Speed 4 ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ Label Loop v1 = v1 + 1 v1 = v1 + 2 v1 = v1 + 3 v1 = v1 + 4 v1 = v1 + 5 v1 = v1 + 6 v1 = v1 + 7 v1 = v1 + 8 v1 = v1 + 9 v1 = v1 + 10 v1 = v1 + 11 v1 = v1 + 12 v1 = v1 + 13 v1 = v1 + 14 v1 = v1 + 15 v1 = v1 + 16 v1 = v1 + 17 v1 = v1 + 18 v1 = v1 + 19 v1 = v1 + 20 v1 = v1 + 21 v1 = v1 + 22 v1 = v1 + 23 v1 = v1 + 24 v1 = v1 + 25 v1 = v1 + 26 v1 = v1 + 27 v1 = v1 + 28 v1 = v1 + 29 v1 = v1 + 30 Goto Loop ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ------ ' ============================================================================= ' Folder Demo Programs\Scroll ' File Test ProgramCounterCursor.txt ' ============================================================================= For v1 = 0 To 9e99 Gosub PrintValues Next Stop Label PrintValues Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Print v1 v1 = v1 + 1 Return ' ============================================================================= ' Folder Demo Programs\Select-Case ' File Demo - Select-Comparations.txt ' ============================================================================= ' Select the first "True" Case Select True Case Slot(1) = 2 Print "Slot 1 = 2" Case Slot(1) = 3 Print "Slot 1 = 3" Case Slot(1) = 27 And V1 <> 3 And S1 = "OK" Print "Slot 1 = 27 and V1 <> 3 and S1 = OK" CaseElse Print "Slot 1 value is different from 2, 3 and 27" EndSelect ' ============================================================================= ' Folder Demo Programs\Select-Case ' File Demo - Select-True-False.txt ' ============================================================================= ' Select with True and False Select Slot(1) = 3 Case True Print "Slot 1 = 3" Case False Print "Slot 1 is not 3" EndSelect ' ============================================================================= ' Folder Demo Programs\Select-Case ' File Demo -Select Expressions.txt ' ============================================================================= v1 = 3 Select Slot(1) Case v1 * 2 Print "This is executed when Slot(1) = 6" Case Slot(2) + 2 Print "This is executed when Slot(1) = Slot(2) + 2" EndSelect '>>> here the execution restarts from the first line ' ============================================================================= ' Folder Demo Programs\Select-Case ' File DEMO_SelectCase_Nested.txt ' ============================================================================= Load Theremino_SlotViewer.exe Controls OpenTextBox Slot 1 = 1 Slot 2 = 2 Slot 3 = 3 Label loop Controls ClearTextBox Select Slot(1) Case 1 Print "Slot1 = 1" + CRLF Select Slot(2) Case 1 Print "Slot2 = 1" + CRLF Case 2 Print "Slot2 = 2" + CRLF Select Slot(3) Case 1 Print "Slot3 = 1" + CRLF Case 2 Print "Slot3 = 2" + CRLF Case 3 Print "Slot3 = 3" + CRLF CaseElse Print "Slot3 <> 1-2-3" + CRLF EndSelect CaseElse Print "Slot2 <> 1-2" + CRLF EndSelect Case 2 Print "Slot1 = 2" + CRLF CaseElse Print "Slot1 <> 1-2" + CRLF EndSelect Wait Seconds 1 Goto loop ' ============================================================================= ' Folder Demo Programs\Select-Case ' File Test - Case with strings.txt ' ============================================================================= ' try changing the s1 value s1 = "Two" Select s1 Case "One" Print 1 Case "Two" Print 2 CaseElse Print "Not ONE and not TWO" EndSelect '>>> the execution restarts to the first line ' ============================================================================= ' Folder Demo Programs\Select-Case ' File Test - CaseElse.txt ' ============================================================================= ' try changing the v1 value v1 = 1 Select v1 Case 1 Print 1 Case 2 Print 2 CaseElse Print "Not 1 and not 2" EndSelect '>>> the execution restarts to the first line ' ============================================================================= ' Folder Demo Programs\Select-Case ' File Test - Select.txt ' ============================================================================= ' try to change the v1 value (2 or 5) v1 = 5 v2 = 2 Select v1 Case v2 Beep Case 2 + 3 Beep Beep EndSelect '>>> the execution restarts to the first line ' ============================================================================= ' Folder Demo Programs\Select-Case ' File TEST without CaseElse - Simple.txt ' ============================================================================= Gosub ExecKeys Stop Label ExecKeys Select True Case Key("SHIFT") Beep 1000 10 Case Key("CTRL") Beep 1000 10 'CaseElse Beep 1000 10 ' WITHOUT THIS CaseElse ' THE EXECUTION GOES TO THE NEXT CaseElse EndSelect Return Label ExecSequence Select "" Case "EndSeq" Beep 1000 10 Case "Stop" Beep 1000 10 CaseElse Print CRLF + " Unrecognized command: " + CRLF Beep 440 500 ' EndSelect Return ' ============================================================================= ' Folder Demo Programs\Select-Case ' File TEST_SelectCase_Nested.txt ' ============================================================================= ' IF the first CaseElse is not present ' then the second CaseElse is not working Controls CloseTextBox Slot 1 = 1 Slot 2 = 1 Select Slot(1) Case 1 Select Slot(2) Case 1 Print "Slot2 = 1" + CRLF 'CaseElse ' Print "Slot2 <> 1" + CRLF EndSelect CaseElse Print "Slot1 <> 1" EndSelect Wait Seconds 0.5 Print "" ' ============================================================================= ' Folder Demo Programs\SendKeys PressKeys ' File PressKeys_Animal_Jam_Helper.txt ' ============================================================================= Button 1 Label TestPosAndColor Button 3 Label CollectEcoCredits Button 5 Label AssignAllPets Button 6 Label UnassignAllPets Button 8 Label PaintSeedLaunch Button 9 Label PaintSeedLaunchFast PaintSeedLauncherInit Stop Variable Numeric MX = 0 'Monitor 1/2/3 = -1920 / 0 / 1920 ' =================================================================== ' TEST POS AND COLOR ' =================================================================== Label TestPosAndColor For v1 = 1 To Infinity s1 = MouseXP + " " + MouseYP + " " s1 = s1 + GetPixelColor(MouseXP, MouseYP) + " " s1 = s1 + GetColorIndex(GetPixelColor(MouseXP, MouseYP)) Print s1 Next Return ' =================================================================== ' ASSIGN / UNASSIGN PETS ' =================================================================== Label CollectEcoCredits ' -------------------------------- Save the old position v1 = MouseXP v2 = MouseYP ' -------------------------------- CollectEcoCredits2 ' -------------------------------- Controls SetCursorPos v1 v2 Return Label CollectEcoCredits2 ' ---------------------------------- double click the Ajam icon Controls SetCursorPos 1025 70 DoubleClickLeftButton ' ---------------------------------- test and click the DEN button Wait GetColorIndex(GetPixelColor(MX+3607, 51)) = 2 Wait GetColorIndex(GetPixelColor(MX+3618, 86)) = 4 Wait Seconds 0.5 Wait GetColorIndex(GetPixelColor(MX+3607, 51)) = 2 Wait GetColorIndex(GetPixelColor(MX+3618, 86)) = 4 Controls SetCursorPos MX+3618 80 DoubleClickLeftButton Wait Seconds 2 ' ---------------------------------- test the DEN yellow area Wait GetColorIndex(GetPixelColor(MX+3660, 58)) = 2 ' ---------------------------------- click Paintseeds ClickPaintSeeds ' ---------------------------------- click the solar panel Controls SetCursorPos MX+3431 872 DoubleClickLeftButton ' ---------------------------------- test and click the eco credits button Wait GetColorIndex(GetPixelColor(MX+2783, 515)) = 5 Controls SetCursorPos MX+3003 360 DoubleClickLeftButton Wait Seconds 2 ' ---------------------------------- click the red X button Controls SetCursorPos MX+3110 840 DoubleClickLeftButton Wait Seconds 0.5 ' ---------------------------------- click the fox button Controls SetCursorPos MX+2879 85 DoubleClickLeftButton Wait Seconds 0.5 ' ---------------------------------- click the ZZZ button Controls SetCursorPos MX+3122 218 DoubleClickLeftButton Wait Seconds 0.5 ' ---------------------------------- click the GEAR button Controls SetCursorPos MX+3756 1000 DoubleClickLeftButton Wait Seconds 0.5 ' ---------------------------------- click the ZZZ button Controls SetCursorPos MX+3369 160 DoubleClickLeftButton Wait Seconds 0.5 ' ---------------------------------- click the YES button Controls SetCursorPos MX+3055 417 DoubleClickLeftButton Wait Seconds 0.5 Return Label ClickLeftButton Wait Seconds 0.05 PressKeys LButtonDOWN Wait Seconds 0.05 PressKeys LButtonUP Return Label DoubleClickLeftButton ClickLeftButton ClickLeftButton Wait Seconds 0.1 Return Label ClickPaintSeeds 'Controls SetCursorPos MX+2785 573 'Controls SetCursorPos MX+2841 611 'ClickLeftButton 'Wait Seconds 0.5 Variable Numeric nn Variable Numeric x1 Variable Numeric y1 For x1 = MX+2680 To MX+2899 Step 20 For y1 = 560 To 620 Step 20 If GetColorIndex(GetPixelColor(x1, y1)) = 6 For nn = 1 To 6 Controls SetCursorPos x1 y1 ClickLeftButton Wait Seconds 0.5 Next Exit 2 EndIf Next Next Return ' =================================================================== ' ASSIGN / UNASSIGN ' =================================================================== Label AssignAllPets Controls SetCursorPos MX+2540 614 PressLeftButton PressAssign Controls SetCursorPos MX+2713 614 PressLeftButton PressAssign Controls SetCursorPos MX+2870 614 PressLeftButton PressAssign Controls SetCursorPos MX+3060 614 PressLeftButton PressAssign Controls SetCursorPos MX+3220 614 PressLeftButton PressAssign Controls SetCursorPos MX+3274 761 PressLeftButton Return Label UnassignAllPets Controls SetCursorPos MX+2540 614 PressLeftButton PressOK Controls SetCursorPos MX+2713 614 PressLeftButton PressOK Controls SetCursorPos MX+2870 614 PressLeftButton PressOK Controls SetCursorPos MX+3060 614 PressLeftButton PressOK Controls SetCursorPos MX+3220 614 PressLeftButton PressOK Controls SetCursorPos MX+3274 761 PressLeftButton Return Label PressAssign Wait Seconds 0.3 Controls SetCursorPos MX+2836 559 PressLeftButton Return Label PressOK Controls SetCursorPos MX+3033 413 PressLeftButton Return Label PressLeftButton PressKeys LButtonDOWN Wait Seconds 0.1 PressKeys LButtonUP Wait Seconds 0.2 Return ' =================================================================== ' PAINTSEED LAUNCHER ' =================================================================== Label PaintSeedLauncherInit Variable Numeric ActiveTime Variable Numeric PauseTime Variable Numeric TotalSeeds Option GlobalKeys Enabled Key Up Gosub ExecKeys Key Down Gosub ExecKeys Key Left Gosub ExecKeys Key Right Gosub ExecKeys Return Label PaintSeedLaunch ActiveTime = 0.46 PauseTime = 1.1 TotalSeeds = 380 Gosub Launcher Return Label PaintSeedLaunchFast ActiveTime = 0.46 PauseTime = 0 TotalSeeds = 760 Gosub Launcher Return Label Launcher ' -------------------------------- Save the old position v1 = MouseXP v2 = MouseYP ' ------------------------------------ Set the Cursor position Controls SetCursorPos MX+2875 230 ' ------------------------------------ Wait a little Wait Seconds 1 ' ------------------------------------ Start launcher For v91 = 1 To TotalSeeds ' -------------------------------- Test the color v9 = GetCursorPixelColor() v9 = GetColorIndex(v9) If v9 <> 6 Exit EndIf ' -------------------------------- Launch Wait Not Key("Space") PressKeys LButtonDOWN Wait Seconds ActiveTime PressKeys LButtonUP Wait Seconds PauseTime Print v91 + " " + ActiveTime + " " + PauseTime Next Controls SetCursorPos v1 v2 Return Label ExecKeys Select True Case Key("Up") ActiveTime = ActiveTime + 0.01 Case Key("Down") ActiveTime = ActiveTime - 0.01 Case Key("Right") PauseTime = PauseTime + 0.1 Case Key("Left") PauseTime = PauseTime - 0.1 EndSelect Print v91 + " " + ActiveTime + " " + PauseTime Return ' ============================================================================= ' Folder Demo Programs\SendKeys PressKeys ' File PressKeys_DoubleClick.txt ' ============================================================================= ' ----------------------------------------------------------------- ' BUTTONS ' ----------------------------------------------------------------- Button 2 Label DoubleClick Stop Label DoubleClick Controls SetCursorPos 300 800 PressLeftButton Wait Seconds 0.01 PressLeftButton Return Label PressLeftButton PressKeys LButtonDOWN Wait Seconds 0.01 PressKeys LButtonUP Wait Seconds 0.02 Return ' ============================================================================= ' Folder Demo Programs\SendKeys PressKeys ' File PressKeys_WindowsMenu.txt ' ============================================================================= Button 1 Label SystemDir Stop Label SystemDir PressKeys WINDOWS x Wait Seconds 0.5 PressKeys i Wait Seconds 0.5 PressKeys d i r Enter Return ' ============================================================================= ' Folder Demo Programs\SendKeys PressKeys ' File PressKeys_WindowsMenu_WithVars.txt ' ============================================================================= Button 1 Label SystemDir s1 = "WINDOWS x" s2 = "i" s3 = "d i r Enter" Stop Label SystemDir PressKeys s1 Wait Seconds 0.5 PressKeys s2 Wait Seconds 0.5 PressKeys s3 Return ' ============================================================================= ' Folder Demo Programs\SendKeys PressKeys ' File SendKeys_CommandLine_.txt ' ============================================================================= Button 1 Label Test_CmdExe Stop Label Test_CmdExe Load C:\Windows\System32\Cmd.Exe Wait Seconds 0.1 ' < eventually increase on slow computers SendKeys systeminfo{ENTER} Return ' ============================================================================= ' Folder Demo Programs\SendKeys PressKeys ' File SendKeys_CommandLine_WithVars.txt ' ============================================================================= Button 1 Label Test_CmdExe s1 = "C:\Windows\System32\Cmd.Exe" s2 = "systeminfo{ENTER}" Stop Label Test_CmdExe Load s1 Wait Seconds 0.1 ' < eventually increase on slow computers SendKeys s2 Return ' ============================================================================= ' Folder Demo Programs\Sequences ' File Demo OPEN EDITOR.txt ' ============================================================================= Gosub InitEditorPaths Button 1 Text EditSequence1 Button 2 Text EditSequence2 Stop Label InitEditorPaths Variable String EditorFolder Variable String EditorApp EditorFolder = ".\Apps\Theremino_Editor\" EditorApp = EditorFolder + "Theremino_Editor.exe" Return Label EditSequence1 Load EditorApp + " " + EditorFolder + "Sequences\CircleTest.seq" Return Label EditSequence2 Load EditorApp + " " + EditorFolder + "Sequences\TestSeq.seq" Return ' ============================================================================= ' Folder Demo Programs\Sequences ' File Demo OPEN SEQUENCE and FOLDER.txt ' ============================================================================= ' THIS EXAMPLE OPENS SEQUENCES WITH NOTEPAD Button 2 Text OpenSequence1 Button 3 Text OpenSequence2 Button 5 Text OpenFolders Stop Label OpenSequence1 Load ".\Apps\Theremino_Editor\Sequences\CircleTest.seq" Return Label OpenSequence2 Load ".\Apps\Theremino_Editor\Sequences\TestSeq.seq" Return Label OpenFolders Load "." Load ".\Apps\Theremino_Editor\Sequences" Return ' ============================================================================= ' Folder Demo Programs\Sequences ' File Sequence EXECUTE.txt ' ============================================================================= ' -------------------------------------- Set slots Variable Numeric Slot_LedR = 1 Variable Numeric Slot_LedG = 2 Variable Numeric Slot_LedB = 3 Load ".\Apps\Theremino_Editor\Sequences\TestSequence.seq" Load ".\Apps\Theremino_SlotViewer.exe" Gosub SequenceLoop Stop ' ==================================================================== ' LED COLORS ' ==================================================================== Label Red Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Return Label Magenta Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label Yellow Slot Slot_LedR = 900 Slot Slot_LedG = 400 Slot Slot_LedB = 0 Return Label Green Slot Slot_LedR = 0 Slot Slot_LedG = 1000 Slot Slot_LedB = 0 Return Label Blu Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label White Slot Slot_LedR = 1000 Slot Slot_LedG = 1000 Slot Slot_LedB = 1000 Return Label RgbOff Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Return ' ==================================================================== ' SEQUENCE RUN ' ==================================================================== Label SequenceLoop SequenceToExecute = ".\Apps\Theremino_Editor\Sequences\TestSequence.seq" Gosub ExecSequence Goto SequenceLoop ' ==================================================================== ' SEQUENCE LOADING AND EXECUTION ' ==================================================================== Variable String SequenceToExecute Variable String Sequence Variable String SequenceCmd Variable Numeric SequenceIndex Variable Numeric SequenceLength Label ExecSequence Load Sequence SequenceToExecute If Len(Sequence) = 0 Controls OpenTextBox Print CRLF + " Sequence file not found: " + SequenceToExecute Beep Stop EndIf ' Print CRLF + "Sequence " + GetFileNameWithoutPath(SequenceToExecute) Print " started at " + Format(Now, "HH:mm:ss") + CRLF + Chars("-", 50) + CRLF ' ---------------------------------------------------------- Variable Numeric ExecSequenceStartTime ExecSequenceStartTime = ElapsedTime ' ---------------------------------------------------------- SequenceLength = GetSeparatedStringCount(Sequence, CRLF) For SequenceIndex = 0 To SequenceLength - 1 ' ------------------------------------------------------ SequenceCmd = GetSeparatedString(Sequence, SequenceIndex, CRLF) SequenceCmd = Replace(SequenceCmd, Chr(9), " ") 'TABS to SPACES ' ------------------------------------------------------ Do not print lines containing '' If GetSeparatedStringCount(SequenceCmd, "''") < 2 Print " Exec: " + SequenceCmd + CRLF EndIf ' ------------------------------------------------------ Trim and remove comments SequenceCmd = Trim(RemoveComments(SequenceCmd)) ' ------------------------------------------------------ If SequenceCmd <> "" Select GetSeparatedString(SequenceCmd, 0) ' ---------------------------------------------- LED COLORS Case "Red" Gosub Red Case "Magenta" Gosub Magenta Case "Yellow" Gosub Yellow Case "Green" Gosub Green Case "Blu" Gosub Blu Case "White" Gosub White Case "RgbOFF" Gosub RgbOff ' ---------------------------------------------- End sequence Case "EndSeq" SequenceIndex = SequenceLength-1 ' ---------------------------------------------- With parameters Case "Pause" Wait Seconds GetSeparatedString(SequenceCmd, 1) ' ---------------------------------------------- Error CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + SequenceCmd + CRLF Beep Stop EndSelect EndIf Next Print Chars("-", 50) + CRLF + "Sequence " + GetFileNameWithoutPath(SequenceToExecute) Print " executed in " + Format(ElapsedTime - ExecSequenceStartTime, "0.00") + " sec" + CRLF Return ' ============================================================================= ' Folder Demo Programs\Sequences ' File Sequence OPEN and RUN.txt ' ============================================================================= ' ----------------------------------------------------------------- ' BUTTONS ' ----------------------------------------------------------------- Button 2 Label RunSequence1 Button RunSequence1 Text "Run sequence 1" Button RunSequence1 Color Yellow8 Button 3 Label RunSequence2 Button RunSequence2 Text "Run sequence 2" Button RunSequence2 Color Yellow8 Button 5 Label EditSequence1 Button EditSequence1 Text "Edit sequence 1" Button EditSequence1 Color Yellow8 Button 6 Label EditSequence2 Button EditSequence2 Text "Edit sequence 2" Button EditSequence2 Color Yellow8 Stop ' ' ===================================================================== ' LED COLORS ' ===================================================================== Label Red Slot(1) = 1000 Slot(2) = 0 Slot(3) = 0 Return Label Green Slot(1) = 0 Slot(2) = 1000 Slot(3) = 0 Return Label Blu Slot(1) = 0 Slot(2) = 0 Slot(3) = 1000 Return ' ===================================================================== ' SEQUENCES ' ===================================================================== Label InitSequencePaths Variable String EditorFolder Variable String EditorApp Variable String Sequence1 Variable String Sequence2 ' EditorFolder = ".\Apps\Theremino_Editor\" ' EditorApp = EditorFolder + "Theremino_Editor.exe" ' Sequence1 = EditorFolder + "Sequences\TestSequence.seq" ' Sequence2 = EditorFolder + "Sequences\ChangeSpeed.seq" Return Label RunSequence1 Gosub InitSequencePaths SequenceToExecute = Sequence1 For v1 = 1 To 3 Gosub ExecSequence Next Return Label RunSequence2 Gosub InitSequencePaths SequenceToExecute = Sequence2 Gosub ExecSequence Return Label EditSequence1 Gosub InitSequencePaths Load EditorApp + " " + Sequence1 Return Label EditSequence2 Gosub InitSequencePaths Load EditorApp + " " + Sequence2 Return ' ===================================================================== ' SEQUENCE LOADING AND EXECUTION ' ===================================================================== Variable String SequenceToExecute Variable String Sequence Variable String SequenceCmd Variable Numeric SequenceIndex Variable Numeric SequenceLength Variable Numeric SequenceValue Label ExecSequence Load Sequence SequenceToExecute If Len(Sequence) = 0 Controls OpenTextBox Print CRLF + " Sequence file not found: " + SequenceToExecute Beep Stop EndIf ' Print CRLF + "Sequence " + GetFileNameWithoutPath(SequenceToExecute) Print " started at " + Format(Now, "HH:mm:ss") + CRLF + Chars("-", 50) + CRLF ' ---------------------------------------------------------- Variable Numeric ExecSequenceStartTime ExecSequenceStartTime = ElapsedTime ' ---------------------------------------------------------- SequenceLength = GetSeparatedStringCount(Sequence, CRLF) For SequenceIndex = 0 To SequenceLength - 1 ' ------------------------------------------------------ SequenceCmd = GetSeparatedString(Sequence, SequenceIndex, CRLF) SequenceCmd = Replace(SequenceCmd, Chr(9), " ") 'TABS to SPACES ' ------------------------------------------------------ Do not print lines containing '' If GetSeparatedStringCount(SequenceCmd, "''") < 2 Print " Exec: " + SequenceCmd + CRLF EndIf ' ------------------------------------------------------ Trim and remove comments SequenceCmd = Trim(RemoveComments(SequenceCmd)) ' ------------------------------------------------------ If SequenceCmd <> "" Select GetSeparatedString(SequenceCmd, 0) ' ---------------------------------------------- LED COLORS Case "Red" Gosub Red Case "Green" Gosub Green Case "Blu" Gosub Blu ' ---------------------------------------------- End sequence Case "EendSeq" SequenceIndex = SequenceLength-1 ' ---------------------------------------------- With parameters Case "Pause" Wait Seconds GetSeparatedString(SequenceCmd, 1) Case "Speed" SequenceValue = GetSeparatedString(SequenceCmd, 1) Option Speed SequenceValue Case "Transparency" SequenceValue = GetSeparatedString(SequenceCmd, 1) Option Transparency SequenceValue Case "PressKeys" SequenceCmd = Mid(SequenceCmd, 11) PressKeys SequenceCmd Case "SendKeys" SequenceCmd = Mid(SequenceCmd, 10) SendKeys SequenceCmd ' ---------------------------------------------- Errors CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + SequenceCmd + CRLF Beep Stop EndSelect EndIf Next Print Chars("-", 50) + CRLF + "Sequence " + GetFileNameWithoutPath(SequenceToExecute) Print " executed in " + Format(ElapsedTime - ExecSequenceStartTime, "0.00") + " sec" + CRLF Return ' ============================================================================= ' Folder Demo Programs\Sequences ' File Sequence SELECT EDIT RUN.txt ' ============================================================================= ' ==================================================================== ' Demo for sequence SELECT / EDIT / RUN ' ==================================================================== ' -------------------------------------------------------------------- ' PLEASE SELECT THE SEQUENCE "TestSequence" ' -------------------------------------------------------------------- Option Speed 9 Option GlobalKeys Enabled ' -------------------------------------- Set slots Variable Numeric Slot_LedR = 1 Variable Numeric Slot_LedG = 2 Variable Numeric Slot_LedB = 3 Variable Numeric Slot_WhiteLight = 4 Gosub SetButtons Gosub RestoreVarsAndPositions Gosub ShowSequenceName Stop ' ' ==================================================================== ' BUTTONS ' ==================================================================== Label SetButtons Button 2 Text EditSequence Button EditSequence Text "Edit sequence" Button EditSequence Color PaleGreen Button 3 Text RunSequence Button RunSequence Text "RUN SEQUENCE" Button RunSequence Color Aqua Button 4 Text SelectSequence Button SelectSequence Text "Select Sequence" Button SelectSequence Color PowderBlue Button 7 Text Red Button Red Color Red Button 8 Text Magenta Button Magenta Color Magenta Button 9 Text Yellow Button Yellow Color Yellow Button 10 Text Green Button Green Color Green Button 11 Text Blu Button Blu Color MediumBlue Button 12 Text White Button White Color Green Button 13 Text RgbOff Button RgbOff Color Black Button 15 Text WhiteLightToggle Button WhiteLightToggle Text "WhiteLight ON" Button WhiteLightToggle Color LightCyan Return ' ==================================================================== ' ENABLE/DISABLE BUTTONS ' ==================================================================== Label EnableAllButtons For v1 = 1 To 32 Button v1 Enabled Next Return Label DisableAllButtons For v1 = 1 To 32 Button v1 Disabled Next Return ' ==================================================================== ' CLOSING EVENTS ' ==================================================================== Label CloseAll Gosub SaveVarsAndPositions Return Label EventStop Gosub SaveVarsAndPositions Gosub EnableAllButtons End ' ==================================================================== ' SAVE LOAD VARS ' ==================================================================== Label SaveVarsAndPositions S1 = SequenceName Save Vars Return Label RestoreVarsAndPositions Load Vars SequenceName = S1 Return ' ==================================================================== ' LED COLORS ' ==================================================================== Label Red Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Return Label Magenta Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label Yellow Slot Slot_LedR = 900 Slot Slot_LedG = 400 Slot Slot_LedB = 0 Return Label Green Slot Slot_LedR = 0 Slot Slot_LedG = 1000 Slot Slot_LedB = 0 Return Label Blu Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label White Slot Slot_LedR = 1000 Slot Slot_LedG = 1000 Slot Slot_LedB = 1000 Return Label RgbOff Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Return ' ===================================================================== ' WHITE LIGHT ' ===================================================================== Label WhiteLightToggle If Slot(Slot_WhiteLight) = 0 Gosub WhiteLightON Else Gosub WhiteLightOFF EndIf Return Label WhiteLightON Slot Slot_WhiteLight = 1000 Button WhiteLightToggle Text "WhiteLight OFF" Button WhiteLightToggle Color PowderBlue Return Label WhiteLightOFF Slot Slot_WhiteLight = 0 Button WhiteLightToggle Text "WhiteLight ON" Button WhiteLightToggle Color LightCyan Return ' ===================================================================== ' SEQUENCES ' ===================================================================== Label InitSequencePaths Variable String EditorFolder Variable String EditorApp Variable String SequencePathAndName Variable String SequenceName ' EditorFolder = ".\Apps\Theremino_Editor\" ' EditorApp = EditorFolder + "Theremino_Editor.exe" ' SequencePathAndName = EditorFolder + "Sequences\" + SequenceName Return Label EditSequence Gosub InitSequencePaths If FileExists(SequencePathAndName) Load EditorApp + " " + SequencePathAndName EndIf Return Label SelectSequence Gosub InitSequencePaths s1 = SelectFile(EditorFolder + "Sequences\") If s1 <> "" SequenceName = s1 Gosub ShowSequenceName Gosub EditSequence EndIf Return Label ShowSequenceName Button SelectSequence Text "Sequence" + CRLF + SequenceName Return ' ==================================================================== ' RUN sequence ' ==================================================================== Label RunSequence Gosub DisableAllButtons Button EditSequence Enabled Controls OpenTextBox Gosub InitSequencePaths ' SequenceToExecute = SequencePathAndName Variable Numeric NumCycle For NumCycle = NumCycle To Infinity Gosub ExecSequence Next Gosub EnableAllButtons Return ' ==================================================================== ' SEQUENCE LOADING AND EXECUTION ' ==================================================================== Variable String SequenceToExecute Variable String Sequence Variable String SequenceCmd Variable Numeric SequenceIndex Variable Numeric SequenceLength Label ExecSequence Load Sequence SequenceToExecute If Len(Sequence) = 0 Controls OpenTextBox Print CRLF + " Sequence file not found: " + SequenceToExecute Beep Stop EndIf ' Print CRLF + "Sequence " + GetFileNameWithoutPath(SequenceToExecute) Print " started at " + Format(Now, "HH:mm:ss") + CRLF + Chars("-", 50) + CRLF ' ---------------------------------------------------------- Variable Numeric ExecSequenceStartTime ExecSequenceStartTime = ElapsedTime ' ---------------------------------------------------------- SequenceLength = GetSeparatedStringCount(Sequence, CRLF) For SequenceIndex = 0 To SequenceLength - 1 ' ------------------------------------------------------ SequenceCmd = GetSeparatedString(Sequence, SequenceIndex, CRLF) SequenceCmd = Replace(SequenceCmd, Chr(9), " ") 'TABS to SPACES ' ------------------------------------------------------ Do not print lines containing '' If GetSeparatedStringCount(SequenceCmd, "''") < 2 Print " Exec: " + SequenceCmd + CRLF EndIf ' ------------------------------------------------------ Trim and remove comments SequenceCmd = Trim(RemoveComments(SequenceCmd)) ' ------------------------------------------------------ If SequenceCmd <> "" Select GetSeparatedString(SequenceCmd, 0) ' ---------------------------------------------- LED COLORS Case "Red" Gosub Red Case "Magenta" Gosub Magenta Case "Yellow" Gosub Yellow Case "Green" Gosub Green Case "Blu" Gosub Blu Case "White" Gosub White Case "RgbOFF" Gosub RgbOff ' ---------------------------------------------- White light Case "WhiteLightON" Gosub WhiteLightON Case "WhiteLightOFF" Gosub WhiteLightOFF ' ---------------------------------------------- End sequence Case "EndSeq" SequenceIndex = SequenceLength-1 ' ---------------------------------------------- With parameters Case "Pause" Wait Seconds GetSeparatedString(SequenceCmd, 1) ' ---------------------------------------------- Errors CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + SequenceCmd + CRLF Beep Stop EndSelect EndIf Next Print Chars("-", 50) + CRLF + "Sequence " + GetFileNameWithoutPath(SequenceToExecute) Print " executed in " + Format(ElapsedTime - ExecSequenceStartTime, "0.00") + " sec" + CRLF Return ' ============================================================================= ' Folder Demo Programs\Sequences ' File WXM_CNC_Vslot_Automation_16_4b.txt ' ============================================================================= ' ==================================================================== ' Name: WXM_CNC_Vslot_Automation_16_4b.txt Date: 21 Jun 2021 ' Autor: Leonardo DE PALO ' Scope: Two gripper PWM, rotating with Protocol1 of FeeTech. ' Hardware: Standard Master e SM29. ' note: ' ==================================================================== Option Speed 9 Option GlobalKeys Enabled ' ==================================================================== ' INITIALIZATIONS ' ==================================================================== Gosub InitCoreXY ' -------------------------------------- Set slots Slot_LedR = 907 Slot_LedG = 908 Slot_LedB = 909 Slot_Air = 911 Slot_WhiteLight = 912 Slot_SignalScope = 914 Slot_ClampM1 = 504 Slot_ClampM2 = 604 Gosub SetButtonsAndKeys ' -------------------------------------- Torque parameters - DoorLock ' DoorLock limit: 1.5 newton/meter ' DoorLock limit: 15.3 kg/cm ' -------------------------------------- Torque parameters - Motor ' Motor test: 679 current = 352 g/25cm ' Motor test: 679 current = 8.8 kg/cm ' Motor test: 679 current = 0.863 n/m ' -------------------------------------- Coeff_NM = 0.001271 '(0.863 / 679) ' -------------------------------------- Rotation software limits Rmax = +30719 Rmin = -30719 ' -------------------------------------- Torque limit TorqueLimitRotation = 9e99 ' -------------------------------------- Positions 'A_PickVib = 1 * 4096 / 360 'B_PickVib = 90 * 4096 / 360 'A_PlaceCNC = 180 * 4096 / 360 'B_PlaceCNC = 235 * 4096 / 360 'A_PickCNC = 270 * 4096 / 360 'A_Release = 359 * 4096 / 360 '==================================================================== ' LOAD APPS ' ==================================================================== Load Theremino_RS485\Theremino_RS485.exe Load Theremino_HAL\Theremino_HAL.exe Load DigiClampM1\DigiClampM1.exe Load DigiClampM2\DigiClampM2.exe Load Theremino_HAL\Theremino_SlotViewer.exe Load Theremino_HAL\Theremino_Signalscope_DigiClamp_1.exe Load Theremino_HAL\Theremino_SignalScope_DigiClamp_2.exe 'Load Theremino_HAL\Theremino_SignalScope_MOTOR_TORQUE.exe ' ==================================================================== ' TEST MASTER ' ==================================================================== For v1 = 1 To 9e99 For v2 = 1 To 20 ' <<< testing for 2 seconds If (Slot(0) >= 1 And Slot(0) <= 2) Or Key("CTRL") Exit 2 EndIf Wait Seconds 0.1 Next Print " Invalid master number: " + Slot(0) + CRLF Slot 0 = Recognize Beep Next ' ==================================================================== ' START ' ==================================================================== Gosub RestoreVarsAndPositions Gosub ShowSequenceName Slot(Slot_Speed) = 1000 Controls ClearTextBox 'Window MinSize Load "media\images\SM29_RotatingGripper.png" 'Button sound\gong.wav Button RunSequence Disabled Load Hide Gosub InitMotors Gosub ReleaseM1 Gosub ReleaseM2 Wait Seconds 0.5 Gosub HomeRotation Gosub HomeXY Button RunSequence Enabled Option GlobalKeys Disabled Gosub BlueOn ' ==================================================================== ' MAIN LOOP ' ==================================================================== Label MainLoop Gosub CheckMotorTemperature Gosub UpdateButtons Gosub CheckMotor1AndReinit ' --------------------------------------------------------- ' 0.02 sec. or more to allow time for keys and other tasks Wait Seconds 0.1 ' --------------------------------------------------------- Goto MainLoop Label UpdateButtons Button Rotation Text "Rot.=" + Format(Slot(Slot_Destination1) * 360 / 4096, "0.0") Return Stop ' ' ==================================================================== ' BUTTONS ' ==================================================================== Label SetButtonsAndKeys Button 2 Text HomeRotation Button HomeRotation Text "Home Rotation" Button HomeRotation Color SkyBlue Button 3 Text EnableRotation Button EnableRotation Text "Enable Rotation" Button 4 Text DisableRotation Button DisableRotation Text "Disable Rotation" Button 5 Text EditSequence Button EditSequence Text "Edit sequence" Button EditSequence Color PaleGreen Button 6 Text RunSequence Button RunSequence Text "RUN SEQUENCE" Button RunSequence Color Aqua Button 7 Text SelectSequence Button SelectSequence Text "Select Sequence" Button SelectSequence Color PowderBlue Button 10 Text "Rotation" Button Rotation Color Yellow Button Rotation Text "Rotation" Button 11 Text "BtnDestX" Button BtnDestX Text "X = ?" Button BtnDestX Color Yellow Button 12 Text "BtnDestY" Button BtnDestY Text "Y = ?" Button BtnDestY Color Yellow Button 13 Text ResetLogCounter Button ResetLogCounter Text "Reset Log counter" Button ResetLogCounter Color White Button 14 Text "MotorTemp" Button MotorTemp Color Salmon Button 15 Text CloseAll Button CloseAll Text "CLOSE ALL" Button CloseAll Color Red Button 16 Text Emergency Button Emergency Text "EMERGENCY" Button Emergency Color Red Button Emergency Slot Slot_Emergency Button 17 Text RedOn Button RedOn Color Red Button 18 Text MagentaOn Button MagentaOn Color Magenta Button 19 Text YellowOn Button YellowOn Color Yellow Button 20 Text GreenOn Button GreenOn Color Green Button 21 Text BlueOn Button BlueOn Color MediumBlue Button 22 Text WhiteOn Button GreenOn Color Green Button 23 Text RgbOff Button RgbOff Color Black Button 25 Text ClampM1Toggle Button ClampM1Toggle Text "Clamp M1" Button ClampM1Toggle Color LightBlue Button 26 Text ClampM2Toggle Button ClampM2Toggle Text "Clamp M2" Button ClampM2Toggle Color LightBlue Button 27 Text AirToggle Button AirToggle Text "Air ON" Button AirToggle Color LightCyan Button 28 Text WhiteLightToggle Button WhiteLightToggle Text "WhiteLight ON" Button WhiteLightToggle Color LightCyan Button 29 Text OpenLogfile Button OpenLogfile Text "Open Log file" Button OpenLogfile Color PaleGreen Button 31 Text SetCenterPositions Button SetCenterPositions Text " WARNING" + CRLF + "Set Center Positions" Button SetCenterPositions Color DarkOrange Button 32 Text GotoCenterPositions Button GotoCenterPositions Text "Goto Center Positions" Return ' ==================================================================== ' MOTORS ' ==================================================================== Variable Numeric Slot_Destination1 Variable Numeric Slot_Position1 Label InitMotors ' --------------------------------- Init Destination Slots Slot_Destination1 = 101 ' --------------------------------- Init Position Slots Slot_Position1 = 102 ' --------------------------------- All to 0 to ensure resending values Slot(101) = Slot(101) - 1 Slot(120) = 0 Slot(121) = 0 Slot(122) = 0 Wait Seconds 0.1 Slot(101) = Slot(101) + 1 ' --------------------------------- Torque 0-1000 to motors 1-4 Slot(120) = 800 ' --------------------------------- Acceleration 0-255 to motors 1-4 Slot(121) = 50 ' --------------------------------- Speed 0-10000 to motors 1-4 Slot(122) = 3000 Return Label EnableRotation Slot(123) = 1 Wait Seconds 0.1 Return Label DisableRotation Slot(123) = 0 Return Label SetCenterPositions 'Slot(123) = 180 'Wait Seconds 0.5 'Gosub EnableRotation 'Gosub CopyPositionsToDestinations Return Label CopyPositionsToDestinations Slot(Slot_Destination1) = Slot(Slot_Position1) Return ' ---------------------------------- goto the middle point at 2048 Label GotoCenterPositions ' Slot(Slot_Destination1) = 2048 Return Variable Numeric MotorsTemperature Label TestMotorsTemperature MotorsTemperature = Slot(106) Return Label TorqueReader ' ------------------------------------------------- read the torque Variable Numeric TorqueNM_Rotation TorqueNM_Rotation = Coeff_NM * Slot(104) If TorqueNM_Rotation >= 1024 TorqueNM_Rotation = TorqueNM_Rotation - 1024 EndIf Return Label TorqueTester Gosub TorqueReader ' ------------------------------------------------- read the torque Variable Numeric MaxTorqueRotation TorqueNM_Rotation = Coeff_NM * Slot(104) MaxTorqueRotation = Max(MaxTorqueRotation, TorqueNM_Rotation) ' ------------------------------------------------- test limits If MaxTorqueRotation > TorqueLimitRotation Gosub ALARM Result = Result + CRLF + " Torque limit Rotation " Gosub UpdateResultTorque Result = Result + CRLF Gosub UpdateResult Result = Result + CRLF EndIf Return Label WaitMotor1 Variable Numeric WM1 Wait Seconds 0.2 ' <<< ensures that motors are really started For WM1 = 1 To Infinity If Abs(Slot(103)) < 0.01 Exit EndIf Wait Seconds 0.005 Gosub TorqueTester Next Wait Seconds 0.1 Gosub TorqueTester Return Label TestRaw Variable Numeric TR1 For TR1 = 1 To Infinity If Slot(Slot_RawSensor) < 500 Exit EndIf Gosub YellowOn Load sound\beep.wav Wait Seconds 0.5 Gosub MagentaOn Load sound\PleaseInsertMushroom.m4a Wait Not MediaPlaying Next Gosub GreenOn Return Label CheckMotor1AndReinit If Abs(Slot(103)) > 1 Gosub InitMotors Load sound\beep.wav EndIf Return Label HomeRotation Gosub EnableRotation Slot(Slot_Destination1) = 183 * 4096 / 360 Gosub WaitMotor1 Return Label CheckMotorTemperature Variable Numeric OldTemperature Gosub TestMotorsTemperature If MotorsTemperature <> OldTemperature OldTemperature = MotorsTemperature Button MotorTemp Text "MotorTemp: " + Format(MotorsTemperature, "0") If MotorsTemperature > 55 For v1 = 1 To Infinity '10 Load Sound\Alarm14.wav Wait Not MediaPlaying Next Stop EndIf EndIf If MotorsTemperature = 0 Controls OpenTextBox For v1 = 1 To Infinity '10 Print " RS485 not ready" + CRLF Load Sound\Alarm14.wav Wait Not MediaPlaying Next Stop EndIf Return ' ==================================================================== ' VARIABLES ' ==================================================================== Variable Numeric Slot_LedR Variable Numeric Slot_LedG Variable Numeric Slot_LedB Variable Numeric Slot_Air Variable Numeric Slot_WhiteLight Variable Numeric Slot_SignalScope Variable Numeric Slot_Emergency Variable Numeric Rmax Variable Numeric Rmin Variable Numeric Coeff_NM Variable Numeric TorqueLimitRotation Variable Numeric Slot_ClampM1 Variable Numeric Slot_ClampM2 ' ==================================================================== ' EMERGENCY ' ==================================================================== Label Emergency ' Gosub DisableAllButtons ' Button 15 Enabled ' Button 15 Color Flashing7 Yellow Red ' For v1 = 1 To 9e99 ' Gosub RedOn ' Wait Seconds 0.4 ' Gosub RgbOff ' Wait Seconds 0.4 ' Load sound\Alarm10b.wav ' Next Stop ' ==================================================================== ' ENABLE/DISABLE BUTTONS ' ==================================================================== Label EnableAllButtons For v1 = 1 To 32 Button v1 Enabled Next Return Label DisableAllButtons For v1 = 1 To 32 Button v1 Disabled Next Return ' ==================================================================== ' CLOSING EVENTS ' ==================================================================== Label CloseAll Gosub SaveVarsAndPositions Load CloseApps Return Label EventStop Gosub SaveVarsAndPositions Gosub EnableAllButtons Window Sizable Slot(Slot_SignalScope) = 0 Gosub AirOFF Gosub WhiteLightOFF End ' ==================================================================== ' SAVE LOAD and CLEAR VARS and POSITIONS ' ==================================================================== Label SaveVarsAndPositions v1 = NumCycle v2 = ErrorNumber v3 = DestX v4 = DestY S1 = SequenceName S2 = LogName Save Vars 'Print CRLF + "SAVED SEQUENCENAME = " + s1 + CRLF Return Label RestoreVarsAndPositions Load Vars NumCycle = v1 ErrorNumber = v2 DestX = v3 DestY = v4 SequenceName = S1 LogName = S2 Return Label ClearVars NumCycle = 0 ErrorNumber = 0 Return Label ResetLogCounter Gosub ClearVars Return ' ==================================================================== ' LED COLORS ' ==================================================================== Label RedOn Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Return Label MagentaOn Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label YellowOn Slot Slot_LedR = 900 Slot Slot_LedG = 400 Slot Slot_LedB = 0 Return Label GreenOn Slot Slot_LedR = 0 Slot Slot_LedG = 1000 Slot Slot_LedB = 0 Return Label BlueOn Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label WhiteOn Slot Slot_LedR = 1000 Slot Slot_LedG = 1000 Slot Slot_LedB = 1000 Return Label RgbOff Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Return ' ===================================================================== ' COMPRESSED AIR MANAGEMENT and WHITE LIGHT ' ===================================================================== Label AirToggle If Slot(Slot_Air) = 0 Gosub AirON Else Gosub AirOFF EndIf Return Label AirON Slot(Slot_Air) = 1000 Button AirToggle Text "Air OFF" Button AirToggle Color PowderBlue Return Label AirOFF Slot(Slot_Air) = 0 Button AirToggle Text "Air ON" Button AirToggle Color LightCyan Return Label WhiteLightToggle If Slot(Slot_WhiteLight) = 0 Gosub WhiteLightON Else Gosub WhiteLightOFF EndIf Return Label WhiteLightON Slot Slot_WhiteLight = 1000 Button WhiteLightToggle Text "WhiteLight OFF" Button WhiteLightToggle Color PowderBlue Return Label WhiteLightOFF Slot Slot_WhiteLight = 0 Button WhiteLightToggle Text "WhiteLight ON" Button WhiteLightToggle Color LightCyan Return ' ===================================================================== ' DigiClamp ACTIONS ' ===================================================================== Label ClampM1Toggle If Slot(Slot_ClampM1) = 0 Gosub ClampM1 Else Gosub ReleaseM1 EndIf Return Label ClampM1 Slot(Slot_ClampM1) = 1000 Button ClampM1Toggle Text "Release M1" Button ClampM1Toggle Color PowderBlue Return Label ReleaseM1 Slot(Slot_ClampM1) = 0 Button ClampM1Toggle Text "Clamp M1" Button ClampM1Toggle Color Cyan Return Label ClampM2Toggle If Slot(Slot_ClampM2) = 0 Gosub ClampM2 Else Gosub ReleaseM2 EndIf Return Label ClampM2 Slot(Slot_ClampM2) = 1000 Button ClampM2Toggle Text "Release M2" Button ClampM2Toggle Color PowderBlue Return Label ReleaseM2 Slot(Slot_ClampM2) = 0 Button ClampM2Toggle Text "Clamp M2" Button ClampM2Toggle Color Cyan Return ' ===================================================================== ' SEQUENCES ' ===================================================================== Label InitSequencePaths Variable String EditorFolder Variable String EditorApp Variable String SequencePathAndName Variable String SequenceName ' EditorFolder = ".\Apps\Theremino_Editor\" ' EditorApp = EditorFolder + "Theremino_Editor.exe" ' SequencePathAndName = EditorFolder + "Sequences\" + SequenceName Return Label EditSequence Gosub InitSequencePaths If FileExists(SequencePathAndName) Load EditorApp + " " + SequencePathAndName EndIf Return Label SelectSequence Gosub InitSequencePaths s1 = SelectFile(EditorFolder + "Sequences\") If s1 <> "" SequenceName = s1 LogName = "Files\Logs\" + Replace(SequenceName, ".seq", ".txt") Gosub ShowSequenceName Gosub EditSequence EndIf Return Label ShowSequenceName Button SelectSequence Text "Sequence" + CRLF + SequenceName Return ' ==================================================================== ' RUN sequence ' ==================================================================== Label RunSequence Gosub InitMotors Gosub DisableAllButtons Gosub ReleaseM1 Gosub ReleaseM2 Gosub HomeXY Button EditSequence Enabled Button OpenLogfile Enabled Button CloseAll Enabled Button Emergency Enabled Button Rotation Enabled Button MotorTemp Enabled Button BtnDestX Enabled Button BtnDestY Enabled Variable Numeric ExitFromSequenceLoop ' Slot(Slot_SignalScope) = 1000 Controls OpenTextBox StartTime = ElapsedTime Gosub InitSequencePaths Gosub InitFileHeader ' ExitFromSequenceLoop = 0 SequenceToExecute = SequencePathAndName For NumCycle = NumCycle To Infinity Slot(Slot_SignalScope) = 1000 Result = "" MaxTorqueRotation = 0 Gosub ExecSequence Gosub UpdateLog Slot(Slot_SignalScope) = 0 Wait Seconds 0.5 If ExitFromSequenceLoop > 0 Exit EndIf Next Slot(Slot_SignalScope) = 0 Gosub EnableAllButtons Return ' ==================================================================== ' SEQUENCE LOADING AND EXECUTION ' ==================================================================== Variable String SequenceToExecute Variable String Sequence Variable String SequenceCmd Variable Numeric SequenceIndex Variable Numeric SequenceLength Label ExecSequence Load Sequence SequenceToExecute If Len(Sequence) = 0 Controls OpenTextBox Print CRLF + " Sequence file not found: " + SequenceToExecute Beep Stop EndIf ' Print CRLF + "Sequence " + GetFileNameWithoutPath(SequenceToExecute) Print " started at " + Format(Now, "HH:mm:ss") + CRLF + Chars("-", 50) + CRLF ' ---------------------------------------------------------- Variable Numeric ExecSequenceStartTime ExecSequenceStartTime = ElapsedTime ' ---------------------------------------------------------- SequenceLength = GetSeparatedStringCount(Sequence, CRLF) For SequenceIndex = 0 To SequenceLength - 1 ' ------------------------------------------------------ SequenceCmd = GetSeparatedString(Sequence, SequenceIndex, CRLF) SequenceCmd = Replace(SequenceCmd, Chr(9), " ") 'TABS to SPACES ' ------------------------------------------------------ Do not print lines containing '' If GetSeparatedStringCount(SequenceCmd, "''") < 2 Print " Exec: " + SequenceCmd + CRLF EndIf ' ------------------------------------------------------ Trim and remove comments SequenceCmd = Trim(RemoveComments(SequenceCmd)) ' ------------------------------------------------------ If SequenceCmd <> "" Select GetSeparatedString(SequenceCmd, 0) ' ---------------------------------------------- ACTIONS Case "TestRaw" Gosub TestRaw Case "EnableRotation" Gosub EnableRotation Case "DisableRotation" Gosub DisableRotation Case "WaitMotor1" Gosub WaitMotor1 Case "CloseAll" Gosub CloseAll Case "HomeXY" Gosub HomeXY ' ---------------------------------------------- DigiClamp commands Case "ClampM1" Gosub ClampM1 Case "ClampM2" Gosub ClampM2 Case "ReleaseM1" Gosub ReleaseM1 Case "ReleaseM2" Gosub ReleaseM2 ' ---------------------------------------------- Air compressed IR Case "AirON" Gosub AirON Case "AirOFF" Gosub AirOFF ' ---------------------------------------------- White light Case "WhiteLightON" Gosub WhiteLightON Case "WhiteLightOFF" Gosub WhiteLightOFF ' ---------------------------------------------- LED COLORS Case "RedON" Gosub RedOn Case "MagentaON" Gosub MagentaOn Case "YellowON" Gosub YellowOn Case "GreenON" Gosub GreenOn Case "BlueOn" Gosub BlueOn Case "WhiteOn" Gosub WhiteOn Case "RgbOFF" Gosub RgbOff ' ---------------------------------------------- End sequence Case "EndSeq" SequenceIndex = SequenceLength-1 ' ---------------------------------------------- Event STOP sequence Case "EventStop" Gosub EventStop ' ---------------------------------------------- STOP Case "Stop" ExitFromSequenceLoop = 1 Exit ' ---------------------------------------------- With parameters Case "MoveRotation" v1 = GetSeparatedString(SequenceCmd, 1) Slot(Slot_Destination1) = v1 * 4096 / 360 Gosub WaitMotor1 Case "MoveSlowXY" MoveSlowXY_DestX = GetSeparatedString(SequenceCmd, 1) MoveSlowXY_DestY = GetSeparatedString(SequenceCmd, 2) MoveSlowXY_Speed = GetSeparatedString(SequenceCmd, 3) Gosub MoveSlowXY Case "Pause" Wait Seconds GetSeparatedString(SequenceCmd, 1) Case "SignalScope" Slot(Slot_SignalScope) = GetSeparatedString(SequenceCmd, 1) Case "TorqueLimitRotation" TorqueLimitRotation = GetSeparatedString(SequenceCmd, 1) ' ---------------------------------------------- Errors CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + SequenceCmd + CRLF Beep Stop EndSelect Gosub UpdateButtons EndIf Next Print Chars("-", 50) + CRLF + "Sequence " + GetFileNameWithoutPath(SequenceToExecute) Print " executed in " + Format(ElapsedTime - ExecSequenceStartTime, "0.00") + " sec" + CRLF Return ' ==================================================================== ' PRINT LOG '===================================================================== Variable String LogName Variable String FileHeader Variable Numeric NumCycle Variable Numeric ErrorNumber Variable String Result Label OpenLogfile Load LogName Return Label InitFileHeader FileHeader = CRLF FileHeader = FileHeader + " TEST ROBOT W1 Num Durat. " + CRLF FileHeader = FileHeader + " Date Time Cycle sec. RESULT " + CRLF FileHeader = FileHeader + "-----------------------------------------" Save StringToFile FileHeader LogName Return Variable String LG1 Variable Numeric StartTime Label UpdateLog Controls OpenTextBox LG1 = "" LG1 = LG1 + Format(Now, "yyyy/MM/dd HH:mm:ss") LG1 = LG1 + PadLeft(Format(NumCycle, "00000"), 7) LG1 = LG1 + PadLeft(Format(ElapsedTime - StartTime, "0.00"), 6) If Result <> "" ErrorNumber = ErrorNumber + 1 LG1 = LG1 + " FAIL " + ErrorNumber LG1 = LG1 + " (" + Format(100 * ErrorNumber / NumCycle, "0.0") + "%)" LG1 = CRLF + LG1 + Result + CRLF Else LG1 = LG1 + " PASS" EndIf Save StringToFile LG1 LogName Print CRLF + LG1 + CRLF + CRLF StartTime = ElapsedTime Return Label UpdateResult Result = Result + "Rot.=" + Format(Slot(Slot_Position1) * 360 / 4096, "0.0") + "° " Return Label UpdateResultTorque Result = Result + "TorqueMax=" + Format(MaxTorqueRotation, "0.0") Result = Result + "(" + Format(TorqueLimitRotation, "0.0") + ")" Return Label ALARM Variable Numeric AL For AL = 1 To 1 Gosub RedOn Load "sound/Alarm10b.wav" Wait Not MediaPlaying Next MaxTorqueRotation = 0 Return Stop ' Stop ' Stop ' Stop ' ' CORE XY SECTION Stop ' Stop ' Stop ' Stop ' Label InitCoreXY ' -------------------------------------- Options KeyJog_Speed = 500 ' -------------------------------------- Software limits DestxMax = 318 DestxMin = 1 DestyMax = 300 DestyMin = 14 ' ----------------------------------------- STEPPER SLOTS Slot_MotorA = 1 '1_TabTesterXY pin 1 STEPPER A Slot_MotorB = 3 '1_TabTesterXY pin 3 STEPPER B Slot_SensorX = 7 '1_TabTesterXY pin 7 DIG INPUT Limit X Slot_SensorY = 8 '1_TabTesterXY pin 8 DIG INPUT Limit Y Slot_RawSensor = 9 Slot_EnableMotorsCoreXY = 10 '1_TabTesterXY pin 10 DIG OUT ' ----------------------------------------- EMERGENCY and SPEED Slot_Speed = 6 ' ----------------------------------------- KEYS Key Right Gosub ExecKeys Key Left Gosub ExecKeys Key Up Gosub ExecKeys Key Down Gosub ExecKeys ' ----------------------------------------- START DestX = v1 DestY = v2 Load Hide ' ----------------------------------------------------------------- ' BUTTONS - COREXY ' ----------------------------------------------------------------- Button 1 Text HomeXY Button HomeXY Text "Home XY" Button HomeXY Color Yellow 'Button 34 Text EnableMotorsCoreXY 'Button EnableMotorsCoreXY Text "ENABLE XY" 'Button EnableMotorsCoreXY Color PaleGreen ' 'Button 35 Text DisableMotorsCoreXY 'Button DisableMotorsCoreXY Text "DISABLE XY" 'Button DisableMotorsCoreXY Color PaleGreen Return Stop ' ' ------------------------------------ COREXY Variable Numeric DestxMax Variable Numeric DestxMin Variable Numeric DestyMax Variable Numeric DestyMin ' ------------------------------------ COREXY Label ClearButtons For v1 = 1 To 32 Button v1 Text "" Button v1 Color Moccasin Next Return ' ===================================================================== ' CORE XY ' ===================================================================== Variable Numeric DestX ' destination in mm coords Variable Numeric DestY ' destination in mm coords Variable Numeric Slot_MotorA Variable Numeric Slot_MotorB Variable Numeric Slot_EnableMotorsCoreXY Variable Numeric Slot_SensorX Variable Numeric Slot_SensorY Variable Numeric Slot_RawSensor Label CoreXY_MoveToDestXY_AndWait ' move to destX & destY and wait stop motors Gosub CoreXY_MoveToDestXY Gosub WaitMotorsCoreXY Return Label CoreXY_MoveToDestXY ' move to destX & destY (with limits) DestX = Limit(DestX, DestxMin, DestxMax) DestY = Limit(DestY, DestyMin, DestyMax) If LimitReached Load sound\GeigerClick_16.wav EndIf Gosub CoreXY_PrepareCoreAB Slot(Slot_MotorA) = CoreA Slot(Slot_MotorB) = CoreB Return Label CoreXY_MoveToDestXY_NoLimits ' move to destX & destY (without using limits) Gosub CoreXY_PrepareCoreAB Slot(Slot_MotorA) = CoreA Slot(Slot_MotorB) = CoreB Return ' ---------------------------------------------------------------------- ' To use this function you must prepare DestX and DestY ' with the declared switch positions ' ---------------------------------------------------------------------- Label CoreXY_SetNewZero ' ------------------------- Reset axis X and Y Slot(Slot_MotorA) = Reset Slot(Slot_MotorB) = Reset Wait Seconds 0.15 ' ------------------------- Set reset values with CoreXY correction Gosub CoreXY_MoveToDestXY_NoLimits Gosub WaitMotorsCoreXY Return Variable Numeric CoreA Variable Numeric CoreB Label CoreXY_PrepareCoreAB CoreA = (DestX - DestY) / 2 CoreB = (DestX + DestY) / 2 Return ' ===================================================================== ' HOME - COREXY ' ===================================================================== Variable Numeric HomeAxis Variable Numeric SlotSensor Variable Numeric DetachMM Variable Numeric SpeedSearch Variable Numeric SpeedReturn Variable Numeric DeclaredSwitchPos Variable Numeric InitialPosition Label HomeXY Button RunSequence Disabled Gosub CoreXY_SetNewZero Gosub EnableMotorsCoreXY Gosub HomeY Gosub HomeX 'Gosub CoreXY_SetNewZero Gosub UpdateButtonsXY 'Gosub "DISAB.MOTORS" Button RunSequence Enabled Return Label HomeX HomeAxis = 0 ' 0 = Axis X SlotSensor = Slot_SensorX ' home sensor slot DetachMM = 1 ' initial detach mm (neg or pos) SpeedSearch = -0.6 ' direction and speed SpeedReturn = +0.05 ' detach direction and speed DeclaredSwitchPos = 0 ' declared switch angle InitialPosition = 1 ' move to mm Gosub Home Return Label HomeY HomeAxis = 1 ' 1 = Axis Y SlotSensor = Slot_SensorY ' home sensor slot DetachMM = -1 ' initial detach mm (neg or pos) SpeedSearch = +0.6 ' direction and speed SpeedReturn = -0.05 ' detach direction and speed DeclaredSwitchPos = 300 ' declared switch angle InitialPosition = 299 ' move to mm Gosub Home Return Label Home ' -------------------------- detach if sensor is active If Slot(SlotSensor) > 500 Or Key("CTRL") If HomeAxis = 0 DestX = DestX + DetachMM Else DestY = DestY + DetachMM EndIf Gosub CoreXY_MoveToDestXY_NoLimits Gosub WaitMotorsCoreXY EndIf ' -------------------------- search the sensor Label SearchHome If HomeAxis = 0 DestX = DestX + SpeedSearch Else DestY = DestY + SpeedSearch EndIf Gosub CoreXY_MoveToDestXY_NoLimits ' Wait Seconds 0.005 If Slot(SlotSensor) > 500 Or Key("CTRL") If HomeAxis = 0 DestX = 0 Else DestY = 0 EndIf Gosub CoreXY_SetNewZero Goto DetachSensor EndIf Goto SearchHome ' -------------------------- detach from the sensor Label DetachSensor If HomeAxis = 0 DestX = DestX + SpeedReturn Else DestY = DestY + SpeedReturn EndIf Gosub CoreXY_MoveToDestXY_NoLimits Wait Seconds 0.005 If Slot (SlotSensor) < 500 Or Key("CTRL") Gosub WaitMotorsCoreXY If HomeAxis = 0 DestX = DeclaredSwitchPos Else DestY = DeclaredSwitchPos EndIf Gosub CoreXY_SetNewZero Goto MoveToInitialPosition EndIf Goto DetachSensor ' -------------------------- move to InitialPosition Label MoveToInitialPosition If HomeAxis = 0 DestX = InitialPosition Else DestY = InitialPosition EndIf Gosub CoreXY_MoveToDestXY_NoLimits Gosub WaitMotorsCoreXY Return ' ===================================================================== ' WAIT until the motors A and B are stopped - COREXY ' ===================================================================== Label WaitMotorsCoreXY Wait Seconds 0.1 ' this ensures that the motors are running Label WMXY1 If Abs(Slot(Slot_MotorA + 1)) < 0.05 If Abs(Slot(Slot_MotorB + 1)) < 0.05 Return EndIf EndIf Wait Seconds 0.005 Goto WMXY1 Goto WaitMotorsCoreXY Label EnableMotorsCoreXY Gosub WaitMotorsCoreXY Slot(Slot_EnableMotorsCoreXY) = 1000 Wait Seconds 0.1 Return Label DisableMotorsCoreXY Gosub WaitMotorsCoreXY Slot(Slot_EnableMotorsCoreXY) = 0 Return ' ==================================================================== ' SPEED ' ==================================================================== Variable Numeric Slot_Speed Label ExecSpeed v9 = Slot(Slot_Speed) v9 = 6 + 3 * v9 / 1000 Option Speed V9 Return ' ===================================================================== ' STEPPER-MOTORS MOVE SLOW - COREXY ' ===================================================================== Variable Numeric MoveSlowXY_DestX ' destination in mm Variable Numeric MoveSlowXY_DestY ' destination in mm Variable Numeric MoveSlowXY_Speed ' speed in mm/sec Variable Numeric MSV1 Variable Numeric MSV2 Variable Numeric MSV3 Variable Numeric MSV4 Label MoveSlowXY ' ----------------------------------- test for very low speed If MoveSlowXY_Speed < 0.1 MoveSlowXY_Speed = 1 EndIf ' ----------------------------------- calc the movement in mm MSV1 = MoveSlowXY_DestX - DestX MSV2 = MoveSlowXY_DestY - DestY MSV3 = MSV1 * MSV1 MSV3 = MSV3 + MSV2 * MSV2 MSV3 = Sqrt(MSV3) ' ----------------------------------- calc the loops count MSV4 = MSV3 / 0.01 '<<< loop time MSV4 = Int(MSV4 / MoveSlowXY_Speed) ' ----------------------------------- too much speed ? If MSV4 = 0 DestX = MoveSlowXY_DestX DestY = MoveSlowXY_DestY Gosub CoreXY_MoveToDestXY_AndWait Return EndIf ' ----------------------------------- prepare the increments MSV1 = (MoveSlowXY_DestX - DestX) / MSV4 MSV2 = (MoveSlowXY_DestY - DestY) / MSV4 ' ----------------------------------- loop for v4 times For MSV3 = 1 To MSV4 ' ------------------------------- increment, move and wait DestX = DestX + MSV1 DestY = DestY + MSV2 Gosub CoreXY_MoveToDestXY Wait Seconds 0.01 '<<< loop time Next Gosub WaitMotorsCoreXY Gosub UpdateButtonsXY Return ' ==================================================================== ' JOG with keyboard - COREXY ' ==================================================================== Label ExecKeys Variable Numeric KeyJog_Speed Variable Numeric JogSpeed JogSpeed = KeyJog_Speed / 100 Select True Case Key("SHIFT") JogSpeed = JogSpeed * 0.1 Case Key("CTRL") JogSpeed = JogSpeed * 0.01 Case Key("ALT") JogSpeed = JogSpeed * 0.001 EndSelect ' If Key("Right") DestX = DestX + JogSpeed EndIf If Key("Left") DestX = DestX - JogSpeed EndIf ' If Key("Up") DestY = DestY + JogSpeed 'proto 'DestY = DestY - JogSpeed 'Leo EndIf If Key("Down") DestY = DestY - JogSpeed 'proto ' DestY = DestY - JogSpeed 'Leo EndIf ' 'If Key("PageUp") ' Slot Slot_Z = Limit(Slot(Slot_Z) + JogSpeed, Zmin, Zmax) 'EndIf 'If Key("PageDown") ' Slot Slot_Z = Limit(Slot(Slot_Z) - JogSpeed, Zmin, Zmax) 'EndIf ' Gosub CoreXY_MoveToDestXY Gosub UpdateButtonsXY Return ' ==================================================================== ' PRINT AND UPDATE COORDINATES - COREXY ' ==================================================================== 'Label PrintValues ' Controls OpenTextBox ' s1 = "X=" + Format(DestX, "0.000") ' s2 = "Y=" + Format(DestY, "0.000") ' Print CRLF + s1 + " " + s2 'Return Label UpdateButtonsXY Button BtnDestX Text "X=" + Format(DestX, "0.000") Button BtnDestY Text "Y=" + Format(DestY, "0.000") Return ' ============================================================================= ' Folder Demo Programs\Slots ' File Demo Slots 1.txt ' ============================================================================= Slot(1) = 12 Slot(2) = Rnd * 1000 Slot(3) = Cos(Math_PI * 0.3) v1 = Slot(1) If Slot(2) < 500 Beep EndIf Slot(1) = 12 Slot(5) = 3 Slot(Slot(5)) = Slot(Sin(2)) + Slot(1) / 3 Stop ' ============================================================================= ' Folder Demo Programs\Slots ' File Demo Slots 2.txt ' ============================================================================= Slot(1) = Rnd * 1000 If Slot(1) > 30 Print "More than 30" Else Print "Less than 30 !!!!!" Beep EndIf ' ============================================================================= ' Folder Demo Programs\SlotText ' File SlotText ReadSlotText.txt ' ============================================================================= Print SlotText(1) Wait Seconds 0.1 ' ============================================================================= ' Folder Demo Programs\SlotText ' File SlotText-ReaderWriter.txt ' ============================================================================= Beep 440 1e33 Wait Seconds 0.5 Beep TTS SelectVoice 1 Label Loop s1 = SlotText(1) Print s1 If Len(s1) < Len(s2) TTS Speak s2 Wait Not TTSspeaking EndIf s2 = s1 Goto Loop ' ============================================================================= ' Folder Demo Programs\SlotText ' File SlotTextWriter.txt ' ============================================================================= SlotText 1 = "" Wait Seconds 0.05 SlotText 1 = "Nel mezzo del cammin di nostra vita, mi ritrovai in una selva oscura." Wait Seconds 0.05 SlotText 1 = "Che la diritta via era smarrita." Stop ' ============================================================================= ' Folder Demo Programs\SlotText ' File SlotText_ChineseCharacters.txt ' ============================================================================= SlotText 1 = "Theremino 特雷门乐器" '+ " " + 3 +" PIPPO" Print SlotText(1) Wait Seconds 0.1 ' ============================================================================= ' Folder Demo Programs\SlotText ' File SlotText_Multisound.txt ' ============================================================================= s1 = SlotText(1) If s1 <> s2 s2 = s1 Select s2 Case "Sound1" Load "sound\alarm1.wav" Case "Sound2" Load "sound\alarm24.wav" EndSelect EndIf Wait Seconds 0.1 ' ============================================================================= ' Folder Demo Programs\SlotText ' File SlotText_RandomWriter.txt ' ============================================================================= Label Loop Select Int(Rnd * 6) Case 0 s1 = "Chinese 特雷门乐器" Case 1 s1 = "Random " + Format(Rnd, "0.000000") Case 2 s1 = "LONG TEXT UPPERCASE" Case 3 s1 = "Numbers 0123456789" Case 4 s1 = "Letters abcdefghijk" Case 5 s1 = "" EndSelect SlotText Rnd * 24 = s1 Slot Rnd * 24 = Rnd * 1000 Wait Seconds 0.01 Goto Loop ' ============================================================================= ' Folder Demo Programs\SlotText ' File SlotText_ReadFromQrDecoder_1.txt ' ============================================================================= s2 = SlotText(1) Print Len(s2) + " " + s2 Wait Seconds 0.1 ' ============================================================================= ' Folder Demo Programs\SlotText ' File SlotText_ReadFromQrDecoder_2.txt ' ============================================================================= s2 = SlotText(1) Print s2 Wait Seconds 0.1 ' ============================================================================= ' Folder Demo Programs\SlotText ' File SlotText_ReadFromQrDecoder_3.txt ' ============================================================================= s2 = SlotText(1) Print s2 SlotText(99) = s2 Wait Seconds 0.1 ' ============================================================================= ' Folder Demo Programs\SlotText ' File SlotText_ReadFromQrDecoder_4.txt ' ============================================================================= s2 = SlotText(99) Print Len(s2) + " " + s2 Wait Seconds 0.1 ' ============================================================================= ' Folder Demo Programs\SlotText ' File SlotText_TEST-TIME.txt ' ============================================================================= s1 = Chars("A", 32) v1 = ElapsedTime SlotText 1 = s1 s2 = SlotText(1) 'Print Len(s2) + " " + s2 v3 = ElapsedTime - v1 'v4 = v4 + 0.1 * (v3 - v4) 'Print v4 'Print Len(s2) Wait Seconds 0.1 ' ============================================================================= ' Folder Demo Programs\SlotText ' File SlotText_Test1.txt ' ============================================================================= 'v1 = 33 's1 = "PIPPO" Slot 3 + 6 = 5 + 4 'Print Slot(3) 'SlotText 1 = "Theremino 特雷门乐器" + " " + 3 +" PIPPO" 'SlotText 1 = MickeyMouse1 'SlotText 999 = MickeyMouse999 ' 'Select SlotText(1) ' Case "MickeyMouse1" ' Case "MickeyMouse999" ' Beep 'EndSelect 'Print SlotText(1) + " " + SlotText(999) 's1 = Chars("A", 32767) 'For v1 = 0 To 999 ' SlotText v1 = s1 'Next ' 'For v1 = 0 To 999 ' s2 = SlotText(v1) ' Print Len(s2) 'Next s1 = Chars("A", 32) v1 = ElapsedTime SlotText 1 = s1 s2 = SlotText(1) Print Len(s2) + " " + s2 'v3 = ElapsedTime - v1 'v4 = v4 + 0.1 * (v3 - v4) 'Print v4 'Print Len(s2) Wait Seconds 0.1 ' ============================================================================= ' Folder Demo Programs\SlotText ' File SlotText_Test2.txt ' ============================================================================= s1 = Chars("A", 330000) v1 = ElapsedTime SlotText 111 = s1 s2 = SlotText(111) v3 = ElapsedTime - v1 v4 = v4 + 0.1 * (v3 - v4) s3 = Format(v4 * 1000, "0.000") Print Len(s2) + " " + s3 + " " + s2 Wait Seconds 0.1 ' ============================================================================= ' Folder Demo Programs\SlotText ' File SlotText_Test3.txt ' ============================================================================= s1 = Chars("A", 32) v1 = ElapsedTime SlotText 111 = s1 s2 = SlotText(111) v3 = ElapsedTime - v1 v4 = v4 + 0.1 * (v3 - v4) s3 = Format(v4 * 1000, "0.000") Print Len(s2) + " " + s3 + " " + s2 Wait Seconds 0.1 ' ============================================================================= ' Folder Demo Programs\SlotText ' File SlotText_Test4.txt ' ============================================================================= s1 = "" SlotText 111 = s1 s2 = SlotText(111) Print Len(s1) + " " + Len(s2) Wait Seconds 0.1 Stop ' ============================================================================= ' Folder Demo Programs\SlotText ' File SlotText_WriteAndReadManyTimes.txt ' ============================================================================= ' --------------------------------- ' Write and read many times ' --------------------------------- Button 1 Text "Iteration" Button 2 Text "Btn2" ' ----------------------------- WRITE and READ For v1 = 1 To 100000 SlotText(1) = " " s1 = SlotText(1) If Mod(v1, 1000) = 0 Button Btn2 Text v1 EndIf Next ' ----------------------------- READ ONLY SlotText(1) = " " For v1 = 1 To 100000 s1 = SlotText(1) If Mod(v1, 1000) = 0 Button Btn2 Text v1 EndIf Next ' ============================================================================= ' Folder Demo Programs\SlotText ' File __SlotText_Reader.txt ' ============================================================================= Variable Numeric FirstSlot = 50 Variable Numeric NumSlots = 10 Controls OpenTextBox Label Loop s1 = "" For v1 = FirstSlot To FirstSlot + NumSlots s1 = s1 + v1 + " " + SlotText(v1) + CRLF Next Print s1 + CRLF Wait Seconds 0.1 Goto Loop ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File Cobot_LoadSequence.txt ' ============================================================================= ' ---------------------------------------------- ' COMMANDS ' ---------------------------------------------- ' "LoadSequence SeqName.seq" (without spaces) ' "StartExecution" ' "StopExecution" ' "EnableRepeat" ' "DisableRepeat" ' "GotoHome" ' "GotoCenter ' "SelectLine nnn" ' "ExecuteSelectedLine" ' "EnableCollaborative ' "DisableCollaborative ' "AddNewPosition ' "SetHomePosition ' "SetCenterPosition ' "SetHoldingTorque nnn" ' "SetSafeTorqueLimit nnn" ' "SetTorque nnn" ' "SetAcceleration nnn" ' "SetSpeed nnn" ' ---------------------------------------------- ' RESPONSES ' ---------------------------------------------- ' "Ready" ' "Execution running at line nnn" ' "Motors disconnected" ' "Human detected - Speed reduced" ' "Human too near - Execution stopped" ' "Too much torque - Execution stopped" ' "Motors disconnected - Execution stopped" ' ---------------------------------------------- ' SLOT TEXT for COMMANDS and RESPONSES ' ---------------------------------------------- Variable Numeric SlotCommands = 51 SlotText SlotCommands = LoadSequence Test_A.txt Wait Seconds 1 SlotText SlotCommands = LoadSequence Test_B.txt Wait Seconds 1 SlotText SlotCommands = LoadSequence Test_C.txt Wait Seconds 1 ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File Commands_to_AudioInOut.txt ' ============================================================================= ' ------------------------------------- Audio InOut devices Button 1 Label Title0 Button Title0 Label "Audio InOut devices" Button Title0 Color Green2 Button 2 Label "AudioIn random" Button 3 Label "AudioOut random" Button 4 Label "Open AudioIn" Button 5 Label "Open AudioOut" ' ' ------------------------------------- Wave generators Button 7 Label Title1 Button Title1 Label "Wave generators" Button Title1 Color Green2 Button 8 Label Gen1_ON Button 9 Label Gen1_OFF Button 10 Label "Gen1_Wave random" Button 11 Label "Gen1_Freq random" Button 12 Label "Gen1_Db random" Button 13 Label "Gen1_Pwm random" ' ' ------------------------------------- AudioIn scope Button 17 Label Title2 Button Title2 Label "AudioIn scope" Button Title2 Color Green2 Button 18 Label Negative ON Button 19 Label Negative OFF Button 20 Label Trigger ON Button 21 Label Trigger OFF Button 22 Label "Amplitude random" Button 23 Label "Base Time random" ' ' ------------------------------------- FHT Bands Button 25 Label Title3 Button Title3 Label "FHT Bands" Button Title3 Color Green2 Button 26 Label "Bands random" Button 27 Label AGC ON Button 28 Label AGC OFF Button 29 Label "OutSlot random" ' ' ------------------------------------- FHT Bands Button 33 Label Title4 Button Title4 Label "FHT Bands" Button Title4 Color Green2 Button 34 Label "MaxDB random" Button 35 Label "MinDB random" Button 36 Label "MaxFreq random" Button 37 Label "MinFreq random" Button 38 Label "Speed random" Button 39 Label LogX ON Button 40 Label LogX OFF Button 41 Label LogY ON Button 42 Label LogY OFF ' ' ------------------------------------- FHT Spectrum Button 49 Label Title5 Button Title5 Label "FHT Spectrum" Button Title5 Color Green2 Button 50 Label "_MaxDB random" Button 51 Label "_MinDB random" Button 52 Label "_MaxFreq random" Button 53 Label "_MinFreq random" Button 54 Label "_Speed random" Button 55 Label _LogX ON Button 56 Label _LogX OFF Button 57 Label _LogY ON Button 58 Label _LogY OFF Button 59 Label "Window random" ' ============================================================= ' START AND STOP PROGRAM ' ============================================================= Variable Numeric Slot_Commands = 31 'Variable Numeric Slot_Responses = 32 Load Theremino_SlotViewer.exe Window MinSize Stop Label EventStop For v1 = 0 To 128 Button v1 Text "" Next Window Sizable End ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand Variable String SC1 '<-- Parameter Command-String SlotText Slot_Commands = SC1 Variable Numeric SC2 For SC2 = 0.1 To 0.5 Step 0.1 ' <-- 0.5 seconds timeout If SlotText(Slot_Commands) = "" Exit EndIf Wait Seconds 0.1 Next Return ' ============================================================= ' COMMANDS ' ============================================================= ' ------------------------------------- Audio InOut devices Label AudioIn Random SendCommand("AudioIn " + Int(Rnd * 4)) Return Label AudioOut Random SendCommand("AudioOut " + Int(Rnd * 4)) Return Label Open AudioIn SendCommand("OpenAudioIn") Return Label Open AudioOut SendCommand("OpenAudioOut") Return ' ------------------------------------- Wave generators Label Gen1_ON SendCommand("Gen1_ON") Return Label Gen1_OFF SendCommand("Gen1_OFF") Return Label Gen1_Wave random SendCommand("Gen1_Wave " + Int(Rnd * 5)) Return Label Gen1_Freq random SendCommand("Gen1_Freq " + Int(Rnd * 20000)) Return Label Gen1_Db random SendCommand("Gen1_Db " + (Int(Rnd * 120)-120)) Return Label Gen1_Pwm random SendCommand("Gen1_Pwm " + Int(Rnd * 100)) Return ' ------------------------------------- AudioIn scope Label Negative ON SendCommand("AudioIn_NegativeON") Return Label Negative OFF SendCommand("AudioIn_NegativeOFF") Return Label Trigger ON SendCommand("AudioIn_TriggerON") Return Label Trigger OFF SendCommand("AudioIn_TriggerOFF") Return Label Amplitude random SendCommand("Amplitude " + Int(Rnd * 13)) Return Label Base Time random SendCommand("BaseTime " + Int(Rnd * 10)) Return ' ------------------------------------- FHT Spectrum bands Label Bands random SendCommand("Bands " + Int(Rnd * 100)) Return Label AGC ON SendCommand("Agc_ON") Return Label AGC OFF SendCommand("Agc_OFF") Return Label OutSlot random SendCommand("FirstOutSlot " + Int(Rnd * 99)) Return ' ------------------------------------- FHT Bands Label MaxDB random SendCommand("BandsMaxDb " + (Int(Rnd * 120)-120)) Return Label MinDB random SendCommand("BandsMinDb " + (Int(Rnd * 120)-120)) Return Label MaxFreq random SendCommand("BandsMaxFreq " + (1000 + Int(Rnd * 20000))) Return Label MinFreq random SendCommand("BandsMinFreq " + Int(Rnd * 1000)) Return Label Speed random SendCommand("BandsSpeed " + Int(Rnd * 99)) Return Label LogX ON SendCommand("BandsLogX_ON") Return Label LogX OFF SendCommand("BandsLogX_OFF") Return Label LogY ON SendCommand("BandsLogY_ON") Return Label LogY OFF SendCommand("BandsLogY_OFF") Return ' ' ------------------------------------- FHT Spectrum Label _MaxDB random SendCommand("SpectrumMaxDb " + (Int(Rnd * 120)-120)) Return Label _MinDB random SendCommand("SpectrumMinDb " + (Int(Rnd * 120)-120)) Return Label _MaxFreq random SendCommand("SpectrumMaxFreq " + (1000 + Int(Rnd * 20000))) Return Label _MinFreq random SendCommand("SpectrumMinFreq " + Int(Rnd * 1000)) Return Label _Speed random SendCommand("SpectrumSpeed " + Int(Rnd * 99)) Return Label _LogX ON SendCommand("SpectrumLogX_ON") Return Label _LogX OFF SendCommand("SpectrumLogX_OFF") Return Label _LogY ON SendCommand("SpectrumLogY_ON") Return Label _LogY OFF SendCommand("SpectrumLogY_OFF") Return Label Window random SendCommand("SpectrumWindow " + Int(Rnd * 21)) Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File Commands_to_BLOCKLY.txt ' ============================================================================= Button 1 Label _RUN Button 2 Label _STOP Button 3 Label _PAUSE Button 5 Label CONTINUE Button 6 Label STEP Button 8 Label Turn the LED ON Button 9 Label TURN LED OFF Button 10 Label Turn the LED to RED Button 11 Label TURN LED COLOUR BLACK Button 13 Label EnableButton1 Button 14 Label DisableButton1 Variable Numeric Slot_CommandsToBlockly = 1 Stop ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand Variable Numeric SC1 '<-- Parameter Destinat.-Slot Variable String SC2 '<-- Parameter Command-String Variable Numeric SC3 = 0.5 '<-- The timeout in seconds Variable Numeric SC4 SlotText SC1 = SC2 For SC4 = 0.1 To SC3 Step 0.1 If SlotText(SC1) = "" Exit EndIf Wait Seconds 0.1 Next Return ' ============================================================= ' COMMANDS TO GPS ' ============================================================= Label _RUN SendCommand(Slot_CommandsToBlockly)("Run") Return Label _STOP SendCommand(Slot_CommandsToBlockly)("Stop") Return Label _PAUSE SendCommand(Slot_CommandsToBlockly)("Pause") Return Label STEP SendCommand(Slot_CommandsToBlockly)("STEP") Return Label CONTINUE SendCommand(Slot_CommandsToBlockly)("CONTINUE") Return Label Turn the LED ON SendCommand(Slot_CommandsToBlockly)("Turn the LED ON") Return Label TURN LED OFF SendCommand(Slot_CommandsToBlockly)("TURN LED OFF") Return Label Turn the LED to RED SendCommand(Slot_CommandsToBlockly)("Turn the LED to RED") Return Label TURN LED COLOUR BLACK SendCommand(Slot_CommandsToBlockly)("TURN LED COLOUR BLACK") Return Label EnableButton1 SendCommand(Slot_CommandsToBlockly)("EnableButton 1") Return Label DisableButton1 SendCommand(Slot_CommandsToBlockly)("DisableButton 1") Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File Commands_to_CNC.txt ' ============================================================================= ' ---------------------------------------------- ' Commands to Theremino_CNC ' ---------------------------------------------- Button 1 Label CmdRun Button 2 Label CmdStep Button 3 Label CmdPause Button 4 Label CmdRewind Button 5 Label CmdStop Button 7 Label Rapid500 Button 8 Label Rapid2000 Button 9 Label Feed100 Button 10 Label Feed1000 Button 11 Label Speed0 Button 12 Label Speed20000 Button 17 Label TestLowZ Button 18 Label GotoZero Button 19 Label GotoHome Button 20 Label GotoBottomLeft Button 21 Label GotoTopRight Button 23 Label SetZetaHome Button 24 Label CalibrateXY Button 25 Label CalibrateZ Button 26 Label CalibrateAB Button 28 Label MoveTo_10_20_30 Button 29 Label MoveTo_20_30_10 Button 33 Label ZeroX Button 34 Label ZeroY Button 35 Label ZeroZ Button 36 Label ZeroA Button 37 Label ZeroB Button 39 Label GotoLine5 Button 40 Label GotoLine50 Button 41 Label GotoLine9999 Button 43 Label LoadMaster Button 44 Label LoadPmtAdapter Button 46 Label ErrorTest Variable Numeric Slot_CommandsToCnc = 1 Variable Numeric Slot_Status = 2 Loop Stop Label Loop Print SlotText(Slot_Status) Goto Loop ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand Variable Numeric SC1 '<-- Parameter Destinat.-Slot Variable String SC2 '<-- Parameter Command-String Variable Numeric SC3 = 0.5 '<-- The timeout in seconds Variable Numeric SC4 SlotText SC1 = SC2 For SC4 = 0.1 To SC3 Step 0.1 If SlotText(SC1) = "" Exit EndIf Wait Seconds 0.1 Next Return Label CmdRun SendCommand(Slot_CommandsToCnc)("CmdRun") Return Label CmdStep SendCommand(Slot_CommandsToCnc)("CmdStep") Return Label CmdPause SendCommand(Slot_CommandsToCnc)("CmdPause") Return Label CmdRewind SendCommand(Slot_CommandsToCnc)("CmdRewind") Return Label CmdStop SendCommand(Slot_CommandsToCnc)("CmdStop") Return Label Rapid500 SendCommand(Slot_CommandsToCnc)("Rapid 500") Return Label Rapid2000 SendCommand(Slot_CommandsToCnc)("Rapid 2000") Return Label Feed100 SendCommand(Slot_CommandsToCnc)("Feed 100") Return Label Feed1000 SendCommand(Slot_CommandsToCnc)("Feed 1000") Return Label Speed0 SendCommand(Slot_CommandsToCnc)("Speed 0") Return Label Speed20000 SendCommand(Slot_CommandsToCnc)("Speed 20000") Return Label TestLowZ SendCommand(Slot_CommandsToCnc)("TestLowZ") Return Label GotoZero SendCommand(Slot_CommandsToCnc)("GotoZero") Return Label GotoHome SendCommand(Slot_CommandsToCnc)("GotoHome") Return Label GotoBottomLeft SendCommand(Slot_CommandsToCnc)("GotoBottomLeft") Return Label GotoTopRight SendCommand(Slot_CommandsToCnc)("GotoTopRight") Return Label SetZetaHome SendCommand(Slot_CommandsToCnc)("SetZetaHome") Return Label CalibrateXY SendCommand(Slot_CommandsToCnc)("CalibrateXY") Return Label CalibrateZ SendCommand(Slot_CommandsToCnc)("CalibrateZ") Return Label CalibrateAB SendCommand(Slot_CommandsToCnc)("CalibrateAB") Return Label MoveTo_10_20_30 SendCommand(Slot_CommandsToCnc)("MoveTo 10 20 30") Return Label MoveTo_20_30_10 SendCommand(Slot_CommandsToCnc)("MoveTo 20 30 10") Return Label ZeroX SendCommand(Slot_CommandsToCnc)("ZeroX") Return Label ZeroY SendCommand(Slot_CommandsToCnc)("ZeroY") Return Label ZeroZ SendCommand(Slot_CommandsToCnc)("ZeroZ") Return Label ZeroA SendCommand(Slot_CommandsToCnc)("ZeroA") Return Label ZeroB SendCommand(Slot_CommandsToCnc)("ZeroB") Return Label GotoLine5 SendCommand(Slot_CommandsToCnc)("GotoLine 5") Return Label GotoLine50 SendCommand(Slot_CommandsToCnc)("GotoLine 50") Return Label GotoLine9999 SendCommand(Slot_CommandsToCnc)("GotoLine 9999") Return Label LoadMaster SendCommand(Slot_CommandsToCnc)("LoadGcode PCB Large\MasterDIL-V3.gc") Return Label LoadPmtAdapter SendCommand(Slot_CommandsToCnc)("LoadGcode PCB Large\PmtAdapter.gc") Return Label ErrorTest SendCommand(Slot_CommandsToCnc)("Error Test") Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File Commands_to_COBOT.txt ' ============================================================================= ' ---------------------------------------------- ' Commands to Theremino_COBOT ' ---------------------------------------------- ' ExitFromEdit (exit from editing state) ' StartExecution (auto-exit from editing) ' StopExecution (auto-exit from editing) ' GotoHome (auto-exit from editing) ' GotoCenter (auto-exit from editing) ' EnableRepeat ' DisableRepeat ' SelectLine nnn ' ExecuteSelectedLine ' ArrowUP (auto-exit from run mode) ' ArrowDOWN (auto-exit from run mode) ' EnableCollaborative ' DisableCollaborative ' AddNewPosition ' CorrectSelectedPosition ' AddOrCorrectPosition ' DeleteSelectedLine ' SetHomePosition ' SetCenterPosition ' SetSpeedToTorque n.nn (0.00 to 1.00) ' SetHoldingTorque nnn ' SetTorqueMin nnn ' SetTorqueMax nnn ' SetAcceleration nnn ' SetSpeed nnn ' LoadSequence SeqName.seq (without spaces) ' ---------------------------------------------- ' RESPONSES ' ---------------------------------------------- ' "Editing" ' "Ready" ' "Execution running at line nnn" ' "Motors disconnected" ' "Human detected - Speed reduced" ' "Human too near - Execution stopped" ' "Too much torque - Execution stopped" ' "Motors disconnected - Execution stopped" ' "Execution paused" ' ---------------------------------------------- ' SLOT TEXT for COMMANDS and RESPONSES ' ---------------------------------------------- Variable Numeric Slot_Commands = 51 Variable Numeric Slot_Responses = 52 ' ---------------------------------------------- ' BUTTONS ' ---------------------------------------------- Button 1 Label ExitFromEdit Button 3 Label StartExecution Button 4 Label StopExecution Button 6 Label GotoHome Button 7 Label GotoCenter Button 9 Label EnableRepeat Button 10 Label DisableRepeat Button 12 Label EnableCollaborative Button 13 Label DisableCollaborative Button 17 Label AddNewPosition Button 18 Label CorrectSelectedPosition Button 19 Label AddOrCorrectPosition Button 21 Label DeleteSelectedLine Button 23 Label SetHomePosition Button 24 Label SetCenterPosition Button 26 Label SetHoldingTorque9 Button 27 Label SetSafeTorqueLimit9 Button 28 Label SetTorque9 Button 29 Label SetAcceleration9 Button 30 Label SetSpeed9 Button 33 Label SetAllparamsToMin Button 34 Label SetAllparamsToMax Button 36 Label SelectLine3 Button 37 Label SelectLine6 Button 38 Label ExecuteSelectedLine Button 40 Label ArrowUp Button 41 Label ArrowDown Gosub Loop Stop ' ---------------------------------------------- ' LOOP ' ---------------------------------------------- Label Loop Variable String Response Response = SlotText(Slot_Responses) Print Response Wait Seconds 0.1 ' ------------------------------- how to test partial strings If StringContains(Response, "stopped") Beep EndIf Goto Loop ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand Variable Numeric SC1 '<-- Parameter Destinat.-Slot Variable String SC2 '<-- Parameter Command-String Variable Numeric SC3 = 0.5 '<-- The timeout in seconds Variable Numeric SC4 SlotText SC1 = SC2 For SC4 = 0.1 To SC3 Step 0.1 If SlotText(SC1) = "" Exit EndIf Wait Seconds 0.1 Next Return ' ---------------------------------------------- ' COMMANDS ' ---------------------------------------------- Label ExitFromEdit SendCommand(Slot_Commands)("ExitFromEdit") Return Label StartExecution SendCommand(Slot_Commands)("StartExecution") Return Label StopExecution SendCommand(Slot_Commands)("StopExecution") Return Label EnableRepeat SendCommand(Slot_Commands)("EnableRepeat") Return Label DisableRepeat SendCommand(Slot_Commands)("DisableRepeat") Return Label GotoHome SendCommand(Slot_Commands)("GotoHome") Return Label GotoCenter SendCommand(Slot_Commands)("GotoCenter") Return Label EnableCollaborative SendCommand(Slot_Commands)("EnableCollaborative") Return Label DisableCollaborative SendCommand(Slot_Commands)("DisableCollaborative") Return Label AddNewPosition SendCommand(Slot_Commands)("AddNewPosition") Return Label CorrectSelectedPosition SendCommand(Slot_Commands)("CorrectSelectedPosition") Return Label AddOrCorrectPosition SendCommand(Slot_Commands)("AddOrCorrectPosition") Return Label DeleteSelectedLine SendCommand(Slot_Commands)("DeleteSelectedLine") Return Label SetHomePosition SendCommand(Slot_Commands)("SetHomePosition") Return Label SetCenterPosition SendCommand(Slot_Commands)("SetCenterPosition") Return Label SetHoldingTorque9 SendCommand(Slot_Commands)("SetHoldingTorque 9") Return Label SetSafeTorqueLimit9 SendCommand(Slot_Commands)("SetSafeTorqueLimit 9") Return Label SetTorque9 SendCommand(Slot_Commands)("SetTorque 9") Return Label SetAcceleration9 SendCommand(Slot_Commands)("SetAcceleration 9") Return Label SetSpeed9 SendCommand(Slot_Commands)("SetSpeed 9") Return Label SetAllparamsToMin SendCommand(Slot_Commands)("SetHoldingTorque 0") SendCommand(Slot_Commands)("SetSafeTorqueLimit 0") SendCommand(Slot_Commands)("SetTorque 0") SendCommand(Slot_Commands)("SetAcceleration 0") SendCommand(Slot_Commands)("SetSpeed 0") Return Label SetAllparamsToMax SendCommand(Slot_Commands)("SetHoldingTorque 999") SendCommand(Slot_Commands)("SetSafeTorqueLimit 999") SendCommand(Slot_Commands)("SetTorque 999") SendCommand(Slot_Commands)("SetAcceleration 999") SendCommand(Slot_Commands)("SetSpeed 99999") Return Label SelectLine3 SendCommand(Slot_Commands)("SelectLine 3") Return Label SelectLine6 SendCommand(Slot_Commands)("SelectLine 9999") Return Label ExecuteSelectedLine SendCommand(Slot_Commands)("ExecuteSelectedLine") Return Label ArrowUp SendCommand(Slot_Commands)("ArrowUp") Return Label ArrowDown SendCommand(Slot_Commands)("ArrowDown") Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File Commands_to_COBOT_2.txt ' ============================================================================= Variable Numeric Slot_CommandsToCobot = 51 Button 1 Label ExecCobot Button 2 Label StopCobot Button 4 Label ArrowUp Button 5 Label ArrowDown Button 7 Label ExecSelectedLine Stop ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand Variable Numeric SC1 '<-- Parameter Destinat.-Slot Variable String SC2 '<-- Parameter Command-String Variable Numeric SC3 = 0.5 '<-- The timeout in seconds Variable Numeric SC4 SlotText SC1 = SC2 For SC4 = 0.1 To SC3 Step 0.1 If SlotText(SC1) = "" Exit EndIf Wait Seconds 0.1 Next Return Label ExecCobot SendCommand(Slot_CommandsToCobot)("EnableRepeat") SendCommand(Slot_CommandsToCobot)("SelectLine 1") SendCommand(Slot_CommandsToCobot)("StartExecution") Return Label StopCobot SendCommand(Slot_CommandsToCobot)("StopExecution") Return Label ArrowUpCobot SendCommand(Slot_CommandsToCobot)("ArrowUp") Return Label ArrowDownCobot SendCommand(Slot_CommandsToCobot)("ArrowDown") Return Label ExecSelectedLine SendCommand(Slot_CommandsToCobot)("StartExecution") Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File Commands_to_DICTATION.txt ' ============================================================================= ' ---------------------------------------------- ' Commands to Theremino_Dictation ' ---------------------------------------------- Button 1 Label CmdRun Button 2 Label CmdStop Button 4 Label ClearAllText Button 6 Label Clear_SpegniLedRosso Button 7 Label Clear_Led Button 10 Label ErrorTest Button 17 Label Lang_English Button 18 Label Lang_Inglese Button 19 Label Lang_Eng Button 20 Label Lang_Ing Button 21 Label Lang_Italiano Button 22 Label Lang_Italian Button 23 Label Lang_Ita Button 24 Label Lang_Chinese Button 25 Label Lang_Chxxx Button 26 Label Lang_Chi Button 27 Label Lang_Japanese Button 28 Label Lang_Jap Variable Numeric Slot_Status = 2 Variable Numeric Slot_CommandsToDictation = 3 Loop Stop Label Loop Print SlotText(Slot_Status) Goto Loop ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand Variable Numeric SC1 '<-- Parameter Destinat.-Slot Variable String SC2 '<-- Parameter Command-String Variable Numeric SC3 = 0.5 '<-- The timeout in seconds Variable Numeric SC4 SlotText SC1 = SC2 For SC4 = 0.1 To SC3 Step 0.1 If SlotText(SC1) = "" Exit EndIf Wait Seconds 0.1 Next Return Label CmdRun SendCommand(Slot_CommandsToDictation)("Run") Return Label CmdStop SendCommand(Slot_CommandsToDictation)("Stop") Return Label ClearAllText SendCommand(Slot_CommandsToDictation)("ClearAllText") Return Label Clear_SpegniLedRosso SendCommand(Slot_CommandsToDictation)("Clear_Spegni_Led_Rosso") Return Label Clear_Led SendCommand(Slot_CommandsToDictation)("Clear_Led") Return Label ErrorTest SendCommand(Slot_CommandsToDictation)("zzzz") Return Label Lang_English SendCommand(Slot_CommandsToDictation)("Language_English") Return Label Lang_Inglese SendCommand(Slot_CommandsToDictation)("Language_Inglese") Return Label Lang_Eng SendCommand(Slot_CommandsToDictation)("Language_Eng") Return Label Lang_Ing SendCommand(Slot_CommandsToDictation)("Language_Ing") Return Label Lang_Italiano SendCommand(Slot_CommandsToDictation)("Language_Italiano") Return Label Lang_Italian SendCommand(Slot_CommandsToDictation)("Language_Italian") Return Label Lang_Ita SendCommand(Slot_CommandsToDictation)("Language_Ita") Return Label Lang_Chinese SendCommand(Slot_CommandsToDictation)("Language_Chinese") Return Label Lang_Chxxx SendCommand(Slot_CommandsToDictation)("Language_#######") Return Label Lang_Chi SendCommand(Slot_CommandsToDictation)("Language_Chi") Return Label Lang_Japanese SendCommand(Slot_CommandsToDictation)("Language_Japanese") Return Label Lang_Jap SendCommand(Slot_CommandsToDictation)("Language_Jap") Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File Commands_to_FiltersFIR.txt ' ============================================================================= ' ------------------------------------- Slots Button 1 Label Title1 Button Title1 Label "Slots" Button Title1 Color Green2 Button 2 Label "FirstInSlot random" ' ' ------------------------------------- Params Button 4 Label Title2 Button Title2 Label "Params" Button Title2 Color Green2 Button 5 Label "NumChannels random" Button 6 Label "FilterSeconds random" Button 7 Label "LogSeconds random" ' ------------------------------------- Visualization Button 17 Label Title3 Button Title3 Label "Visualization" Button Title3 Color Green2 Button 18 Label "CPS" Button 19 Label "CPM" Button 20 Label "CPH" ' ------------------------------------- Start-Stop Button 22 Label Title4 Button Title4 Label "Start-Stop" Button Title4 Color Green2 Button 23 Label "START" Button 24 Label "STOP" ' ============================================================= ' START AND STOP PROGRAM ' ============================================================= Variable Numeric Slot_Commands = 31 'Variable Numeric Slot_Responses = 32 Window MinSize Stop Label EventStop For v1 = 0 To 128 Button v1 Text "" Next Window Sizable End ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand Variable String SC1 '<-- Parameter Command-String SlotText Slot_Commands = SC1 Variable Numeric SC2 For SC2 = 0.1 To 0.5 Step 0.1 ' <-- 0.5 seconds timeout If SlotText(Slot_Commands) = "" Exit EndIf Wait Seconds 0.1 Next Return ' ============================================================= ' COMMANDS ' ============================================================= ' ------------------------------------- Slots Label FirstInSlot Random SendCommand("FirstInSlot " + Int(Rnd * 900)) Return ' ------------------------------------- Params Label NumChannels Random SendCommand("NumChannels " + Int(Rnd * 99)) Return Label FilterSeconds Random SendCommand("FilterSeconds " + Int(Rnd * 900)) Return Label LogSeconds Random SendCommand("LogSeconds " + Int(Rnd * 900)) Return Label CPS SendCommand("CPS") Return Label CPM SendCommand("CPM") Return Label CPH SendCommand("CPH") Return Label Start SendCommand("Start") Return Label Stop SendCommand("Stop") Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File Commands_to_GPS.txt ' ============================================================================= ' ---------------------------------------------- ' Commands to Theremino_GPS ' ---------------------------------------------- Button 1 Label Average30 Button 2 Label Average120 Button 4 Label Minimize Button 5 Label Maximize Button 6 Label Normal Button 8 Label Main Button 9 Label Raw Button 10 Label Sat Button 11 Label Pos Button 12 Label Map Button 17 Label MapToLocal Button 18 Label MapTo Button 20 Label Image Button 21 Label ImageTime Button 22 Label ImageName Variable Numeric Slot_CommandsToGPS = 1 Stop ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand Variable Numeric SC1 '<-- Parameter Destinat.-Slot Variable String SC2 '<-- Parameter Command-String Variable Numeric SC3 = 0.5 '<-- The timeout in seconds Variable Numeric SC4 SlotText SC1 = SC2 For SC4 = 0.1 To SC3 Step 0.1 If SlotText(SC1) = "" Exit EndIf Wait Seconds 0.1 Next Return ' ============================================================= ' COMMANDS TO GPS ' ============================================================= Label Average30 SendCommand(Slot_CommandsToGPS)("Average 30") Return Label Average120 s1 = "Average 120" SendCommand(Slot_CommandsToGPS)("s1") Return Label Minimize SendCommand(Slot_CommandsToGPS)("Minimize") Return Label Maximize SendCommand(Slot_CommandsToGPS)("Maximize") Return Label Normal SendCommand(Slot_CommandsToGPS)("Normal") Return Label Main SendCommand(Slot_CommandsToGPS)("Main") Return Label Raw SendCommand(Slot_CommandsToGPS)("Raw") Return Label Sat SendCommand(Slot_CommandsToGPS)("Sat") Return Label Pos SendCommand(Slot_CommandsToGPS)("Pos") Return Label Map SendCommand(Slot_CommandsToGPS)("Map") Return Label MapToLocal SendCommand(Slot_CommandsToGPS)("MapToLocal") Return Label MapTo SendCommand(Slot_CommandsToGPS)("MapTo 45.470690 7.945215 30") Return Label Image SendCommand(Slot_CommandsToGPS)("Image") Return Label ImageTime SendCommand(Slot_CommandsToGPS)("ImageTime") Return Label ImageName SendCommand(Slot_CommandsToGPS)("ImageName" + " TestImage_" + Format(Now, "yyyy_MM_dd_HH_mm_ss")) Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File Commands_to_HAL.txt ' ============================================================================= ' ------------------------------------------------- Toolbar commands Button 1 Label Title1 Button Title1 Label "Toolbar commands" Button Title1 Color Green2 Button 2 Label Recognize Button 3 Label Validate Button 4 Label ErrorBeepON Button 5 Label ErrorBeepOFF Button 7 Label LockON Button 8 Label LockOFF Button 9 Label Disconnect Button 10 Label NoEditsON Button 11 Label NoEditsOFF Button 12 Label Calibrate Button 13 Label Calibration33 ' ------------------------------------------------- Master properties Button 17 Label Title2 Button Title2 Label "Master properties" Button Title2 Color Green2 Button 18 Label SelectMaster1 Button 19 Label SelectMaster2 Button 21 Label LoadConfig1 Button 22 Label LoadConfig2 Button 23 Label LoadConfig3 Button 25 Label SpeedRandom Button 26 Label FastExchangeON Button 27 Label FastExchangeOFF ' ------------------------------------------------- Select Pin Button 29 Label SelectPinRandom Button SelectPinRandom Text "Select Pin by Number" + CRLF + "Random" Button 30 Label SelectPinByName Button SelectPinByName Text "Select Pin by Name" + CRLF + "for IotHAL and NetHAL" ' ------------------------------------------------- Pin properties Button 33 Label Title3 Button Title3 Label "Pin properties" Button Title3 Color Green2 Button 34 Label SetPinTypeRandom Button SetPinTypeRandom Text "SetPinType" + CRLF + "Random" Button 35 Label SetSlotRandom Button SetSlotRandom Text "SetSlot" + CRLF + "Random" Button 36 Label SetMaxValueRandom Button SetMaxValueRandom Text "SetMaxValue" + CRLF + "Random" Button 37 Label SetMinValueRandom Button SetMinValueRandom Text "SetMinValue" + CRLF + "Random" Button 38 Label SetResponseSpeedButtonON Button SetResponseSpeedButtonON Text "ResponseSpeedButton" + CRLF + "ON" Button 39 Label SetResponseSpeedButtonOFF Button SetResponseSpeedButtonOFF Text "ResponseSpeedButton" + CRLF + "OFF" Button 40 Label SetResponseSpeedRandom Button SetResponseSpeedRandom Text "SetResponseSpeed" + CRLF + "Random" ' ------------------------------------------------- PWM and Servo properties Button 42 Label Title4 Button Title4 Label "PWM and SERVO" Button Title4 Color Green2 Button 43 Label MaxTimeRandom Button 44 Label MinTimeRandom Button 45 Label LogResponseON Button 46 Label LogResponseOFF ' ------------------------------------------------- Stepper properties Button 49 Label Title5 Button Title5 Label "STEPPERS" Button Title5 Color Green2 Button 50 Label MaxSpeedRandom Button MaxSpeedRandom Text "MaxSpeed" + CRLF + "Random" Button 51 Label MaxAccRandom Button MaxAccRandom Text "MaxAcc" + CRLF + "Random" Button 52 Label StepsPerMmRandom Button StepsPerMmRandom Text "StepsPerMm" + CRLF + "Random" Button 53 Label LinkedtoPreviousON Button LinkedtoPreviousON Text "LinkedtoPrevious" + CRLF + "ON" Button 54 Label LinkedtoPreviousOFF Button LinkedtoPreviousOFF Text "LinkedtoPrevious" + CRLF + "OFF" ' ------------------------------------------------- Pwm_Fast properties Button 56 Label Title6 Button Title6 Label "PWM FAST" Button Title6 Color Green2 Button 57 Label PwmFastFrequencyRandom Button PwmFastFrequencyRandom Text "PwmFastFrequency" + CRLF + "Random" Button 58 Label PwmFastDutyCycleRandom Button PwmFastDutyCycleRandom Text "PwmFastDutyCycle" + CRLF + "Random" Button 59 Label FrequencyFromSlotON Button FrequencyFromSlotON Text "FrequencyFromSlot" + CRLF + "ON" Button 60 Label FrequencyFromSlotOFF Button FrequencyFromSlotOFF Text "FrequencyFromSlot" + CRLF + "OFF" Button 61 Label DutyCycleFromSlotON Button DutyCycleFromSlotON Text "DutyCycleFromSlot" + CRLF + "ON" Button 62 Label DutyCycleFromSlotOFF Button DutyCycleFromSlotOFF Text "DutyCycleFromSlot" + CRLF + "OFF" ' ------------------------------------------------- Touch properties (cap) Button 65 Label Title7 Button Title7 Label "TOUCH (cap)" Button Title7 Color Green2 Button 66 Label MinVariationRandom Button MinVariationRandom Text "MinVariation" + CRLF + "Random" Button 67 Label ProportionalAreaRandom Button ProportionalAreaRandom Text "ProportionalArea" + CRLF + "Random" ' ------------------------------------------------- Freq. properties (counter/fastcounter/period/slowperiod) Button 69 Label Title8 Button Title8 Label "FREQUENCY FOR" + CR + "COUNTERS and PERIOD" Button Title8 Color Green2 Button 70 Label ConvertToFrequencyON Button ConvertToFrequencyON Text "ConvertToFrequency" + CRLF + "ON" Button 71 Label ConvertToFrequencyOFF Button ConvertToFrequencyOFF Text "ConvertToFrequency" + CRLF + "OFF" Button 72 Label MaxFreqRandom Button 73 Label MinFreqRandom ' ------------------------------------------------- CapSensor and Ultrasound properties (usound sensor) Button 75 Label Title9 Button Title9 Label "CAPSENSOR and USOUND" Button Title9 Color Green2 Button 76 Label MaxDistRandom Button 77 Label MinDistRandom Button 78 Label AreaRandom Button 79 Label RemoveErrorsON Button 80 Label RemoveErrorsOFF ' ------------------------------------------------- Adc24 properties Button 81 Label Title10 Button Title10 Label "ADC24 MAIN PIN" Button Title10 Color Green2 Button 82 Label NumberOfPinsRandom Button NumberOfPinsRandom Text "NumberOfPins" + CRLF + "Random" Button 83 Label SamplesSecRandom Button SamplesSecRandom Text "SamplesSec" + CRLF + "Random" Button 84 Label FilterRandom Button FilterRandom Text "Filter" + CRLF + "Random" ' ------------------------------------------------- Adc24 channel properties Button 86 Label Title11 Button Title11 Label "ADC24 PIN PROPS" Button Title11 Color Green2 Button 87 Label TypeRandom Button 88 Label GainRandom Button 89 Label BiasedON Button 90 Label BiasedOFF ' ------------------------------------------------- GET PROPS Button 92 Label Title12 Button Title12 Label "GET PROPS" Button Title12 Color Green2 Button 93 Label GetMasterName Button 94 Label GetFPS Button 95 Label GetPinType ' ============================================================= ' START AND STOP PROGRAM ' ============================================================= Variable Numeric Slot_Commands = 0 Variable Numeric Slot_Responses = 1 Load Theremino_SlotViewer.exe Window MinSize Stop Label EventStop For v1 = 0 To 128 Button v1 Text "" Next Window Sizable End ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand Variable String SC1 '<-- Parameter Command-String SlotText Slot_Commands = SC1 Variable Numeric SC2 For SC2 = 0.1 To 0.5 Step 0.1 ' <-- 0.5 seconds timeout If SlotText(Slot_Commands) = "" Exit EndIf Wait Seconds 0.1 Next Return ' ============================================================= ' COMMANDS ' ============================================================= ' ----------------------------------------------------- Toolbar commands Label Recognize SendCommand("Recognize") Return Label Validate SendCommand("Validate") Return Label ErrorBeepON SendCommand("ErrorBeep 1") Return Label ErrorBeepOFF SendCommand("ErrorBeep 0") Return Label LockON SendCommand("LockMasters 1") Return Label LockOFF SendCommand("LockMasters 0") Return Label Disconnect SendCommand("Disconnect") Return Label NoEditsON SendCommand("NoEdits 1") Return Label NoEditsOFF SendCommand("NoEdits 0") Return Label Calibrate SendCommand("Calibrate") Return Label Calibration33 SendCommand("CalibrationValue 33") Return ' ------------------------------------------------- Master properties Label SelectMaster1 SendCommand("SelectMaster 1") Return Label SelectMaster2 SendCommand("SelectMaster 2") Return Label LoadConfig1 SendCommand("LoadConfig Test1") Return Label LoadConfig2 SendCommand("LoadConfig Test2") Return Label LoadConfig3 SendCommand("LoadConfig Test3") Return Label SpeedRandom SendCommand("Speed " + Int(1 + Rnd * 12)) Return Label FastExchangeON SendCommand("FastDataExchange 1") Return Label FastExchangeOFF SendCommand("FastDataExchange 0") Return ' ------------------------------------------------- Select Pins Label SelectPinRandom SendCommand("SelectPin " + Int(1 + Rnd * 20)) Return Label SelectPinByName s1 = Input "Pin name ?" SendCommand("SelectPin " + s1) Return ' ------------------------------------------------- Pin properties Label SetPinTypeRandom Select Int(Rnd * 16) Case 0 SendCommand("SetPinType unUsed") Case 1 SendCommand("SetPinType dig-out") Case 2 SendCommand("SetPinType pwm 16") Case 3 SendCommand("SetPinType servo 16") Case 4 SendCommand("SetPinType pwm fast") Case 5 SendCommand("SetPinType DIGIN pu") Case 6 SendCommand("SetPinType cap16") Case 7 SendCommand("SetPinType res16") Case 8 SendCommand("SetPinType adc16") Case 9 SendCommand("SetPinType COUNTER pu") Case 10 SendCommand("SetPinType fast counterPU") Case 11 SendCommand("SetPinType PeRiOD---pu") Case 12 SendCommand("SetPinType usound---sensor") Case 13 SendCommand("SetPinType encoder_a pu") Case 14 SendCommand("SetPinType SlowPeriodPu") Case 15 SendCommand("SetPinType Adc24") EndSelect Return Label SetSlotRandom SendCommand("SetSlot " + Int(1 + Rnd * 99)) Return Label SetMaxValueRandom SendCommand("SetMaxValue " + Int(Rnd * 10000) / 10) Return Label SetMinValueRandom SendCommand("SetMinValue " + Int(Rnd * 10000) / 10) Return Label SetResponseSpeedButtonON SendCommand("SetResponseSpeedButton 1") Return Label SetResponseSpeedButtonOFF SendCommand("SetResponseSpeedButton 0") Return Label SetResponseSpeedRandom SendCommand("SetResponseSpeed " + Int(1 + Rnd * 100)) Return ' ------------------------------------------------- PWM and Servo properties Label MaxTimeRandom SendCommand("MaxTime " + Int(Rnd * 100)) Return Label MinTimeRandom SendCommand("MinTime " + Int(Rnd * 100)) Return Label LogResponseON SendCommand("LogarithmicResponse 1") Return Label LogResponseOFF SendCommand("LogarithmicResponse 0") Return ' ------------------------------------------------- Stepper properties Label MaxSpeedRandom SendCommand("MaxSpeed " + Int(Rnd * 10000) / 10) Return Label MaxAccRandom SendCommand("MaxAcc " + Int(Rnd * 1000) / 10) Return Label StepsPerMmRandom SendCommand("StepsPerMm " + Int(Rnd * 100) / 10) Return Label LinkedtoPreviousON SendCommand("LinkedtoPrevious 1") Return Label LinkedtoPreviousOFF SendCommand("LinkedtoPrevious 0") Return ' ------------------------------------------------- Pwm_Fast properties Label PwmFastFrequencyRandom SendCommand("PwmFastFrequency " + Int(Rnd * 100000)) Return Label PwmFastDutyCycleRandom SendCommand("PwmFastDutyCycle " + Int(Rnd * 1000)) Return Label FrequencyFromSlotON SendCommand("FrequencyFromSlot 1") Return Label FrequencyFromSlotOFF SendCommand("FrequencyFromSlot 0") Return Label DutyCycleFromSlotON SendCommand("DutyCycleFromSlot 1") Return Label DutyCycleFromSlotOFF SendCommand("DutyCycleFromSlot 0") Return ' ------------------------------------------------- Touch properties (cap) Label MinVariationRandom SendCommand("MinVariation " + Int(Rnd * 1000 - 500)) Return Label ProportionalAreaRandom SendCommand("ProportionalArea " + Int(Rnd * 1000 - 500)) Return ' ------------------------------------------------- Freq. properties (counter/fastcounter/period/slowperiod) Label ConvertToFrequencyON SendCommand("ConvertToFrequency 1") Return Label ConvertToFrequencyOFF SendCommand("ConvertToFrequency 0") Return Label MaxFreqRandom SendCommand("MaxFreq " + Int(Rnd * 10000)) Return Label MinFreqRandom SendCommand("MinFreq " + Int(Rnd * 10000)) Return ' ------------------------------------------------- CapSensor and Ultrasound properties (usound sensor) Label MaxDistRandom SendCommand("MaxDist " + Int(50 + Rnd * 9000)) Return Label MinDistRandom SendCommand("MinDist " + Int(Rnd * 5000)) Return Label AreaRandom SendCommand("Area " + Int(Rnd * 1000)) Return Label RemoveErrorsON SendCommand("RemoveErrors 1") Return Label RemoveErrorsOFF SendCommand("RemoveErrors 0") Return ' ------------------------------------------------- Adc24 properties Label NumberOfPinsRandom SendCommand("NumberOfPins " + Int(Rnd * 16)) Return Label SamplesSecRandom Select Int(Rnd * 21) Case 0 SendCommand("SamplesSec 19200") Case 1 SendCommand("SamplesSec 9600") Case 2 SendCommand("SamplesSec 4800") Case 3 SendCommand("SamplesSec 3840") Case 4 SendCommand("SamplesSec 3200") Case 5 SendCommand("SamplesSec 2400") Case 6 SendCommand("SamplesSec 1600") Case 7 SendCommand("SamplesSec 1200") Case 8 SendCommand("SamplesSec 1000") Case 9 SendCommand("SamplesSec 600") Case 10 SendCommand("SamplesSec 500") Case 11 SendCommand("SamplesSec 300") Case 12 SendCommand("SamplesSec 200") Case 13 SendCommand("SamplesSec 120") Case 14 SendCommand("SamplesSec 100") Case 15 SendCommand("SamplesSec 60") Case 16 SendCommand("SamplesSec 50") Case 17 SendCommand("SamplesSec 30") Case 18 SendCommand("SamplesSec 20") Case 19 SendCommand("SamplesSec 12") Case 20 SendCommand("SamplesSec 10") EndSelect Return Label FilterRandom Select Int(Rnd * 8) Case 0 SendCommand("Filter Max Speed") Case 1 SendCommand("Filter Fast") Case 2 SendCommand("Filter Medium") Case 3 SendCommand("Filter Slow") Case 4 SendCommand("Filter Post Max") Case 5 SendCommand("Filter Post Fast") Case 6 SendCommand("Filter Post Medium") Case 7 SendCommand("Filter Post Slow") EndSelect Return ' ------------------------------------------------- Adc24 channel properties Label TypeRandom Select Int(Rnd * 3) Case 0 SendCommand("Type Differential") Case 1 SendCommand("Type Pseudo Diff") Case 2 SendCommand("Type Single Ended") EndSelect Return Label GainRandom Select Int(Rnd * 8) Case 0 SendCommand("Gain 1") Case 1 SendCommand("Gain 2") Case 2 SendCommand("Gain 4") Case 3 SendCommand("Gain 8") Case 4 SendCommand("Gain 16") Case 5 SendCommand("Gain 32") Case 6 SendCommand("Gain 64") Case 7 SendCommand("Gain 128") EndSelect Return Label BiasedON SendCommand("Biased 1") Return Label BiasedOFF SendCommand("Biased 0") Return ' ------------------------------------------------- GET Label GetMasterName SendCommand("GetMasterName") Print SlotText(Slot_Responses) Return Label GetFPS SendCommand("GetFPS") Print SlotText(Slot_Responses) Return Label GetPinType SendCommand("GetPinType") Print SlotText(Slot_Responses) Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File Commands_to_LOGGERS.txt ' ============================================================================= Variable Numeric Slot_Commands = 1 Button 1 Label Log_Run Button 2 Label Log_Stop Button 3 Label Log_Pause Button 4 Label Log_Resume Button 6 Label Backup_File Button 8 Label Interval_001 Button 9 Label Interval_01 Button 10 Label Interval_1 Button 11 Label Interval_10 Stop ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand Variable String SC1 '<-- Parameter Command-String SlotText Slot_Commands = SC1 Variable Numeric SC2 For SC2 = 0.1 To 0.5 Step 0.1 ' <-- 0.5 seconds timeout If SlotText(Slot_Commands) = "" Exit EndIf Wait Seconds 0.1 Next Return ' ============================================================= ' COMMANDS ' ============================================================= ' ----------------------------------------------------- Toolbar commands Label Log_Run SendCommand("LogRun") Return Label Log_Stop SendCommand("LogStop") Return Label Log_Pause SendCommand("LogPause") Return Label Log_Resume SendCommand("LogResume") Return Label Backup_File SendCommand("BackupFile") Return Label Interval_001 SendCommand("RecordingInterval 0.01") Return Label Interval_01 SendCommand("RecordingInterval 0.1") Return Label Interval_1 SendCommand("RecordingInterval 1") Return Label Interval_10 SendCommand("RecordingInterval 10") Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File Commands_to_MOTORS.txt ' ============================================================================= ' ---------------------------------------------- ' Commands to Theremino_Motors ' ---------------------------------------------- ' EnableConnection ' DisableConnection ' ResetAllMultiturnValues ' ResetAllCalibrationValues ' Calibrate Motor x To nn.n ' ---------------------------------------------- ' SLOT TEXT for COMMANDS ' ---------------------------------------------- Variable Numeric Slot_Commands = 50 ' ---------------------------------------------- ' BUTTONS ' ---------------------------------------------- Button 1 Label EnableConnection Button 2 Label DisableConnection Button 4 Label WriteFirmware Button 5 Label SendReset Button 7 Label ShowWindow Button 9 Label ResetAllMultiturnValues Button 10 Label ResetAllCalibrationValues Button 12 Label "Calibrate Motor 1 To 0" Button 13 Label "Calibrate Motor 1 To 30" Button 14 Label "Calibrate Motor 1 To 60" Button 15 Label "Calibrate Motor 1 To 90" Gosub Loop Stop ' ---------------------------------------------- ' LOOP ' ---------------------------------------------- Label Loop 'Variable String Response 'Response = SlotText(Slot_Responses) 'Print Response Wait Seconds 0.1 Goto Loop ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand Variable Numeric SC1 '<-- Parameter Destinat.-Slot Variable String SC2 '<-- Parameter Command-String Variable Numeric SC3 = 0.5 '<-- The timeout in seconds Variable Numeric SC4 SlotText SC1 = SC2 For SC4 = 0.1 To SC3 Step 0.1 If SlotText(SC1) = "" Exit EndIf Wait Seconds 0.1 Next Return ' ---------------------------------------------- ' COMMANDS ' ---------------------------------------------- Label EnableConnection SendCommand(Slot_Commands)("EnableConnection") Return Label DisableConnection SendCommand(Slot_Commands)("DisableConnection") Return Label WriteFirmware SendCommand(Slot_Commands)("WriteFirmware") Return Label SendReset SendCommand(Slot_Commands)("SendReset") Return Label ShowWindow SendCommand(Slot_Commands)("ShowWindow") Return Label ResetAllMultiturnValues SendCommand(Slot_Commands)("ResetAllMultiturnValues") Return Label ResetAllCalibrationValues SendCommand(Slot_Commands)("ResetAllCalibrationValues") Return Label Calibrate Motor 1 To 0 SendCommand(Slot_Commands)("Calibrate Motor 1 To 0") Return Label Calibrate Motor 1 To 30 SendCommand(Slot_Commands)("Calibrate Motor 1 To 30") Return Label Calibrate Motor 1 To 60 SendCommand(Slot_Commands)("Calibrate Motor 1 To 60") Return Label Calibrate Motor 1 To 90 SendCommand(Slot_Commands)("Calibrate Motor 1 To 90") Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File Commands_to_OpenAI.txt ' ============================================================================= ' ---------------------------------------------- ' Commands to Theremino_OpenAI ' ---------------------------------------------- Button 1 Label Send Button 2 Label Get News Button 3 Label Clear All Button 5 Label Recog. ON Button 6 Label Recog. OFF Button 7 Label Speech ON Button 8 Label Speech OFF Button 10 Label Save Button 11 Label Load Button 12 Label Save_TestTxt Button 13 Label Load_TestTxt Button 17 Label Volume 10 Button 18 Label Volume 100 Button 20 Label Speed 3 Button 21 Label Speed 0 Button 23 Label Random 80 Button 24 Label Random 50 Button 26 Label Voice Elsa Button 27 Label Voice ENG Button 29 Label "Key MyFriend" Button 30 Label "Key MyRobot" Button 33 Label Options ON Button 34 Label Options OFF Button 36 Label Maximize Button 37 Label Minimize Button 38 Label Normal Button 41 Label HowAreYou Button HowAreYou Color Yellow9 Button 42 Label DateAndTime Button DateAndTime Color Yellow9 Variable Numeric Slot_Text = 1 Variable Numeric Slot_Responses = 4 Variable Numeric Slot_Commands = 5 Loop Stop ' ============================================================= ' LOOP ' ============================================================= Label Loop Print SlotText(Slot_Responses) Wait Seconds 0.01 Goto Loop ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand Variable Numeric SC1 '<-- Parameter Destinat.-Slot Variable String SC2 '<-- Parameter Command-String Variable Numeric SC3 = 0.5 '<-- The timeout in seconds Variable Numeric SC4 SlotText SC1 = SC2 For SC4 = 0.1 To SC3 Step 0.1 If SlotText(SC1) = "" Exit EndIf Wait Seconds 0.1 Next Return ' ============================================================= ' COMMANDS TO OpenAI ' ============================================================= Label Send SendCommand(Slot_Commands)("Send") Return Label Get News SendCommand(Slot_Commands)("GetNews") Return Label Clear All s1 = "Average 120" SendCommand(Slot_Commands)("ClearAll") Return Label Recog. ON SendCommand(Slot_Commands)("RecogON") Return Label Recog. OFF SendCommand(Slot_Commands)("RecogOFF") Return Label Speech ON SendCommand(Slot_Commands)("SpeechON") Return Label Speech OFF SendCommand(Slot_Commands)("SpeechOFF") Return Label Save SendCommand(Slot_Commands)("Save") Return Label Load SendCommand(Slot_Commands)("Load") Return Label Save_TestTxt SendCommand(Slot_Commands)("Save test.txt") Return Label Load_TestTxt SendCommand(Slot_Commands)("Load test.txt") Return Label Volume 10 SendCommand(Slot_Commands)("Volume 10") Return Label Volume 100 SendCommand(Slot_Commands)("Volume 100") Return Label Speed 0 SendCommand(Slot_Commands)("Speed 0") Return Label Speed 3 SendCommand(Slot_Commands)("Speed 3") Return Label Random 50 SendCommand(Slot_Commands)("Random 50") Return Label Random 80 SendCommand(Slot_Commands)("Random 80") Return ' Please use "-" or "_" instead of spaces Label Voice Elsa SendCommand(Slot_Commands)("Voice Elsa") Return Label Voice ENG SendCommand(Slot_Commands)("Voice English-Male") Return ' Please use "-" or "_" instead of spaces Label Key MyFriend SendCommand(Slot_Commands)("Keyword My_Friend") Return Label Key MyRobot SendCommand(Slot_Commands)("Keyword My_Robot") Return Label Options ON SendCommand(Slot_Commands)("OptionsON") Return Label Options OFF SendCommand(Slot_Commands)("OptionsOFF") Return Label Maximize SendCommand(Slot_Commands)("Maximize") Return Label Minimize SendCommand(Slot_Commands)("Minimize") Return Label Normal SendCommand(Slot_Commands)("Normal") Return Label HowAreYou SendCommand(Slot_Text)("How Are You") Send SlotText(Slot_Text) = "" Return Label DateAndTime SendCommand(Slot_Text)("What is Date And Time?") Send SlotText(Slot_Text) = "" Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File Commands_to_Player.txt ' ============================================================================= ' ---------------------------------------------- ' Commands to Theremino_CNC ' ---------------------------------------------- Button 1 Label SearchWeb1 Button 2 Label SearchWeb2 Button 3 Label SearchWeb3 Button 4 Label SearchWeb4 Button 5 Label SearchWeb5 Button 6 Label SearchWeb6 Button 7 Label PlayStream1 Button 8 Label PlayStream2 Button 9 Label PlayStream3 Button 10 Label PlayStream4 Button 11 Label PlayStream5 Button 12 Label PlayStream6 Button 17 Label PlayWeb1 Button 18 Label PlayWeb2 Button 19 Label PlayWeb3 Button 20 Label PlayWeb4 Button 21 Label PlayWeb5 Button 22 Label PlayWeb6 Button 23 Label PlayWeb7 Button 24 Label PlayWeb8 Button 25 Label PlayWeb9 Button 26 Label PlayWeb10 Button 27 Label PlayWeb11 Button 28 Label PlayWeb12 Button 30 Label ErrorTest Button 33 Label PlayWeb13 Button 34 Label PlayWeb14 Button 35 Label PlayWeb15 Button 36 Label PlayWeb16 Button 37 Label PlayWeb17 Button 38 Label PlayWeb18 Button 39 Label PlayWeb19 Button 40 Label PlayWeb20 Button 41 Label PlayWeb21 Button 42 Label PlayWeb22 Button 43 Label PlayWeb23 Button 44 Label PlayWeb24 Button 49 Label SearchLocal1 Button 50 Label SearchLocal2 Button 51 Label SearchLocal3 Button 52 Label SearchLocal4 Button 53 Label SearchLocal5 Button 55 Label SearchFavorites1 Button 56 Label SearchFavorites2 Button 57 Label SearchFavorites3 Button 58 Label SearchFavorites4 Button 59 Label SearchFavorites5 Button 65 Label PlayFavorites Button 66 Label AddToFavorites Button 67 Label DeleteFromFav. Button 68 Label EditFavorites Button 70 Label Forward Button 71 Label Backward Button 73 Label Next Button 74 Label Previous Button 76 Label FullScreen Button 77 Label Maximized Button 78 Label Normal Button 79 Label Minimized Variable Numeric Slot_Commands = 6 Variable Numeric Slot_Responses = 7 Controls OpenTextBox 'Loop Stop Label Loop If SlotText(Slot_Responses) <> "" Print SlotText(Slot_Responses) + CRLF + CRLF SlotText(Slot_Responses) = "" EndIf Goto Loop ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand Variable Numeric SC1 '<-- Parameter Destinat.-Slot Variable String SC2 '<-- Parameter Command-String Variable Numeric SC3 = 0.5 '<-- The timeout in seconds Variable Numeric SC4 SlotText SC1 = SC2 For SC4 = 0.1 To SC3 Step 0.1 If SlotText(SC1) = "" Exit EndIf Wait Seconds 0.1 Next Return Label SearchWeb1 SendCommand(Slot_Commands)("SearchWeb Boz Scaggs - Thanks To You - Jay's Audio Lab") Return Label SearchWeb2 SendCommand(Slot_Commands)("SearchWeb Boz Scaggs") Return Label SearchWeb3 SendCommand(Slot_Commands)("SearchWeb Norah Jones") Return Label SearchWeb4 SendCommand(Slot_Commands)("SearchWeb Candy Dulfer") Return Label SearchWeb5 SendCommand(Slot_Commands)("SearchWeb Angelina Jordan - Fly Me to the Moon") Return Label SearchWeb6 SendCommand(Slot_Commands)("SearchWeb Pino Daniele") Return Label PlayStream1 SendCommand(Slot_Commands)("PlayWeb http://radio.streemlion.com:1430/stream") Return Label PlayStream2 SendCommand(Slot_Commands)("PlayWeb http://c30.radioboss.fm:8119/autodj") Return Label PlayStream3 SendCommand(Slot_Commands)("PlayWeb http://igor.torontocast.com:2840/stream") Return Label PlayStream4 SendCommand(Slot_Commands)("PlayWeb http://streams.radiomast.io/4fdf004c-c2f3-49c1-bdb1-22e208d48780") Return Label PlayStream5 SendCommand(Slot_Commands)("PlayWeb https://soulcitythebeat.stream.laut.fm/soulcitythebeat") Return Label PlayStream6 SendCommand(Slot_Commands)("PlayWeb http://quincy.torontocast.com:2580/stream") Return Label ErrorTest SendCommand(Slot_Commands)("Error Test") Return Label PlayWeb1 SendCommand(Slot_Commands)("PlayWeb https://youtu.be/tgD5SJka07M") ' Boz Scaggs Thanks To You Return Label PlayWeb2 'SendCommand(Slot_Commands)("PlayWeb https://youtu.be/rO59UO-YXrc")' Boz Scaggs Thanks To You LIVE SendCommand(Slot_Commands)("PlayWeb https://youtu.be/HCBVwdS1Mt0")' Boz Scaggs at Home Return Label PlayWeb3 SendCommand(Slot_Commands)("PlayWeb https://www.youtube.com/watch?v=GILHv2R4UR8") Return Label PlayWeb4 SendCommand(Slot_Commands)("PlayWeb https://www.youtube.com/watch?v=P59LcdjcxMs") Return Label PlayWeb5 SendCommand(Slot_Commands)("PlayWeb https://youtu.be/GcYRKgsr53E") 'SendCommand(Slot_Commands)("PlayWeb https://youtu.be/iI7DLKNJguw") 'SendCommand(Slot_Commands)("PlayWeb https://youtu.be/3okPYG9zU0I") 'SendCommand(Slot_Commands)("PlayWeb https://www.youtube.com/@CozyJazzMusjc/videos") ' COZY OFFICIAL SITE Return Label PlayWeb6 SendCommand(Slot_Commands)("PlayWeb https://youtu.be/nO3QY2UOU-M")' jazz Return Label PlayWeb7 SendCommand(Slot_Commands)("PlayWeb https://www.youtube.com/watch?v=EOAPMhaCtuw")' jazz Return Label PlayWeb8 SendCommand(Slot_Commands)("PlayWeb https://youtu.be/YVm5_eyocKo")' jazz Return Label PlayWeb9 SendCommand(Slot_Commands)("PlayWeb https://youtu.be/4X2b7qE9AFY")' jazz Return Label PlayWeb10 SendCommand(Slot_Commands)("PlayWeb https://www.youtube.com/watch?v=5WSulenOUb0")' Jethro Tull Return Label PlayWeb11 SendCommand(Slot_Commands)("PlayWeb https://youtu.be/gf6v59c5yuY") ' Hotel California Return Label PlayWeb12 SendCommand(Slot_Commands)("PlayWeb https://youtu.be/DWO_eojWezg") ' Santana Return Label PlayWeb13 SendCommand(Slot_Commands)("PlayWeb https://www.youtube.com/watch?v=jh4C7w-dvho") 'Caffè Music relax in jazz 'https://www.youtube.com/watch?v=b4puhonCebE 'Caffè Music relax in jazz 'https://youtu.be/IRyJe-0Uie0 'Caffè Music relax in jazz 'https://youtu.be/az8T-ED6tgs 'Caffè Music relax in jazz Return Label PlayWeb14 SendCommand(Slot_Commands)("PlayWeb https://youtu.be/Wyzqmfu1W14") ' Hammond Return Label PlayWeb15 SendCommand(Slot_Commands)("PlayWeb https://youtu.be/v8I5vDewcZo")' Little dream of me Return Label PlayWeb16 SendCommand(Slot_Commands)("PlayWeb https://youtu.be/SZiods4xwmM")' Erik Clapton SendCommand(Slot_Commands)("PlayWeb https://youtu.be/bk50SoNkvhw") ' Boz We are all alone Return Label PlayWeb17 SendCommand(Slot_Commands)("PlayWeb https://youtu.be/vQegbgyBYFY")' Bossanova Return Label PlayWeb18 SendCommand(Slot_Commands)("PlayWeb https://youtu.be/9wxkkt5g0gg")' Bossanova Return Label PlayWeb19 SendCommand(Slot_Commands)("PlayWeb https://youtu.be/q6_kkJZCj4I")' Bossanova Return Label PlayWeb20 SendCommand(Slot_Commands)("PlayWeb https://youtu.be/fnv5i9rXkSc") ' Brasil Return Label PlayWeb21 SendCommand(Slot_Commands)("PlayWeb https://www.youtube.com/watch?v=5WSulenOUb0")' Jethro Tull Return Label PlayWeb22 SendCommand(Slot_Commands)("PlayWeb https://youtu.be/gf6v59c5yuY") ' Hotel California Return Label PlayWeb23 SendCommand(Slot_Commands)("PlayWeb https://youtu.be/DWO_eojWezg") ' Santana Return Label PlayWeb24 SendCommand(Slot_Commands)("PlayWeb https://youtu.be/3XbEUv_MCj0")' Radio Live Return Label SearchLocal1 SendCommand(Slot_Commands)("SearchLocal sade") Return Label SearchLocal2 SendCommand(Slot_Commands)("SearchLocal gino vannelli") Return Label SearchLocal3 SendCommand(Slot_Commands)("SearchLocal sinatra fly me to the moon") Return Label SearchLocal4 SendCommand(Slot_Commands)("SearchLocal the great gig in the sky") 'SendCommand(Slot_Commands)("SearchLocal The bird and the bee mp4") Return Label SearchLocal5 SendCommand(Slot_Commands)("SearchLocal Gabriella Quevedo") 'SendCommand(Slot_Commands)("SearchLocal Here Comes The Sun - Gabriella Quevedo") 'SendCommand(Slot_Commands)("SearchLocal Another brick - Gabriella Quevedo") Return Label SearchFavorites1 SendCommand(Slot_Commands)("SearchFavorites") Return Label SearchFavorites2 SendCommand(Slot_Commands)("SearchFavorites music") Return Label SearchFavorites3 SendCommand(Slot_Commands)("SearchFavorites Funny animals") Return Label SearchFavorites4 SendCommand(Slot_Commands)("SearchFavorites Cave") Return Label SearchFavorites5 SendCommand(Slot_Commands)("SearchFavorites Sade") Return Label SearchFavorites6 SendCommand(Slot_Commands)("SearchFavorites Parrot") Return Label PlayFavorites SendCommand(Slot_Commands)("PlayFavorites") Return Label AddToFavorites SendCommand(Slot_Commands)("AddToFavorites") Return Label DeleteFromFav. SendCommand(Slot_Commands)("DeleteFromFavorites") Return Label EditFavorites SendCommand(Slot_Commands)("EditFavorites") Return Label Forward SendCommand(Slot_Commands)("Forward") Return Label Backward SendCommand(Slot_Commands)("Backward") Return Label Next SendCommand(Slot_Commands)("Next") Return Label Previous SendCommand(Slot_Commands)("Previous") Return Label FullScreen SendCommand(Slot_Commands)("FullScreen") Return Label Maximized SendCommand(Slot_Commands)("Maximized") Return Label Normal SendCommand(Slot_Commands)("Normal") Return Label Minimized SendCommand(Slot_Commands)("Minimized") Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File Commands_to_SlotTextToSpeech.txt ' ============================================================================= Button 1 Label CommandStop Button 3 Label CommandSpeed-10 Button 4 Label CommandSpeed0 Button 5 Label CommandSpeed10 Button 7 Label CommandVolume0 Button 8 Label CommandVolume50 Button 9 Label CommandVolume100 Button 17 Label CommandVoiceItaF Button 18 Label CommandVoiceItaM Button 19 Label CommandVoiceEngF Button 20 Label CommandVoiceEngM Button 22 Label SayTextIta Button 23 Label SayTextEng Variable Numeric Slot_CommandsToSlotTextToSpeechApplication = 1 Stop ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand Variable Numeric SC1 '<-- Parameter Destinat.-Slot Variable String SC2 '<-- Parameter Command-String Variable Numeric SC3 = 0.5 '<-- The timeout in seconds Variable Numeric SC4 SlotText SC1 = "" Wait Seconds 0.1 SlotText SC1 = SC2 For SC4 = 0.1 To SC3 Step 0.1 If SlotText(SC1) = "" Exit EndIf Wait Seconds 0.1 Next Return ' ============================================================= ' COMMANDS TO SlotTextToSpeechApplication ' ============================================================= Label CommandStop SendCommand(Slot_CommandsToSlotTextToSpeechApplication)("COMMAND: Stop") Return Label CommandSpeed-10 SendCommand(Slot_CommandsToSlotTextToSpeechApplication)("COMMAND: Speed -10") Return Label CommandSpeed0 SendCommand(Slot_CommandsToSlotTextToSpeechApplication)("COMMAND: Speed 0") Return Label CommandSpeed10 SendCommand(Slot_CommandsToSlotTextToSpeechApplication)("COMMAND: Speed 10") Return Label CommandVolume0 SendCommand(Slot_CommandsToSlotTextToSpeechApplication)("COMMAND: Volume 0") Return Label CommandVolume50 SendCommand(Slot_CommandsToSlotTextToSpeechApplication)("COMMAND: Volume 50") Return Label CommandVolume100 SendCommand(Slot_CommandsToSlotTextToSpeechApplication)("COMMAND: Volume 100") Return Label CommandVoiceItaF SendCommand(Slot_CommandsToSlotTextToSpeechApplication)("COMMAND: Voice ITA F") Return Label CommandVoiceItaM SendCommand(Slot_CommandsToSlotTextToSpeechApplication)("COMMAND: Voice ITA M") Return Label CommandVoiceEngF SendCommand(Slot_CommandsToSlotTextToSpeechApplication)("COMMAND: Voice ENG F") Return Label CommandVoiceEngM SendCommand(Slot_CommandsToSlotTextToSpeechApplication)("COMMAND: Voice ENG M") Return Label SayTextIta SendCommand(Slot_CommandsToSlotTextToSpeechApplication)("Prova di testo in italiano.") Return Label SayTextEng SendCommand(Slot_CommandsToSlotTextToSpeechApplication)("English text to speec.") Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File Commands_to_Spectrometer.txt ' ============================================================================= ' ------------------------------------- MENU commands Button 1 Label Title0 Button Title0 Label "Menu commands" Button Title0 Color Green2 Button 2 Label LoadSpectrumFile1 Button 3 Label LoadSpectrumFile2 Button 4 Label LoadSpectrumFile3 Button 5 Label LoadCalibrationFile1 Button 6 Label LoadCalibrationFile2 Button 7 Label LoadCalibrationFile3 Button 8 Label LoadIrradianceFile1 Button 9 Label LoadIrradianceFile2 Button 10 Label LoadIrradianceFile3 Button 11 Label SensorTypeRandom ' ------------------------------------- Toolbar commands Button 17 Label Title1 Button Title1 Label "Toolbar commands" Button Title1 Color Green2 Button 18 Label SaveSpectrumImage Button 19 Label SaveTotalImage Button 20 Label WriteDataON Button 21 Label WriteDataOFF Button 22 Label WriteDataTimeRandom Button 23 Label WriteDataRepeatON Button 24 Label WriteDataRepeatOFF Button 25 Label OptionsON Button 26 Label OptionsOFF ' ------------------------------------- Serial Port Button 33 Label Title2 Button Title2 Label "Serial Port" Button Title2 Color Green2 Button 34 Label PortRandom Button 35 Label BaudsRandom Button 36 Label ComConnect Button 37 Label ComDisconnect Button 38 Label AutoExpON Button AutoExpON Text "AutoExp" + CRLF + "ON" Button 39 Label AutoExpOFF Button AutoExpOFF Text "AutoExp" + CRLF + "OFF" Button 40 Label ExposureRandom Button ExposureRandom Text "Exposure" + CRLF + "Random" ' ------------------------------------- SENSOR Button 42 Label Title4 Button Title4 Label "Sensor" Button Title4 Color Green2 Button 43 Label SamplesRandom Button SamplesRandom Text "Samples" + CRLF + "Random" Button 44 Label AdcSpeedRandom Button AdcSpeedRandom Text "AdcSpeed" + CRLF + "Random" Button 45 Label ModeRandom Button 46 Label AdcScaleRandom ' ' ------------------------------------- WEBCAM Button 49 Label Title3 Button Title3 Label "WebCam" Button Title3 Color Green2 Button 50 Label WebCamRandom Button 51 Label WebCamConnect Button 52 Label WebCamDisconnect Button 53 Label VideoInControlsON Button 54 Label VideoInControlsOFF ' ' ------------------------------------- FILES Button 59 Label Title5 Button Title5 Label "Files" Button Title5 Color Green2 Button 60 Label FileNameRandom Button FileNameRandom Text "FileName" + CRLF + "Random" Button 61 Label ImageTypeRandom Button ImageTypeRandom Text "ImageType" + CRLF + "Random" Button 62 Label FilePathRandom Button FilePathRandom Text "FilePath" + CRLF + "Random" ' ' ------------------------------------- FILTERS Button 65 Label Title6 Button Title6 Label "Filters" Button Title6 Color Green2 Button 66 Label AverageON Button 67 Label AverageOFF Button 68 Label AverageRandom Button AverageRandom Text "Average" + CRLF + "Random" Button 69 Label SpatialFilterRandom Button SpatialFilterRandom Text "Spatial filter" + CRLF + "Random" Button 70 Label ReferenceON Button 71 Label ReferenceOFF Button 72 Label BackgroundON Button 73 Label BackgroundOFF Button 74 Label RisingSpeed Button RisingSpeed Text "RisingSpeed" + CRLF + "Random" Button 75 Label FallingSpeed Button FallingSpeed Text "FallingSpeed" + CRLF + "Random" Button 76 Label ResetSpectrumData ' ------------------------------------- SENSOR SAMPLES Button 81 Label Title7 Button Title7 Label "Sensor samples" Button Title7 Color Green2 Button 82 Label AdcMaxRandom Button 83 Label AdcMinRandom Button 84 Label AdcMinAuto_ON Button 85 Label AdcMinAuto_OFF Button 86 Label StartX_Random Button 87 Label EndX_Random Button 88 Label SizeY_Random Button 89 Label StartY_Random Button 90 Label FlipH_ON Button 91 Label FlipH_OFF Button 92 Label FlipV_ON Button 93 Label FlipV_OFF ' ------------------------------------- STATUS BAR Button 97 Label Title8 Button Title8 Label "Status bar" Button Title8 Color Green2 Button 98 Label LogScaleRandom Button LogScaleRandom Text "Log Scale" + CRLF + "Random" Button 99 Label DipsON Button 100 Label DipsOFF Button 101 Label PeaksON Button 102 Label PeaksOFF Button 103 Label ColorsON Button 104 Label ColorsOFF Button 105 Label TrimScaleON Button 106 Label TrimScaleOFF ' ============================================================= ' START AND STOP PROGRAM ' ============================================================= Variable Numeric Slot_Commands = 31 'Variable Numeric Slot_Responses = 32 Load Theremino_SlotViewer.exe Window MinSize Stop Label EventStop For v1 = 0 To 128 Button v1 Text "" Next Window Sizable End ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand Variable String SC1 '<-- Parameter Command-String SlotText Slot_Commands = SC1 Variable Numeric SC2 For SC2 = 0.1 To 0.5 Step 0.1 ' <-- 0.5 seconds timeout If SlotText(Slot_Commands) = "" Exit EndIf Wait Seconds 0.1 Next Return ' ============================================================= ' COMMANDS ' ============================================================= ' ------------------------------------- Menu commands Label LoadSpectrumFile SendCommand("LoadSpectrumFile Test1_001.csv") Return Label LoadSpectrumFile2 SendCommand("LoadSpectrumFile Test1_002.csv") Return Label LoadSpectrumFile3 SendCommand("LoadSpectrumFile Test1_003.csv") Return Label LoadCalibrationFile1 SendCommand("LoadCalibrationFile Calib1.txt") Return Label LoadCalibrationFile2 SendCommand("LoadCalibrationFile Calib2.txt") Return Label LoadCalibrationFile3 SendCommand("LoadCalibrationFile Calib3.txt") Return Label LoadIrradianceFile1 SendCommand("LoadIrradianceFile Coeffs_FLAT.txt") Return Label LoadIrradianceFile2 SendCommand("LoadIrradianceFile Random_100_to_2000_nm.txt") Return Label LoadIrradianceFile3 SendCommand("LoadIrradianceFile Sinusoidal_100_to_2000_nm.txt") Return Label SensorTypeRandom Random = Mod((Random + 1), 3) Select Random Case 0 SendCommand("SensorType WebCam") Case 1 SendCommand("SensorType TCD1304") Case 2 SendCommand("SensorType TCD1254") EndSelect Return ' ------------------------------------- Toolbar commands Label SaveSpectrumImage SendCommand("SaveSpectrumImage") Return Label SaveTotalImage SendCommand("SaveTotalImage") Return Label WriteDataON SendCommand("WriteDataON") Return Label WriteDataOFF SendCommand("WriteDataOFF") Return Label WriteDataTimeRandom Random = Mod((Random + 1), 3) Select Random Case 0 SendCommand("WriteDataTime 0 sec") Case 1 SendCommand("WriteDataTime 3.0 sec") Case 2 SendCommand("WriteDataTime 10 sec") EndSelect Return Label WriteDataRepeatON SendCommand("WriteDataRepeatON") Return Label WriteDataRepeatOFF SendCommand("WriteDataRepeatOFF") Return Label OptionsON SendCommand("OptionsON") Return Label OptionsOFF SendCommand("OptionsOFF") Return ' ----------------------------------- SERIAL PORT Label PortRandom Random = Mod((Random + 1), 3) Select Random Case 0 SendCommand("ComPort COM1") Case 1 SendCommand("ComPort COM4") Case 2 SendCommand("ComPort COM11") EndSelect Return Label BaudsRandom Random = Mod((Random + 1), 3) Select Random Case 0 SendCommand("Bauds 115200") Case 1 SendCommand("Bauds 250000") Case 2 SendCommand("Bauds 1000000") EndSelect Return Label ComConnect SendCommand("ComConnect") Return Label ComDisconnect SendCommand("ComDisconnect") Return Label AutoExpON SendCommand("AutoExpON") Return Label AutoExpOFF SendCommand("AutoExpOFF") Return Label ExposureRandom Random = Mod((Random + 1), 3) Select Random Case 0 SendCommand("Exposure 10 us") Case 1 SendCommand("Exposure 20 ms") Case 2 SendCommand("Exposure 100 ms") EndSelect Return ' ------------------------------------ SENSOR Variable Numeric Random Label SamplesRandom Random = Mod((Random + 1), 3) Select Random Case 0 SendCommand("Samples 500") Case 1 SendCommand("Samples 1000") Case 2 SendCommand("Samples 3600") EndSelect Return Label AdcSpeedRandom Random = Mod((Random + 1), 3) Select Random Case 0 SendCommand("AdcSpeed 1") Case 1 SendCommand("AdcSpeed 2") Case 2 SendCommand("AdcSpeed 3") EndSelect Return Label ModeRandom Random = Mod((Random + 1), 3) Select Random Case 0 SendCommand("Mode Normal") Case 1 SendCommand("Mode Debug1C") Case 2 SendCommand("Mode Debug3C") EndSelect Return Label AdcScaleRandom Random = Mod((Random + 1), 3) Select Random Case 0 SendCommand("AdcScale 8 bit") Case 1 SendCommand("AdcScale 10 bit") Case 2 SendCommand("AdcScale 16 bit") EndSelect Return ' ------------------------------------ WEBCAM Label WebCamRandom SendCommand("WebCamIndex " + Int(Rnd * 2)) Return Label WebCamConnect SendCommand("WebCamConnect") Return Label WebCamDisconnect SendCommand("WebCamDisconnect") Return Label VideoInControlsON SendCommand("VideoInControlsON") Return Label VideoInControlsOFF SendCommand("VideoInControlsOFF") Return ' ------------------------------------- FILES Label FileNameRandom Random = Mod((Random + 1), 3) Select Random Case 0 SendCommand("FileName Test1") Case 1 SendCommand("FileName File 1") Case 2 SendCommand("FileName File___3") EndSelect Return Label ImageTypeRandom Random = Mod((Random + 1), 3) Select Random Case 0 SendCommand("ImageType Jpg") Case 1 SendCommand("ImageType Png") Case 2 SendCommand("ImageType Bmp") EndSelect Return Label FilePathRandom Random = Mod((Random + 1), 3) Select Random Case 0 SendCommand("FilePath C:\Users\Win10\Documents") Case 1 SendCommand("FilePath C:\Users\Win10\Downloads") Case 2 SendCommand("FilePath C:\Users\Win10\Desktop") EndSelect Return ' ' ------------------------------------- FILTERS Label AverageON SendCommand("AverageON") Return Label AverageOFF SendCommand("AverageOFF") Return Label AverageRandom Random = Mod((Random + 1), 3) Select Random Case 0 SendCommand("Average 1") Case 1 SendCommand("Average 10") Case 2 SendCommand("Average 100") EndSelect Return Label SpatialFilterRandom SendCommand("SpatialFilter " + Int(Rnd * 10)) Return Label ReferenceON SendCommand("Reference_ON") Return Label ReferenceOFF SendCommand("Reference_OFF") Return Label BackgroundON SendCommand("Background_ON") Return Label BackgroundOFF SendCommand("Background_OFF") Return Label RisingSpeedRandom SendCommand("RisingSpeed " + Int(Rnd * 100)) Return Label FallingSpeedRandom SendCommand("FallingSpeed " + Int(Rnd * 100)) Return Label ResetSpectrumData SendCommand("ResetSpectrumData") Return ' ------------------------------------- Sensor samples Label AdcMaxRandom SendCommand("AdcMax " + Int(600 + Rnd * 200)) Return Label AdcMinRandom SendCommand("AdcMin " + Int(200 + Rnd * 200)) Return Label AdcMinAuto_ON SendCommand("AdcMinAuto_ON") Return Label AdcMinAuto_OFF SendCommand("AdcMinAuto_OFF") Return Label StartX_Random SendCommand("StartX " + Int(Rnd * 300)) Return Label EndX_Random SendCommand("EndX " + Int(1000 - Rnd * 400)) Return Label SizeY_Random SendCommand("SizeY " + Int(Rnd * 50 + 1) ) Return Label StartY_Random SendCommand("StartY " + Int(Rnd * 50)) Return Label FlipH_ON SendCommand("FlipH_ON") Return Label FlipH_OFF SendCommand("FlipH_OFF") Return Label FlipV_ON SendCommand("FlipV_ON") Return Label FlipV_OFF SendCommand("FlipV_OFF") Return ' ------------------------------------- STATUS BAR Label LogScaleRandom SendCommand("LogScale " + Int(Rnd * 20 - 10)) Return Label DipsON SendCommand("Dips_ON") Return Label DipsOFF SendCommand("Dips_OFF") Return Label PeaksON SendCommand("Peaks_ON") Return Label PeaksOFF SendCommand("Peaks_OFF") Return Label ColorsON SendCommand("Colors_ON") Return Label ColorsOFF SendCommand("Colors_OFF") Return Label TrimScaleON SendCommand("TrimScale_ON") Return Label TrimScaleOFF SendCommand("TrimScale_OFF") Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File Commands_to_VOICE_COMMANDS.txt ' ============================================================================= Button 1 Label _RUN Button 2 Label _STOP Button 4 Label LoadGarden Button 5 Label LoadHouse Variable Numeric Slot_CommandsToVoiceCommands = 2 Stop ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand Variable Numeric SC1 '<-- Parameter Destinat.-Slot Variable String SC2 '<-- Parameter Command-String Variable Numeric SC3 = 0.5 '<-- The timeout in seconds Variable Numeric SC4 SlotText SC1 = SC2 For SC4 = 0.1 To SC3 Step 0.1 If SlotText(SC1) = "" Exit EndIf Wait Seconds 0.1 Next Return ' ============================================================= ' COMMANDS TO GPS ' ============================================================= Label _RUN SendCommand(Slot_CommandsToVoiceCommands)("Run") Return Label _STOP SendCommand(Slot_CommandsToVoiceCommands)("Stop") Return Label LoadGarden SendCommand(Slot_CommandsToVoiceCommands)("Load ENG_garden.txt") Return Label LoadHouse SendCommand(Slot_CommandsToVoiceCommands)("Load ENG_house.txt") Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File SlotText-ExternalCommands_EVENT_1.txt ' ============================================================================= ' ========================================================== ' EXTERNAL COMMANDS EXAMPLE ' ========================================================== Variable Numeric Slot_ExternalCommands = 1 Stop Label Event_ExternalCommands ' --------------------------------- Extract first word Select GetSeparatedString(CommandText, 0) Case "" ' ----------------------------- Case "Beep" Beep 440 300 ClearCommand ' ----------------------------- Case "Beep_Multiple" ExecBeepMultiple ClearCommand ' --------------------- Commands with parameters Case "Say" TTS Speak Mid(CFE1, 5) Wait TTSready ClearCommand ' ------------------------- Unrecognized command CaseElse Wait Seconds 0.5 Beep 200 500 Print "Unrecognized command: " + CommandText Wait Seconds 0.5 ClearCommand EndSelect Return Label ClearCommand SlotText(Slot_ExternalCommands) = "" Return Label ExecBeepMultiple For v1 = 1 To 3 Beep 880 400 Wait Seconds 0.5 Next Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File SlotText-ExternalCommands_EVENT_2.txt ' ============================================================================= Variable Numeric Slot_ExternalCommands = 53 Label Event_ExternalCommands ' ------------------------------------------------------ Do not print lines containing '' 'Print " Exec: " + CommandText + CRLF ' ------------------------------------------------------ Select GetSeparatedString(CommandText, 0) ' ---------------------------------------------- ACTIONS Case "Say" TTS Speak Mid(CommandText, 5) ' Remove "Say " Wait TTSready ClearCommand Case "RedOn" ClearCommand Case "GreenOn" ClearCommand Case "BlueOn" ClearCommand Case "WhiteOn" ClearCommand Case "MagentaOn" ClearCommand Case "YellowOn" ClearCommand Case "Beep" Beep 880-100 ClearCommand Case "StartPump" ClearCommand Case "StopPump" ClearCommand CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + CommandText + CRLF Beep ClearCommand EndSelect Return Label ClearCommand SlotText(Slot_ExternalCommands) = "" Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File SlotText-ExternalCommands_POLLING.txt ' ============================================================================= Variable Numeric Slot_PollExternalCommands = 53'1 Label Loop1 Poll_ExternalCommands Goto Loop1 Stop Label Poll_ExternalCommands Variable String PEC1 PEC1 = SlotText(Slot_PollExternalCommands) ' --------------------------------- Extract first word Select GetSeparatedString(PEC1, 0) Case "" ' ------------------------- Case "Beep" Beep 440 300 ClearCommand ' ------------------------- Case "Beep_Multiple" ExecBeepMultiple ClearCommand ' ------------------------- Commands with parameters Case "Say" TTS Speak Mid(PEC1, 5) Wait TTSready ClearCommand ' ------------------------- Unrecognized command CaseElse Wait Seconds 0.5 Beep 200 500 Print "Unrecognized command: " + PEC1 Wait Seconds 0.5 ClearCommand EndSelect Return Label ClearCommand SlotText(Slot_PollExternalCommands) = "" Return Label ExecBeepMultiple For v1 = 1 To 3 Beep 880 400 Wait Seconds 0.5 Next Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File SlotText-ExternalCommands_POLLING_1.txt ' ============================================================================= Variable Numeric Slot_PollExternalCommands = 53'1 Label Loop1 Poll_ExternalCommands Goto Loop1 Stop Label Poll_ExternalCommands Variable String PEC1 PEC1 = SlotText(Slot_PollExternalCommands) ' --------------------------------- Extract first word Select GetSeparatedString(PEC1, 0) Case "" ' ------------------------- Case "Beep" Beep 440 300 ClearCommand ' ------------------------- Case "Beep_Multiple" ExecBeepMultiple ClearCommand ' ------------------------- Commands with parameters Case "Say" TTS Speak Mid(PEC1, 5) Wait TTSready ClearCommand ' ------------------------- Unrecognized command CaseElse Wait Seconds 0.5 Beep 200 500 Print "Unrecognized command: " + PEC1 Wait Seconds 0.5 ClearCommand EndSelect Return Label ClearCommand SlotText(Slot_PollExternalCommands) = "" Return Label ExecBeepMultiple For v1 = 1 To 3 Beep 880 400 Wait Seconds 0.5 Next Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File SlotText-ExternalCommands_POLLING_2.txt ' ============================================================================= Variable Numeric Slot_ExternalCommands = 1 Label Loop1 Poll_ExternalCommands Goto Loop1 Stop Label Poll_ExternalCommands ' --------------------------------- Extract first word Select GetSeparatedString(CommandText, 0) Case "" ' ------------------------- Case "Beep" Beep 440 300 ClearCommand ' ------------------------- Case "Beep_Multiple" ExecBeepMultiple ClearCommand ' ------------------------- Commands with parameters Case "Say" TTS Speak Mid(CommandText, 5) Wait TTSready ClearCommand ' ------------------------- Unrecognized command CaseElse Wait Seconds 0.5 Beep 200 500 Print "Unrecognized command: " + CommandText Wait Seconds 0.5 ClearCommand EndSelect Return Label ClearCommand CommandText = "" SlotText(Slot_ExternalCommands) = "" Return Label ExecBeepMultiple For v1 = 1 To 3 Beep 880 400 Wait Seconds 0.5 Next Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File SlotText-ExternalCommands_TO-BUTTONS.txt ' ============================================================================= ' ========================================================== ' EXTERNAL COMMANDS TO BUTTONS EXAMPLE ' ========================================================== Button 1 Label Beep1 Button 2 Label Beep2 Button 3 Label Beep3 Variable Numeric Slot_ExternalCommands = 1 Stop Label Beep1 Beep 440 100 ClearCommand Return Label Beep2 Beep 600 100 ClearCommand Return Label Beep3 ClearCommand ExecBeepMultiple Return Label ExecBeepMultiple For v1 = 1 To 3 Beep 880 100 Wait Seconds 0.1 Next Return Label ClearCommand SlotText(Slot_ExternalCommands) = "" Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands ' File SlotText-Reader.txt ' ============================================================================= Variable Numeric FirstSlot = 50 Variable Numeric NumSlots = 10 Controls OpenTextBox Label Loop s1 = "" For v1 = FirstSlot To FirstSlot + NumSlots s1 = s1 + v1 + " " + SlotText(v1) + CRLF Next Print s1 + CRLF Wait Seconds 0.1 Goto Loop ' ============================================================================= ' Folder Demo Programs\SlotText Commands\OLD EXAMPLES ' File Commands_to_CNC_WithoutParams.txt ' ============================================================================= Button 1 Text CmdRun Button 2 Text CmdStep Button 3 Text CmdPause Button 4 Text CmdRewind Button 5 Text CmdStop Button 7 Text Rapid500 Button 8 Text Rapid2000 Button 9 Text Feed100 Button 10 Text Feed1000 Button 11 Text Speed0 Button 12 Text Speed20000 Button 17 Text TestLowZ Button 18 Text GotoZero Button 19 Text GotoHome Button 20 Text GotoBottomLeft Button 21 Text GotoTopRight Button 23 Text SetZetaHome Button 24 Text CalibrateXY Button 25 Text CalibrateZ Button 26 Text CalibrateAB Button 28 Text MoveTo_10_20_30 Button 29 Text MoveTo_20_30_10 Button 33 Text ZeroX Button 34 Text ZeroY Button 35 Text ZeroZ Button 36 Text ZeroA Button 37 Text ZeroB Button 39 Text GotoLine5 Button 40 Text GotoLine50 Button 41 Text GotoLine9999 Button 43 Text LoadMaster Button 44 Text LoadPmtAdapter Button 46 Text ErrorTest Variable Numeric SlotCommands = 1 Variable Numeric SlotStatus = 2 Loop Stop Label Loop Print SlotText(SlotStatus) Goto Loop Label CmdRun SlotText SlotCommands = "CmdRun" Return Label CmdStep SlotText SlotCommands = "CmdStep" Return Label CmdPause SlotText SlotCommands = "CmdPause" Return Label CmdRewind SlotText SlotCommands = "CmdRewind" Return Label CmdStop SlotText SlotCommands = "CmdStop" Return Label Rapid500 SlotText SlotCommands = "Rapid 500" Return Label Rapid2000 SlotText SlotCommands = "Rapid 2000" Return Label Feed100 SlotText SlotCommands = "Feed 100" Return Label Feed1000 SlotText SlotCommands = "Feed 1000" Return Label Speed0 SlotText SlotCommands = "Speed 0" Return Label Speed20000 SlotText SlotCommands = "Speed 20000" Return Label TestLowZ SlotText SlotCommands = "TestLowZ" Return Label GotoZero SlotText SlotCommands = "GotoZero" Return Label GotoHome SlotText SlotCommands = "GotoHome" Return Label GotoBottomLeft SlotText SlotCommands = "GotoBottomLeft" Return Label GotoTopRight SlotText SlotCommands = "GotoTopRight" Return Label SetZetaHome SlotText SlotCommands = "SetZetaHome" Return Label CalibrateXY SlotText SlotCommands = "CalibrateXY" Return Label CalibrateZ SlotText SlotCommands = "CalibrateZ" Return Label CalibrateAB SlotText SlotCommands = "CalibrateAB" Return Label MoveTo_10_20_30 SlotText SlotCommands = "MoveTo 10 20 30" Return Label MoveTo_20_30_10 SlotText SlotCommands = "MoveTo 20 30 10" Return Label ZeroX SlotText SlotCommands = "ZeroX" Return Label ZeroY SlotText SlotCommands = "ZeroY" Return Label ZeroZ SlotText SlotCommands = "ZeroZ" Return Label ZeroA SlotText SlotCommands = "ZeroA" Return Label ZeroB SlotText SlotCommands = "ZeroB" Return Label GotoLine5 SlotText SlotCommands = "GotoLine 5" Return Label GotoLine50 SlotText SlotCommands = "GotoLine 50" Return Label GotoLine9999 SlotText SlotCommands = "GotoLine 9999" Return Label LoadMaster SlotText SlotCommands = "LoadGcode PCB Large\MasterDIL-V3.gc" Return Label LoadPmtAdapter SlotText SlotCommands = "LoadGcode PCB Large\PmtAdapter.gc" Return Label ErrorTest SlotText SlotCommands = "Error Test" Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands\OLD EXAMPLES ' File Commands_to_COBOT_WithoutParams.txt ' ============================================================================= ' ---------------------------------------------- ' COMMANDS ' ---------------------------------------------- ' "ExitFromEdit" (exit from editing state) ' "StartExecution" (auto-exit from editing) ' "StopExecution" (auto-exit from editing) ' "GotoHome" (auto-exit from editing) ' "GotoCenter" (auto-exit from editing) ' "EnableRepeat" ' "DisableRepeat" ' "SelectLine nnn" ' "ExecuteSelectedLine" ' "ArrowUP" (auto-exit from run mode) ' "ArrowDOWN" (auto-exit from run mode) ' "EnableCollaborative ' "DisableCollaborative ' "AddNewPosition ' "SetHomePosition ' "SetCenterPosition ' "SetSpeedToTorque n.nn" (0.00 to 1.00) ' "SetHoldingTorque nnn" ' "SetTorqueMin nnn" ' "SetTorqueMax nnn" ' "SetAcceleration nnn" ' "SetSpeed nnn" ' "LoadSequence SeqName.seq" (without spaces) ' ---------------------------------------------- ' RESPONSES ' ---------------------------------------------- ' "Ready" ' "Execution running at line nnn" ' "Motors disconnected" ' "Human detected - Speed reduced" ' "Human too near - Execution stopped" ' "Too much torque - Execution stopped" ' "Motors disconnected - Execution stopped" ' ---------------------------------------------- ' SLOT TEXT for COMMANDS and RESPONSES ' ---------------------------------------------- Variable Numeric SlotCommands = 51 Variable Numeric SlotResponses = 52 ' ---------------------------------------------- ' BUTTONS ' ---------------------------------------------- Button 1 Label ExitFromEdit Button 3 Label StartExecution Button 4 Label StopExecution Button 6 Label GotoHome Button 7 Label GotoCenter Button 9 Label EnableRepeat Button 10 Label DisableRepeat Button 17 Label SelectLine3 Button 18 Label SelectLine6 Button 19 Label ExecuteSelectedLine Button 21 Label ArrowUP Button 22 Label ArrowDOWN Button 24 Label EnableCollaborative Button 25 Label DisableCollaborative Button 26 Label AddNewPosition Button 27 Label SetHomePosition Button 28 Label SetCenterPosition Button 33 Label SetHoldingTorque9 Button 34 Label SetSafeTorqueLimit9 Button 35 Label SetTorqueMin9 Button 36 Label SetTorqueMax9 Button 37 Label SetAcceleration9 Button 38 Label SetSpeed9 Button 40 Label SetTorqueCoeff Button 41 Label SetAllparamsToMin Button 42 Label SetAllparamsToMax Gosub Loop Stop ' ---------------------------------------------- ' LOOP ' ---------------------------------------------- Label Loop Variable String Response Response = SlotText(SlotResponses) Print Response Wait Seconds 0.1 ' ------------------------------- how to test partial strings If StringContains(Response, "stopped") Beep EndIf Goto Loop ' ---------------------------------------------- ' COMMANDS ' ---------------------------------------------- Label WaitExecution Wait SlotText(SlotCommands) = "" Return Label ExitFromEdit SlotText SlotCommands = "ExitFromEdit" WaitExecution Return Label StartExecution SlotText SlotCommands = "StartExecution" WaitExecution Return Label StopExecution SlotText SlotCommands = "StopExecution" WaitExecution Return Label EnableRepeat SlotText SlotCommands = "EnableRepeat" WaitExecution Return Label DisableRepeat SlotText SlotCommands = "DisableRepeat" WaitExecution Return Label GotoHome SlotText SlotCommands = "GotoHome" WaitExecution Return Label GotoCenter SlotText SlotCommands = "GotoCenter" WaitExecution Return Label SelectLine3 SlotText SlotCommands = "SelectLine 3" WaitExecution Return Label SelectLine6 SlotText SlotCommands = "SelectLine 6" WaitExecution Return Label ExecuteSelectedLine SlotText SlotCommands = "ExecuteSelectedLine" WaitExecution Return Label ArrowUP SlotText SlotCommands = "ArrowUP" Return Label ArrowDOWN SlotText SlotCommands = "ArrowDOWN" Return ' ----------------------------------------------------- Label EnableCollaborative SlotText SlotCommands = "EnableCollaborative" WaitExecution Return Label DisableCollaborative SlotText SlotCommands = "DisableCollaborative" WaitExecution Return Label AddNewPosition SlotText SlotCommands = "AddNewPosition" WaitExecution Return Label SetHomePosition SlotText SlotCommands = "SetHomePosition" WaitExecution Return Label SetCenterPosition SlotText SlotCommands = "SetCenterPosition" WaitExecution Return ' --------------------------------------------------------- Label SetHoldingTorque9 SlotText SlotCommands = "SetHoldingTorque 9" WaitExecution Return Label SetSafeTorqueLimit9 SlotText SlotCommands = "SetSafeTorqueLimit 9" WaitExecution Return Label SetTorque9 SlotText SlotCommands = "SetTorque 9" WaitExecution Return Label SetAcceleration9 SlotText SlotCommands = "SetAcceleration 9" WaitExecution Return Label SetSpeed9 SlotText SlotCommands = "SetSpeed 9" WaitExecution Return Label SetTorqueCoeff SlotText SlotCommands = SetSpeedToTorqueCoefficient 0.22 WaitExecution Return Label SetAllparamsToMin SlotText SlotCommands = "SetHoldingTorque 0" WaitExecution SlotText SlotCommands = "SetTorqueMin 0" WaitExecution SlotText SlotCommands = "SetTorqueMax 0" WaitExecution SlotText SlotCommands = "SetAcceleration 0" WaitExecution SlotText SlotCommands = "SetSpeed 0" WaitExecution SlotText SlotCommands = "SetSpeedToTorqueCoefficient 0" WaitExecution Return Label SetAllparamsToMax SlotText SlotCommands = "SetHoldingTorque 999" WaitExecution SlotText SlotCommands = "SetTorqueMin 999" WaitExecution SlotText SlotCommands = "SetTorqueMax 999" WaitExecution SlotText SlotCommands = "SetAcceleration 999" WaitExecution SlotText SlotCommands = "SetSpeed 99999" WaitExecution SlotText SlotCommands = "SetSpeedToTorqueCoefficient 1" WaitExecution Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands\OLD EXAMPLES ' File Commands_to_GPS_WithoutParams.txt ' ============================================================================= Button 1 Text Average30 Button 2 Text Average120 Button 4 Text Minimize Button 5 Text Maximize Button 6 Text Normal Button 8 Text Main Button 9 Text Raw Button 10 Text Sat Button 11 Text Pos Button 12 Text Map Button 17 Text MapToLocal Button 18 Text MapTo Button 20 Text Image Button 21 Text ImageTime Button 22 Text ImageName Variable Numeric SlotTextNumber = 1 Stop Label SendCommand Variable String Command SlotText SlotTextNumber = Command Wait SlotText(SlotTextNumber) = "" Return Label Average30 Command = "Average 30" SendCommand Return Label Average120 Command = "Average 120" SendCommand Return Label Minimize Command = "Minimize" SendCommand Return Label Maximize Command = "Maximize" SendCommand Return Label Normal Command = "Normal" SendCommand Return Label Main Command = "Main" SendCommand Return Label Raw Command = "Raw" SendCommand Return Label Sat Command = "Sat" SendCommand Return Label Pos Command = "Pos" SendCommand Return Label Map Command = "Map" SendCommand Return Label MapToLocal Command = "MapToLocal" SendCommand Return Label MapTo Command = "MapTo 45.470690 7.945215 100" SendCommand Return Label Image Command = "Image" SendCommand Return Label ImageTime Command = "ImageTime" SendCommand Return Label ImageName Command = "ImageName" + " TestImage_" + Format(Now, "yyyy_MM_dd_HH_mm_ss") SendCommand Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands\OLD EXAMPLES\Cobot Commands ' File SlotText-SendCommands_EVENT.txt ' ============================================================================= ' ========================================================== ' TO TEST THIS EXAMPLE ' ========================================================== ' - Open Theremino_Cobot V1.1.22 or more recent ' - Load example "Test_A.txt" (or TestB or TestC or TestD) ' - In the app Cobot enable "Repeat" ' - In the app Cobot press "Execute" Variable Numeric Slot_CommandsToCobot = 51 Variable Numeric Slot_ResponsesFromCobot = 52 Variable Numeric Slot_CommandsFromCobot = 53 Loop1 Stop Label Loop1 Loop2 Return Label Loop2 Print SlotText(Slot_ResponsesFromCobot) Wait Seconds 0.1 If Key("CTRL") Return EndIf Goto Loop2 Label Event_CommandsFromCobot ' --------------------------------- Extract first word Select GetSeparatedString(CommandText, 0) ' ----------------------------- Case "Beep" ClearCommand ExecBeep ' ----------------------------- Case "Beep_Multiple" ClearCommand ExecBeepMultiple ' ----------------------------- Case "LoadSequence-Test_A" LoadSequenceA ' ----------------------------- Case "LoadSequence-Test_B" LoadSequenceB ' --------------------- Commands with parameters Case "Pause" Wait Seconds GetSeparatedString(CommandText, 1) Case "Say" TTS Speak Mid(CommandText, 5) Wait TTSready ' ------------------------- Unrecognized command CaseElse Wait Seconds 0.5 Beep 200 500 Print "Unrecognized command: " + CommandText Wait Seconds 0.5 EndSelect ClearCommand Return Label ClearCommand SlotText(Slot_CommandsFromCobot) = "" Return Label ExecBeep Beep 440 300 Wait Seconds 0.5 Beep 440 300 Return Label ExecBeepMultiple For v1 = 1 To 3 Beep 880 400 Wait Seconds 0.5 Next Return Label LoadSequenceA Beep 1660 200 SendCommand(Slot_CommandsToCobot)(LoadSequence Test_A.txt) Return Label LoadSequenceB Beep 2200 200 SendCommand(Slot_CommandsToCobot)(LoadSequence Test_B.txt) Return ' ------------------------------------------ ' SEND COMMAND (default timeout = 0.5 Sec) ' ------------------------------------------ Label SendCommand Variable Numeric SC1 '<-- Parameter Destinat.-Slot Variable String SC2 '<-- Parameter Command-String Variable Numeric SC3 = 0.5 '<-- The timeout in seconds Variable Numeric SC4 SlotText SC1 = SC2 For SC4 = 0.1 To SC3 Step 0.1 If SlotText(SC1) = "" Exit EndIf Wait Seconds 0.1 Next Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands\OLD EXAMPLES\LEO examples ' File MotorCalibration_C6 - Copy.txt ' ============================================================================= '╔═══════════════════════════════════════════════════════════╗ '║ Name: MotorCalibration_C6 Date: 12 Nov 2022 ║ '║ Author: Leonardo ║ '║ Scope: Test all the functionality of the PVC-150 ║ '╠═══════════════════════════════════════════════════════════╣ '║Hardware: 5 FeeTech STS3215 ║ '╟───────────────────────────────────────────────────────────╢ '║ Note: Vacuum motor and valve at 6V ║ '║ FeeTech at 7.5V ║ '╟───────────────────────────────────────────────────────────╢ '║ISO Culture Gender Age Name ║ '╟───────────────────────────────────────────────────────────╢ '║ENG EN-US Male Adult Microsoft David Desktop ║ '║ENG EN-US Female Adult Microsoft Zira Desktop ║ '║ITA IT-IT Female Adult Microsoft Elsa Desktop ║ '║JPN JA-JP Female Adult Microsoft Haruka Desktop ║ '║ZHO ZH-CN Female Adult Microsoft Huihui Desktop ║ '╚═══════════════════════════════════════════════════════════╝ Option Speed 9 Beep "2500 20, 1500 100" 'Load images\PVCArm_150.jpg TTS SelectVoice "ENG" s1 = TTSvoices TTS SetVolume 100 TTS SetSpeed -2 TTS SelectVoice 3 'TTS Speak "Theremino Automation programming language is running." ' ╔════════════════════════════════════════════╗ ' ║ SLOT TEXT for COMMANDS and RESPONSES ║ ' ╚════════════════════════════════════════════╝ Variable Numeric Slot_CommandsToMotors = 50 Variable Numeric Slot_CommandsToCobot = 51 Variable Numeric Slot_ResponsesFromCobot = 52 Variable Numeric Slot_ExternalCommands = 53 Variable Numeric Slot_ResponsesFromQRDecode = 54 Variable Numeric Slot_WordRecognized = 55 ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █▀▀█ ▀▀█▀▀ ' ║ SLOT INITIALIZATIONS ║ ▀▀▀█ █ █ █ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄ █▄▄█ █ 'Variable Numeric Slot_Vacuum = 1 Variable Numeric Slot_LedR = 7 Variable Numeric Slot_LedG = 8 Variable Numeric Slot_LedB = 9 'Variable Numeric Slot_Pedal = 10 Variable Numeric Slot_Pump = 11 Variable Numeric Slot_SignalScope = 13 Variable Numeric Slot_Slider1 = 2 Variable Numeric Slot_Slider2 = 3 Variable Numeric Slot_Slider3 = 4 Variable Numeric Slot_Slider4 = 5 Variable Numeric Slot_Slider5 = 6 Variable Numeric Slot_Encoder1 = 21 Variable Numeric Slot_Encoder2 = 22 Variable Numeric Slot_Encoder3 = 23 Variable Numeric Slot_Encoder4 = 24 Variable Numeric Slot_Encoder5 = 25 Variable Numeric Slot_EncoderSlow = 31 Variable Numeric Slot_M1 = 101 Variable Numeric Slot_M2 = 201 Variable Numeric Slot_M3 = 301 Variable Numeric Slot_M4 = 401 Variable Numeric Slot_M5 = 501 Variable Numeric Slot_M1pos = 102 Variable Numeric Slot_M2pos = 202 Variable Numeric Slot_M3pos = 302 Variable Numeric Slot_M4pos = 402 Variable Numeric Slot_M5pos = 502 Variable Numeric Slot_M1center = 123 Variable Numeric Slot_MotorsFPS = 56 ' ╔════════════════════════════════════════════╗ █▀▀▄ █ █ ▀▀█▀▀ ' ║ BUTTONS ║ █▀▀█ █ █ █ ' ╚════════════════════════════════════════════╝ █▄▄█ █▄▄█ █ Button 1 Label MotorFPS Button MotorFPS Text "NO MOTORS" Button MotorFPS Color Flashing7 Yellow DarkOrange Button 2 Label "MotorTemp" Button 3 Label CurrentMeter Button 4 Label GoToShow Button GoToShow Text "Go to show" Button GoToShow Color Yellow Button 5 Label GoToZero Button GoToZero Text "Go to Zero" Button GoToZero Color Yellow Button 6 Label CopyPositionsToDestinations Button CopyPositionsToDestinations Text "Copy Positions" + CRLF + "To Destinations" Button CopyPositionsToDestinations Color Orange 'Button 6 Label SetCenterHere 'Button SetCenterHere Text "Set Center Here" 'Button SetCenterHere Color Orange ' 'Button 7 Label CalibrateToZero 'Button CalibrateToZero Text "Calibrate to Zero" 'Button CalibrateToZero Color Orange ' ================================================ 'Button 2 Label JobQrCode 'Button JobQrCode Text "JOB QRcode" 'Button JobQrCode Color Cyan ' 'Button 4 Label Sliders 'Button Sliders Text "Sliders" 'Button Sliders Color Cyan ' 'Button 5 Label Encoder 'Button Encoder Text "Encoder" 'Button Encoder Color Cyan 'Button 6 Label Voice 'Button Voice Text "Voice" 'Button Voice Color PaleTurquoise Button 10 Label TunaCans Button TunaCans Text "Tuna cans" Button TunaCans Color Indigo Button 11 Label WanpyJob Button WanpyJob Text "Wanpy Job" Button WanpyJob Color Indigo Button 12 Label StartPump Button StartPump Text "Start Pump" Button StartPump Color Lime Button 13 Label StopPump Button StopPump Text "Stop Pump" Button StopPump Color Crimson Button 15 Label CloseAll Button CloseAll Text "CLOSE ALL" Button CloseAll Color Red Button 17 Label Homing Button Homing Text "HOMING" Button Homing Color Gold Button 18 Label Homing1 Button Homing1 Text "Homing 1" Button Homing1 Color Yellow Button 19 Label Homing2 Button Homing2 Text "Homing 2" Button Homing2 Color Yellow Button 20 Label Homing3 Button Homing3 Text "Homing 3" Button Homing3 Color Yellow Button 21 Label Homing4 Button Homing4 Text "Homing 4" Button Homing4 Color Yellow Button 22 Label Homing5 Button Homing5 Text "Homing 5" Button Homing5 Color Yellow ''Button 23 Label GotoFinalPos 'Button GotoFinalPos Text "Goto final pos" 'Button GotoFinalPos Color Yellow Button 25 Label ShowFiches Button ShowFiches Text "ShowFiches" Button ShowFiches Color SteelBlue Button 26 Label ReleaseFiches Button ReleaseFiches Text "ReleaseFiches" Button ReleaseFiches Color SteelBlue Button 27 Label ShowTuna Button ShowTuna Text "ShowTuna" Button ShowTuna Color SteelBlue Button 28 Label ReleaseTuna Button ReleaseTuna Text "ReleaseTuna" Button ReleaseTuna Color SteelBlue Button 29 Label ShowWanpy Button ShowWanpy Text "ShowWanpy" Button ShowWanpy Color SteelBlue Button 30 Label ReleaseWanpy Button ReleaseWanpy Text "ReleaseWanpy" Button ReleaseWanpy Color SteelBlue Button 31 Label VoiceLoop Button VoiceLoop Text "VoiceLoop" Button VoiceLoop Color Blue Button 32 Label Say Button Say Text "Say" Button Say Color DeepSkyBlue ' ╔════════════════════════════════════════════╗ █ █▀▀█ █▀▀█ █▀▀▄ ' ║ LOAD APPS ║ █ █ █ █▄▄█ █ █ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄█ █ █ █▄▄█ Load Theremino_Motors.exe WaitApplicationsStarted '' ------------------------------------- ' MOTORS must be active before Cobot ' ------------------------------------- Load Theremino_HAL.exe Load Theremino_SlotViewer.exe Load Theremino_SlotViewer_Motors.exe Load Theremino_SlotViewer_STR.exe Load Theremino_MicroVideo.exe 'Load Theremino_QRdecoder.exe 'Load Theremino_VoiceCommands.exe Load Theremino_SlotViewer_Strings.exe Load Theremino_SignalScope_M1.exe Load Theremino_SignalScope_M2.exe Load Theremino_SignalScope_M3.exe 'Load Theremino_SignalScope_M4.exe 'Load Theremino_SignalScope_M5.exe Load Theremino_Cobot.exe 'WaitApplicationsStarted Load Hide ' ╔════════════════════════════════════════════╗ █▀▀▀ ▀▀█▀▀ █▀▀▀█ █▀▀▀█ ▀▀█▀▀ ' ║ EXECUTION START FROM HERE ║ ▀▀▀█ █ █▀▀▀█ █▀█▀▀ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █ █ █ ▀▄ █ ResetEncoders YellowOn CopyPositionsToDestinations 'DisableHomeButtons ' ------------------------- GOTO Homing - Command to Cobot 'WaitCobotReady 'SendCommand(Slot_CommandsToCobot)(GotoHoming) 'Homing 'Controls OpenTextBox 'Controls ClearTextBox Loop Stop ' ╔════════════════════════════════════════════╗ █ █▀▀█ █▀▀█ █▀▀█ ' ║ LOOP ║ █ █ █ █ █ █▄▄█ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄█ █▄▄█ █ Label Loop CurrentMeter ShowMotorFPS PositionDelta TestTemp 'InterpretateVoiceCommands 'Encoder Goto Loop Stop Label PositionDelta Slot(109) = Slot(101) - Slot(102) Slot(209) = Slot(201) - Slot(202) Slot(309) = Slot(301) - Slot(302) Slot(409) = Slot(401) - Slot(402) Slot(509) = Slot(501) - Slot(502) Return Label TestTemp Variable Numeric TT1 Variable Numeric TT2 = 0 'TT2 = 0 For TT1 = 1 To 3 '5 TT2 = Max(TT2, Slot(TT1 * 100 + 6)) Next Button MotorTemp Text "MaxT " + TT2 + "°C" Return ' ╔════════════════════════════════════════════╗ ' ║ ENABLE/DISABLE BUTTONS ║ ' ╚════════════════════════════════════════════╝ Label EnableAllButtons For v1 = 1 To 48 Button v1 Enabled Next Return Label DisableAllButtons For v1 = 1 To 48 Button v1 Disabled Next Return ' ╔════════════════════════════════════════════╗ ' ║ WAIT COBOT READY ║ ' ╚════════════════════════════════════════════╝ Label WaitCobotReady Variable Numeric WCR1 For WCR1 = 1 To Infinity Wait Seconds 0.05 If SlotText(Slot_ResponsesFromCobot) = "Ready" Exit EndIf Next Return ' ╔════════════════════════════════════════════╗ ' ║ WAIT APPS STARTED ║ ' ╚════════════════════════════════════════════╝ Label WaitApplicationsStarted Slot(Slot_MotorsFPS) = 0 Wait Slot(Slot_MotorsFPS) > 10 Wait Seconds 0.1 Return ' ╔════════════════════════════════════════════╗ █▀▀▀ ▀▀█▀▀ █▀▀█ █▀▀█ ' ║ STOP EVENT (when pressing stop button) ║ ▀▀▀█ █ █ █ █▄▄█ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █▄▄█ █ Label EventStop StopPump ' GoToShow ' StopCobotAndGotoHoming End 'Label StopCobotAndGotoHoming ' 'StopCobot ' WaitMotorsNotMoving ' 'GotoSafePosition 'Return Label GotoSafePosition SendCommand(Slot_CommandsToCobot)(GotoHoming) WaitMotorsNotMoving Return ' ╔════════════════════════════════════════════╗ █▀▀ █ █▀▀█ █▀▀▀ █▀▀▀ ' ║ CLOSE ALL (when pressing X on form) ║ █ █ █ █ ▀▀▀█ █▀▀ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█ ▄▄▄█ █▄▄▄ Label CloseAll StopPump ' GoToShow ' StopCobotAndGotoHoming Load CloseAll End ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand '(Destination Slot)(Command String) Variable Numeric SC1 Variable String SC2 Variable Numeric SC3 = 0.5 '<-- The timeout in seconds Variable Numeric SC4 SlotText SC1 = SC2 For SC4 = 0.1 To SC3 Step 0.1 If SlotText(SC1) = "" Exit EndIf Wait Seconds 0.1 Next Return ' ============================================================= ' COMMANDS to Cobot ' ============================================================= Label ExecCobot SendCommand(Slot_CommandsToCobot)(EnableRepeat) SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label StopCobot SendCommand(Slot_CommandsToCobot)(StopExecution) Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █ █▀█ ' ║ S U B R O U T I N E A R E A ║ ▀▀▀█ █ █ █▀▀█ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄█ █▄▄█ Label EnableHomeButtons For v1 = 17 To 22 Button v1 Enabled Next Return Label DisableHomeButtons For v1 = 17 To 22 Button v1 Disabled Next Return Label CurrentMeter Variable Numeric mA mA = Slot(108) + Slot(208) + Slot (308) + Slot (408) + Slot (508) mA = FilterLP(mA, 0.1, 1) '<-- Filter 0.5 seconds / 1 pole Button CurrentMeter Text "Current " + Str(mA, "0 mA") Return Label ShowMotorFPS Variable String MotorsAreEnabled Variable Numeric SMF1 = Slot(Slot_MotorsFPS) If SMF1 > 30 If MotorsAreEnabled <> "TRUE" MotorsAreEnabled = "TRUE" Button MotorFPS Color GreenYellow EndIf Button MotorFPS Text "FPS " + Str(SMF1) Else If MotorsAreEnabled = "TRUE" MotorsAreEnabled = "FALSE" Button MotorFPS Color Flashing7 Yellow DarkOrange Button MotorFPS Text "NO MOTORS" EndIf EndIf Return Label MotorFPS If MotorsAreEnabled = "TRUE" SendCommand(Slot_CommandsToMotors)(DisableConnection) Else SendCommand(Slot_CommandsToMotors)(EnableConnection) EndIf Return Label StartPump RedOn 'Slot(Slot_SignScope) = 1000 Slot(Slot_Pump) = 1000 Button StartPump Disabled Button StopPump Enabled Wait Seconds 0.4 'If Slot(Slot_Vacuum) > 56 ' 'Beep "500, 300, 0, 300" ' 'SayVacuumProblem ' RedOn ' StopPump ' Print "Vacuum Problem" + CRLF ' 'CobotShowPoint ' Print "Execution stopped" + CRLF ' RedBlink ' End 'Else ' Print "Target picked" 'EndIf Return Label StopPump Slot(Slot_Pump) = 0 Button StopPump Disabled Button StartPump Enabled GreenOn Return Label GoToShow MoveMotorTo(4)(90)(0.1) MoveMotorTo(1) (0)(0.1) MoveMotorTo(2)(16)(0.1) MoveMotorTo(3)(36)(0.1) MoveMotorTo(5) (0)(0.1) Return Label GoToZero MoveMotorTo(4)(0)(0.1) MoveMotorTo(1)(0)(0.1) MoveMotorTo(2)(0)(0.1) MoveMotorTo(3)(0)(0.1) MoveMotorTo(5)(0)(0.1) Return ' ╔════════════════════════════════════════════╗ █ █▀▀ █▀▄ ' ║ LED COLORS ║ █ █▀ █ █ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█ Label RedOn Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Return Label MagentaOn Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label YellowOn Slot Slot_LedR = 900 Slot Slot_LedG = 400 Slot Slot_LedB = 0 Return Label GreenOn Slot Slot_LedR = 0 Slot Slot_LedG = 1000 Slot Slot_LedB = 0 Return Label BlueOn Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label WhiteOn Slot Slot_LedR = 1000 Slot Slot_LedG = 1000 Slot Slot_LedB = 1000 Return Label RgbOff Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Return Label RedBlink RedOn WhiteOn Return ' ╔═════════════════════════╗ █▀▀▀ █▀▀█ █▄ ▄█ █▀▀ █▀▀▀ █▀▀█ █▀█ ' ║ COMMANDS FROM COBOT ║ █ █ █ █ ▀ █ █▀ █ █ █ █▀▀█ ' ╚═════════════════════════╝ █▄▄▄ █▄▄█ █ █ ▄ █ ▄ █▄▄▄ █▄▄█ █▄▄█ Label Event_ExternalCommands ' ------------------------------------------------------ Do not print lines containing '' 'Print " Exec: " + CommandText + CRLF ' ------------------------------------------------------ Select CommandText ' ---------------------------------------------- ACTIONS Case "RedOn" RedOn ClearCommand Case "GreenOn" GreenOn ClearCommand Case "BlueOn" BlueOn ClearCommand Case "WhiteOn" WhiteOn ClearCommand Case "MagentaOn" MagentaOn ClearCommand Case "YellowOn" YellowOn ClearCommand Case "Beep" Beep 880-100 ClearCommand Case "Pause" Wait Seconds GetSeparatedString(CommandText, 1) ClearCommand Case "StartPump" StartPump ClearCommand Case "StopPump" StopPump ClearCommand Case "Homing1" Homing1 ClearCommand Case "Homing2" Homing2 ClearCommand Case "Homing3" Homing3 ClearCommand Case "Homing4" Homing4 ClearCommand Case "Homing5" Homing5 ClearCommand Case "MemorizeQrCode" Variable Numeric MQR1 For MQR1 = 1 To 5 QrCode = SlotText(Slot_ResponsesFromQRDecode) Print QrCode If QrCode <> "" Exit EndIf If MQR1 = 5 SendCommand(Slot_CommandsToCobot)(StopExecution) EndIf Wait Seconds 1 Next ClearCommand Case "ExecQrCode" ExecQRcode ClearCommand Case "StartFichesPick" StartFichesPick ClearCommand Case "EndOfTask" EndOfTask ClearCommand CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + CommandText + CRLF Beep ClearCommand Stop ' EndSelect Return Label ClearCommand SlotText(Slot_ExternalCommands) = "" Return ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █▄ █ ' ║ WANPY ║ █ █ █▄▄█ █ ▀█ ' ╚════════════════════════════════════════════╝ ▀▄▀ █ █ █ █ Label WanpyJob TTS Speak "Wanpy job started." Controls OpenTextBox Controls ClearTextBox StartTime = ElapsedTime RedOn Wanpy_A5toB1 Return Variable String Status = "A5toB1" Label EndOfTask PrintTime StartTimePartial = ElapsedTime Select Status Case "A5toB1" 'Wanpy_B1toA5 Wanpy_A4toB2 Case "A4toB2" Wanpy_A3toB3 Case "A3toB3" Wanpy_A2toB4 Case "A2toB4" Wanpy_A1toB5 Case "A1toB5" Wanpy_B5toA1 Case "B5toA1" Wanpy_B4toA2 Case "B4toA2" Wanpy_B3toA3 Case "B3toA3" Wanpy_B2toA4 Case "B2toA4" Wanpy_B1toA5 Case "B1toA5" StartTime = ElapsedTime Print CRLF Wanpy_A5toB1 EndSelect Return Variable Numeric StartTime Variable Numeric StartTimePartial Variable String Time Label PrintTime Time = "Partial time = " Time = Time + PadLeft(Format(ElapsedTime - StartTimePartial, "0.0"),4) Time = Time + " Total time = " Time = Time + PadLeft(Format(ElapsedTime - StartTime, "0.0"),4) Print Status + " " + Time + CRLF Return Label Wanpy_A5toB1 Status = "A5toB1" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A5toB1.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A4toB2 Status = "A4toB2" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A4toB2.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A3toB3 Status = "A3toB3" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A3toB3.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A2toB4 Status = "A2toB4" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A2toB4.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A1toB5 Status = "A1toB5" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A1toB5.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B5toA1 Status = "B5toA1" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B5toA1.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B4toA2 Status = "B4toA2" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B4toA2.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B3toA3 Status = "B3toA3" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B3toA3.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B2toA4 Status = "B2toA4" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B2toA4.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B1toA5 Status = "B1toA5" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B1toA5.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return ' ╔════════════════════════════════════════════╗ █▀▀█ █▀▀█ █▀▀▀ ' ║ QR CODE ║ █ █ █▄▄█ █ ' ╚════════════════════════════════════════════╝ █▄██▄ █ ▀▄ █▄▄▄ Label JobQrCode TTS Speak "QR code recognition and action related is started." StartFichesPick Return Label StartFichesPick BlueOn SendCommand(Slot_CommandsToCobot)("LoadSequence fiches_pick.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label ExecQRcode Variable String QrCode Select QrCode Case "WHITE" WhiteOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_white.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "RED" RedOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_red.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "GREEN" GreenOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_green.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "BLUE" BlueOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_Place_blue.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "BLACK" RgbOff SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_black.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) CaseElse Controls OpenTextBox Print CRLF + " Unrecognized color command: " + CommandText + CRLF StopPump Beep ClearCommand Stop EndSelect Return ' ╔════════════════════════════════════════════╗ ▀▀█▀▀ █ █ █▄ █ ' ║ TUNA ║ █ █ █ █ ▀█ ' ╚════════════════════════════════════════════╝ █ █▄▄█ █ █ Label TunaCans TTS Speak "Tuna can handling." YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Tuna_Cans.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █ █▀▀▄ ' ║ SLIDERS ║ ▀▀▀█ █ █ █ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄ █ █▄▄█ Variable Numeric SLD Label Sliders BlueOn 'Button Sliders Color Flashing7 Blue White For SLD = 1 To Infinity Slot(Slot_M1) = Slot(Slot_Slider1) Slot(Slot_M2) = Slot(Slot_Slider2) Slot(Slot_M3) = Slot(Slot_Slider3) + Slot(Slot_Slider2) Slot(Slot_M4) = Slot(Slot_Slider4) Slot(Slot_M5) = Slot(Slot_Slider5) Next Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █▀▀█ ▀▄ ▄▀ ' ║ SAY ║ ▀▀▀█ █▄▄█ ▀▄▀ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █ █ Label Say TTS SelectVoice "ENGF" TTS Speak "Today is a beautiful day because we spend time together." Wait TTSready TTS SelectVoice "ITA FEM" TTS Speak "Oggi è una bella giornata perche passeremo del tempo insieme." Wait TTSready TTS SelectVoice "JPN" TTS Speak "私たちは一緒に時間を過ごすので、今日は美しい日です。" Wait TTSready TTS SelectVoice "ZHO" TTS Speak "今天是美好的一天,因为我们共度时光。" Wait TTSready Return ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █ █▀▀▀ █▀▀▀ ' ║ VOICE COMMANDS ║ █ █ █ █ █ █ █▀▀ ' ╚════════════════════════════════════════════╝ █ █▄▄█ █ █▄▄▄ █▄▄▄ Label Voice ClearVoiceCommand If VoiceCommandsStatus = "active" VoiceCommandsStatus = "" 'Button Voice Color PaleTurquoise Else VoiceCommandsStatus = "active" 'Button Voice Color Flashing7 Orange White EndIf Return Variable String Word Variable String VoiceCommandsStatus Label InterpretateVoiceCommands If VoiceCommandsStatus = "active" If SlotText(Slot_WordRecognized) <> "" Word = SlotText(Slot_WordRecognized) Print Word + " " Interpretate ClearVoiceCommand EndIf EndIf Return Variable String ShowingType Label Interpretate Select Word Case "show.fiches" If ShowingType = "" WhiteOn ShowingType = "Fiches" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Fiches.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "show.wanpy" If ShowingType = "" YellowOn ShowingType = "Wanpy" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Wanpy.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "show.tuna" If ShowingType = "" GreenOn ShowingType = "Tuna" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Tuna.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf '------------------------------------------------------------------------- Case "release" Select ShowingType Case "fiches" WhiteOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Fiches.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" Case "wanpy" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Wanpy.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" Case "tuna" GreenOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Tuna.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" CaseElse ' EndSelect '------------------------------------------------------------------------- Case "goto.center" If ShowingType = "" RedOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_goto_Center.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "goto.Homing" If ShowingType = "" MagentaOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_goto_Homing.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf '------------------------------------------------------------------------- CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + Word + CRLF Beep ClearCommand Stop EndSelect Return Label ClearVoiceCommand SlotText(Slot_WordRecognized) = "" Return '============================= TRIALS ==================== Label ShowFiches YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Fiches.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label ReleaseFiches YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Fiches.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label ShowTuna YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Tuna.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label ReleaseTuna YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Tuna.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label ShowWanpy YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Wanpy.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label ReleaseWanpy YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Wanpy.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Variable Numeric VOL Label VoiceLoop For VOL = 1 To Infinity ShowFiches Wait Seconds 1 ReleaseFiches Wait Seconds 1 ShowTuna Wait Seconds 1 ReleaseTuna Wait Seconds 1 ShowWanpy Wait Seconds 1 ReleaseWanpy Wait Seconds 1 Next Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █▄ █ █▀▀▀ ' ║ ENCODERS ║ █▀▀ █ ▀█ █ ' ╚════════════════════════════════════════════╝ █▄▄▄ █ █ █▄▄▄ Variable Numeric EncoderSteps1 Variable Numeric OldEncoderSteps1 Variable Numeric Difference1 Variable Numeric EncoderSteps2 Variable Numeric OldEncoderSteps2 Variable Numeric Difference2 Variable Numeric EncoderSteps3 Variable Numeric OldEncoderSteps3 Variable Numeric Difference3 Variable Numeric EncoderSteps4 Variable Numeric OldEncoderSteps4 Variable Numeric Difference4 Variable Numeric EncoderSteps5 Variable Numeric OldEncoderSteps5 Variable Numeric Difference5 Label Encoder '------------------------------------------------ read encoder1 EncoderSteps1 = Slot(Slot_Encoder1) Difference1 = EncoderSteps1 - OldEncoderSteps1 OldEncoderSteps1 = EncoderSteps1 If Difference1 > 32000 Difference1 = Difference1 - 65536 EndIf If Difference1 < -32000 Difference1 = Difference1 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference1 = Difference1 * 0.1 EndIf Slot(Slot_M1) = Limit(Slot (Slot_M1) + Difference1, -70, 0) '------------------------------------------------ read encoder2 EncoderSteps2 = Slot(Slot_Encoder2) Difference2 = EncoderSteps2 - OldEncoderSteps2 OldEncoderSteps2 = EncoderSteps2 If Difference2 > 32000 Difference2 = Difference2 - 65536 EndIf If Difference2 < -32000 Difference2 = Difference2 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference2 = Difference2 * 0.1 EndIf Slot(Slot_M2) = Limit(Slot (Slot_M2) + Difference2, -160, 0) '------------------------------------------------ read encoder3 EncoderSteps3 = Slot(Slot_Encoder3) Difference3 = EncoderSteps3 - OldEncoderSteps3 OldEncoderSteps3 = EncoderSteps3 If Difference3 > 32000 Difference3 = Difference3 - 65536 EndIf If Difference3 < -32000 Difference3 = Difference3 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference3 = Difference3 * 0.1 EndIf Slot(Slot_M3) = Limit(Slot (Slot_M3) + Difference3, -100, 100) '------------------------------------------------ read encoder4 EncoderSteps4 = Slot(Slot_Encoder4) Difference4 = EncoderSteps4 - OldEncoderSteps4 OldEncoderSteps4 = EncoderSteps4 If Difference4 > 32000 Difference4 = Difference4 - 65536 EndIf If Difference4 < -32000 Difference4 = Difference4 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference4 = Difference4 * 0.1 EndIf Slot(Slot_M4) = Limit(Slot (Slot_M4) + Difference4, -180, 0) '------------------------------------------------ read encoder5 EncoderSteps5 = Slot(Slot_Encoder5) Difference5 = EncoderSteps5 - OldEncoderSteps5 OldEncoderSteps5 = EncoderSteps5 If Difference5 > 32000 Difference5 = Difference5 - 65536 EndIf If Difference5 < -32000 Difference5 = Difference5 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference5 = Difference5 * 0.1 EndIf Slot(Slot_M5) = Limit(Slot (Slot_M5) + Difference5, -240, 0) Return Label ResetEncoders OldEncoderSteps1 = Slot(Slot_Encoder1) OldEncoderSteps2 = Slot(Slot_Encoder2) OldEncoderSteps3 = Slot(Slot_Encoder3) OldEncoderSteps4 = Slot(Slot_Encoder4) OldEncoderSteps5 = Slot(Slot_Encoder5) Return ' ╔════════════════════════════════════════════╗ █▀▀█ █▀▀█ █ ' ║ CALIBRATIONS ║ █ █▄▄█ █ ' ╚════════════════════════════════════════════╝ █▄▄█ █ █ █▄▄▄ Label ResetAllMultiturnValues SendCommand(Slot_CommandsToMotors)("ResetAllMultiturnValues") Return Label CopyPositionsToDestinations Slot Slot_M1 = Slot(Slot_M1pos) Slot Slot_M2 = Slot(Slot_M2pos) Slot Slot_M3 = Slot(Slot_M3pos) Slot Slot_M4 = Slot(Slot_M4pos) Slot Slot_M5 = Slot(Slot_M5pos) Return Label CalibrateMotorToZero '(Motor Number) Variable Numeric CMTZ1 SendCommand(Slot_CommandsToMotors)("Calibrate Motor " + CMTZ1 + " To 0") CMTZ1 = (CMTZ1*100-100) Slot(Slot_M1 + CMTZ1) = Slot(Slot_M1pos + CMTZ1) Return Label SetMotorCenterHere '(Motor Number) Variable Numeric SMC1 SMC1 = Slot_M1center + (SMC1*100-100) Slot SMC1 = 128 Wait Seconds 0.1 Slot SMC1 = 1 Wait Seconds 0.1 Return Label SetMotor_OFF_ON '(Motor Number) Variable Numeric SMO1 SMO1 = Slot_M1center + (SMO1*100-100) Slot SMO1 = 0 Wait Seconds 0.1 Slot SMO1 = 1 Wait Seconds 0.1 Return Label WaitMotorsNotMoving Variable Numeric WMN1 For WMN1 = 1 To 5 WaitMotor(WMN1)(0.1) Next Return ' ------------------------------------------------------- ' The "Wait seconds" parameter is a initial delay ' If this delay is short and the motor starts slowly ' then the "WaitMotor" functions could exit immediately ' ------------------------------------------------------- Label WaitMotor '(Motor Number)(Wait seconds) Variable Numeric WM1 Variable Numeric WM2 WM1 = (WM1*100-100) Wait Seconds WM2 Variable Numeric WM3 For WM3 = 0 To Infinity 'If Slot(Slot_M1 + 2 + WM1) = 0 Or Key("CTRL") ' test Velocity ' Exit For 'EndIf If Slot(Slot_M1 + 6 + WM1) = 0 Or Key("CTRL") ' test Moving Exit For EndIf Next Return Label MoveMotorTo '(Motor Number)(Destination)(Wait seconds) Variable Numeric MMT1 Variable Numeric MMT2 Variable Numeric MMT3 Slot(Slot_M1 + MMT1*100-100) = MMT2 WaitMotor(MMT1)(MMT3) Return ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █▄ ▄█ █▀▀▀ ' ║ H O M I N G ║ █▀▀█ █ █ █ ▀ █ █▀▀ ' ╚════════════════════════════════════════════╝ █ █ █▄▄█ █ █ █▄▄▄ Label Homing BlueOn Homing4 Homing5 Homing2 Homing3 Homing1 Return Label GotoFinalPositions Slot(Slot_M1) = 0 Slot(Slot_M2) = 0 Slot(Slot_M3) = 0 Slot(Slot_M4) = 90 Slot(Slot_M5) = 0 Return Label Homing1 HomingMotor(1)(+0.3)(300)( -75)( 0)(400)(100)(1000) Return Label Homing2 HomingMotor(2)(+0.2)(300)( -42)( 0)(450)(100)(1000) Return Label Homing3 HomingMotor(3)(-0.2)(350)( +60)( 0)(400)(100)(1000) Return Label Homing4 HomingMotor(4)(+0.4)(300)(-115)(90)(350)(100)(1000) Return Label Homing5 HomingMotor(5)(+0.8)(300)(-127)( 0)(400)(100)(1000) Return Label HomingMotor ' ----------------------------------- Parameters Variable Numeric HM_MotNum Variable Numeric HM_SearchSpeed Variable Numeric HM_SearchTorque Variable Numeric HM_MoveToCenter Variable Numeric HM_MoveToFinal Variable Numeric HM_MotorTorque Variable Numeric HM_MotorAcc Variable Numeric HM_MotorSpeed ' ----------------------------------- Local Variables Variable Numeric HM_MotSlot HM_MotSlot = Slot_M1 + HM_MotNum * 100 - 100 Variable Numeric HM1 ' ----------------------------------- DisableAllButtons FlashHomingButton(HM_MotNum) Slot(Slot_SignalScope) = 1000 SendCommand(Slot_CommandsToCobot)(StopExecution) SendCommand(Slot_CommandsToCobot)("SetTorque " + HM_MotorTorque) SendCommand(Slot_CommandsToCobot)("SetAcceleration " + HM_MotorAcc) SendCommand(Slot_CommandsToCobot)("SetSpeed " + HM_MotorSpeed) ResetAllMultiturnValues CalibrateMotorToZero(HM_MotNum) ' Calibrate To Zero For HM1 = 1 To Infinity Slot(HM_MotSlot) = Slot(HM_MotSlot) + HM_SearchSpeed If Abs(Slot(HM_MotSlot + 7)) > HM_SearchTorque ' +7=current Beep 2200 50 Exit EndIf If Abs(Slot(HM_MotSlot) - Slot(HM_MotSlot + 1)) > 30 Beep 800 100 SetMotorCenterHere(1) ' Set Center here CopyPositionsToDestinations EndIf Wait Seconds 0.01 Next ' ----------------------------------- Beep 2500 50 'Wait Seconds 0.1 ' Stabilization time 'CalibrateMotorToZero(HM_MotNum) ' Calibrate To Zero 'Wait Seconds 0.1 'SetMotor_OFF_ON(HM_MotNum) ' SpeedUp next movement 'Wait Seconds 0.1 CalibrateMotorToZero(HM_MotNum) ' Calibrate To Zero MoveMotorTo(HM_MotNum)(HM_MoveToCenter)(1.5)' Move to Center CalibrateMotorToZero(HM_MotNum) ' Calibrate to Zero SetMotorCenterHere(HM_MotNum) ' Set Center here CalibrateMotorToZero(HM_MotNum) ' Calibrate to Zero MoveMotorTo(HM_MotNum)(HM_MoveToFinal)(0.1) ' Move to Final position Beep 2800 200 ' ----------------------------------- EnableAllButtons Slot(Slot_SignalScope) = 0 UnFlashHomingButtons 'SendCommand(Slot_CommandsToCobot)(SelectLine 10) ' <<<<<<>>>>>> 'SendCommand(Slot_CommandsToCobot)(StartExecution) ' <<<<<<>>>>>> Return Label FlashHomingButton Variable Numeric FHB1 ' First Param = Motor Number Select FHB1 Case 1 Button Homing1 Color Flashing6 Blue White Case 2 Button Homing2 Color Flashing6 Blue White Case 3 Button Homing3 Color Flashing6 Blue White Case 4 Button Homing4 Color Flashing6 Blue White Case 5 Button Homing5 Color Flashing6 Blue White 'Case 6 ' Button Homing6 Color Flashing6 Blue White 'Case 7 ' Button Homing7 Color Flashing6 Blue White EndSelect Return Label UnFlashHomingButtons Button Homing1 Color Yellow Button Homing2 Color Yellow Button Homing3 Color Yellow Button Homing4 Color Yellow Button Homing5 Color Yellow 'Button Homing6 Color Yellow 'Button Homing7 Color Yellow Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands\OLD EXAMPLES\LEO examples ' File MotorCalibration_C6.txt ' ============================================================================= '╔═══════════════════════════════════════════════════════════╗ '║ Name: MotorCalibration_C6 Date: 12 Nov 2022 ║ '║ Author: Leonardo ║ '║ Scope: Test all the functionality of the PVC-150 ║ '╠═══════════════════════════════════════════════════════════╣ '║Hardware: 5 FeeTech STS3215 ║ '╟───────────────────────────────────────────────────────────╢ '║ Note: Vacuum motor and valve at 6V ║ '║ FeeTech at 7.5V ║ '╟───────────────────────────────────────────────────────────╢ '║ISO Culture Gender Age Name ║ '╟───────────────────────────────────────────────────────────╢ '║ENG EN-US Male Adult Microsoft David Desktop ║ '║ENG EN-US Female Adult Microsoft Zira Desktop ║ '║ITA IT-IT Female Adult Microsoft Elsa Desktop ║ '║JPN JA-JP Female Adult Microsoft Haruka Desktop ║ '║ZHO ZH-CN Female Adult Microsoft Huihui Desktop ║ '╚═══════════════════════════════════════════════════════════╝ Option Speed 9 Beep "2500 20, 1500 100" 'Load images\PVCArm_150.jpg TTS SelectVoice "ENG" s1 = TTSvoices TTS SetVolume 100 TTS SetSpeed -2 TTS SelectVoice 3 'TTS Speak "Theremino Automation programming language is running." ' ╔════════════════════════════════════════════╗ ' ║ SLOT TEXT for COMMANDS and RESPONSES ║ ' ╚════════════════════════════════════════════╝ Variable Numeric Slot_CommandsToMotors = 50 Variable Numeric Slot_CommandsToCobot = 51 Variable Numeric Slot_ResponsesFromCobot = 52 Variable Numeric Slot_ExternalCommands = 53 Variable Numeric Slot_ResponsesFromQRDecode = 54 Variable Numeric Slot_WordRecognized = 55 ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █▀▀█ ▀▀█▀▀ ' ║ SLOT INITIALIZATIONS ║ ▀▀▀█ █ █ █ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄ █▄▄█ █ 'Variable Numeric Slot_Vacuum = 1 Variable Numeric Slot_LedR = 7 Variable Numeric Slot_LedG = 8 Variable Numeric Slot_LedB = 9 'Variable Numeric Slot_Pedal = 10 Variable Numeric Slot_Pump = 11 Variable Numeric Slot_SignalScope = 13 Variable Numeric Slot_Slider1 = 2 Variable Numeric Slot_Slider2 = 3 Variable Numeric Slot_Slider3 = 4 Variable Numeric Slot_Slider4 = 5 Variable Numeric Slot_Slider5 = 6 Variable Numeric Slot_Encoder1 = 21 Variable Numeric Slot_Encoder2 = 22 Variable Numeric Slot_Encoder3 = 23 Variable Numeric Slot_Encoder4 = 24 Variable Numeric Slot_Encoder5 = 25 Variable Numeric Slot_EncoderSlow = 31 Variable Numeric Slot_M1 = 101 Variable Numeric Slot_M2 = 201 Variable Numeric Slot_M3 = 301 Variable Numeric Slot_M4 = 401 Variable Numeric Slot_M5 = 501 Variable Numeric Slot_M1pos = 102 Variable Numeric Slot_M2pos = 202 Variable Numeric Slot_M3pos = 302 Variable Numeric Slot_M4pos = 402 Variable Numeric Slot_M5pos = 502 Variable Numeric Slot_M1center = 123 Variable Numeric Slot_MotorsFPS = 56 ' ╔════════════════════════════════════════════╗ █▀▀▄ █ █ ▀▀█▀▀ ' ║ BUTTONS ║ █▀▀█ █ █ █ ' ╚════════════════════════════════════════════╝ █▄▄█ █▄▄█ █ Button 1 Label MotorFPS Button MotorFPS Text "NO MOTORS" Button MotorFPS Color Flashing7 Yellow DarkOrange Button 2 Label "MotorTemp" Button 3 Label CurrentMeter Button 4 Label GoToShow Button GoToShow Text "Go to show" Button GoToShow Color Yellow Button 5 Label GoToZero Button GoToZero Text "Go to Zero" Button GoToZero Color Yellow Button 6 Label CopyPositionsToDestinations Button CopyPositionsToDestinations Text "Copy Positions" + CRLF + "To Destinations" Button CopyPositionsToDestinations Color Orange 'Button 6 Label SetCenterHere 'Button SetCenterHere Text "Set Center Here" 'Button SetCenterHere Color Orange ' 'Button 7 Label CalibrateToZero 'Button CalibrateToZero Text "Calibrate to Zero" 'Button CalibrateToZero Color Orange ' ================================================ 'Button 2 Label JobQrCode 'Button JobQrCode Text "JOB QRcode" 'Button JobQrCode Color Cyan ' 'Button 4 Label Sliders 'Button Sliders Text "Sliders" 'Button Sliders Color Cyan ' 'Button 5 Label Encoder 'Button Encoder Text "Encoder" 'Button Encoder Color Cyan 'Button 6 Label Voice 'Button Voice Text "Voice" 'Button Voice Color PaleTurquoise Button 10 Label TunaCans Button TunaCans Text "Tuna cans" Button TunaCans Color Indigo Button 11 Label WanpyJob Button WanpyJob Text "Wanpy Job" Button WanpyJob Color Indigo Button 12 Label StartPump Button StartPump Text "Start Pump" Button StartPump Color Lime Button 13 Label StopPump Button StopPump Text "Stop Pump" Button StopPump Color Crimson Button 15 Label CloseAll Button CloseAll Text "CLOSE ALL" Button CloseAll Color Red Button 17 Label Homing Button Homing Text "HOMING" Button Homing Color Gold Button 18 Label Homing1 Button Homing1 Text "Homing 1" Button Homing1 Color Yellow Button 19 Label Homing2 Button Homing2 Text "Homing 2" Button Homing2 Color Yellow Button 20 Label Homing3 Button Homing3 Text "Homing 3" Button Homing3 Color Yellow Button 21 Label Homing4 Button Homing4 Text "Homing 4" Button Homing4 Color Yellow Button 22 Label Homing5 Button Homing5 Text "Homing 5" Button Homing5 Color Yellow ''Button 23 Label GotoFinalPos 'Button GotoFinalPos Text "Goto final pos" 'Button GotoFinalPos Color Yellow Button 25 Label ShowFiches Button ShowFiches Text "ShowFiches" Button ShowFiches Color SteelBlue Button 26 Label ReleaseFiches Button ReleaseFiches Text "ReleaseFiches" Button ReleaseFiches Color SteelBlue Button 27 Label ShowTuna Button ShowTuna Text "ShowTuna" Button ShowTuna Color SteelBlue Button 28 Label ReleaseTuna Button ReleaseTuna Text "ReleaseTuna" Button ReleaseTuna Color SteelBlue Button 29 Label ShowWanpy Button ShowWanpy Text "ShowWanpy" Button ShowWanpy Color SteelBlue Button 30 Label ReleaseWanpy Button ReleaseWanpy Text "ReleaseWanpy" Button ReleaseWanpy Color SteelBlue Button 31 Label VoiceLoop Button VoiceLoop Text "VoiceLoop" Button VoiceLoop Color Blue Button 32 Label Say Button Say Text "Say" Button Say Color DeepSkyBlue ' ╔════════════════════════════════════════════╗ █ █▀▀█ █▀▀█ █▀▀▄ ' ║ LOAD APPS ║ █ █ █ █▄▄█ █ █ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄█ █ █ █▄▄█ Load Theremino_Motors.exe WaitApplicationsStarted '' ------------------------------------- ' MOTORS must be active before Cobot ' ------------------------------------- Load Theremino_HAL.exe Load Theremino_SlotViewer.exe Load Theremino_SlotViewer_Motors.exe Load Theremino_SlotViewer_STR.exe Load Theremino_MicroVideo.exe 'Load Theremino_QRdecoder.exe 'Load Theremino_VoiceCommands.exe Load Theremino_SlotViewer_Strings.exe 'Load Theremino_SignalScope_FPS.exe Load Theremino_SignalScope_M1.exe Load Theremino_SignalScope_M2.exe 'Load Theremino_SignalScope_M3.exe 'Load Theremino_SignalScope_M4.exe 'Load Theremino_SignalScope_M5.exe Load Theremino_Cobot.exe 'WaitApplicationsStarted Load Hide ' ╔════════════════════════════════════════════╗ █▀▀▀ ▀▀█▀▀ █▀▀▀█ █▀▀▀█ ▀▀█▀▀ ' ║ EXECUTION START FROM HERE ║ ▀▀▀█ █ █▀▀▀█ █▀█▀▀ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █ █ █ ▀▄ █ ResetEncoders YellowOn CopyPositionsToDestinations 'DisableHomeButtons ' ------------------------- GOTO Homing - Command to Cobot 'WaitCobotReady 'SendCommand(Slot_CommandsToCobot)(GotoHoming) 'Homing 'Controls OpenTextBox 'Controls ClearTextBox Loop Stop ' ╔════════════════════════════════════════════╗ █ █▀▀█ █▀▀█ █▀▀█ ' ║ LOOP ║ █ █ █ █ █ █▄▄█ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄█ █▄▄█ █ Label Loop CurrentMeter ShowMotorFPS PositionDelta TestTemp 'InterpretateVoiceCommands 'Encoder Goto Loop Stop Label PositionDelta Slot(109) = Slot(101) - Slot(102) Slot(209) = Slot(201) - Slot(202) Slot(309) = Slot(301) - Slot(302) Slot(409) = Slot(401) - Slot(402) Slot(509) = Slot(501) - Slot(502) Return Label TestTemp Variable Numeric TT1 Variable Numeric TT2 = 0 'TT2 = 0 For TT1 = 1 To 3 '5 TT2 = Max(TT2, Slot(TT1 * 100 + 6)) Next Button MotorTemp Text "MaxT " + TT2 + "°C" Return ' ╔════════════════════════════════════════════╗ ' ║ ENABLE/DISABLE BUTTONS ║ ' ╚════════════════════════════════════════════╝ Label EnableAllButtons For v1 = 1 To 48 Button v1 Enabled Next Return Label DisableAllButtons For v1 = 1 To 48 Button v1 Disabled Next Return ' ╔════════════════════════════════════════════╗ ' ║ WAIT COBOT READY ║ ' ╚════════════════════════════════════════════╝ Label WaitCobotReady Variable Numeric WCR1 For WCR1 = 1 To Infinity Wait Seconds 0.05 If SlotText(Slot_ResponsesFromCobot) = "Ready" Exit EndIf Next Return ' ╔════════════════════════════════════════════╗ ' ║ WAIT APPS STARTED ║ ' ╚════════════════════════════════════════════╝ Label WaitApplicationsStarted Slot(Slot_MotorsFPS) = 0 Wait Slot(Slot_MotorsFPS) > 10 Wait Seconds 0.1 Return ' ╔════════════════════════════════════════════╗ █▀▀▀ ▀▀█▀▀ █▀▀█ █▀▀█ ' ║ STOP EVENT (when pressing stop button) ║ ▀▀▀█ █ █ █ █▄▄█ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █▄▄█ █ Label EventStop StopPump ' GoToShow ' StopCobotAndGotoHoming End 'Label StopCobotAndGotoHoming ' 'StopCobot ' WaitMotorsNotMoving ' 'GotoSafePosition 'Return Label GotoSafePosition SendCommand(Slot_CommandsToCobot)(GotoHoming) WaitMotorsNotMoving Return ' ╔════════════════════════════════════════════╗ █▀▀ █ █▀▀█ █▀▀▀ █▀▀▀ ' ║ CLOSE ALL (when pressing X on form) ║ █ █ █ █ ▀▀▀█ █▀▀ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█ ▄▄▄█ █▄▄▄ Label CloseAll StopPump ' GoToShow ' StopCobotAndGotoHoming Load CloseAll End ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand '(Destination Slot)(Command String) Variable Numeric SC1 Variable String SC2 Variable Numeric SC3 = 0.5 '<-- The timeout in seconds Variable Numeric SC4 SlotText SC1 = SC2 For SC4 = 0.1 To SC3 Step 0.1 If SlotText(SC1) = "" Exit EndIf Wait Seconds 0.1 Next Return ' ============================================================= ' COMMANDS to Cobot ' ============================================================= Label ExecCobot SendCommand(Slot_CommandsToCobot)(EnableRepeat) SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label StopCobot SendCommand(Slot_CommandsToCobot)(StopExecution) Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █ █▀█ ' ║ S U B R O U T I N E A R E A ║ ▀▀▀█ █ █ █▀▀█ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄█ █▄▄█ Label EnableHomeButtons For v1 = 17 To 22 Button v1 Enabled Next Return Label DisableHomeButtons For v1 = 17 To 22 Button v1 Disabled Next Return Label CurrentMeter Variable Numeric mA mA = Slot(108) + Slot(208) + Slot (308) + Slot (408) + Slot (508) mA = FilterLP(mA, 0.1, 1) '<-- Filter 0.5 seconds / 1 pole Button CurrentMeter Text "Current " + Str(mA, "0 mA") Return Label ShowMotorFPS Variable String MotorsAreEnabled Variable Numeric SMF1 = Slot(Slot_MotorsFPS) If SMF1 > 30 If MotorsAreEnabled <> "TRUE" MotorsAreEnabled = "TRUE" Button MotorFPS Color GreenYellow EndIf Button MotorFPS Text "FPS " + Str(SMF1) Else If MotorsAreEnabled = "TRUE" MotorsAreEnabled = "FALSE" Button MotorFPS Color Flashing7 Yellow DarkOrange Button MotorFPS Text "NO MOTORS" EndIf EndIf Return Label MotorFPS If MotorsAreEnabled = "TRUE" SendCommand(Slot_CommandsToMotors)(DisableConnection) Else SendCommand(Slot_CommandsToMotors)(EnableConnection) EndIf Return Label StartPump RedOn 'Slot(Slot_SignScope) = 1000 Slot(Slot_Pump) = 1000 Button StartPump Disabled Button StopPump Enabled Wait Seconds 0.4 'If Slot(Slot_Vacuum) > 56 ' 'Beep "500, 300, 0, 300" ' 'SayVacuumProblem ' RedOn ' StopPump ' Print "Vacuum Problem" + CRLF ' 'CobotShowPoint ' Print "Execution stopped" + CRLF ' RedBlink ' End 'Else ' Print "Target picked" 'EndIf Return Label StopPump Slot(Slot_Pump) = 0 Button StopPump Disabled Button StartPump Enabled GreenOn Return Label GoToShow MoveMotorTo(4)(90)(0.1) MoveMotorTo(1) (0)(0.1) MoveMotorTo(2)(16)(0.1) MoveMotorTo(3)(36)(0.1) MoveMotorTo(5) (0)(0.1) Return Label GoToZero MoveMotorTo(4)(0)(0.1) MoveMotorTo(1)(0)(0.1) MoveMotorTo(2)(0)(0.1) MoveMotorTo(3)(0)(0.1) MoveMotorTo(5)(0)(0.1) Return ' ╔════════════════════════════════════════════╗ █ █▀▀ █▀▄ ' ║ LED COLORS ║ █ █▀ █ █ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█ Label RedOn Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Return Label MagentaOn Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label YellowOn Slot Slot_LedR = 900 Slot Slot_LedG = 400 Slot Slot_LedB = 0 Return Label GreenOn Slot Slot_LedR = 0 Slot Slot_LedG = 1000 Slot Slot_LedB = 0 Return Label BlueOn Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label WhiteOn Slot Slot_LedR = 1000 Slot Slot_LedG = 1000 Slot Slot_LedB = 1000 Return Label RgbOff Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Return Label RedBlink RedOn WhiteOn Return ' ╔═════════════════════════╗ █▀▀▀ █▀▀█ █▄ ▄█ █▀▀ █▀▀▀ █▀▀█ █▀█ ' ║ COMMANDS FROM COBOT ║ █ █ █ █ ▀ █ █▀ █ █ █ █▀▀█ ' ╚═════════════════════════╝ █▄▄▄ █▄▄█ █ █ ▄ █ ▄ █▄▄▄ █▄▄█ █▄▄█ Label Event_ExternalCommands ' ------------------------------------------------------ Do not print lines containing '' Print " Exec: " + CommandText + CRLF ' ------------------------------------------------------ Select CommandText ' ---------------------------------------------- ACTIONS Case "RedOn" RedOn ClearCommand Case "GreenOn" GreenOn ClearCommand Case "BlueOn" BlueOn ClearCommand Case "WhiteOn" WhiteOn ClearCommand Case "MagentaOn" MagentaOn ClearCommand Case "YellowOn" YellowOn ClearCommand Case "Beep" Beep 880-100 ClearCommand Case "Pause" Wait Seconds GetSeparatedString(CommandText, 1) ClearCommand Case "StartPump" StartPump ClearCommand Case "StopPump" StopPump ClearCommand Case "Homing1" Homing1 ClearCommand Case "Homing2" Homing2 ClearCommand Case "Homing3" Homing3 ClearCommand Case "Homing4" Homing4 ClearCommand Case "Homing5" Homing5 ClearCommand Case "MemorizeQrCode" Variable Numeric MQR1 For MQR1 = 1 To 5 QrCode = SlotText(Slot_ResponsesFromQRDecode) Print QrCode If QrCode <> "" Exit EndIf If MQR1 = 5 SendCommand(Slot_CommandsToCobot)(StopExecution) EndIf Wait Seconds 1 Next ClearCommand Case "ExecQrCode" ExecQRcode ClearCommand Case "StartFichesPick" StartFichesPick ClearCommand Case "EndOfTask" EndOfTask ClearCommand CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + CommandText + CRLF Beep ClearCommand Stop ' EndSelect Return Label ClearCommand SlotText(Slot_ExternalCommands) = "" Return ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █▄ █ ' ║ WANPY ║ █ █ █▄▄█ █ ▀█ ' ╚════════════════════════════════════════════╝ ▀▄▀ █ █ █ █ Label WanpyJob TTS Speak "Wanpy job started." Controls OpenTextBox Controls ClearTextBox StartTime = ElapsedTime RedOn Wanpy_A5toB1 Return Variable String Status = "A5toB1" Label EndOfTask PrintTime StartTimePartial = ElapsedTime Select Status Case "A5toB1" 'Wanpy_B1toA5 Wanpy_A4toB2 Case "A4toB2" Wanpy_A3toB3 Case "A3toB3" Wanpy_A2toB4 Case "A2toB4" Wanpy_A1toB5 Case "A1toB5" Wanpy_B5toA1 Case "B5toA1" Wanpy_B4toA2 Case "B4toA2" Wanpy_B3toA3 Case "B3toA3" Wanpy_B2toA4 Case "B2toA4" Wanpy_B1toA5 Case "B1toA5" StartTime = ElapsedTime Print CRLF Wanpy_A5toB1 EndSelect Return Variable Numeric StartTime Variable Numeric StartTimePartial Variable String Time Label PrintTime Time = "Partial time = " Time = Time + PadLeft(Format(ElapsedTime - StartTimePartial, "0.0"),4) Time = Time + " Total time = " Time = Time + PadLeft(Format(ElapsedTime - StartTime, "0.0"),4) Print Status + " " + Time + CRLF Return Label Wanpy_A5toB1 Status = "A5toB1" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A5toB1.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A4toB2 Status = "A4toB2" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A4toB2.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A3toB3 Status = "A3toB3" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A3toB3.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A2toB4 Status = "A2toB4" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A2toB4.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A1toB5 Status = "A1toB5" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A1toB5.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B5toA1 Status = "B5toA1" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B5toA1.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B4toA2 Status = "B4toA2" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B4toA2.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B3toA3 Status = "B3toA3" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B3toA3.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B2toA4 Status = "B2toA4" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B2toA4.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B1toA5 Status = "B1toA5" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B1toA5.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return ' ╔════════════════════════════════════════════╗ █▀▀█ █▀▀█ █▀▀▀ ' ║ QR CODE ║ █ █ █▄▄█ █ ' ╚════════════════════════════════════════════╝ █▄██▄ █ ▀▄ █▄▄▄ Label JobQrCode TTS Speak "QR code recognition and action related is started." StartFichesPick Return Label StartFichesPick BlueOn SendCommand(Slot_CommandsToCobot)("LoadSequence fiches_pick.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label ExecQRcode Variable String QrCode Select QrCode Case "WHITE" WhiteOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_white.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "RED" RedOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_red.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "GREEN" GreenOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_green.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "BLUE" BlueOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_Place_blue.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "BLACK" RgbOff SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_black.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) CaseElse Controls OpenTextBox Print CRLF + " Unrecognized color command: " + CommandText + CRLF StopPump Beep ClearCommand Stop EndSelect Return ' ╔════════════════════════════════════════════╗ ▀▀█▀▀ █ █ █▄ █ ' ║ TUNA ║ █ █ █ █ ▀█ ' ╚════════════════════════════════════════════╝ █ █▄▄█ █ █ Label TunaCans TTS Speak "Tuna can handling." YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Tuna_Cans.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █ █▀▀▄ ' ║ SLIDERS ║ ▀▀▀█ █ █ █ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄ █ █▄▄█ Variable Numeric SLD Label Sliders BlueOn 'Button Sliders Color Flashing7 Blue White For SLD = 1 To Infinity Slot(Slot_M1) = Slot(Slot_Slider1) Slot(Slot_M2) = Slot(Slot_Slider2) Slot(Slot_M3) = Slot(Slot_Slider3) + Slot(Slot_Slider2) Slot(Slot_M4) = Slot(Slot_Slider4) Slot(Slot_M5) = Slot(Slot_Slider5) Next Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █▀▀█ ▀▄ ▄▀ ' ║ SAY ║ ▀▀▀█ █▄▄█ ▀▄▀ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █ █ Label Say TTS SelectVoice "ENGF" TTS Speak "Today is a beautiful day because we spend time together." Wait TTSready TTS SelectVoice "ITA FEM" TTS Speak "Oggi è una bella giornata perche passeremo del tempo insieme." Wait TTSready TTS SelectVoice "JPN" TTS Speak "私たちは一緒に時間を過ごすので、今日は美しい日です。" Wait TTSready TTS SelectVoice "ZHO" TTS Speak "今天是美好的一天,因为我们共度时光。" Wait TTSready Return ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █ █▀▀▀ █▀▀▀ ' ║ VOICE COMMANDS ║ █ █ █ █ █ █ █▀▀ ' ╚════════════════════════════════════════════╝ █ █▄▄█ █ █▄▄▄ █▄▄▄ Label Voice ClearVoiceCommand If VoiceCommandsStatus = "active" VoiceCommandsStatus = "" 'Button Voice Color PaleTurquoise Else VoiceCommandsStatus = "active" 'Button Voice Color Flashing7 Orange White EndIf Return Variable String Word Variable String VoiceCommandsStatus Label InterpretateVoiceCommands If VoiceCommandsStatus = "active" If SlotText(Slot_WordRecognized) <> "" Word = SlotText(Slot_WordRecognized) Print Word + " " Interpretate ClearVoiceCommand EndIf EndIf Return Variable String ShowingType Label Interpretate Select Word Case "show.fiches" If ShowingType = "" WhiteOn ShowingType = "Fiches" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Fiches.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "show.wanpy" If ShowingType = "" YellowOn ShowingType = "Wanpy" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Wanpy.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "show.tuna" If ShowingType = "" GreenOn ShowingType = "Tuna" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Tuna.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf '------------------------------------------------------------------------- Case "release" Select ShowingType Case "fiches" WhiteOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Fiches.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" Case "wanpy" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Wanpy.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" Case "tuna" GreenOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Tuna.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" CaseElse ' EndSelect '------------------------------------------------------------------------- Case "goto.center" If ShowingType = "" RedOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_goto_Center.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "goto.Homing" If ShowingType = "" MagentaOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_goto_Homing.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf '------------------------------------------------------------------------- CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + Word + CRLF Beep ClearCommand Stop EndSelect Return Label ClearVoiceCommand SlotText(Slot_WordRecognized) = "" Return '============================= TRIALS ==================== Label ShowFiches YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Fiches.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label ReleaseFiches YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Fiches.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label ShowTuna YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Tuna.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label ReleaseTuna YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Tuna.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label ShowWanpy YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Wanpy.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label ReleaseWanpy YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Wanpy.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Variable Numeric VOL Label VoiceLoop For VOL = 1 To Infinity ShowFiches Wait Seconds 1 ReleaseFiches Wait Seconds 1 ShowTuna Wait Seconds 1 ReleaseTuna Wait Seconds 1 ShowWanpy Wait Seconds 1 ReleaseWanpy Wait Seconds 1 Next Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █▄ █ █▀▀▀ ' ║ ENCODERS ║ █▀▀ █ ▀█ █ ' ╚════════════════════════════════════════════╝ █▄▄▄ █ █ █▄▄▄ Variable Numeric EncoderSteps1 Variable Numeric OldEncoderSteps1 Variable Numeric Difference1 Variable Numeric EncoderSteps2 Variable Numeric OldEncoderSteps2 Variable Numeric Difference2 Variable Numeric EncoderSteps3 Variable Numeric OldEncoderSteps3 Variable Numeric Difference3 Variable Numeric EncoderSteps4 Variable Numeric OldEncoderSteps4 Variable Numeric Difference4 Variable Numeric EncoderSteps5 Variable Numeric OldEncoderSteps5 Variable Numeric Difference5 Label Encoder '------------------------------------------------ read encoder1 EncoderSteps1 = Slot(Slot_Encoder1) Difference1 = EncoderSteps1 - OldEncoderSteps1 OldEncoderSteps1 = EncoderSteps1 If Difference1 > 32000 Difference1 = Difference1 - 65536 EndIf If Difference1 < -32000 Difference1 = Difference1 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference1 = Difference1 * 0.1 EndIf Slot(Slot_M1) = Limit(Slot (Slot_M1) + Difference1, -70, 0) '------------------------------------------------ read encoder2 EncoderSteps2 = Slot(Slot_Encoder2) Difference2 = EncoderSteps2 - OldEncoderSteps2 OldEncoderSteps2 = EncoderSteps2 If Difference2 > 32000 Difference2 = Difference2 - 65536 EndIf If Difference2 < -32000 Difference2 = Difference2 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference2 = Difference2 * 0.1 EndIf Slot(Slot_M2) = Limit(Slot (Slot_M2) + Difference2, -160, 0) '------------------------------------------------ read encoder3 EncoderSteps3 = Slot(Slot_Encoder3) Difference3 = EncoderSteps3 - OldEncoderSteps3 OldEncoderSteps3 = EncoderSteps3 If Difference3 > 32000 Difference3 = Difference3 - 65536 EndIf If Difference3 < -32000 Difference3 = Difference3 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference3 = Difference3 * 0.1 EndIf Slot(Slot_M3) = Limit(Slot (Slot_M3) + Difference3, -100, 100) '------------------------------------------------ read encoder4 EncoderSteps4 = Slot(Slot_Encoder4) Difference4 = EncoderSteps4 - OldEncoderSteps4 OldEncoderSteps4 = EncoderSteps4 If Difference4 > 32000 Difference4 = Difference4 - 65536 EndIf If Difference4 < -32000 Difference4 = Difference4 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference4 = Difference4 * 0.1 EndIf Slot(Slot_M4) = Limit(Slot (Slot_M4) + Difference4, -180, 0) '------------------------------------------------ read encoder5 EncoderSteps5 = Slot(Slot_Encoder5) Difference5 = EncoderSteps5 - OldEncoderSteps5 OldEncoderSteps5 = EncoderSteps5 If Difference5 > 32000 Difference5 = Difference5 - 65536 EndIf If Difference5 < -32000 Difference5 = Difference5 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference5 = Difference5 * 0.1 EndIf Slot(Slot_M5) = Limit(Slot (Slot_M5) + Difference5, -240, 0) Return Label ResetEncoders OldEncoderSteps1 = Slot(Slot_Encoder1) OldEncoderSteps2 = Slot(Slot_Encoder2) OldEncoderSteps3 = Slot(Slot_Encoder3) OldEncoderSteps4 = Slot(Slot_Encoder4) OldEncoderSteps5 = Slot(Slot_Encoder5) Return ' ╔════════════════════════════════════════════╗ █▀▀█ █▀▀█ █ ' ║ CALIBRATIONS ║ █ █▄▄█ █ ' ╚════════════════════════════════════════════╝ █▄▄█ █ █ █▄▄▄ Label ResetAllMultiturnValues SendCommand(Slot_CommandsToMotors)("ResetAllMultiturnValues") Return Label CopyPositionsToDestinations Slot Slot_M1 = Slot(Slot_M1pos) Slot Slot_M2 = Slot(Slot_M2pos) Slot Slot_M3 = Slot(Slot_M3pos) Slot Slot_M4 = Slot(Slot_M4pos) Slot Slot_M5 = Slot(Slot_M5pos) Return Label CalibrateMotorToZero '(Motor Number) Variable Numeric CMTZ1 SendCommand(Slot_CommandsToMotors)("Calibrate Motor " + CMTZ1 + " To 0") CMTZ1 = (CMTZ1*100-100) Slot(Slot_M1 + CMTZ1) = Slot(Slot_M1pos + CMTZ1) Return Label SetMotorCenterHere '(Motor Number) Variable Numeric SMC1 SMC1 = Slot_M1center + (SMC1*100-100) Slot SMC1 = 128 Wait Seconds 0.1 Slot SMC1 = 1 Wait Seconds 0.1 Return Label SetMotor_OFF_ON '(Motor Number) Variable Numeric SMO1 SMO1 = Slot_M1center + (SMO1*100-100) Slot SMO1 = 0 Wait Seconds 0.1 Slot SMO1 = 1 Wait Seconds 0.1 Return Label WaitMotorsNotMoving Variable Numeric WMN1 For WMN1 = 1 To 5 WaitMotor(WMN1)(0.1) Next Return ' ------------------------------------------------------- ' The "Wait seconds" parameter is a initial delay ' If this delay is short and the motor starts slowly ' then the "WaitMotor" functions could exit immediately ' ------------------------------------------------------- Label WaitMotor '(Motor Number)(Wait seconds) Variable Numeric WM1 Variable Numeric WM2 WM1 = (WM1*100-100) Wait Seconds WM2 Variable Numeric WM3 For WM3 = 0 To Infinity If Slot(Slot_M1 + 2 + WM1) = 0 Or Key("CTRL") ' test Velocity Exit For EndIf 'If Slot(Slot_M1 + 6 + WM1) = 0 Or Key("CTRL") ' test Moving ' Exit For 'EndIf Next Return Label MoveMotorTo '(Motor Number)(Destination)(Wait seconds) Variable Numeric MMT1 Variable Numeric MMT2 Variable Numeric MMT3 Slot(Slot_M1 + MMT1*100-100) = MMT2 WaitMotor(MMT1)(MMT3) Return ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █▄ ▄█ █▀▀▀ ' ║ H O M I N G ║ █▀▀█ █ █ █ ▀ █ █▀▀ ' ╚════════════════════════════════════════════╝ █ █ █▄▄█ █ █ █▄▄▄ Label Homing BlueOn Homing4 Homing5 Homing2 Homing3 Homing1 Return Label GotoFinalPositions Slot(Slot_M1) = 0 Slot(Slot_M2) = 0 Slot(Slot_M3) = 0 Slot(Slot_M4) = 90 Slot(Slot_M5) = 0 Return Label Homing1 HomingMotor(1)(+0.3)(300)( -75)( 0)(400)(100)(1000) Return Label Homing2 'HomingMotor(2)(+0.5)(300)( -60)( 0)(450)(100)(1000) 'HomingMotor(2)(+0.2)(500)( -60)(-180)(450)(100)(1000) 'HomingMotor(2)(+0.2)(500)( -60)(-180)(600)(100)(1000) 'HomingMotor(2)(+0.2)(200)( -42)( +21)(250)(100)(1000) ' LEO belt*4 HomingMotor(2)(+0.2)(150)(-168)( +84)(250)(100)(1000) ' LEO belt*4 simulated Return Label Homing3 HomingMotor(3)(-0.2)(350)( +60)( 0)(400)(100)(1000) Return Label Homing4 HomingMotor(4)(+0.4)(300)(-115)(90)(350)(100)(1000) Return Label Homing5 HomingMotor(5)(+0.8)(300)(-127)( 0)(400)(100)(1000) Return Label HomingMotor ' ----------------------------------- Parameters Variable Numeric HM_MotNum Variable Numeric HM_SearchSpeed Variable Numeric HM_SearchTorque Variable Numeric HM_MoveToCenter Variable Numeric HM_MoveToFinal Variable Numeric HM_MotorTorque Variable Numeric HM_MotorAcc Variable Numeric HM_MotorSpeed ' ----------------------------------- Local Variables Variable Numeric HM_MotSlot HM_MotSlot = Slot_M1 + HM_MotNum * 100 - 100 Variable Numeric HM1 ' ----------------------------------- 'DisableAllButtons FlashHomingButton(HM_MotNum) Slot(Slot_SignalScope) = 1000 SendCommand(Slot_CommandsToCobot)(StopExecution) SendCommand(Slot_CommandsToCobot)("SetTorque " + HM_MotorTorque) SendCommand(Slot_CommandsToCobot)("SetAcceleration " + HM_MotorAcc) SendCommand(Slot_CommandsToCobot)("SetSpeed " + HM_MotorSpeed) ResetAllMultiturnValues CalibrateMotorToZero(HM_MotNum) ' Calibrate To Zero For HM1 = 1 To Infinity Slot(HM_MotSlot) = Slot(HM_MotSlot) + HM_SearchSpeed If Abs(Slot(HM_MotSlot + 7)) > HM_SearchTorque ' +7=current Beep 2200 50 Exit EndIf If Abs(Slot(HM_MotSlot) - Slot(HM_MotSlot + 1)) > 30 Beep 800 100 SetMotorCenterHere(1) ' Set Center here CopyPositionsToDestinations EndIf Wait Seconds 0.01 Next ' ----------------------------------- Beep 2500 50 'Wait Seconds 0.1 ' Stabilization time 'CalibrateMotorToZero(HM_MotNum) ' Calibrate To Zero 'Wait Seconds 0.1 'SetMotor_OFF_ON(HM_MotNum) ' SpeedUp next movement 'Wait Seconds 0.1 CalibrateMotorToZero(HM_MotNum) ' Calibrate To Zero MoveMotorTo(HM_MotNum)(HM_MoveToCenter)(1.5)' Move to Center CalibrateMotorToZero(HM_MotNum) ' Calibrate to Zero SetMotorCenterHere(HM_MotNum) ' Set Center here CalibrateMotorToZero(HM_MotNum) ' Calibrate to Zero MoveMotorTo(HM_MotNum)(HM_MoveToFinal)(0.1) ' Move to Final position Beep 2800 200 ' ----------------------------------- EnableAllButtons Slot(Slot_SignalScope) = 0 UnFlashHomingButtons Return Label FlashHomingButton Variable Numeric FHB1 ' First Param = Motor Number Select FHB1 Case 1 Button Homing1 Color Flashing6 Blue White Case 2 Button Homing2 Color Flashing6 Blue White Case 3 Button Homing3 Color Flashing6 Blue White Case 4 Button Homing4 Color Flashing6 Blue White Case 5 Button Homing5 Color Flashing6 Blue White 'Case 6 ' Button Homing6 Color Flashing6 Blue White 'Case 7 ' Button Homing7 Color Flashing6 Blue White EndSelect Return Label UnFlashHomingButtons Button Homing1 Color Yellow Button Homing2 Color Yellow Button Homing3 Color Yellow Button Homing4 Color Yellow Button Homing5 Color Yellow 'Button Homing6 Color Yellow 'Button Homing7 Color Yellow Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands\OLD EXAMPLES\LEO examples ' File MotorCalib_Zero_3.txt ' ============================================================================= '╔═══════════════════════════════════════════════════════════╗ '║ Name: MotorCalib_Zero_3.txt Date: 13 Dic 2022 ║ '║ Author: Leonardo ║ '║ Scope: Test all the functionality of the PVC-150 ║ '╠═══════════════════════════════════════════════════════════╣ '║Hardware: 5 FeeTech STS3215 new MOTOR ║ '╟───────────────────────────────────────────────────────────╢ '║ Note: Vacuum motor and valve at 6V ║ '║ FeeTech at 7.5V ║ '╟───────────────────────────────────────────────────────────╢ '║ISO Culture Gender Age Name ║ '╟───────────────────────────────────────────────────────────╢ '║ENG EN-US Male Adult Microsoft David Desktop ║ '║ENG EN-US Female Adult Microsoft Zira Desktop ║ '║ITA IT-IT Female Adult Microsoft Elsa Desktop ║ '║JPN JA-JP Female Adult Microsoft Haruka Desktop ║ '║ZHO ZH-CN Female Adult Microsoft Huihui Desktop ║ '╚═══════════════════════════════════════════════════════════╝ Option Speed 9 Beep "2500 20, 1500 100" 'Load images\PVCArm_150.jpg TTS SelectVoice "ENG" s1 = TTSvoices TTS SetVolume 100 TTS SetSpeed -2 TTS SelectVoice 3 'TTS Speak "Theremino Automation programming language is running." ' ╔════════════════════════════════════════════╗ ' ║ SLOT TEXT for COMMANDS and RESPONSES ║ ' ╚════════════════════════════════════════════╝ Variable Numeric Slot_CommandsToMotors = 50 Variable Numeric Slot_CommandsToCobot = 51 Variable Numeric Slot_ResponsesFromCobot = 52 Variable Numeric Slot_ExternalCommands = 53 Variable Numeric Slot_ResponsesFromQRDecode = 54 Variable Numeric Slot_WordRecognized = 55 ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █▀▀█ ▀▀█▀▀ ' ║ SLOT INITIALIZATIONS ║ ▀▀▀█ █ █ █ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄ █▄▄█ █ 'Variable Numeric Slot_Vacuum = 1 Variable Numeric Slot_FiveButton = 26 Variable Numeric Slot_LedR = 7 Variable Numeric Slot_LedG = 8 Variable Numeric Slot_LedB = 9 Variable Numeric Slot_Pedal = 10 Variable Numeric Slot_Pump = 11 Variable Numeric Slot_SignalScope = 13 Variable Numeric Slot_Slider1 = 2 Variable Numeric Slot_Slider2 = 3 Variable Numeric Slot_Slider3 = 4 Variable Numeric Slot_Slider4 = 5 Variable Numeric Slot_Slider5 = 6 Variable Numeric Slot_Encoder1 = 21 Variable Numeric Slot_Encoder2 = 22 Variable Numeric Slot_Encoder3 = 23 Variable Numeric Slot_Encoder4 = 24 Variable Numeric Slot_Encoder5 = 25 Variable Numeric Slot_EncoderSlow = 31 Variable Numeric Slot_M1 = 101 Variable Numeric Slot_M2 = 201 Variable Numeric Slot_M3 = 301 Variable Numeric Slot_M4 = 401 Variable Numeric Slot_M5 = 501 Variable Numeric Slot_M1pos = 102 Variable Numeric Slot_M2pos = 202 Variable Numeric Slot_M3pos = 302 Variable Numeric Slot_M4pos = 402 Variable Numeric Slot_M5pos = 502 Variable Numeric Slot_M1center = 123 Variable Numeric Slot_MotorsFPS = 56 ' ╔════════════════════════════════════════════╗ █▀▀▄ █ █ ▀▀█▀▀ ' ║ BUTTONS ║ █▀▀█ █ █ █ ' ╚════════════════════════════════════════════╝ █▄▄█ █▄▄█ █ Button 1 Label MotorFPS Button MotorFPS Text "NO MOTORS" Button MotorFPS Color Flashing7 Yellow DarkOrange Button 2 Label "MotorTemp" Button 3 Label CurrentMeter Button 4 Label GoTo12_70 Button GoTo12_70 Text "GoTo 12 70" Button GoTo12_70 Color Yellow Button 5 Label GoToHome Button GoToHome Text "GoTo Home" Button GoToHome Color Yellow Button 6 Label GoTo45 Button GoTo45 Text "GoTo 45" Button GoTo45 Color Gold Button 7 Label GoTo70 Button GoTo70 Text "GoTo 70" Button GoTo70 Color Yellow Button 8 Label CopyPositionsToDestinations Button CopyPositionsToDestinations Text "Copy Positions" + CRLF + "To Destinations" Button CopyPositionsToDestinations Color Orange 'Button 8 Label ActivateMotors 'Button ActivateMotors Text "Activate" + CRLF + "Motors" 'Button ActivateMotors Color Orange 'Button 6 Label SetCenterHere 'Button SetCenterHere Text "Set Center Here" 'Button SetCenterHere Color Orange ' 'Button 7 Label CalibrateToZero 'Button CalibrateToZero Text "Calibrate to Zero" 'Button CalibrateToZero Color Orange ' ================================================ 'Button 2 Label JobQrCode 'Button JobQrCode Text "JOB QRcode" 'Button JobQrCode Color Cyan ' 'Button 4 Label Sliders 'Button Sliders Text "Sliders" 'Button Sliders Color Cyan 'Button 6 Label Voice 'Button Voice Text "Voice" 'Button Voice Color PaleTurquoise Button 10 Label TunaCans Button TunaCans Text "Tuna cans" Button TunaCans Color Indigo Button 11 Label WanpyJob5 Button WanpyJob5 Text "Wanpy Job 5" Button WanpyJob5 Color Indigo Button 12 Label StartPump Button StartPump Text "Start Pump" Button StartPump Color Lime Button 13 Label StopPump Button StopPump Text "Stop Pump" Button StopPump Color Crimson Button 15 Label CloseAll Button CloseAll Text "CLOSE ALL" Button CloseAll Color Red Button 23 Label RecognizeEncoder Button RecognizeEncoder Text "Recognize" + CRLF + "Encoder" Button RecognizeEncoder Color LightBlue Button 24 Label CloseScopes Button CloseScopes Text "Close Scopes" Button CloseScopes Color SkyBlue Button 25 Label OpenScope_1 Button OpenScope_1 Text "Open Scope 1" Button OpenScope_1 Color PaleTurquoise Button 26 Label OpenScope_2 Button OpenScope_2 Text "Open Scope 2" Button OpenScope_2 Color PaleTurquoise Button 27 Label OpenScope_3 Button OpenScope_3 Text "Open Scope 3" Button OpenScope_3 Color PaleTurquoise Button 28 Label OpenScope_4 Button OpenScope_4 Text "Open Scope 4" Button OpenScope_4 Color PaleTurquoise Button 29 Label OpenScope_5 Button OpenScope_5 Text "Open Scope 5" Button OpenScope_5 Color PaleTurquoise Button 30 Label OpenFPS Button OpenFPS Text "Open FPS" Button OpenFPS Color PaleTurquoise Button 31 Label VoiceLoop Button VoiceLoop Text "VoiceLoop" Button VoiceLoop Color Blue Button 32 Label Say Button Say Text "Say" Button Say Color DeepSkyBlue ' ╔════════════════════════════════════════════╗ █ █▀▀█ █▀▀█ █▀▀▄ ' ║ LOAD APPS ║ █ █ █ █▄▄█ █ █ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄█ █ █ █▄▄█ Load Theremino_Motors.exe WaitApplicationsStarted '' ------------------------------------- ' MOTORS must be active before Cobot ' ------------------------------------- Load Theremino_HAL.exe Load Theremino_SlotViewer.exe Load Theremino_SlotViewer_Motors.exe Load Theremino_SlotViewer_STR.exe 'Load Theremino_MicroVideo.exe 'Load Theremino_QRdecoder.exe 'Load Theremino_VoiceCommands.exe Load Theremino_SlotViewer_Strings.exe Load Theremino_Cobot.exe 'WaitApplicationsStarted Load Hide ' ╔════════════════════════════════════════════╗ █▀▀▀ ▀▀█▀▀ █▀▀▀█ █▀▀▀█ ▀▀█▀▀ ' ║ EXECUTION START FROM HERE ║ ▀▀▀█ █ █▀▀▀█ █▀█▀▀ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █ █ █ ▀▄ █ ResetEncoders YellowOn Slot(Slot_SignalScope) = 1000 'CopyPositionsToDestinations 'DisableHomeButtons ' ------------------------- GOTO Homing - Command to Cobot 'WaitCobotReady 'SendCommand(Slot_CommandsToCobot)(GotoHoming) 'Homing 'Controls OpenTextBox 'Controls ClearTextBox ActivateMotors Loop Stop ' ╔════════════════════════════════════════════╗ █ █▀▀█ █▀▀█ █▀▀█ ' ║ LOOP ║ █ █ █ █ █ █▄▄█ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄█ █▄▄█ █ Label Loop CurrentMeter ShowMotorFPS PositionDelta TestTemp 'InterpretateVoiceCommands Encoder FiveButton 'If Slot(Slot_MotorsFPS) < 5 ' Print "The robot is not in POWER ON or serial port is not correct." ' End 'EndIf 'If Slot(0) = -2 ' Print "Master disconnected." ' End 'EndIf Goto Loop Label PositionDelta Slot(109) = Slot(101) - Slot(102) Slot(209) = Slot(201) - Slot(202) Slot(309) = Slot(301) - Slot(302) Slot(409) = Slot(401) - Slot(402) Slot(509) = Slot(501) - Slot(502) Return Label TestTemp Variable Numeric TT1 Variable Numeric TT2 = 0 'TT2 = 0 For TT1 = 1 To 3 '5 TT2 = Max(TT2, Slot(TT1 * 100 + 6)) Next Button MotorTemp Text "MaxT " + TT2 + "°C" Return ' ╔════════════════════════════════════════════╗ ' ║ ENABLE/DISABLE BUTTONS ║ ' ╚════════════════════════════════════════════╝ Label EnableAllButtons For v1 = 1 To 48 Button v1 Enabled Next Return Label DisableAllButtons For v1 = 1 To 48 Button v1 Disabled Next Return ' ╔════════════════════════════════════════════╗ ' ║ WAIT COBOT READY ║ ' ╚════════════════════════════════════════════╝ Label WaitCobotReady Variable Numeric WCR1 For WCR1 = 1 To Infinity Wait Seconds 0.05 If SlotText(Slot_ResponsesFromCobot) = "Ready" Exit EndIf Next Return ' ╔════════════════════════════════════════════╗ ' ║ WAIT APPS STARTED ║ ' ╚════════════════════════════════════════════╝ Label WaitApplicationsStarted Slot(Slot_MotorsFPS) = 0 Wait Slot(Slot_MotorsFPS) > 10 Wait Seconds 0.1 Return ' ╔════════════════════════════════════════════╗ █▀▀▀ ▀▀█▀▀ █▀▀█ █▀▀█ ' ║ STOP EVENT (when pressing stop button) ║ ▀▀▀█ █ █ █ █▄▄█ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █▄▄█ █ Label EventStop StopPump StopCobot Slot(Slot_SignalScope) = 0 ' GoToShow ' StopCobotAndGotoHoming End 'Label StopCobotAndGotoHoming ' 'StopCobot ' WaitMotorsNotMoving ' 'GotoSafePosition 'Return Label GotoSafePosition SendCommand(Slot_CommandsToCobot)("GotoHoming") WaitMotorsNotMoving Return ' ╔════════════════════════════════════════════╗ █▀▀ █ █▀▀█ █▀▀▀ █▀▀▀ ' ║ CLOSE ALL (when pressing X on form) ║ █ █ █ █ ▀▀▀█ █▀▀ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█ ▄▄▄█ █▄▄▄ Label CloseAll StopPump StopCobot Slot(Slot_SignalScope) = 0 ' GoToShow ' StopCobotAndGotoHoming Load CloseAll End ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand '(Destination Slot)(Command String) Variable Numeric SC1 Variable String SC2 Variable Numeric SC3 = 0.5 '<-- The timeout in seconds Variable Numeric SC4 SlotText SC1 = SC2 For SC4 = 0.1 To SC3 Step 0.1 If SlotText(SC1) = "" Exit EndIf Wait Seconds 0.1 Next Return ' ============================================================= ' COMMANDS to Cobot ' ============================================================= Label ExecCobot SendCommand(Slot_CommandsToCobot)("EnableRepeat") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label StopCobot SendCommand(Slot_CommandsToCobot)(StopExecution) Return Label ArrowUpCobot SendCommand(Slot_CommandsToCobot)(ArrowUp) Return Label ArrowDownCobot SendCommand(Slot_CommandsToCobot)(ArrowDown) Return Label EmulatePedal Slot(Slot_Pedal) = 1000 Wait Seconds 0.5 Slot(Slot_Pedal) = 0 Return Label ExecuteCobotFromSelectedLine SendCommand(Slot_CommandsToCobot)(StartExecution) Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █ █▀█ ' ║ S U B R O U T I N E A R E A ║ ▀▀▀█ █ █ █▀▀█ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄█ █▄▄█ Label EnableHomeButtons For v1 = 17 To 22 Button v1 Enabled Next Return Label DisableHomeButtons For v1 = 17 To 22 Button v1 Disabled Next Return Label CurrentMeter Variable Numeric mA mA = Slot(108) + Slot(208) + Slot (308) + Slot (408) + Slot (508) mA = FilterLP(mA, 0.1, 1) '<-- Filter 0.5 seconds / 1 pole Button CurrentMeter Text "Current " + Str(mA, "0 mA") Return Label ShowMotorFPS Variable String MotorsAreEnabled Variable Numeric SMF1 = Slot(Slot_MotorsFPS) If SMF1 > 30 If MotorsAreEnabled <> "TRUE" MotorsAreEnabled = "TRUE" Button MotorFPS Color GreenYellow EndIf Button MotorFPS Text "FPS " + Str(SMF1) Else If MotorsAreEnabled = "TRUE" MotorsAreEnabled = "FALSE" Button MotorFPS Color Flashing7 Yellow DarkOrange Button MotorFPS Text "NO MOTORS" EndIf EndIf Return Label MotorFPS If MotorsAreEnabled = "TRUE" SendCommand(Slot_CommandsToMotors)(DisableConnection) Else SendCommand(Slot_CommandsToMotors)(EnableConnection) EndIf Return Label StartPump BlueOn 'Slot(Slot_SignScope) = 1000 Slot(Slot_Pump) = 1000 Button StartPump Disabled Button StopPump Enabled Wait Seconds 0.4 'If Slot(Slot_Vacuum) > 56 ' 'Beep "500, 300, 0, 300" ' 'SayVacuumProblem ' RedOn ' StopPump ' Print "Vacuum Problem" + CRLF ' 'CobotShowPoint ' Print "Execution stopped" + CRLF ' RedBlink ' End 'Else ' Print "Target picked" 'EndIf Return Label StopPump Slot(Slot_Pump) = 0 Button StopPump Disabled Button StartPump Enabled GreenOn Return Label GoTo70 MoveMotorTo(4)(70)(0.1) MoveMotorTo(1)(70)(0.1) MoveMotorTo(3)(70)(0.1) MoveMotorTo(2)(70)(0.1) MoveMotorTo(5)(70)(0.1) Return ' nota: quando si muove il 2, il 3 non deve mai avere ' un valore superiore a 50 altrimenti salta Label GoTo12_70 MoveMotorTo(4)(12)(0.1) MoveMotorTo(5)(70)(0.1) MoveMotorTo(1)(12)(0.1) MoveMotorTo(3)(12)(0.1) 'Breakpoint MoveMotorTo(2)(12)(0.1) MoveMotorTo(3)(12)(0.1) Return Label GoToHome MoveMotorTo(1)(10)(0.1) MoveMotorTo(2)(10)(0.1) MoveMotorTo(3)(125)(0.1) MoveMotorTo(5)(120)(0.1) MoveMotorTo(4)(10)(0.1) Return Label GoTo45 MoveMotorTo(4)(45)(0.1) MoveMotorTo(1)(45)(0.1) MoveMotorTo(2)(45)(0.1) MoveMotorTo(3)(45)(0.1) MoveMotorTo(5)(135)(0.1) MoveMotorTo(4)(45)(0.1) Return ' ╔════════════════════════════════════════════╗ █▀▀ █▀█ █ █ ▀▀█▀▀ ' ║ FIVE PUSH BUTTONS ║ ▀▀█ █▀▀█ █ █ █ ' ╚════════════════════════════════════════════╝ ▄▄█ █▄▄█ █▄▄█ █ Variable String PressedButton Label FiveButton Variable Numeric FB0 Variable Numeric FB1 FB1 = Slot(Slot_FiveButton) ' ------------------------------ Test buttons If FB0 = 0 FB0 = 1 Select True Case FB1 > 500 Print "" PressedButton = "" Case FB1 > 250 Print "red" PressedButton = "red" ExecCobot Case FB1 > 120 Print "white" PressedButton = "white" ExecuteCobotFromSelectedLine Case FB1 > 56 Print "green" PressedButton = "green" ArrowDownCobot Case FB1 > 15 Print "blue" PressedButton = "blue" ArrowUpCobot CaseElse Print "yellow" PressedButton = "yellow" EmulatePedal EndSelect EndIf ' ------------------------------ Rearm buttons If FB1 > 500 FB0 = 0 EndIf Return Label CloseScopes Load CloseApps Theremino_SignalScope_M1.exe Load CloseApps Theremino_SignalScope_M2.exe Load CloseApps Theremino_SignalScope_M3.exe Load CloseApps Theremino_SignalScope_M4.exe Load CloseApps Theremino_SignalScope_M5.exe Load CloseApps Theremino_SignalScope_FPS.exe Return Label OpenScope_1 Load Theremino_SignalScope_M1.exe Return Label OpenScope_2 Load Theremino_SignalScope_M2.exe Return Label OpenScope_3 Load Theremino_SignalScope_M3.exe Return Label OpenScope_4 Load Theremino_SignalScope_M4.exe Return Label OpenScope_5 Load Theremino_SignalScope_M5.exe Return Label OpenFPS Load Theremino_SignalScope_FPS.exe Return ' ╔════════════════════════════════════════════╗ █ █▀▀ █▀▄ ' ║ LED COLORS ║ █ █▀ █ █ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█ Label RedOn Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Return Label MagentaOn Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label YellowOn Slot Slot_LedR = 900 Slot Slot_LedG = 400 Slot Slot_LedB = 0 Return Label GreenOn Slot Slot_LedR = 0 Slot Slot_LedG = 1000 Slot Slot_LedB = 0 Return Label BlueOn Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label WhiteOn Slot Slot_LedR = 1000 Slot Slot_LedG = 1000 Slot Slot_LedB = 1000 Return Label RgbOff Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Return Label RedBlink RedOn WhiteOn Return ' ╔═════════════════════════╗ █▀▀▀ █▀▀█ █▄ ▄█ █▀▀ █▀▀▀ █▀▀█ █▀█ ' ║ COMMANDS FROM COBOT ║ █ █ █ █ ▀ █ █▀ █ █ █ █▀▀█ ' ╚═════════════════════════╝ █▄▄▄ █▄▄█ █ █ ▄ █ ▄ █▄▄▄ █▄▄█ █▄▄█ Label Event_ExternalCommands ' ------------------------------------------------------ Do not print lines containing '' 'Print " Exec: " + CommandText + CRLF ' ------------------------------------------------------ Select CommandText ' ---------------------------------------------- ACTIONS Case "RedOn" RedOn ClearCommand Case "GreenOn" GreenOn ClearCommand Case "BlueOn" BlueOn ClearCommand Case "WhiteOn" WhiteOn ClearCommand Case "MagentaOn" MagentaOn ClearCommand Case "YellowOn" YellowOn ClearCommand Case "Beep" Beep 880-100 ClearCommand Case "Pause" Wait Seconds GetSeparatedString(CommandText, 1) ClearCommand Case "StartPump" StartPump ClearCommand Case "StopPump" StopPump ClearCommand Case "MemorizeQrCode" Variable Numeric MQR1 For MQR1 = 1 To 5 QrCode = SlotText(Slot_ResponsesFromQRDecode) Print QrCode If QrCode <> "" Exit EndIf If MQR1 = 5 SendCommand(Slot_CommandsToCobot)(StopExecution) EndIf Wait Seconds 1 Next ClearCommand Case "ExecQrCode" ExecQRcode ClearCommand Case "StartFichesPick" StartFichesPick ClearCommand Case "EndOfTask" EndOfTask ClearCommand Case "Executing" ClearCommand CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + CommandText + CRLF Beep ClearCommand Stop ' EndSelect Return Label ClearCommand SlotText(Slot_ExternalCommands) = "" Return ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █▄ █ █▀▀▀ ' ║ WANPY 5 ║ █ █ █▄▄█ █ ▀█ ▀▀▀█ ' ╚════════════════════════════════════════════╝ ▀▄▀ █ █ █ █ ▄▄▄█ Label WanpyJob5 TTS Speak "Wanpy job started." Controls OpenTextBox Controls ClearTextBox StartTime = ElapsedTime Wanpy_A5toB1 Return Variable String Status = "A5toB1" Label EndOfTask PrintTime StartTimePartial = ElapsedTime Select Status Case "A5toB1" 'Wanpy_B1toA5 Wanpy_A4toB2 Case "A4toB2" Wanpy_A3toB3 Case "A3toB3" Wanpy_A2toB4 Case "A2toB4" Wanpy_A1toB5 Case "A1toB5" Wanpy_B5toA1 Case "B5toA1" Wanpy_B4toA2 Case "B4toA2" Wanpy_B3toA3 Case "B3toA3" Wanpy_B2toA4 Case "B2toA4" Wanpy_B1toA5 Case "B1toA5" StartTime = ElapsedTime Print CRLF Wanpy_A5toB1 EndSelect Return Variable Numeric StartTime Variable Numeric StartTimePartial Variable String Time Label PrintTime Time = "Partial time = " Time = Time + PadLeft(Format(ElapsedTime - StartTimePartial, "0.0"),4) Time = Time + " Total time = " Time = Time + PadLeft(Format(ElapsedTime - StartTime, "0.0"),4) Print Status + " " + Time + CRLF Return Label Wanpy_A5toB1 Status = "A5toB1" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A5toB1.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A4toB2 Status = "A4toB2" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A4toB2.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A3toB3 Status = "A3toB3" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A3toB3.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A2toB4 Status = "A2toB4" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A2toB4.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A1toB5 Status = "A1toB5" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A1toB5.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B5toA1 Status = "B5toA1" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B5toA1.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B4toA2 Status = "B4toA2" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B4toA2.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B3toA3 Status = "B3toA3" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B3toA3.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B2toA4 Status = "B2toA4" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B2toA4.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B1toA5 Status = "B1toA5" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B1toA5.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return ' ╔════════════════════════════════════════════╗ █▀▀█ █▀▀█ █▀▀▀ ' ║ QR CODE ║ █ █ █▄▄█ █ ' ╚════════════════════════════════════════════╝ █▄██▄ █ ▀▄ █▄▄▄ Label JobQrCode TTS Speak "QR code recognition and action related is started." StartFichesPick Return Label StartFichesPick BlueOn SendCommand(Slot_CommandsToCobot)("LoadSequence fiches_pick.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label ExecQRcode Variable String QrCode Select QrCode Case "WHITE" WhiteOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_white.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "RED" RedOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_red.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "GREEN" GreenOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_green.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "BLUE" BlueOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_Place_blue.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "BLACK" RgbOff SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_black.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) CaseElse Controls OpenTextBox Print CRLF + " Unrecognized color command: " + CommandText + CRLF StopPump Beep ClearCommand Stop EndSelect Return ' ╔════════════════════════════════════════════╗ ▀▀█▀▀ █ █ █▄ █ ' ║ TUNA ║ █ █ █ █ ▀█ ' ╚════════════════════════════════════════════╝ █ █▄▄█ █ █ Label TunaCans TTS Speak "Tuna can handling." YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Tuna_Cans.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █ █▀▀▄ ' ║ SLIDERS ║ ▀▀▀█ █ █ █ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄ █ █▄▄█ Variable Numeric SLD Label Sliders BlueOn 'Button Sliders Color Flashing7 Blue White For SLD = 1 To Infinity Slot(Slot_M1) = Slot(Slot_Slider1) Slot(Slot_M2) = Slot(Slot_Slider2) Slot(Slot_M3) = Slot(Slot_Slider3) + Slot(Slot_Slider2) Slot(Slot_M4) = Slot(Slot_Slider4) Slot(Slot_M5) = Slot(Slot_Slider5) Next Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █▀▀█ ▀▄ ▄▀ ' ║ SAY ║ ▀▀▀█ █▄▄█ ▀▄▀ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █ █ Label Say TTS SelectVoice "ENGF" TTS Speak "Today is a beautiful day because we spend time together." Wait TTSready TTS SelectVoice "ITA FEM" TTS Speak "Oggi è una bella giornata perche passeremo del tempo insieme." Wait TTSready TTS SelectVoice "JPN" TTS Speak "私たちは一緒に時間を過ごすので、今日は美しい日です。" Wait TTSready TTS SelectVoice "ZHO" TTS Speak "今天是美好的一天,因为我们共度时光。" Wait TTSready Return ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █ █▀▀▀ █▀▀▀ ' ║ VOICE COMMANDS ║ █ █ █ █ █ █ █▀▀ ' ╚════════════════════════════════════════════╝ █ █▄▄█ █ █▄▄▄ █▄▄▄ Label Voice ClearVoiceCommand If VoiceCommandsStatus = "active" VoiceCommandsStatus = "" 'Button Voice Color PaleTurquoise Else VoiceCommandsStatus = "active" 'Button Voice Color Flashing7 Orange White EndIf Return Variable String Word Variable String VoiceCommandsStatus Label InterpretateVoiceCommands If VoiceCommandsStatus = "active" If SlotText(Slot_WordRecognized) <> "" Word = SlotText(Slot_WordRecognized) Print Word + " " Interpretate ClearVoiceCommand EndIf EndIf Return Variable String ShowingType Label Interpretate Select Word Case "show.fiches" If ShowingType = "" WhiteOn ShowingType = "Fiches" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Fiches.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "show.wanpy" If ShowingType = "" YellowOn ShowingType = "Wanpy" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Wanpy.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "show.tuna" If ShowingType = "" GreenOn ShowingType = "Tuna" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Tuna.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf '------------------------------------------------------------------------- Case "release" Select ShowingType Case "fiches" WhiteOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Fiches.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" Case "wanpy" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Wanpy.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" Case "tuna" GreenOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Tuna.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" CaseElse ' EndSelect '------------------------------------------------------------------------- Case "goto.center" If ShowingType = "" RedOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_goto_Center.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "goto.Homing" If ShowingType = "" MagentaOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_goto_Homing.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf '------------------------------------------------------------------------- CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + Word + CRLF Beep ClearCommand Stop EndSelect Return Label ClearVoiceCommand SlotText(Slot_WordRecognized) = "" Return ' ╔════════════════════════════════════════════╗ ▀▀█▀▀ █▀▀█ █ █▀▀█ █ ' ║ T R I A L S ║ █ █▄▄▀ █ █▄▄█ █ ' ╚════════════════════════════════════════════╝ █ █ ▀▄ █ █ █ █▄▄ ' ╔════════════════════════════════════════════╗ █▀▀▀ █▄ █ █▀▀▀ ' ║ ENCODERS ║ █▀▀ █ ▀█ █ ' ╚════════════════════════════════════════════╝ █▄▄▄ █ █ █▄▄▄ Variable Numeric EncoderSteps1 Variable Numeric OldEncoderSteps1 Variable Numeric Difference1 Variable Numeric EncoderSteps2 Variable Numeric OldEncoderSteps2 Variable Numeric Difference2 Variable Numeric EncoderSteps3 Variable Numeric OldEncoderSteps3 Variable Numeric Difference3 Variable Numeric EncoderSteps4 Variable Numeric OldEncoderSteps4 Variable Numeric Difference4 Variable Numeric EncoderSteps5 Variable Numeric OldEncoderSteps5 Variable Numeric Difference5 Label RecognizeEncoder Slot(0) = Recognize Return Label Encoder '------------------------------------------------ encoder1 to mot 1 or 6 EncoderSteps1 = Slot(Slot_Encoder1) Difference1 = EncoderSteps1 - OldEncoderSteps1 OldEncoderSteps1 = EncoderSteps1 If Difference1 > 32000 Difference1 = Difference1 - 65536 EndIf If Difference1 < -32000 Difference1 = Difference1 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference1 = Difference1 * 0.1 EndIf If PressedButton <> "yellow" Slot(Slot_M1) = Limit(Slot (Slot_M1) + Difference1, 10, 163) Else 'Slot(Slot_M6) = Limit(Slot (Slot_M6) + Difference1, -130, +130) EndIf '------------------------------------------------ read encoder2 EncoderSteps2 = Slot(Slot_Encoder2) Difference2 = EncoderSteps2 - OldEncoderSteps2 OldEncoderSteps2 = EncoderSteps2 If Difference2 > 32000 Difference2 = Difference2 - 65536 EndIf If Difference2 < -32000 Difference2 = Difference2 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference2 = Difference2 * 0.1 EndIf Slot(Slot_M2) = Limit(Slot (Slot_M2) + Difference2, 10, 98) '------------------------------------------------ read encoder3 EncoderSteps3 = Slot(Slot_Encoder3) Difference3 = EncoderSteps3 - OldEncoderSteps3 OldEncoderSteps3 = EncoderSteps3 If Difference3 > 32000 Difference3 = Difference3 - 65536 EndIf If Difference3 < -32000 Difference3 = Difference3 + 65536 EndIf Difference3 = Difference3 * 0.5 If Slot(Slot_EncoderSlow) < 500 Difference3 = Difference3 * 0.1 EndIf Slot(Slot_M3) = Limit(Slot (Slot_M3) + Difference3, 5, 94) '------------------------------------------------ read encoder4 EncoderSteps4 = Slot(Slot_Encoder4) Difference4 = EncoderSteps4 - OldEncoderSteps4 OldEncoderSteps4 = EncoderSteps4 If Difference4 > 32000 Difference4 = Difference4 - 65536 EndIf If Difference4 < -32000 Difference4 = Difference4 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference4 = Difference4 * 0.01 EndIf Slot(Slot_M4) = Limit(Slot (Slot_M4) + Difference4, 10, 190) '------------------------------------------------ read encoder5 EncoderSteps5 = Slot(Slot_Encoder5) Difference5 = EncoderSteps5 - OldEncoderSteps5 OldEncoderSteps5 = EncoderSteps5 If Difference5 > 32000 Difference5 = Difference5 - 65536 EndIf If Difference5 < -32000 Difference5 = Difference5 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference5 = Difference5 * 0.1 EndIf Slot(Slot_M5) = Limit(Slot (Slot_M5) + Difference5, 62, 298) Return Label ResetEncoders OldEncoderSteps1 = Slot(Slot_Encoder1) OldEncoderSteps2 = Slot(Slot_Encoder2) OldEncoderSteps3 = Slot(Slot_Encoder3) OldEncoderSteps4 = Slot(Slot_Encoder4) OldEncoderSteps5 = Slot(Slot_Encoder5) Return ' ╔════════════════════════════════════════════╗ █▀▀█ █▀▀█ █ ' ║ CALIBRATIONS ║ █ █▄▄█ █ ' ╚════════════════════════════════════════════╝ █▄▄█ █ █ █▄▄▄ Label ResetAllMultiturnValues SendCommand(Slot_CommandsToMotors)("ResetAllMultiturnValues") Return Label CopyPositionsToDestinations Slot Slot_M1 = Slot(Slot_M1pos) Slot Slot_M2 = Slot(Slot_M2pos) Slot Slot_M3 = Slot(Slot_M3pos) Slot Slot_M4 = Slot(Slot_M4pos) Slot Slot_M5 = Slot(Slot_M5pos) Return Label CalibrateMotorToZero '(Motor Number) Variable Numeric CMTZ1 SendCommand(Slot_CommandsToMotors)("Calibrate Motor " + CMTZ1 + " To 0") CMTZ1 = (CMTZ1*100-100) Slot(Slot_M1 + CMTZ1) = Slot(Slot_M1pos + CMTZ1) Return 'Label SetMotorCenterHere '(Motor Number) ' Variable Numeric SMC1 ' SMC1 = Slot_M1center + (SMC1*100-100) ' Slot SMC1 = 128 ' Wait Seconds 0.1 ' Slot SMC1 = 1 ' Wait Seconds 0.1 'Return Label SetMotor_ON '(Motor Number) Variable Numeric SMON1 SMON1 = Slot_M1center + (SMON1*100-100) Slot SMON1 = 0 Wait Seconds 0.1 Slot SMON1 = 1 Wait Seconds 0.1 Return Label SetMotor_OFF '(Motor Number) Variable Numeric SMOFF1 SMOFF1 = Slot_M1center + (SMOFF1*100-100) Slot SMOFF1 = 0 Wait Seconds 0.1 Slot SMOFF1 = 1 Wait Seconds 0.1 Return Label WaitMotorsNotMoving Variable Numeric WMN1 For WMN1 = 1 To 5 WaitMotor(WMN1)(0.1) Next Return ' ------------------------------------------------------- ' The "Wait seconds" parameter is a initial delay ' If this delay is short and the motor starts slowly ' then the "WaitMotor" functions could exit immediately ' ------------------------------------------------------- Label WaitMotor '(Motor Number)(Wait seconds) Variable Numeric WM1 Variable Numeric WM2 WM1 = (WM1*100-100) Wait Seconds WM2 Variable Numeric WM3 For WM3 = 0 To Infinity If Slot(Slot_M1 + 2 + WM1) = 0 Or Key("CTRL") ' test Velocity Exit For EndIf 'If Slot(Slot_M1 + 6 + WM1) = 0 Or Key("CTRL") ' test Moving ' Exit For 'EndIf Next Return Label MoveMotorTo '(Motor Number)(Destination)(Wait seconds) Variable Numeric MMT1 Variable Numeric MMT2 Variable Numeric MMT3 Slot(Slot_M1 + MMT1*100-100) = MMT2 WaitMotor(MMT1)(MMT3) Return ' ╔════════════════════════════════════════════╗ ' ║ ACTIVATE MOTORS ║ ' ╚════════════════════════════════════════════╝ Label ActivateMotors ResetAllMultiturnValues Variable Numeric AM1 For AM1 = 1 To 5 SetMotor_ON(AM1) Next SendCommand(Slot_CommandsToCobot)("SetTorque 200") SendCommand(Slot_CommandsToCobot)("SetAcceleration 100") SendCommand(Slot_CommandsToCobot)("SetSpeed 1000") SendCommand(Slot_CommandsToMotors)(ShowWindow) Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands\OLD EXAMPLES\LEO examples ' File MotorCalib_Zero_4.txt ' ============================================================================= '╔═══════════════════════════════════════════════════════════╗ '║ Name: MotorCalib_Zero_4_LIVIO.txt Date: 13 Dic 2022 ║ '║ Author: Leonardo ║ '║ Scope: Test all the functionality of the PVC-150 ║ '╠═══════════════════════════════════════════════════════════╣ '║Hardware: 5 FeeTech STS3215 new MOTOR ║ '╟───────────────────────────────────────────────────────────╢ '║ Note: Vacuum motor and valve at 6V ║ '║ FeeTech at 7.5V ║ '╟───────────────────────────────────────────────────────────╢ '║ISO Culture Gender Age Name ║ '╟───────────────────────────────────────────────────────────╢ '║ENG EN-US Male Adult Microsoft David Desktop ║ '║ENG EN-US Female Adult Microsoft Zira Desktop ║ '║ITA IT-IT Female Adult Microsoft Elsa Desktop ║ '║JPN JA-JP Female Adult Microsoft Haruka Desktop ║ '║ZHO ZH-CN Female Adult Microsoft Huihui Desktop ║ '╚═══════════════════════════════════════════════════════════╝ Option Speed 9 Beep "2500 20, 1500 100" 'Load images\PVCArm_150.jpg TTS SelectVoice "ENG" s1 = TTSvoices TTS SetVolume 100 TTS SetSpeed -2 TTS SelectVoice 3 'TTS Speak "Theremino Automation programming language is running." ' ╔════════════════════════════════════════════╗ ' ║ SLOT TEXT for COMMANDS and RESPONSES ║ ' ╚════════════════════════════════════════════╝ Variable Numeric Slot_CommandsToMotors = 50 Variable Numeric Slot_CommandsToCobot = 51 Variable Numeric Slot_ResponsesFromCobot = 52 Variable Numeric Slot_ExternalCommands = 53 Variable Numeric Slot_ResponsesFromQRDecode = 54 Variable Numeric Slot_WordRecognized = 55 ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █▀▀█ ▀▀█▀▀ ' ║ SLOT INITIALIZATIONS ║ ▀▀▀█ █ █ █ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄ █▄▄█ █ 'Variable Numeric Slot_Vacuum = 1 Variable Numeric Slot_FiveButton = 26 Variable Numeric Slot_LedR = 7 Variable Numeric Slot_LedG = 8 Variable Numeric Slot_LedB = 9 Variable Numeric Slot_Pedal = 10 Variable Numeric Slot_Pump = 11 Variable Numeric Slot_SignalScope = 13 Variable Numeric Slot_SetWayPoint = 14 Variable Numeric Slot_Slider1 = 2 Variable Numeric Slot_Slider2 = 3 Variable Numeric Slot_Slider3 = 4 Variable Numeric Slot_Slider4 = 5 Variable Numeric Slot_Slider5 = 6 Variable Numeric Slot_Encoder1 = 21 Variable Numeric Slot_Encoder2 = 22 Variable Numeric Slot_Encoder3 = 23 Variable Numeric Slot_Encoder4 = 24 Variable Numeric Slot_Encoder5 = 25 Variable Numeric Slot_EncoderSlow = 31 Variable Numeric Slot_M1 = 101 Variable Numeric Slot_M2 = 201 Variable Numeric Slot_M3 = 301 Variable Numeric Slot_M4 = 401 Variable Numeric Slot_M5 = 501 Variable Numeric Slot_M1pos = 102 Variable Numeric Slot_M2pos = 202 Variable Numeric Slot_M3pos = 302 Variable Numeric Slot_M4pos = 402 Variable Numeric Slot_M5pos = 502 Variable Numeric Slot_M1center = 123 Variable Numeric Slot_MotorsFPS = 56 ' ╔════════════════════════════════════════════╗ █▀▀▄ █ █ ▀▀█▀▀ ' ║ BUTTONS ║ █▀▀█ █ █ █ ' ╚════════════════════════════════════════════╝ █▄▄█ █▄▄█ █ Button 1 Label MotorFPS Button MotorFPS Text "NO MOTORS" Button MotorFPS Color Flashing7 Yellow DarkOrange Button 2 Label "MotorTemp" Button 3 Label CurrentMeter Button 4 Label GoTo12_70 Button GoTo12_70 Text "GoTo 12 70" Button GoTo12_70 Color Yellow Button 5 Label GoToHome Button GoToHome Text "GoTo Home" Button GoToHome Color Yellow Button 6 Label GoTo45 Button GoTo45 Text "GoTo 45" Button GoTo45 Color Gold Button 7 Label GoTo70 Button GoTo70 Text "GoTo 70" Button GoTo70 Color Yellow Button 8 Label CopyPositionsToDestinations Button CopyPositionsToDestinations Text "Copy Positions" + CRLF + "To Destinations" Button CopyPositionsToDestinations Color Orange 'Button 8 Label ActivateMotors 'Button ActivateMotors Text "Activate" + CRLF + "Motors" 'Button ActivateMotors Color Orange 'Button 6 Label SetCenterHere 'Button SetCenterHere Text "Set Center Here" 'Button SetCenterHere Color Orange ' 'Button 7 Label CalibrateToZero 'Button CalibrateToZero Text "Calibrate to Zero" 'Button CalibrateToZero Color Orange ' ================================================ 'Button 2 Label JobQrCode 'Button JobQrCode Text "JOB QRcode" 'Button JobQrCode Color Cyan ' 'Button 4 Label Sliders 'Button Sliders Text "Sliders" 'Button Sliders Color Cyan 'Button 6 Label Voice 'Button Voice Text "Voice" 'Button Voice Color PaleTurquoise Button 10 Label TunaCans Button TunaCans Text "Tuna cans" Button TunaCans Color Indigo Button 11 Label WanpyJob5 Button WanpyJob5 Text "Wanpy Job 5" Button WanpyJob5 Color Indigo Button 12 Label StartPump Button StartPump Text "Start Pump" Button StartPump Color Lime Button 13 Label StopPump Button StopPump Text "Stop Pump" Button StopPump Color Crimson Button 15 Label CloseAll Button CloseAll Text "CLOSE ALL" Button CloseAll Color Red Button 23 Label RecognizeEncoder Button RecognizeEncoder Text "Recognize" + CRLF + "Encoder" Button RecognizeEncoder Color LightBlue Button 24 Label CloseScopes Button CloseScopes Text "Close Scopes" Button CloseScopes Color SkyBlue Button 25 Label OpenScope_1 Button OpenScope_1 Text "Open Scope 1" Button OpenScope_1 Color PaleTurquoise Button 26 Label OpenScope_2 Button OpenScope_2 Text "Open Scope 2" Button OpenScope_2 Color PaleTurquoise Button 27 Label OpenScope_3 Button OpenScope_3 Text "Open Scope 3" Button OpenScope_3 Color PaleTurquoise Button 28 Label OpenScope_4 Button OpenScope_4 Text "Open Scope 4" Button OpenScope_4 Color PaleTurquoise Button 29 Label OpenScope_5 Button OpenScope_5 Text "Open Scope 5" Button OpenScope_5 Color PaleTurquoise Button 30 Label OpenFPS Button OpenFPS Text "Open FPS" Button OpenFPS Color PaleTurquoise Button 31 Label VoiceLoop Button VoiceLoop Text "VoiceLoop" Button VoiceLoop Color Blue Button 32 Label Say Button Say Text "Say" Button Say Color DeepSkyBlue ' ╔════════════════════════════════════════════╗ █ █▀▀█ █▀▀█ █▀▀▄ ' ║ LOAD APPS ║ █ █ █ █▄▄█ █ █ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄█ █ █ █▄▄█ Load Theremino_Motors.exe WaitApplicationsStarted '' ------------------------------------- ' MOTORS must be active before Cobot ' ------------------------------------- Load Theremino_HAL.exe Load Theremino_SlotViewer.exe Load Theremino_SlotViewer_Motors.exe Load Theremino_SlotViewer_STR.exe 'Load Theremino_MicroVideo.exe 'Load Theremino_QRdecoder.exe 'Load Theremino_VoiceCommands.exe Load Theremino_SlotViewer_Strings.exe Load Theremino_Cobot.exe 'WaitApplicationsStarted Load Hide ' ╔════════════════════════════════════════════╗ █▀▀▀ ▀▀█▀▀ █▀▀▀█ █▀▀▀█ ▀▀█▀▀ ' ║ EXECUTION START FROM HERE ║ ▀▀▀█ █ █▀▀▀█ █▀█▀▀ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █ █ █ ▀▄ █ ResetEncoders YellowOn Slot(Slot_SignalScope) = 1000 'CopyPositionsToDestinations 'DisableHomeButtons ' ------------------------- GOTO Homing - Command to Cobot 'WaitCobotReady 'SendCommand(Slot_CommandsToCobot)(GotoHoming) 'Homing 'Controls OpenTextBox 'Controls ClearTextBox ActivateMotors Loop Stop ' ╔════════════════════════════════════════════╗ █ █▀▀█ █▀▀█ █▀▀█ ' ║ LOOP ║ █ █ █ █ █ █▄▄█ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄█ █▄▄█ █ Label Loop CurrentMeter ShowMotorFPS PositionDelta TestTemp 'InterpretateVoiceCommands Encoder FiveButton TestPedal 'If Slot(Slot_MotorsFPS) < 5 ' Print "The robot is not in POWER ON or serial port is not correct." ' End 'EndIf 'If Slot(0) = -2 ' Print "Master disconnected." ' End 'EndIf Goto Loop Label PositionDelta Slot(109) = Slot(101) - Slot(102) Slot(209) = Slot(201) - Slot(202) Slot(309) = Slot(301) - Slot(302) Slot(409) = Slot(401) - Slot(402) Slot(509) = Slot(501) - Slot(502) Return Label TestTemp Variable Numeric TT1 Variable Numeric TT2 = 0 'TT2 = 0 For TT1 = 1 To 3 '5 TT2 = Max(TT2, Slot(TT1 * 100 + 6)) Next Button MotorTemp Text "MaxT " + TT2 + "°C" Return ' ╔════════════════════════════════════════════╗ ' ║ ENABLE/DISABLE BUTTONS ║ ' ╚════════════════════════════════════════════╝ Label EnableAllButtons For v1 = 1 To 48 Button v1 Enabled Next Return Label DisableAllButtons For v1 = 1 To 48 Button v1 Disabled Next Return ' ╔════════════════════════════════════════════╗ ' ║ WAIT COBOT READY ║ ' ╚════════════════════════════════════════════╝ Label WaitCobotReady Variable Numeric WCR1 For WCR1 = 1 To Infinity Wait Seconds 0.05 If SlotText(Slot_ResponsesFromCobot) = "Ready" Exit EndIf Next Return ' ╔════════════════════════════════════════════╗ ' ║ WAIT APPS STARTED ║ ' ╚════════════════════════════════════════════╝ Label WaitApplicationsStarted Slot(Slot_MotorsFPS) = 0 Wait Slot(Slot_MotorsFPS) > 10 Wait Seconds 0.1 Return ' ╔════════════════════════════════════════════╗ █▀▀▀ ▀▀█▀▀ █▀▀█ █▀▀█ ' ║ STOP EVENT (when pressing stop button) ║ ▀▀▀█ █ █ █ █▄▄█ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █▄▄█ █ Label EventStop StopPump StopCobot Slot(Slot_SignalScope) = 0 ' GoToShow ' StopCobotAndGotoHoming End 'Label StopCobotAndGotoHoming ' 'StopCobot ' WaitMotorsNotMoving ' 'GotoSafePosition 'Return Label GotoSafePosition SendCommand(Slot_CommandsToCobot)(GotoHoming) WaitMotorsNotMoving Return ' ╔════════════════════════════════════════════╗ █▀▀ █ █▀▀█ █▀▀▀ █▀▀▀ ' ║ CLOSE ALL (when pressing X on form) ║ █ █ █ █ ▀▀▀█ █▀▀ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█ ▄▄▄█ █▄▄▄ Label CloseAll StopPump StopCobot Slot(Slot_SignalScope) = 0 ' GoToShow ' StopCobotAndGotoHoming Load CloseAll End ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand '(Destination Slot)(Command String) Variable Numeric SC1 Variable String SC2 Variable Numeric SC3 = 0.5 '<-- The timeout in seconds Variable Numeric SC4 SlotText SC1 = SC2 For SC4 = 0.1 To SC3 Step 0.1 If SlotText(SC1) = "" Exit EndIf Wait Seconds 0.1 Next Return ' ============================================================= ' COMMANDS to Cobot ' ============================================================= Label ExecCobot SendCommand(Slot_CommandsToCobot)(EnableRepeat) SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label StopCobot SendCommand(Slot_CommandsToCobot)(StopExecution) Return Label ArrowUpCobot SendCommand(Slot_CommandsToCobot)(ArrowUp) Return Label ArrowDownCobot SendCommand(Slot_CommandsToCobot)(ArrowDown) Return Label ExecuteCobotFromSelectedLine SendCommand(Slot_CommandsToCobot)(StartExecution) Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █ █▀█ ' ║ S U B R O U T I N E A R E A ║ ▀▀▀█ █ █ █▀▀█ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄█ █▄▄█ Label EnableHomeButtons For v1 = 17 To 22 Button v1 Enabled Next Return Label DisableHomeButtons For v1 = 17 To 22 Button v1 Disabled Next Return Label CurrentMeter Variable Numeric mA mA = Slot(108) + Slot(208) + Slot (308) + Slot (408) + Slot (508) mA = FilterLP(mA, 0.1, 1) '<-- Filter 0.5 seconds / 1 pole Button CurrentMeter Text "Current " + Str(mA, "0 mA") Return Label ShowMotorFPS Variable String MotorsAreEnabled Variable Numeric SMF1 = Slot(Slot_MotorsFPS) If SMF1 > 30 If MotorsAreEnabled <> "TRUE" MotorsAreEnabled = "TRUE" Button MotorFPS Color GreenYellow EndIf Button MotorFPS Text "FPS " + Str(SMF1) Else If MotorsAreEnabled = "TRUE" MotorsAreEnabled = "FALSE" Button MotorFPS Color Flashing7 Yellow DarkOrange Button MotorFPS Text "NO MOTORS" EndIf EndIf Return Label MotorFPS If MotorsAreEnabled = "TRUE" SendCommand(Slot_CommandsToMotors)(DisableConnection) Else SendCommand(Slot_CommandsToMotors)(EnableConnection) EndIf Return Label StartPump BlueOn 'Slot(Slot_SignScope) = 1000 Slot(Slot_Pump) = 1000 Button StartPump Disabled Button StopPump Enabled Wait Seconds 0.4 'If Slot(Slot_Vacuum) > 56 ' 'Beep "500, 300, 0, 300" ' 'SayVacuumProblem ' RedOn ' StopPump ' Print "Vacuum Problem" + CRLF ' 'CobotShowPoint ' Print "Execution stopped" + CRLF ' RedBlink ' End 'Else ' Print "Target picked" 'EndIf Return Label StopPump Slot(Slot_Pump) = 0 Button StopPump Disabled Button StartPump Enabled GreenOn Return Label GoTo70 MoveMotorTo(4)(70)(0.1) MoveMotorTo(1)(70)(0.1) MoveMotorTo(3)(70)(0.1) MoveMotorTo(2)(70)(0.1) MoveMotorTo(5)(70)(0.1) Return ' nota: quando si muove il 2, il 3 non deve mai avere ' un valore superiore a 50 altrimenti salta Label GoTo12_70 MoveMotorTo(4)(12)(0.1) MoveMotorTo(5)(70)(0.1) MoveMotorTo(1)(12)(0.1) MoveMotorTo(3)(12)(0.1) 'Breakpoint MoveMotorTo(2)(12)(0.1) MoveMotorTo(3)(12)(0.1) Return Label GoToHome MoveMotorTo(1)(10)(0.1) MoveMotorTo(2)(10)(0.1) MoveMotorTo(3)(125)(0.1) MoveMotorTo(5)(120)(0.1) MoveMotorTo(4)(10)(0.1) Return Label GoTo45 MoveMotorTo(4)(45)(0.1) MoveMotorTo(1)(45)(0.1) MoveMotorTo(2)(45)(0.1) MoveMotorTo(3)(45)(0.1) MoveMotorTo(5)(135)(0.1) MoveMotorTo(4)(45)(0.1) Return Label TestPedal Variable Numeric TestPedalEnabled = 1 If TestPedalEnabled = 1 If Slot(Slot_Pedal) > 500 Slot(Slot_SetWayPoint) = 1000 Else Slot(Slot_SetWayPoint) = 0 EndIf EndIf Return ' ╔════════════════════════════════════════════╗ █▀▀ █▀█ █ █ ▀▀█▀▀ ' ║ FIVE PUSH BUTTONS ║ ▀▀█ █▀▀█ █ █ █ ' ╚════════════════════════════════════════════╝ ▄▄█ █▄▄█ █▄▄█ █ Variable String PressedButton Label FiveButton Variable Numeric FB0 Variable Numeric FB1 Variable Numeric FB2 ' ------------------------------ Read the value two times FB1 = Slot(Slot_FiveButton) FB2 = Slot(Slot_FiveButton) ' ------------------------------ If similar values If Abs(FB2 - FB1) < 5 ' -------------------------- If armed If FB0 = 0 FB0 = 1 Select True Case FB1 > 500 TestPedalEnabled = 1 Print "" PressedButton = "" Case FB1 > 250 Print "red" PressedButton = "red" ExecCobot Case FB1 > 120 Print "white" PressedButton = "white" ExecuteCobotFromSelectedLine Case FB1 > 56 Print "green" PressedButton = "green" ArrowDownCobot Case FB1 > 15 Print "blue" PressedButton = "blue" ArrowUpCobot CaseElse Print "yellow" PressedButton = "yellow" TestPedalEnabled = 0 Slot(Slot_SetWayPoint) = 1000 EndSelect EndIf EndIf ' ------------------------------ Rearm buttons If FB1 > 500 FB0 = 0 EndIf Return Label CloseScopes Load CloseApps Theremino_SignalScope_M1.exe Load CloseApps Theremino_SignalScope_M2.exe Load CloseApps Theremino_SignalScope_M3.exe Load CloseApps Theremino_SignalScope_M4.exe Load CloseApps Theremino_SignalScope_M5.exe Load CloseApps Theremino_SignalScope_FPS.exe Return Label OpenScope_1 Load Theremino_SignalScope_M1.exe Return Label OpenScope_2 Load Theremino_SignalScope_M2.exe Return Label OpenScope_3 Load Theremino_SignalScope_M3.exe Return Label OpenScope_4 Load Theremino_SignalScope_M4.exe Return Label OpenScope_5 Load Theremino_SignalScope_M5.exe Return Label OpenFPS Load Theremino_SignalScope_FPS.exe Return ' ╔════════════════════════════════════════════╗ █ █▀▀ █▀▄ ' ║ LED COLORS ║ █ █▀ █ █ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█ Label RedOn Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Return Label MagentaOn Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label YellowOn Slot Slot_LedR = 900 Slot Slot_LedG = 400 Slot Slot_LedB = 0 Return Label GreenOn Slot Slot_LedR = 0 Slot Slot_LedG = 1000 Slot Slot_LedB = 0 Return Label BlueOn Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label WhiteOn Slot Slot_LedR = 1000 Slot Slot_LedG = 1000 Slot Slot_LedB = 1000 Return Label RgbOff Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Return Label RedBlink RedOn WhiteOn Return ' ╔═════════════════════════╗ █▀▀▀ █▀▀█ █▄ ▄█ █▀▀ █▀▀▀ █▀▀█ █▀█ ' ║ COMMANDS FROM COBOT ║ █ █ █ █ ▀ █ █▀ █ █ █ █▀▀█ ' ╚═════════════════════════╝ █▄▄▄ █▄▄█ █ █ ▄ █ ▄ █▄▄▄ █▄▄█ █▄▄█ Label Event_ExternalCommands ' ------------------------------------------------------ Do not print lines containing '' 'Print " Exec: " + CommandText + CRLF ' ------------------------------------------------------ Select CommandText ' ---------------------------------------------- ACTIONS Case "RedOn" RedOn ClearCommand Case "GreenOn" GreenOn ClearCommand Case "BlueOn" BlueOn ClearCommand Case "WhiteOn" WhiteOn ClearCommand Case "MagentaOn" MagentaOn ClearCommand Case "YellowOn" YellowOn ClearCommand Case "Beep" Beep 880-100 ClearCommand Case "Pause" Wait Seconds GetSeparatedString(CommandText, 1) ClearCommand Case "StartPump" StartPump ClearCommand Case "StopPump" StopPump ClearCommand Case "MemorizeQrCode" Variable Numeric MQR1 For MQR1 = 1 To 5 QrCode = SlotText(Slot_ResponsesFromQRDecode) Print QrCode If QrCode <> "" Exit EndIf If MQR1 = 5 SendCommand(Slot_CommandsToCobot)(StopExecution) EndIf Wait Seconds 1 Next ClearCommand Case "ExecQrCode" ExecQRcode ClearCommand Case "StartFichesPick" StartFichesPick ClearCommand Case "EndOfTask" EndOfTask ClearCommand CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + CommandText + CRLF Beep ClearCommand Stop ' EndSelect Return Label ClearCommand SlotText(Slot_ExternalCommands) = "" Return ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █▄ █ █▀▀▀ ' ║ WANPY 5 ║ █ █ █▄▄█ █ ▀█ ▀▀▀█ ' ╚════════════════════════════════════════════╝ ▀▄▀ █ █ █ █ ▄▄▄█ Label WanpyJob5 TTS Speak "Wanpy job started." Controls OpenTextBox Controls ClearTextBox StartTime = ElapsedTime Wanpy_A5toB1 Return Variable String Status = "A5toB1" Label EndOfTask PrintTime StartTimePartial = ElapsedTime Select Status Case "A5toB1" 'Wanpy_B1toA5 Wanpy_A4toB2 Case "A4toB2" Wanpy_A3toB3 Case "A3toB3" Wanpy_A2toB4 Case "A2toB4" Wanpy_A1toB5 Case "A1toB5" Wanpy_B5toA1 Case "B5toA1" Wanpy_B4toA2 Case "B4toA2" Wanpy_B3toA3 Case "B3toA3" Wanpy_B2toA4 Case "B2toA4" Wanpy_B1toA5 Case "B1toA5" StartTime = ElapsedTime Print CRLF Wanpy_A5toB1 EndSelect Return Variable Numeric StartTime Variable Numeric StartTimePartial Variable String Time Label PrintTime Time = "Partial time = " Time = Time + PadLeft(Format(ElapsedTime - StartTimePartial, "0.0"),4) Time = Time + " Total time = " Time = Time + PadLeft(Format(ElapsedTime - StartTime, "0.0"),4) Print Status + " " + Time + CRLF Return Label Wanpy_A5toB1 Status = "A5toB1" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A5toB1.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A4toB2 Status = "A4toB2" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A4toB2.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A3toB3 Status = "A3toB3" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A3toB3.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A2toB4 Status = "A2toB4" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A2toB4.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A1toB5 Status = "A1toB5" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A1toB5.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B5toA1 Status = "B5toA1" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B5toA1.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B4toA2 Status = "B4toA2" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B4toA2.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B3toA3 Status = "B3toA3" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B3toA3.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B2toA4 Status = "B2toA4" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B2toA4.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B1toA5 Status = "B1toA5" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B1toA5.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return ' ╔════════════════════════════════════════════╗ █▀▀█ █▀▀█ █▀▀▀ ' ║ QR CODE ║ █ █ █▄▄█ █ ' ╚════════════════════════════════════════════╝ █▄██▄ █ ▀▄ █▄▄▄ Label JobQrCode TTS Speak "QR code recognition and action related is started." StartFichesPick Return Label StartFichesPick BlueOn SendCommand(Slot_CommandsToCobot)("LoadSequence fiches_pick.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label ExecQRcode Variable String QrCode Select QrCode Case "WHITE" WhiteOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_white.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "RED" RedOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_red.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "GREEN" GreenOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_green.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "BLUE" BlueOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_Place_blue.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "BLACK" RgbOff SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_black.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) CaseElse Controls OpenTextBox Print CRLF + " Unrecognized color command: " + CommandText + CRLF StopPump Beep ClearCommand Stop EndSelect Return ' ╔════════════════════════════════════════════╗ ▀▀█▀▀ █ █ █▄ █ ' ║ TUNA ║ █ █ █ █ ▀█ ' ╚════════════════════════════════════════════╝ █ █▄▄█ █ █ Label TunaCans TTS Speak "Tuna can handling." YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Tuna_Cans.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █ █▀▀▄ ' ║ SLIDERS ║ ▀▀▀█ █ █ █ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄ █ █▄▄█ Variable Numeric SLD Label Sliders BlueOn 'Button Sliders Color Flashing7 Blue White For SLD = 1 To Infinity Slot(Slot_M1) = Slot(Slot_Slider1) Slot(Slot_M2) = Slot(Slot_Slider2) Slot(Slot_M3) = Slot(Slot_Slider3) + Slot(Slot_Slider2) Slot(Slot_M4) = Slot(Slot_Slider4) Slot(Slot_M5) = Slot(Slot_Slider5) Next Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █▀▀█ ▀▄ ▄▀ ' ║ SAY ║ ▀▀▀█ █▄▄█ ▀▄▀ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █ █ Label Say TTS SelectVoice "ENGF" TTS Speak "Today is a beautiful day because we spend time together." Wait TTSready TTS SelectVoice "ITA FEM" TTS Speak "Oggi è una bella giornata perche passeremo del tempo insieme." Wait TTSready TTS SelectVoice "JPN" TTS Speak "私たちは一緒に時間を過ごすので、今日は美しい日です。" Wait TTSready TTS SelectVoice "ZHO" TTS Speak "今天是美好的一天,因为我们共度时光。" Wait TTSready Return ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █ █▀▀▀ █▀▀▀ ' ║ VOICE COMMANDS ║ █ █ █ █ █ █ █▀▀ ' ╚════════════════════════════════════════════╝ █ █▄▄█ █ █▄▄▄ █▄▄▄ Label Voice ClearVoiceCommand If VoiceCommandsStatus = "active" VoiceCommandsStatus = "" 'Button Voice Color PaleTurquoise Else VoiceCommandsStatus = "active" 'Button Voice Color Flashing7 Orange White EndIf Return Variable String Word Variable String VoiceCommandsStatus Label InterpretateVoiceCommands If VoiceCommandsStatus = "active" If SlotText(Slot_WordRecognized) <> "" Word = SlotText(Slot_WordRecognized) Print Word + " " Interpretate ClearVoiceCommand EndIf EndIf Return Variable String ShowingType Label Interpretate Select Word Case "show.fiches" If ShowingType = "" WhiteOn ShowingType = "Fiches" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Fiches.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "show.wanpy" If ShowingType = "" YellowOn ShowingType = "Wanpy" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Wanpy.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "show.tuna" If ShowingType = "" GreenOn ShowingType = "Tuna" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Tuna.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf '------------------------------------------------------------------------- Case "release" Select ShowingType Case "fiches" WhiteOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Fiches.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" Case "wanpy" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Wanpy.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" Case "tuna" GreenOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Tuna.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" CaseElse ' EndSelect '------------------------------------------------------------------------- Case "goto.center" If ShowingType = "" RedOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_goto_Center.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "goto.Homing" If ShowingType = "" MagentaOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_goto_Homing.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf '------------------------------------------------------------------------- CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + Word + CRLF Beep ClearCommand Stop EndSelect Return Label ClearVoiceCommand SlotText(Slot_WordRecognized) = "" Return ' ╔════════════════════════════════════════════╗ ▀▀█▀▀ █▀▀█ █ █▀▀█ █ ' ║ T R I A L S ║ █ █▄▄▀ █ █▄▄█ █ ' ╚════════════════════════════════════════════╝ █ █ ▀▄ █ █ █ █▄▄ ' ╔════════════════════════════════════════════╗ █▀▀▀ █▄ █ █▀▀▀ ' ║ ENCODERS ║ █▀▀ █ ▀█ █ ' ╚════════════════════════════════════════════╝ █▄▄▄ █ █ █▄▄▄ Variable Numeric EncoderSteps1 Variable Numeric OldEncoderSteps1 = Slot(Slot_Encoder1) Variable Numeric Difference1 Variable Numeric EncoderSteps2 Variable Numeric OldEncoderSteps2 = Slot(Slot_Encoder2) Variable Numeric Difference2 Variable Numeric EncoderSteps3 Variable Numeric OldEncoderSteps3 = Slot(Slot_Encoder3) Variable Numeric Difference3 Variable Numeric EncoderSteps4 Variable Numeric OldEncoderSteps4 = Slot(Slot_Encoder4) Variable Numeric Difference4 Variable Numeric EncoderSteps5 Variable Numeric OldEncoderSteps5 = Slot(Slot_Encoder5) Variable Numeric Difference5 Label RecognizeEncoder Slot(0) = Recognize Return Label Encoder '------------------------------------------------ encoder1 to mot 1 or 6 EncoderSteps1 = Slot(Slot_Encoder1) Difference1 = EncoderSteps1 - OldEncoderSteps1 OldEncoderSteps1 = EncoderSteps1 If Difference1 > 32000 Difference1 = Difference1 - 65536 EndIf If Difference1 < -32000 Difference1 = Difference1 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference1 = Difference1 * 0.1 EndIf If PressedButton <> "yellow" Slot(Slot_M1) = Limit(Slot (Slot_M1) + Difference1, 10, 163) Else 'Slot(Slot_M6) = Limit(Slot (Slot_M6) + Difference1, -130, +130) EndIf '------------------------------------------------ read encoder2 EncoderSteps2 = Slot(Slot_Encoder2) Difference2 = EncoderSteps2 - OldEncoderSteps2 OldEncoderSteps2 = EncoderSteps2 If Difference2 > 32000 Difference2 = Difference2 - 65536 EndIf If Difference2 < -32000 Difference2 = Difference2 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference2 = Difference2 * 0.1 EndIf Slot(Slot_M2) = Limit(Slot (Slot_M2) + Difference2, 10, 98) '------------------------------------------------ read encoder3 EncoderSteps3 = Slot(Slot_Encoder3) Difference3 = EncoderSteps3 - OldEncoderSteps3 OldEncoderSteps3 = EncoderSteps3 If Difference3 > 32000 Difference3 = Difference3 - 65536 EndIf If Difference3 < -32000 Difference3 = Difference3 + 65536 EndIf Difference3 = Difference3 * 0.5 If Slot(Slot_EncoderSlow) < 500 Difference3 = Difference3 * 0.1 EndIf Slot(Slot_M3) = Limit(Slot (Slot_M3) + Difference3, 5, 94) '------------------------------------------------ read encoder4 EncoderSteps4 = Slot(Slot_Encoder4) Difference4 = EncoderSteps4 - OldEncoderSteps4 OldEncoderSteps4 = EncoderSteps4 If Difference4 > 32000 Difference4 = Difference4 - 65536 EndIf If Difference4 < -32000 Difference4 = Difference4 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference4 = Difference4 * 0.01 EndIf Slot(Slot_M4) = Limit(Slot (Slot_M4) + Difference4, 10, 190) '------------------------------------------------ read encoder5 EncoderSteps5 = Slot(Slot_Encoder5) Difference5 = EncoderSteps5 - OldEncoderSteps5 OldEncoderSteps5 = EncoderSteps5 If Difference5 > 32000 Difference5 = Difference5 - 65536 EndIf If Difference5 < -32000 Difference5 = Difference5 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference5 = Difference5 * 0.1 EndIf Slot(Slot_M5) = Limit(Slot (Slot_M5) + Difference5, 62, 298) Return Label ResetEncoders OldEncoderSteps1 = Slot(Slot_Encoder1) OldEncoderSteps2 = Slot(Slot_Encoder2) OldEncoderSteps3 = Slot(Slot_Encoder3) OldEncoderSteps4 = Slot(Slot_Encoder4) OldEncoderSteps5 = Slot(Slot_Encoder5) Return ' ╔════════════════════════════════════════════╗ █▀▀█ █▀▀█ █ ' ║ CALIBRATIONS ║ █ █▄▄█ █ ' ╚════════════════════════════════════════════╝ █▄▄█ █ █ █▄▄▄ Label ResetAllMultiturnValues SendCommand(Slot_CommandsToMotors)("ResetAllMultiturnValues") Return Label CopyPositionsToDestinations Slot Slot_M1 = Slot(Slot_M1pos) Slot Slot_M2 = Slot(Slot_M2pos) Slot Slot_M3 = Slot(Slot_M3pos) Slot Slot_M4 = Slot(Slot_M4pos) Slot Slot_M5 = Slot(Slot_M5pos) Return Label CalibrateMotorToZero '(Motor Number) Variable Numeric CMTZ1 SendCommand(Slot_CommandsToMotors)("Calibrate Motor " + CMTZ1 + " To 0") CMTZ1 = (CMTZ1*100-100) Slot(Slot_M1 + CMTZ1) = Slot(Slot_M1pos + CMTZ1) Return 'Label SetMotorCenterHere '(Motor Number) ' Variable Numeric SMC1 ' SMC1 = Slot_M1center + (SMC1*100-100) ' Slot SMC1 = 128 ' Wait Seconds 0.1 ' Slot SMC1 = 1 ' Wait Seconds 0.1 'Return Label SetMotor_ON '(Motor Number) Variable Numeric SMON1 SMON1 = Slot_M1center + (SMON1*100-100) Slot SMON1 = 0 Wait Seconds 0.1 Slot SMON1 = 1 Wait Seconds 0.1 Return Label SetMotor_OFF '(Motor Number) Variable Numeric SMOFF1 SMOFF1 = Slot_M1center + (SMOFF1*100-100) Slot SMOFF1 = 0 Wait Seconds 0.1 Slot SMOFF1 = 1 Wait Seconds 0.1 Return Label WaitMotorsNotMoving Variable Numeric WMN1 For WMN1 = 1 To 5 WaitMotor(WMN1)(0.1) Next Return ' ------------------------------------------------------- ' The "Wait seconds" parameter is a initial delay ' If this delay is short and the motor starts slowly ' then the "WaitMotor" functions could exit immediately ' ------------------------------------------------------- Label WaitMotor '(Motor Number)(Wait seconds) Variable Numeric WM1 Variable Numeric WM2 WM1 = (WM1*100-100) Wait Seconds WM2 Variable Numeric WM3 For WM3 = 0 To Infinity If Slot(Slot_M1 + 2 + WM1) = 0 Or Key("CTRL") ' test Velocity Exit For EndIf 'If Slot(Slot_M1 + 6 + WM1) = 0 Or Key("CTRL") ' test Moving ' Exit For 'EndIf Next Return Label MoveMotorTo '(Motor Number)(Destination)(Wait seconds) Variable Numeric MMT1 Variable Numeric MMT2 Variable Numeric MMT3 Slot(Slot_M1 + MMT1*100-100) = MMT2 WaitMotor(MMT1)(MMT3) Return ' ╔════════════════════════════════════════════╗ ' ║ ACTIVATE MOTORS ║ ' ╚════════════════════════════════════════════╝ Label ActivateMotors ResetAllMultiturnValues Variable Numeric AM1 For AM1 = 1 To 5 SetMotor_ON(AM1) Next SendCommand(Slot_CommandsToCobot)("SetTorque 200") SendCommand(Slot_CommandsToCobot)("SetAcceleration 100") SendCommand(Slot_CommandsToCobot)("SetSpeed 1000") SendCommand(Slot_CommandsToMotors)(ShowWindow) Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands\OLD EXAMPLES\LEO examples ' File MotorCalib_Zero_4_LIVIO.txt ' ============================================================================= '╔═══════════════════════════════════════════════════════════╗ '║ Name: MotorCalib_Zero_4_LIVIO.txt Date: 13 Dic 2022 ║ '║ Author: Leonardo ║ '║ Scope: Test all the functionality of the PVC-150 ║ '╠═══════════════════════════════════════════════════════════╣ '║Hardware: 5 FeeTech STS3215 new MOTOR ║ '╟───────────────────────────────────────────────────────────╢ '║ Note: Vacuum motor and valve at 6V ║ '║ FeeTech at 7.5V ║ '╟───────────────────────────────────────────────────────────╢ '║ISO Culture Gender Age Name ║ '╟───────────────────────────────────────────────────────────╢ '║ENG EN-US Male Adult Microsoft David Desktop ║ '║ENG EN-US Female Adult Microsoft Zira Desktop ║ '║ITA IT-IT Female Adult Microsoft Elsa Desktop ║ '║JPN JA-JP Female Adult Microsoft Haruka Desktop ║ '║ZHO ZH-CN Female Adult Microsoft Huihui Desktop ║ '╚═══════════════════════════════════════════════════════════╝ Option Speed 9 Beep "2500 20, 1500 100" 'Load images\PVCArm_150.jpg TTS SelectVoice "ENG" s1 = TTSvoices TTS SetVolume 100 TTS SetSpeed -2 TTS SelectVoice 3 'TTS Speak "Theremino Automation programming language is running." ' ╔════════════════════════════════════════════╗ ' ║ SLOT TEXT for COMMANDS and RESPONSES ║ ' ╚════════════════════════════════════════════╝ Variable Numeric Slot_CommandsToMotors = 50 Variable Numeric Slot_CommandsToCobot = 51 Variable Numeric Slot_ResponsesFromCobot = 52 Variable Numeric Slot_ExternalCommands = 53 Variable Numeric Slot_ResponsesFromQRDecode = 54 Variable Numeric Slot_WordRecognized = 55 ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █▀▀█ ▀▀█▀▀ ' ║ SLOT INITIALIZATIONS ║ ▀▀▀█ █ █ █ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄ █▄▄█ █ 'Variable Numeric Slot_Vacuum = 1 Variable Numeric Slot_FiveButton = 26 Variable Numeric Slot_LedR = 7 Variable Numeric Slot_LedG = 8 Variable Numeric Slot_LedB = 9 Variable Numeric Slot_Pedal = 10 Variable Numeric Slot_Pump = 11 Variable Numeric Slot_SignalScope = 13 Variable Numeric Slot_SetWayPoint = 14 Variable Numeric Slot_Slider1 = 2 Variable Numeric Slot_Slider2 = 3 Variable Numeric Slot_Slider3 = 4 Variable Numeric Slot_Slider4 = 5 Variable Numeric Slot_Slider5 = 6 Variable Numeric Slot_Encoder1 = 21 Variable Numeric Slot_Encoder2 = 22 Variable Numeric Slot_Encoder3 = 23 Variable Numeric Slot_Encoder4 = 24 Variable Numeric Slot_Encoder5 = 25 Variable Numeric Slot_EncoderSlow = 31 Variable Numeric Slot_M1 = 101 Variable Numeric Slot_M2 = 201 Variable Numeric Slot_M3 = 301 Variable Numeric Slot_M4 = 401 Variable Numeric Slot_M5 = 501 Variable Numeric Slot_M1pos = 102 Variable Numeric Slot_M2pos = 202 Variable Numeric Slot_M3pos = 302 Variable Numeric Slot_M4pos = 402 Variable Numeric Slot_M5pos = 502 Variable Numeric Slot_M1center = 123 Variable Numeric Slot_MotorsFPS = 56 ' ╔════════════════════════════════════════════╗ █▀▀▄ █ █ ▀▀█▀▀ ' ║ BUTTONS ║ █▀▀█ █ █ █ ' ╚════════════════════════════════════════════╝ █▄▄█ █▄▄█ █ Button 1 Label MotorFPS Button MotorFPS Text "NO MOTORS" Button MotorFPS Color Flashing7 Yellow DarkOrange Button 2 Label "MotorTemp" Button 3 Label CurrentMeter Button 4 Label GoTo12_70 Button GoTo12_70 Text "GoTo 12 70" Button GoTo12_70 Color Yellow Button 5 Label GoToHome Button GoToHome Text "GoTo Home" Button GoToHome Color Yellow Button 6 Label GoTo45 Button GoTo45 Text "GoTo 45" Button GoTo45 Color Gold Button 7 Label GoTo70 Button GoTo70 Text "GoTo 70" Button GoTo70 Color Yellow Button 8 Label CopyPositionsToDestinations Button CopyPositionsToDestinations Text "Copy Positions" + CRLF + "To Destinations" Button CopyPositionsToDestinations Color Orange 'Button 8 Label ActivateMotors 'Button ActivateMotors Text "Activate" + CRLF + "Motors" 'Button ActivateMotors Color Orange 'Button 6 Label SetCenterHere 'Button SetCenterHere Text "Set Center Here" 'Button SetCenterHere Color Orange ' 'Button 7 Label CalibrateToZero 'Button CalibrateToZero Text "Calibrate to Zero" 'Button CalibrateToZero Color Orange ' ================================================ 'Button 2 Label JobQrCode 'Button JobQrCode Text "JOB QRcode" 'Button JobQrCode Color Cyan ' 'Button 4 Label Sliders 'Button Sliders Text "Sliders" 'Button Sliders Color Cyan 'Button 6 Label Voice 'Button Voice Text "Voice" 'Button Voice Color PaleTurquoise Button 10 Label TunaCans Button TunaCans Text "Tuna cans" Button TunaCans Color Indigo Button 11 Label WanpyJob5 Button WanpyJob5 Text "Wanpy Job 5" Button WanpyJob5 Color Indigo Button 12 Label StartPump Button StartPump Text "Start Pump" Button StartPump Color Lime Button 13 Label StopPump Button StopPump Text "Stop Pump" Button StopPump Color Crimson Button 15 Label CloseAll Button CloseAll Text "CLOSE ALL" Button CloseAll Color Red Button 23 Label RecognizeEncoder Button RecognizeEncoder Text "Recognize" + CRLF + "Encoder" Button RecognizeEncoder Color LightBlue Button 24 Label CloseScopes Button CloseScopes Text "Close Scopes" Button CloseScopes Color SkyBlue Button 25 Label OpenScope_1 Button OpenScope_1 Text "Open Scope 1" Button OpenScope_1 Color PaleTurquoise Button 26 Label OpenScope_2 Button OpenScope_2 Text "Open Scope 2" Button OpenScope_2 Color PaleTurquoise Button 27 Label OpenScope_3 Button OpenScope_3 Text "Open Scope 3" Button OpenScope_3 Color PaleTurquoise Button 28 Label OpenScope_4 Button OpenScope_4 Text "Open Scope 4" Button OpenScope_4 Color PaleTurquoise Button 29 Label OpenScope_5 Button OpenScope_5 Text "Open Scope 5" Button OpenScope_5 Color PaleTurquoise Button 30 Label OpenFPS Button OpenFPS Text "Open FPS" Button OpenFPS Color PaleTurquoise Button 31 Label VoiceLoop Button VoiceLoop Text "VoiceLoop" Button VoiceLoop Color Blue Button 32 Label Say Button Say Text "Say" Button Say Color DeepSkyBlue ' ╔════════════════════════════════════════════╗ █ █▀▀█ █▀▀█ █▀▀▄ ' ║ LOAD APPS ║ █ █ █ █▄▄█ █ █ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄█ █ █ █▄▄█ Load Theremino_Motors.exe WaitApplicationsStarted '' ------------------------------------- ' MOTORS must be active before Cobot ' ------------------------------------- Load Theremino_HAL.exe Load Theremino_SlotViewer.exe Load Theremino_SlotViewer_Motors.exe Load Theremino_SlotViewer_STR.exe 'Load Theremino_MicroVideo.exe 'Load Theremino_QRdecoder.exe 'Load Theremino_VoiceCommands.exe Load Theremino_SlotViewer_Strings.exe Load Theremino_Cobot.exe 'WaitApplicationsStarted Load Hide ' ╔════════════════════════════════════════════╗ █▀▀▀ ▀▀█▀▀ █▀▀▀█ █▀▀▀█ ▀▀█▀▀ ' ║ EXECUTION START FROM HERE ║ ▀▀▀█ █ █▀▀▀█ █▀█▀▀ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █ █ █ ▀▄ █ ResetEncoders YellowOn Slot(Slot_SignalScope) = 1000 'CopyPositionsToDestinations 'DisableHomeButtons ' ------------------------- GOTO Homing - Command to Cobot 'WaitCobotReady 'SendCommand(Slot_CommandsToCobot)(GotoHoming) 'Homing 'Controls OpenTextBox 'Controls ClearTextBox ActivateMotors Loop Stop ' ╔════════════════════════════════════════════╗ █ █▀▀█ █▀▀█ █▀▀█ ' ║ LOOP ║ █ █ █ █ █ █▄▄█ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄█ █▄▄█ █ Label Loop CurrentMeter ShowMotorFPS PositionDelta TestTemp 'InterpretateVoiceCommands Encoder FiveButton TestPedal 'If Slot(Slot_MotorsFPS) < 5 ' Print "The robot is not in POWER ON or serial port is not correct." ' End 'EndIf 'If Slot(0) = -2 ' Print "Master disconnected." ' End 'EndIf Goto Loop Label PositionDelta Slot(109) = Slot(101) - Slot(102) Slot(209) = Slot(201) - Slot(202) Slot(309) = Slot(301) - Slot(302) Slot(409) = Slot(401) - Slot(402) Slot(509) = Slot(501) - Slot(502) Return Label TestTemp Variable Numeric TT1 Variable Numeric TT2 = 0 'TT2 = 0 For TT1 = 1 To 3 '5 TT2 = Max(TT2, Slot(TT1 * 100 + 6)) Next Button MotorTemp Text "MaxT " + TT2 + "°C" Return ' ╔════════════════════════════════════════════╗ ' ║ ENABLE/DISABLE BUTTONS ║ ' ╚════════════════════════════════════════════╝ Label EnableAllButtons For v1 = 1 To 48 Button v1 Enabled Next Return Label DisableAllButtons For v1 = 1 To 48 Button v1 Disabled Next Return ' ╔════════════════════════════════════════════╗ ' ║ WAIT COBOT READY ║ ' ╚════════════════════════════════════════════╝ Label WaitCobotReady Variable Numeric WCR1 For WCR1 = 1 To Infinity Wait Seconds 0.05 If SlotText(Slot_ResponsesFromCobot) = "Ready" Exit EndIf Next Return ' ╔════════════════════════════════════════════╗ ' ║ WAIT APPS STARTED ║ ' ╚════════════════════════════════════════════╝ Label WaitApplicationsStarted Slot(Slot_MotorsFPS) = 0 Wait Slot(Slot_MotorsFPS) > 10 Wait Seconds 0.1 Return ' ╔════════════════════════════════════════════╗ █▀▀▀ ▀▀█▀▀ █▀▀█ █▀▀█ ' ║ STOP EVENT (when pressing stop button) ║ ▀▀▀█ █ █ █ █▄▄█ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █▄▄█ █ Label EventStop StopPump StopCobot Slot(Slot_SignalScope) = 0 ' GoToShow ' StopCobotAndGotoHoming End 'Label StopCobotAndGotoHoming ' 'StopCobot ' WaitMotorsNotMoving ' 'GotoSafePosition 'Return Label GotoSafePosition SendCommand(Slot_CommandsToCobot)(GotoHoming) WaitMotorsNotMoving Return ' ╔════════════════════════════════════════════╗ █▀▀ █ █▀▀█ █▀▀▀ █▀▀▀ ' ║ CLOSE ALL (when pressing X on form) ║ █ █ █ █ ▀▀▀█ █▀▀ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█ ▄▄▄█ █▄▄▄ Label CloseAll StopPump StopCobot Slot(Slot_SignalScope) = 0 ' GoToShow ' StopCobotAndGotoHoming Load CloseAll End ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand '(Destination Slot)(Command String) Variable Numeric SC1 Variable String SC2 Variable Numeric SC3 = 0.5 '<-- The timeout in seconds Variable Numeric SC4 SlotText SC1 = SC2 For SC4 = 0.1 To SC3 Step 0.1 If SlotText(SC1) = "" Exit EndIf Wait Seconds 0.1 Next Return ' ============================================================= ' COMMANDS to Cobot ' ============================================================= Label ExecCobot SendCommand(Slot_CommandsToCobot)(EnableRepeat) SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label StopCobot SendCommand(Slot_CommandsToCobot)(StopExecution) Return Label ArrowUpCobot SendCommand(Slot_CommandsToCobot)(ArrowUp) Return Label ArrowDownCobot SendCommand(Slot_CommandsToCobot)(ArrowDown) Return Label ExecuteCobotFromSelectedLine SendCommand(Slot_CommandsToCobot)(StartExecution) Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █ █▀█ ' ║ S U B R O U T I N E A R E A ║ ▀▀▀█ █ █ █▀▀█ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄█ █▄▄█ Label EnableHomeButtons For v1 = 17 To 22 Button v1 Enabled Next Return Label DisableHomeButtons For v1 = 17 To 22 Button v1 Disabled Next Return Label CurrentMeter Variable Numeric mA mA = Slot(108) + Slot(208) + Slot (308) + Slot (408) + Slot (508) mA = FilterLP(mA, 0.1, 1) '<-- Filter 0.5 seconds / 1 pole Button CurrentMeter Text "Current " + Str(mA, "0 mA") Return Label ShowMotorFPS Variable String MotorsAreEnabled Variable Numeric SMF1 = Slot(Slot_MotorsFPS) If SMF1 > 30 If MotorsAreEnabled <> "TRUE" MotorsAreEnabled = "TRUE" Button MotorFPS Color GreenYellow EndIf Button MotorFPS Text "FPS " + Str(SMF1) Else If MotorsAreEnabled = "TRUE" MotorsAreEnabled = "FALSE" Button MotorFPS Color Flashing7 Yellow DarkOrange Button MotorFPS Text "NO MOTORS" EndIf EndIf Return Label MotorFPS If MotorsAreEnabled = "TRUE" SendCommand(Slot_CommandsToMotors)(DisableConnection) Else SendCommand(Slot_CommandsToMotors)(EnableConnection) EndIf Return Label StartPump BlueOn 'Slot(Slot_SignScope) = 1000 Slot(Slot_Pump) = 1000 Button StartPump Disabled Button StopPump Enabled Wait Seconds 0.4 'If Slot(Slot_Vacuum) > 56 ' 'Beep "500, 300, 0, 300" ' 'SayVacuumProblem ' RedOn ' StopPump ' Print "Vacuum Problem" + CRLF ' 'CobotShowPoint ' Print "Execution stopped" + CRLF ' RedBlink ' End 'Else ' Print "Target picked" 'EndIf Return Label StopPump Slot(Slot_Pump) = 0 Button StopPump Disabled Button StartPump Enabled GreenOn Return Label GoTo70 MoveMotorTo(4)(70)(0.1) MoveMotorTo(1)(70)(0.1) MoveMotorTo(3)(70)(0.1) MoveMotorTo(2)(70)(0.1) MoveMotorTo(5)(70)(0.1) Return ' nota: quando si muove il 2, il 3 non deve mai avere ' un valore superiore a 50 altrimenti salta Label GoTo12_70 MoveMotorTo(4)(12)(0.1) MoveMotorTo(5)(70)(0.1) MoveMotorTo(1)(12)(0.1) MoveMotorTo(3)(12)(0.1) 'Breakpoint MoveMotorTo(2)(12)(0.1) MoveMotorTo(3)(12)(0.1) Return Label GoToHome MoveMotorTo(1)(10)(0.1) MoveMotorTo(2)(10)(0.1) MoveMotorTo(3)(125)(0.1) MoveMotorTo(5)(120)(0.1) MoveMotorTo(4)(10)(0.1) Return Label GoTo45 MoveMotorTo(4)(45)(0.1) MoveMotorTo(1)(45)(0.1) MoveMotorTo(2)(45)(0.1) MoveMotorTo(3)(45)(0.1) MoveMotorTo(5)(135)(0.1) MoveMotorTo(4)(45)(0.1) Return Variable Numeric TestPedalEnabled = 1 Label TestPedal If TestPedalEnabled = 1 If Slot(Slot_Pedal) > 500 Slot(Slot_SetWayPoint) = 1000 Else Slot(Slot_SetWayPoint) = 0 EndIf EndIf Return ' ╔════════════════════════════════════════════╗ █▀▀ █▀█ █ █ ▀▀█▀▀ ' ║ FIVE PUSH BUTTONS ║ ▀▀█ █▀▀█ █ █ █ ' ╚════════════════════════════════════════════╝ ▄▄█ █▄▄█ █▄▄█ █ Variable String PressedButton Label FiveButton Variable Numeric FB0 Variable Numeric FB1 Variable Numeric FB2 ' ------------------------------ Read the value two times FB1 = Slot(Slot_FiveButton) FB2 = Slot(Slot_FiveButton) ' ------------------------------ If similar values If Abs(FB2 - FB1) < 5 ' -------------------------- If armed If FB0 = 0 FB0 = 1 Select True Case FB1 > 500 TestPedalEnabled = 1 Print "" PressedButton = "" Case FB1 > 250 Print "red" PressedButton = "red" ExecCobot Case FB1 > 120 Print "white" PressedButton = "white" ExecuteCobotFromSelectedLine Case FB1 > 56 Print "green" PressedButton = "green" ArrowDownCobot Case FB1 > 15 Print "blue" PressedButton = "blue" ArrowUpCobot CaseElse Print "yellow" PressedButton = "yellow" TestPedalEnabled = 0 Slot(Slot_SetWayPoint) = 1000 EndSelect EndIf EndIf ' ------------------------------ Rearm buttons If FB1 > 500 FB0 = 0 EndIf Return Label CloseScopes Load CloseApps Theremino_SignalScope_M1.exe Load CloseApps Theremino_SignalScope_M2.exe Load CloseApps Theremino_SignalScope_M3.exe Load CloseApps Theremino_SignalScope_M4.exe Load CloseApps Theremino_SignalScope_M5.exe Load CloseApps Theremino_SignalScope_FPS.exe Return Label OpenScope_1 Load Theremino_SignalScope_M1.exe Return Label OpenScope_2 Load Theremino_SignalScope_M2.exe Return Label OpenScope_3 Load Theremino_SignalScope_M3.exe Return Label OpenScope_4 Load Theremino_SignalScope_M4.exe Return Label OpenScope_5 Load Theremino_SignalScope_M5.exe Return Label OpenFPS Load Theremino_SignalScope_FPS.exe Return ' ╔════════════════════════════════════════════╗ █ █▀▀ █▀▄ ' ║ LED COLORS ║ █ █▀ █ █ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█ Label RedOn Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Return Label MagentaOn Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label YellowOn Slot Slot_LedR = 900 Slot Slot_LedG = 400 Slot Slot_LedB = 0 Return Label GreenOn Slot Slot_LedR = 0 Slot Slot_LedG = 1000 Slot Slot_LedB = 0 Return Label BlueOn Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label WhiteOn Slot Slot_LedR = 1000 Slot Slot_LedG = 1000 Slot Slot_LedB = 1000 Return Label RgbOff Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Return Label RedBlink RedOn WhiteOn Return ' ╔═════════════════════════╗ █▀▀▀ █▀▀█ █▄ ▄█ █▀▀ █▀▀▀ █▀▀█ █▀█ ' ║ COMMANDS FROM COBOT ║ █ █ █ █ ▀ █ █▀ █ █ █ █▀▀█ ' ╚═════════════════════════╝ █▄▄▄ █▄▄█ █ █ ▄ █ ▄ █▄▄▄ █▄▄█ █▄▄█ Label Event_ExternalCommands ' ------------------------------------------------------ Do not print lines containing '' 'Print " Exec: " + CommandText + CRLF ' ------------------------------------------------------ Select CommandText ' ---------------------------------------------- ACTIONS Case "RedOn" RedOn ClearCommand Case "GreenOn" GreenOn ClearCommand Case "BlueOn" BlueOn ClearCommand Case "WhiteOn" WhiteOn ClearCommand Case "MagentaOn" MagentaOn ClearCommand Case "YellowOn" YellowOn ClearCommand Case "Beep" Beep 880-100 ClearCommand Case "Pause" Wait Seconds GetSeparatedString(CommandText, 1) ClearCommand Case "StartPump" StartPump ClearCommand Case "StopPump" StopPump ClearCommand Case "MemorizeQrCode" Variable Numeric MQR1 For MQR1 = 1 To 5 QrCode = SlotText(Slot_ResponsesFromQRDecode) Print QrCode If QrCode <> "" Exit EndIf If MQR1 = 5 SendCommand(Slot_CommandsToCobot)(StopExecution) EndIf Wait Seconds 1 Next ClearCommand Case "ExecQrCode" ExecQRcode ClearCommand Case "StartFichesPick" StartFichesPick ClearCommand Case "EndOfTask" EndOfTask ClearCommand CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + CommandText + CRLF Beep ClearCommand Stop ' EndSelect Return Label ClearCommand SlotText(Slot_ExternalCommands) = "" Return ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █▄ █ █▀▀▀ ' ║ WANPY 5 ║ █ █ █▄▄█ █ ▀█ ▀▀▀█ ' ╚════════════════════════════════════════════╝ ▀▄▀ █ █ █ █ ▄▄▄█ Label WanpyJob5 TTS Speak "Wanpy job started." Controls OpenTextBox Controls ClearTextBox StartTime = ElapsedTime Wanpy_A5toB1 Return Variable String Status = "A5toB1" Label EndOfTask PrintTime StartTimePartial = ElapsedTime Select Status Case "A5toB1" 'Wanpy_B1toA5 Wanpy_A4toB2 Case "A4toB2" Wanpy_A3toB3 Case "A3toB3" Wanpy_A2toB4 Case "A2toB4" Wanpy_A1toB5 Case "A1toB5" Wanpy_B5toA1 Case "B5toA1" Wanpy_B4toA2 Case "B4toA2" Wanpy_B3toA3 Case "B3toA3" Wanpy_B2toA4 Case "B2toA4" Wanpy_B1toA5 Case "B1toA5" StartTime = ElapsedTime Print CRLF Wanpy_A5toB1 EndSelect Return Variable Numeric StartTime Variable Numeric StartTimePartial Variable String Time Label PrintTime Time = "Partial time = " Time = Time + PadLeft(Format(ElapsedTime - StartTimePartial, "0.0"),4) Time = Time + " Total time = " Time = Time + PadLeft(Format(ElapsedTime - StartTime, "0.0"),4) Print Status + " " + Time + CRLF Return Label Wanpy_A5toB1 Status = "A5toB1" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A5toB1.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A4toB2 Status = "A4toB2" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A4toB2.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A3toB3 Status = "A3toB3" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A3toB3.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A2toB4 Status = "A2toB4" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A2toB4.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_A1toB5 Status = "A1toB5" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_A1toB5.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B5toA1 Status = "B5toA1" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B5toA1.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B4toA2 Status = "B4toA2" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B4toA2.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B3toA3 Status = "B3toA3" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B3toA3.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B2toA4 Status = "B2toA4" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B2toA4.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label Wanpy_B1toA5 Status = "B1toA5" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Wanpy_B1toA5.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return ' ╔════════════════════════════════════════════╗ █▀▀█ █▀▀█ █▀▀▀ ' ║ QR CODE ║ █ █ █▄▄█ █ ' ╚════════════════════════════════════════════╝ █▄██▄ █ ▀▄ █▄▄▄ Label JobQrCode TTS Speak "QR code recognition and action related is started." StartFichesPick Return Label StartFichesPick BlueOn SendCommand(Slot_CommandsToCobot)("LoadSequence fiches_pick.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return Label ExecQRcode Variable String QrCode Select QrCode Case "WHITE" WhiteOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_white.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "RED" RedOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_red.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "GREEN" GreenOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_green.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "BLUE" BlueOn SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_Place_blue.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Case "BLACK" RgbOff SendCommand(Slot_CommandsToCobot)("LoadSequence Fiches_place_black.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) CaseElse Controls OpenTextBox Print CRLF + " Unrecognized color command: " + CommandText + CRLF StopPump Beep ClearCommand Stop EndSelect Return ' ╔════════════════════════════════════════════╗ ▀▀█▀▀ █ █ █▄ █ ' ║ TUNA ║ █ █ █ █ ▀█ ' ╚════════════════════════════════════════════╝ █ █▄▄█ █ █ Label TunaCans TTS Speak "Tuna can handling." YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Tuna_Cans.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █ █ █▀▀▄ ' ║ SLIDERS ║ ▀▀▀█ █ █ █ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄ █ █▄▄█ Variable Numeric SLD Label Sliders BlueOn 'Button Sliders Color Flashing7 Blue White For SLD = 1 To Infinity Slot(Slot_M1) = Slot(Slot_Slider1) Slot(Slot_M2) = Slot(Slot_Slider2) Slot(Slot_M3) = Slot(Slot_Slider3) + Slot(Slot_Slider2) Slot(Slot_M4) = Slot(Slot_Slider4) Slot(Slot_M5) = Slot(Slot_Slider5) Next Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █▀▀█ ▀▄ ▄▀ ' ║ SAY ║ ▀▀▀█ █▄▄█ ▀▄▀ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █ █ Label Say TTS SelectVoice "ENGF" TTS Speak "Today is a beautiful day because we spend time together." Wait TTSready TTS SelectVoice "ITA FEM" TTS Speak "Oggi è una bella giornata perche passeremo del tempo insieme." Wait TTSready TTS SelectVoice "JPN" TTS Speak "私たちは一緒に時間を過ごすので、今日は美しい日です。" Wait TTSready TTS SelectVoice "ZHO" TTS Speak "今天是美好的一天,因为我们共度时光。" Wait TTSready Return ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █ █▀▀▀ █▀▀▀ ' ║ VOICE COMMANDS ║ █ █ █ █ █ █ █▀▀ ' ╚════════════════════════════════════════════╝ █ █▄▄█ █ █▄▄▄ █▄▄▄ Label Voice ClearVoiceCommand If VoiceCommandsStatus = "active" VoiceCommandsStatus = "" 'Button Voice Color PaleTurquoise Else VoiceCommandsStatus = "active" 'Button Voice Color Flashing7 Orange White EndIf Return Variable String Word Variable String VoiceCommandsStatus Label InterpretateVoiceCommands If VoiceCommandsStatus = "active" If SlotText(Slot_WordRecognized) <> "" Word = SlotText(Slot_WordRecognized) Print Word + " " Interpretate ClearVoiceCommand EndIf EndIf Return Variable String ShowingType Label Interpretate Select Word Case "show.fiches" If ShowingType = "" WhiteOn ShowingType = "Fiches" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Fiches.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "show.wanpy" If ShowingType = "" YellowOn ShowingType = "Wanpy" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Wanpy.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "show.tuna" If ShowingType = "" GreenOn ShowingType = "Tuna" SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Show_Tuna.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf '------------------------------------------------------------------------- Case "release" Select ShowingType Case "fiches" WhiteOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Fiches.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" Case "wanpy" YellowOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Wanpy.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" Case "tuna" GreenOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_Release_Tuna.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) ShowingType = "" CaseElse ' EndSelect '------------------------------------------------------------------------- Case "goto.center" If ShowingType = "" RedOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_goto_Center.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf Case "goto.Homing" If ShowingType = "" MagentaOn SendCommand(Slot_CommandsToCobot)("LoadSequence Voice_goto_Homing.txt") SendCommand(Slot_CommandsToCobot)(SelectLine 1) SendCommand(Slot_CommandsToCobot)(StartExecution) EndIf '------------------------------------------------------------------------- CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + Word + CRLF Beep ClearCommand Stop EndSelect Return Label ClearVoiceCommand SlotText(Slot_WordRecognized) = "" Return ' ╔════════════════════════════════════════════╗ ▀▀█▀▀ █▀▀█ █ █▀▀█ █ ' ║ T R I A L S ║ █ █▄▄▀ █ █▄▄█ █ ' ╚════════════════════════════════════════════╝ █ █ ▀▄ █ █ █ █▄▄ ' ╔════════════════════════════════════════════╗ █▀▀▀ █▄ █ █▀▀▀ ' ║ ENCODERS ║ █▀▀ █ ▀█ █ ' ╚════════════════════════════════════════════╝ █▄▄▄ █ █ █▄▄▄ Variable Numeric EncoderSteps1 Variable Numeric OldEncoderSteps1 = Slot(Slot_Encoder1) Variable Numeric Difference1 Variable Numeric EncoderSteps2 Variable Numeric OldEncoderSteps2 = Slot(Slot_Encoder2) Variable Numeric Difference2 Variable Numeric EncoderSteps3 Variable Numeric OldEncoderSteps3 = Slot(Slot_Encoder3) Variable Numeric Difference3 Variable Numeric EncoderSteps4 Variable Numeric OldEncoderSteps4 = Slot(Slot_Encoder4) Variable Numeric Difference4 Variable Numeric EncoderSteps5 Variable Numeric OldEncoderSteps5 = Slot(Slot_Encoder5) Variable Numeric Difference5 Label RecognizeEncoder Slot(0) = Recognize Return Label Encoder '------------------------------------------------ encoder1 to mot 1 or 6 EncoderSteps1 = Slot(Slot_Encoder1) Difference1 = EncoderSteps1 - OldEncoderSteps1 OldEncoderSteps1 = EncoderSteps1 If Difference1 > 32000 Difference1 = Difference1 - 65536 EndIf If Difference1 < -32000 Difference1 = Difference1 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference1 = Difference1 * 0.1 EndIf If PressedButton <> "yellow" Slot(Slot_M1) = Limit(Slot (Slot_M1) + Difference1, 10, 163) Else 'Slot(Slot_M6) = Limit(Slot (Slot_M6) + Difference1, -130, +130) EndIf '------------------------------------------------ read encoder2 EncoderSteps2 = Slot(Slot_Encoder2) Difference2 = EncoderSteps2 - OldEncoderSteps2 OldEncoderSteps2 = EncoderSteps2 If Difference2 > 32000 Difference2 = Difference2 - 65536 EndIf If Difference2 < -32000 Difference2 = Difference2 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference2 = Difference2 * 0.1 EndIf Slot(Slot_M2) = Limit(Slot (Slot_M2) + Difference2, 10, 98) '------------------------------------------------ read encoder3 EncoderSteps3 = Slot(Slot_Encoder3) Difference3 = EncoderSteps3 - OldEncoderSteps3 OldEncoderSteps3 = EncoderSteps3 If Difference3 > 32000 Difference3 = Difference3 - 65536 EndIf If Difference3 < -32000 Difference3 = Difference3 + 65536 EndIf Difference3 = Difference3 * 0.5 If Slot(Slot_EncoderSlow) < 500 Difference3 = Difference3 * 0.1 EndIf Slot(Slot_M3) = Limit(Slot (Slot_M3) + Difference3, 5, 94) '------------------------------------------------ read encoder4 EncoderSteps4 = Slot(Slot_Encoder4) Difference4 = EncoderSteps4 - OldEncoderSteps4 OldEncoderSteps4 = EncoderSteps4 If Difference4 > 32000 Difference4 = Difference4 - 65536 EndIf If Difference4 < -32000 Difference4 = Difference4 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference4 = Difference4 * 0.01 EndIf Slot(Slot_M4) = Limit(Slot (Slot_M4) + Difference4, 10, 190) '------------------------------------------------ read encoder5 EncoderSteps5 = Slot(Slot_Encoder5) Difference5 = EncoderSteps5 - OldEncoderSteps5 OldEncoderSteps5 = EncoderSteps5 If Difference5 > 32000 Difference5 = Difference5 - 65536 EndIf If Difference5 < -32000 Difference5 = Difference5 + 65536 EndIf If Slot(Slot_EncoderSlow) < 500 Difference5 = Difference5 * 0.1 EndIf Slot(Slot_M5) = Limit(Slot (Slot_M5) + Difference5, 62, 298) Return Label ResetEncoders OldEncoderSteps1 = Slot(Slot_Encoder1) OldEncoderSteps2 = Slot(Slot_Encoder2) OldEncoderSteps3 = Slot(Slot_Encoder3) OldEncoderSteps4 = Slot(Slot_Encoder4) OldEncoderSteps5 = Slot(Slot_Encoder5) Return ' ╔════════════════════════════════════════════╗ █▀▀█ █▀▀█ █ ' ║ CALIBRATIONS ║ █ █▄▄█ █ ' ╚════════════════════════════════════════════╝ █▄▄█ █ █ █▄▄▄ Label ResetAllMultiturnValues SendCommand(Slot_CommandsToMotors)("ResetAllMultiturnValues") Return Label CopyPositionsToDestinations Slot Slot_M1 = Slot(Slot_M1pos) Slot Slot_M2 = Slot(Slot_M2pos) Slot Slot_M3 = Slot(Slot_M3pos) Slot Slot_M4 = Slot(Slot_M4pos) Slot Slot_M5 = Slot(Slot_M5pos) Return Label CalibrateMotorToZero '(Motor Number) Variable Numeric CMTZ1 SendCommand(Slot_CommandsToMotors)("Calibrate Motor " + CMTZ1 + " To 0") CMTZ1 = (CMTZ1*100-100) Slot(Slot_M1 + CMTZ1) = Slot(Slot_M1pos + CMTZ1) Return 'Label SetMotorCenterHere '(Motor Number) ' Variable Numeric SMC1 ' SMC1 = Slot_M1center + (SMC1*100-100) ' Slot SMC1 = 128 ' Wait Seconds 0.1 ' Slot SMC1 = 1 ' Wait Seconds 0.1 'Return Label SetMotor_ON '(Motor Number) Variable Numeric SMON1 SMON1 = Slot_M1center + (SMON1*100-100) Slot SMON1 = 0 Wait Seconds 0.1 Slot SMON1 = 1 Wait Seconds 0.1 Return Label SetMotor_OFF '(Motor Number) Variable Numeric SMOFF1 SMOFF1 = Slot_M1center + (SMOFF1*100-100) Slot SMOFF1 = 0 Wait Seconds 0.1 Slot SMOFF1 = 1 Wait Seconds 0.1 Return Label WaitMotorsNotMoving Variable Numeric WMN1 For WMN1 = 1 To 5 WaitMotor(WMN1)(0.1) Next Return ' ------------------------------------------------------- ' The "Wait seconds" parameter is a initial delay ' If this delay is short and the motor starts slowly ' then the "WaitMotor" functions could exit immediately ' ------------------------------------------------------- Label WaitMotor '(Motor Number)(Wait seconds) Variable Numeric WM1 Variable Numeric WM2 WM1 = (WM1*100-100) Wait Seconds WM2 Variable Numeric WM3 For WM3 = 0 To Infinity If Slot(Slot_M1 + 2 + WM1) = 0 Or Key("CTRL") ' test Velocity Exit For EndIf 'If Slot(Slot_M1 + 6 + WM1) = 0 Or Key("CTRL") ' test Moving ' Exit For 'EndIf Next Return Label MoveMotorTo '(Motor Number)(Destination)(Wait seconds) Variable Numeric MMT1 Variable Numeric MMT2 Variable Numeric MMT3 Slot(Slot_M1 + MMT1*100-100) = MMT2 WaitMotor(MMT1)(MMT3) Return ' ╔════════════════════════════════════════════╗ ' ║ ACTIVATE MOTORS ║ ' ╚════════════════════════════════════════════╝ Label ActivateMotors ResetAllMultiturnValues Variable Numeric AM1 For AM1 = 1 To 5 SetMotor_ON(AM1) Next SendCommand(Slot_CommandsToCobot)("SetTorque 200") SendCommand(Slot_CommandsToCobot)("SetAcceleration 100") SendCommand(Slot_CommandsToCobot)("SetSpeed 1000") SendCommand(Slot_CommandsToMotors)(ShowWindow) Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands\OLD EXAMPLES\LEO examples ' File PalletArmCOBOT_V00.txt ' ============================================================================= '╔════════════════════════════════════════════════════════════╗ '║ Name: PalletArmCOBOT_V00.txt Date: 26 Jun 2022 ║ '║ Author: Leonardo ║ '║ Scope: Test the functionality of Palletized robot arm ║ '╠════════════════════════════════════════════════════════════╣ '║Hardware: Stepper motor ║ '╟────────────────────────────────────────────────────────────╢ '║ Note: COBOT version 28 Jun 2022 ║ '║ ║ '╚════════════════════════════════════════════════════════════╝ Option Speed 9 Beep "2500 100, 1500 100" 'Variable Numeric Debug = 0 ' 1 = DEBUG 0 = NORMAL RestoreVars 'Load images\PalletArmBlack.jpg 'Beep "2500 200, 1500 200, 2500 300, 0500, 1500 300" 'TTS SelectVoice Language TTS SetVolume 0 '100 TTS SetSpeed -1 ' ╔════════════════════════════════════════════╗ ' ║ SLOT TEXT for COMMANDS and RESPONSES ║ ' ╚════════════════════════════════════════════╝ 'Variable Numeric SlotCobotCommands = 1 'Variable Numeric SlotCobotResponses = 2 'Variable Numeric SlotQRcode = 3 ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █▀▀▀█ ' ║ VARIABLE INITIALIZATIONS & ASSIGNEMENTS ║ █ █ █▄▄█ █▄▄▄█ ' ╚════════════════════════════════════════════╝ ▀▄▀ █ █ █ ▀▄ 'Variable Numeric NumCycle 'Variable Numeric StartTime 'Variable String Result 'Variable Numeric Slot_Emergency 'Variable Numeric Slot_CommandsToCobot = 51 'Variable Numeric Slot_ResponsesFromCobot = 52 Variable Numeric Slot_CommandsFromCobot = 53 Variable Numeric Slot_M1 = 101 Variable Numeric Slot_M2 = 201 Variable Numeric Slot_M3 = 301 Variable Numeric Slot_EnableMotors = 11 'Variable Numeric Slot_Clamp = 401 Variable Numeric Slot_AnalogBut = 5 Variable Numeric Slot_LedR = 7 Variable Numeric Slot_LedG = 8 Variable Numeric Slot_LedB = 9 Variable Numeric Slot_SignalScope = 13 ' -------------------------------------- Software limits Variable Numeric M1max = 131 Variable Numeric M1min = 44 Variable Numeric M2max = 98 Variable Numeric M2min = 60 Variable Numeric M3max = 94 Variable Numeric M3min = 60 Key 1 BtnCoord_M1 Key 2 BtnCoord_M2 Key 3 BtnCoord_M3 ' ╔════════════════════════════════════════════╗ █▀▀▄ █ █ ▀▀█▀▀ ' ║ BUTTONS ║ █▀▀█ █ █ █ ' ╚════════════════════════════════════════════╝ █▄▄█ █▄▄█ █ Button 1 Text HardHome Button HardHome Color Coral Button 2 Text "BtnCoord_M1" Button BtnCoord_M1 Text "M1 = ?" Button BtnCoord_M1 Color LightBlue Button 3 Text "BtnCoord_M2" Button BtnCoord_M2 Text "M2 = ?" Button BtnCoord_M2 Color LightBlue Button 4 Text "BtnCoord_M3" Button BtnCoord_M3 Text "M3 = ?" Button BtnCoord_M3 Color LightBlue Button 5 Text ColorButton Button ColorButton Text "COLOR BUTTON" Button ColorButton Color Plum Button 9 Text YELLOW Button Yellow Color Yellow Button 10 Text BLUE Button Blue Color Blue Button 11 Text RED Button Red Color Red Button 12 Text GREEN Button Green Color Green Button 13 Text WHITE Button White Color White Button 14 Text BLACK Button Black Color Black Button 15 Text SafePos Button SafePos Text "90 90 90" Button SafePos Color Bisque Button 16 Text CloseAll Button CloseAll Text "CLOSE ALL" Button CloseAll Color Red ' 'Button 17 Text RepTest 'Button RepTest Text " "REPET.TEST"" 'Button RepTest Color Khaki 'Button 16 Text Emergency 'Button Emergency Text "EMERGENCY" 'Button Emergency Color Red 'Button Emergency Slot Slot_Emergency 'Button 17 Text RedOn 'Button RedOn Color Red 'Button 18 Text GreenOn 'Button GreenOn Color Green 'Button 19 Text YellowOn 'Button YellowOn Color Yellow 'Button 20 Text BlueOn 'Button BlueOn Color MediumBlue 'Button 21 Text WhiteOn 'Button GreenOn Color Green 'Button 22 Text RgbOff 'Button RgbOff Color Black ' -------------------------------------- KEYS Key Right Gosub ExecKeys Key Left Gosub ExecKeys Key Up Gosub ExecKeys Key Down Gosub ExecKeys Key Pageup Gosub ExecKeys Key Pagedown Gosub ExecKeys ' ╔════════════════════════════════════════════╗ █ █▀▀█ █▀▀█ █▀▀▄ ' ║ LOAD APPS ║ █ █ █ █▄▄█ █ █ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄█ █ █ █▄▄█ Load Theremino_HAL.exe Load Theremino_SlotViewer.exe Load Theremino_COBOT.exe 'Load Theremino_SignalScope.exe ' ╔════════════════════════════════════════════╗ █▀▀▀ ▀▀█▀▀ █▀▀▀█ █▀▀▀█ ▀▀█▀▀ ' ║ START FROM HERE ║ ▀▀▀█ █ █▀▀▀█ █▀█▀▀ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █ █ █ ▀▄ █ EnableMotors Controls OpenTextBox DisableAllButtons Controls ClearTextBox YellowOn Print TTSvoices EnableAllButtons 'HardHome Load Hide 'Loop Stop ' ╔════════════════════════════════════════════╗ █ █▀▀█ █▀▀█ █▀▀█ ' ║ LOOP ║ █ █ █ █ █ █▄▄█ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄█ █▄▄█ █ Label Loop ' ------------------------------------------ ' 0.02 sec. or more to allow time for keys and other tasks Wait Seconds 0.02 ' --------------------------------------------------------- Goto Loop ' ╔════════════════════════════════════════════╗ ' ║ ENABLE/DISABLE BUTTONS ║ ' ╚════════════════════════════════════════════╝ Label EnableAllButtons For v1 = 1 To 16 Button v1 Enabled Next Return Label DisableAllButtons For v1 = 1 To 16 Button v1 Disabled Next Return ' ╔════════════════════════════════════════════╗ ' ║ SAVE LOAD VARS ║ ' ╚════════════════════════════════════════════╝ Label SaveVars Save Vars Print CRLF + "SAVED SEQUENCENAME = " + s1 + CRLF Return Label RestoreVars Load Vars Return ' ╔════════════════════════════════════════════╗ █▀▀ █ █▀▀█ █▀▀▀ █▀▀▀ ' ║ CLOSE ALL ║ █ █ █ █ ▀▀▀█ █▀▀ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█ ▄▄▄█ █▄▄▄ Label CloseAll RedOn SaveVars DisableMotors Window Sizable Slot(Slot_SignalScope) = 0 TTS Speak "End Of Program." 'HomeFirstArm 'HomeSecondArm 'HomeFirstArm 'DisableMotors Load CloseApps Return ' ╔════════════════════════════════════════════╗ █▀▀▀ ▀▀█▀▀ █▀▀█ █▀▀█ ' ║ STOP EVENT (when pressing stop button) ║ ▀▀▀█ █ █ █ █▄▄█ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █▄▄█ █ Label EventStop SaveVars RedOn EnableAllButtons Window Sizable Slot(Slot_SignalScope) = 0 TTS Speak "End Of Program." 'HomeFirstArm 'HomeSecondArm 'HomeFirstArm DisableMotors End ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █▀▀█ █ █ █▀▀█ █▀▄▀█ █▀▀▀ ' ║ HARD HOME ALL 3 STEPPERS ║ █▀▀█ █▀▀█ ██▀▀ █▀▀█ █ █ █ █ █▀▀ ' ╚════════════════════════════════════════════╝ █ █ █ █ █ ▀▄ █ █ █▄▄█ █ █ █▄▄▄ Label HardHome EnableMotors Slot(Slot_M2) = Slot(Slot_M2) + 30 WaitAllMotors Slot(Slot_M3) = Slot(Slot_M3) - 10 WaitAllMotors Slot(Slot_M1) = Slot(Slot_M1) - 10 WaitAllMotors HomeBase ' HomeFirstArm HomeSecondArm ' HomeFirstArm ' HomeSecondArm HomeFirstArm HomeSecondArm Return ' ===================================================================== ' Wait until the rotation motor is stopped FROM DIGICLAMP OFFICE DEMO ' ===================================================================== Variable Numeric WaitMot1 Label HomeBase Gosub EnableMotors Slot(Slot_M1) = Slot(Slot_M1) - 70 ' -------------------------------------------------------- Wait Seconds 0.1 For WaitMot1 = 1 To 9e99 If Abs(Slot(Slot_M1 + 1)) < 0.01 Exit EndIf Wait Seconds 0.005 Next ' -------------------------------------------------------- Slot(Slot_M1) = Reset Wait Seconds 0.1 Slot(Slot_M1) = 45 Wait Seconds 0.1 ' -------------------------------------------------------- 'Gosub PrintValues Slot(Slot_M1) = 90 Return Label HomeFirstArm Gosub EnableMotors Slot(Slot_M2) = Slot(Slot_M2) + 50 ' -------------------------------------------------------- Wait Seconds 0.1 For WaitMot1 = 1 To 9e99 If Abs(Slot(Slot_M2 + 1)) < 0.01 Exit EndIf Wait Seconds 0.005 Next ' -------------------------------------------------------- Slot(Slot_M2) = Reset Wait Seconds 0.1 Slot(Slot_M2) = 98 Wait Seconds 0.1 ' -------------------------------------------------------- 'Gosub PrintValues Slot(Slot_M2) = 90 Return Label HomeSecondArm Gosub EnableMotors Slot (Slot_M3) = Slot(Slot_M3) + 30 ' -------------------------------------------------------- Wait Seconds 0.1 For WaitMot1 = 1 To 9e99 If Abs(Slot(Slot_M3 + 1)) < 0.01 Exit EndIf Wait Seconds 0.005 Next ' -------------------------------------------------------- Slot(Slot_M3) = Reset Wait Seconds 0.1 Slot(Slot_M3) = 95 Wait Seconds 0.1 ' -------------------------------------------------------- 'Gosub PrintValues Slot(Slot_M3) = 90 Return ' ╔════════════════════════════════════════════╗ █ █ █▀▀█ █ ▀▀█▀▀ ' ║ WAIT ALL MOTOR - Wait until motors stopped ║ █ █ █▄▄█ █ █ ' ╚════════════════════════════════════════════╝ ▀▄▀▄▀ █ █ █ █ Label WaitAllMotors Wait Seconds 0.1 ' <<< ensures that motors are really started Variable Numeric WAM1 For WAM1 = 1 To Infinity If Abs(Slot(Slot_M1 + 1)) < 0.01 If Abs(Slot(Slot_M2 + 1)) < 0.01 If Abs(Slot(Slot_M3 + 1)) < 0.01 Exit EndIf EndIf EndIf Wait Seconds 0.05 UpdateButtons Next Return Label EnableMotors Slot(Slot_EnableMotors) = 1000 Return Label DisableMotors Slot(Slot_EnableMotors) = 0 Return ' ╔════════════════════════════════════════════╗ ' ║ EMERGENCY ║ ' ╚════════════════════════════════════════════╝ Label Emergency ' DisableAllButtons ' Button 15 Enabled ' Button 15 Color Flashing7 Yellow Red ' For v1 = 1 To Infinity ' RedOn ' Wait Seconds 0.4 ' RgbOff ' Wait Seconds 0.4 ' Load sound\Alarm10b.wav ' Next Stop ' ╔════════════════════════════════════════════╗ █ █▀▀ █▀▄ ' ║ LED COLORS ║ █ █▀ █ █ ' ╚════════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█ Label RedOn TTS Speak "Status red." Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Wait TTSready Return Label MagentaOn Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label YellowOn TTS Speak "Status yellow." Slot Slot_LedR = 900 Slot Slot_LedG = 400 Slot Slot_LedB = 0 Wait TTSready Return Label GreenOn TTS Speak "Status green." Slot Slot_LedR = 0 Slot Slot_LedG = 1000 Slot Slot_LedB = 0 Wait TTSready Return Label BlueOn TTS Speak "Status blue." Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Wait TTSready Return Label WhiteOn TTS Speak "Status white." Slot Slot_LedR = 1000 Slot Slot_LedG = 1000 Slot Slot_LedB = 1000 Wait TTSready Return Label RgbOff TTS Speak "Status black." Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Wait TTSready Return Label RedBlink RedOn WhiteOn Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █▀▀█ █ █▀▀▄ █ █ ▀▀█▀▀ ' ║ COLOR BUTTON ║ █ █ █ █ █▀▀█ █ █ █ ' ╚════════════════════════════════════════════╝ █▄▄▄ █▄▄█ █▄▄▄ █▄▄█ █▄▄█ █ Label ColorButton Button ColorButton Color Flashing7 Black White For v1 = 1 To Infinity If Int(Slot(Slot_AnalogBut)) = 0 And Slot(Slot_AnalogBut) < 2 YELLOW EndIf If Int(Slot(Slot_AnalogBut)) > 43 And Slot(Slot_AnalogBut) < 49 BLUE EndIf If Int(Slot(Slot_AnalogBut)) > 244 And Slot(Slot_AnalogBut) < 250 RED EndIf If Slot(Slot_AnalogBut) > 128 And Slot(Slot_AnalogBut) < 134 GREEN EndIf If Int(Slot(Slot_AnalogBut)) > 521 And Slot(Slot_AnalogBut) < 527 BLACK EndIf Wait Seconds 0.01 Next Return ' ╔════════════════════════════════════════════╗ █▀▀█ █▀▀█ █▄ ▄█ █▀▀▀ █▀▀█ █ ' ║ ARM COLOR POSITION ║ █▄▄█ █▄▄█ █ ▀ █ █ █ █ █ ' ╚════════════════════════════════════════════╝ █ █ █ ▀▄ █ █ █▄▄▄ █▄▄█ █▄▄▄ Label YELLOW TTS Speak "Going to yellow dear Kemiao." SafePos Slot(Slot_M1) = 66 Slot(Slot_M2) = 67 Slot(Slot_M3) = 75 WaitAllMotors Return Label BLUE TTS Speak "Going to blue." SafePos Slot(Slot_M1) = 83 Slot(Slot_M2) = 69 Slot(Slot_M3) = 71 WaitAllMotors Return Label RED TTS Speak "Going to red." SafePos Slot(Slot_M1) = 93 Slot(Slot_M2) = 71 Slot(Slot_M3) = 65 WaitAllMotors Return Label GREEN TTS Speak "Going to green." SafePos Slot(Slot_M1) = 69 Slot(Slot_M2) = 71 Slot(Slot_M3) = 67 WaitAllMotors Return Label BLACK TTS Speak "Going to black." SafePos Slot(Slot_M1) = 122 Slot(Slot_M2) = 70 Slot(Slot_M3) = 68 WaitAllMotors Return Label WHITE TTS Speak "Going to white." SafePos Slot(Slot_M1) = 104 Slot(Slot_M2) = 69 Slot(Slot_M3) = 71 WaitAllMotors Return Label SafePos Slot(Slot_M1) = 90 Slot(Slot_M2) = 90 Slot(Slot_M3) = 90 WaitAllMotors Return Label RepTest For v99 = 1 To Infinity Slot(Slot_M1) = 70 Slot(Slot_M2) = 90 Slot(Slot_M3) = 90 WaitAllMotors Slot(Slot_M1) = 110 Slot(Slot_M2) = 90 Slot(Slot_M3) = 90 WaitAllMotors Slot(Slot_M1) = 90 Slot(Slot_M2) = 76 Slot(Slot_M3) = 82 WaitAllMotors Wait Seconds 0.2 Slot(Slot_M1) = 90 Slot(Slot_M2) = 76 Slot(Slot_M3) = 76 WaitAllMotors Wait Seconds 1.3 Slot(Slot_M1) = 90 Slot(Slot_M2) = 76 Slot(Slot_M3) = 82 WaitAllMotors Next Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █▀▀▀ █▀▀█ █ █▀▀█ ' ║ COMMAND EXECUTOR ║ ▀▀▀█ █▀▀▀ █ █ █ █ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █▄▄▄ █▄██▄ █▄▄▄ █▄▄█ Variable Numeric SlotDummy Label Event_CommandsFromCobot ' -------------------------------------- Print command Print " Exec: " + CommandText + CRLF ' -------------------------------------- Select Select CommandText ' ------------------------------ ACTIONS Case "HardHome" HardHome Case "WaitAllMotors" WaitAllMotors ' ------------------------------ Motor movementD COLO Case "Red" RED Case "Green" GREEN Case "Blue" BLUE Case "Yellow" YELLOW Case "BLACK" BLACK ' ------------------------------ LED COLORS Case "RedOn" RedOn Case "GreenON" GreenOn Case "MagentaOn" MagentaOn Case "GreenON" GreenOn Case "BlueOn" BlueOn Case "YellowOn" YellowOn Case "WhiteOn" WhiteOn Case "RGBOFF" RgbOff ' ------------------------------ Enable/Disable motors Case "EnableMotors" EnableMotors Case "DisableMotors" DisableMotors ' ------------------------------ With parameters Case "WriteSlot" SlotDummy = GetSeparatedString(CommandText, 1) Slot(SlotDummy) = GetSeparatedString(CommandText, 2) Case "ResetStepper" SlotDummy = GetSeparatedString(CommandText, 1) Slot(SlotDummy) = Reset Wait Seconds 0.05 Slot(SlotDummy) = GetSeparatedString(CommandText, 2) Wait Seconds 0.05 Slot(SlotDummy) = GetSeparatedString(CommandText, 3) Case "Move_M1" Slot(Slot_M1) = GetSeparatedString(CommandText, 1) WaitAllMotors Case "Move_M2" Slot(Slot_M2) = GetSeparatedString(CommandText, 1) WaitAllMotors Case "Move_M3" Slot(Slot_M3) = GetSeparatedString(CommandText, 1) WaitAllMotors Case "MOVE_M1M2" Slot(Slot_M1) = GetSeparatedString(CommandText, 1) Slot(Slot_M2) = GetSeparatedString(CommandText, 2) WaitAllMotors Case "MOVE_M1M2M3" Slot(Slot_M1) = GetSeparatedString(CommandText, 1) Slot(Slot_M2) = GetSeparatedString(CommandText, 2) Slot(Slot_M3) = GetSeparatedString(CommandText, 3) WaitAllMotors Case "MOVESLOW_M1" MoveSlow_DestM1 = GetSeparatedString(CommandText, 1) MoveSlow_Speed = GetSeparatedString(CommandText, 2) MoveSlowM1 WaitAllMotors Case "MOVESLOW_M2" MoveSlow_DestM2 = GetSeparatedString(CommandText, 1) MoveSlow_Speed = GetSeparatedString(CommandText, 2) MoveSlowM2 WaitAllMotors Case "MOVESLOW_M3" MoveSlow_DestM3 = GetSeparatedString(CommandText, 1) MoveSlow_Speed = GetSeparatedString(CommandText, 2) MoveSlowM3 WaitAllMotors Case "MOVESLOW_M1M2" MoveSlow_DestM1 = GetSeparatedString(CommandText, 1) MoveSlow_DestM2 = GetSeparatedString(CommandText, 2) MoveSlow_Speed = GetSeparatedString(CommandText, 3) MoveSlowM1M2 WaitAllMotors Case "MOVESLOW_M1M2M3" MoveSlow_DestM1 = GetSeparatedString(CommandText, 1) MoveSlow_DestM2 = GetSeparatedString(CommandText, 2) MoveSlow_DestM3 = GetSeparatedString(CommandText, 3) MoveSlow_Speed = GetSeparatedString(CommandText, 4) MoveSlowM1M2M3 WaitAllMotors Case "Pause" Wait Seconds GetSeparatedString(CommandText, 1) CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + CommandText + CRLF Beep Stop ' EndSelect ClearCommand Return Label ClearCommand SlotText(Slot_CommandsFromCobot) = "" Return ' ===================================================================== ' STEPPER-MOTORS MOVE SLOW ' ===================================================================== Variable Numeric MSV1 Variable Numeric MSV2 Variable Numeric MSV3 Variable Numeric MSV4 Variable Numeric MSV5 ' ===================================================================== ' MOVE SLOW ' ===================================================================== Variable Numeric MoveSlow_DestM1 ' destination in mm Variable Numeric MoveSlow_DestM2 ' destination in mm Variable Numeric MoveSlow_DestM3 ' destination in mm Variable Numeric MoveSlow_Speed ' speed in mm/sec Label MoveSlowM1 ' ----------------------------------- test for out of limit Slot(Slot_M1) = Limit(Slot(Slot_M1), M1min, M1max) ' ----------------------------------- test for very low speed If MoveSlow_Speed < 0.1 MoveSlow_Speed = 1 EndIf ' ----------------------------------- calc the movement in mm MSV1 = MoveSlow_DestM1 - Slot(Slot_M1) MSV1 = Abs(MSV1) ' ----------------------------------- calc the loops count MSV4 = MSV1 / 0.01 '<<< loop time MSV4 = Int(MSV4 / MoveSlow_Speed) ' ----------------------------------- too much speed ? If MSV4 = 0 Slot(Slot_M1) = Limit(MoveSlow_DestM1, M1min, M1max) Return EndIf ' ----------------------------------- prepare the increment MSV1 = (MoveSlow_DestM1 - Slot(Slot_M1)) / MSV4 ' ----------------------------------- loop for v4 times For MSV3 = 1 To MSV4 ' ------------------------------- increment, move and wait Slot(Slot_M1) = Limit(Slot(Slot_M1) + MSV1, M1min, M1max) Wait Seconds 0.01 '<<< loop time Next Gosub WaitAllMotors Return Label MoveSlowM2 ' ----------------------------------- test for out of limit Slot(Slot_M2) = Limit(Slot(Slot_M2), M2min, M2max) ' ----------------------------------- test for very low speed If MoveSlow_Speed < 0.1 MoveSlow_Speed = 1 EndIf ' ----------------------------------- calc the movement in mm MSV1 = MoveSlow_DestM2 - Slot(Slot_M2) MSV1 = Abs(MSV1) ' ----------------------------------- calc the loops count MSV4 = MSV1 / 0.01 '<<< loop time MSV4 = Int(MSV4 / MoveSlow_Speed) ' ----------------------------------- too much speed ? If MSV4 = 0 Slot(Slot_M2) = Limit(MoveSlow_DestM2, M2min, M2max) Return EndIf ' ----------------------------------- prepare the increment MSV1 = (MoveSlow_DestM2 - Slot(Slot_M2)) / MSV4 ' ----------------------------------- loop for v4 times For MSV3 = 1 To MSV4 ' ------------------------------- increment, move and wait Slot(Slot_M2) = Limit(Slot(Slot_M2) + MSV1, M2min, M2max) Wait Seconds 0.01 '<<< loop time Next Gosub WaitAllMotors Return Label MoveSlowM3 ' ----------------------------------- test for out of limit Slot(Slot_M3) = Limit(Slot(Slot_M3), M3min, M3max) ' ----------------------------------- test for very low speed If MoveSlow_Speed < 0.1 MoveSlow_Speed = 1 EndIf ' ----------------------------------- calc the movement in mm MSV1 = MoveSlow_DestM3 - Slot(Slot_M3) MSV1 = Abs(MSV1) ' ----------------------------------- calc the loops count MSV4 = MSV1 / 0.01 '<<< loop time MSV4 = Int(MSV4 / MoveSlow_Speed) ' ----------------------------------- too much speed ? If MSV4 = 0 Slot(Slot_M3) = Limit(MoveSlow_DestM3, M3min, M3max) Return EndIf ' ----------------------------------- prepare the increment MSV1 = (MoveSlow_DestM3 - Slot(Slot_M3)) / MSV4 ' ----------------------------------- loop for v4 times For MSV3 = 1 To MSV4 ' ------------------------------- increment, move and wait Slot(Slot_M3) = Limit(Slot(Slot_M3) + MSV1, M3min, M3max) Wait Seconds 0.01 '<<< loop time Next Gosub WaitAllMotors Return Label MoveSlowM1M2 ' ----------------------------------- test for out of limit Slot(Slot_M1) = Limit(Slot(Slot_M1), M1min, M1max) Slot(Slot_M2) = Limit(Slot(Slot_M2), M2min, M2max) ' ----------------------------------- test for very low speed If MoveSlow_Speed < 0.1 MoveSlow_Speed = 1 EndIf ' ----------------------------------- calc the movement in mm MSV1 = MoveSlow_DestM1 - Slot(Slot_M1) MSV2 = MoveSlow_DestM2 - Slot(Slot_M2) MSV3 = MSV1 * MSV1 MSV3 = MSV3 + MSV2 * MSV2 MSV3 = Sqrt(MSV3) ' ----------------------------------- calc the loops count MSV4 = MSV3 / 0.01 '<<< loop time MSV4 = Int(MSV4 / MoveSlow_Speed) ' ----------------------------------- too much speed ? If MSV4 = 0 Slot(Slot_M1) = Limit(MoveSlow_DestM1, M1min, M1max) Slot(Slot_M2) = Limit(MoveSlow_DestM2, M2min, M2max) Return EndIf ' ----------------------------------- prepare the increments MSV1 = (MoveSlow_DestM1 - Slot(Slot_M1)) / MSV4 MSV2 = (MoveSlow_DestM2 - Slot(Slot_M2)) / MSV4 ' ----------------------------------- loop for v4 times For MSV3 = 1 To MSV4 ' ------------------------------- increment, move and wait Slot(Slot_M1) = Limit(Slot(Slot_M1) + MSV1, M1min, M1max) Slot(Slot_M2) = Limit(Slot(Slot_M2) + MSV2, M2min, M2max) Wait Seconds 0.01 '<<< loop time Next Gosub WaitAllMotors Return Label MoveSlowM1M2M3 ' ----------------------------------- test for out of limit Slot(Slot_M1) = Limit(Slot(Slot_M1), M1min, M1max) Slot(Slot_M2) = Limit(Slot(Slot_M2), M2min, M2max) Slot(Slot_M3) = Limit(Slot(Slot_M3), M3min, M3max) ' ----------------------------------- test for very low speed If MoveSlow_Speed < 0.1 MoveSlow_Speed = 1 EndIf ' ----------------------------------- calc the movement in mm MSV1 = MoveSlow_DestM1 - Slot(Slot_M1) MSV2 = MoveSlow_DestM2 - Slot(Slot_M2) MSV3 = MoveSlow_DestM3 - Slot(Slot_M3) MSV3 = MSV1 * MSV1 + MSV2 * MSV2 + MSV3 * MSV3 MSV3 = Sqrt(MSV3) ' ----------------------------------- calc the loops count MSV4 = MSV3 / 0.01 '<<< loop time MSV4 = Int(MSV4 / MoveSlow_Speed) ' ----------------------------------- too much speed ? If MSV4 = 0 Slot(Slot_M1) = Limit(MoveSlow_DestM1, M1min, M1max) Slot(Slot_M2) = Limit(MoveSlow_DestM2, M2min, M2max) Slot(Slot_M3) = Limit(MoveSlow_DestM3, M3min, M3max) Return EndIf ' ----------------------------------- prepare the increments MSV1 = (MoveSlow_DestM1 - Slot(Slot_M1)) / MSV4 MSV2 = (MoveSlow_DestM2 - Slot(Slot_M2)) / MSV4 MSV3 = (MoveSlow_DestM3 - Slot(Slot_M3)) / MSV4 ' ----------------------------------- loop for v4 times For MSV5 = 1 To MSV4 ' ------------------------------- increment, move and wait Slot(Slot_M1) = Limit(Slot(Slot_M1) + MSV1, M1min, M1max) Slot(Slot_M2) = Limit(Slot(Slot_M2) + MSV2, M2min, M2max) Slot(Slot_M3) = Limit(Slot(Slot_M3) + MSV3, M3min, M3max) Wait Seconds 0.01 '<<< loop time Next Gosub WaitAllMotors Return ' ==================================================================== ' CONFIGURATION FILE '===================================================================== Label EditConfigVars Variable String VarsFilePathAndName Variable String EditorFolder Variable String EditorApp ' EditorFolder = ".\Theremino_HAL\Theremino_Notepad\" ' EditorApp = EditorFolder + "Theremino_Notepad.exe" ' VarsFilePathAndName = EditorFolder + "ConfigVars.txt" ' Load EditorApp + " " + VarsFilePathAndName Return ' ╔════════════════════════════════════════════╗ ▀▀█▀ █▀▀█ █▀▀█ █ █ █▀▀▀ █ █ ' ║ JOG WITH KEYBOARD ║ █ █ █ █ ▄▄ █▄▀ █▀▀ ▀▄▀ ' ╚════════════════════════════════════════════╝ █▄█ █▄▄█ █▄▄█ █ ▀▄ █▄▄▄ █ Label ExecKeys Variable Numeric JogSpeed = 1 Select True Case Key("SHIFT") JogSpeed = JogSpeed * 0.1 Case Key("CTRL") JogSpeed = JogSpeed * 0.01 EndSelect ' Select MotorToEdit Case 1 If Key("Up") Slot(Slot_M1) = Limit(Slot(Slot_M1) - JogSpeed, M1min, M1max) EndIf If Key("Down") Slot(Slot_M1) = Limit(Slot(Slot_M1) + JogSpeed, M1min, M1max) EndIf Case 2 If Key("Up") Slot(Slot_M2) = Limit(Slot(Slot_M2) + JogSpeed, M2min, M2max) EndIf If Key("Down") Slot(Slot_M2) = Limit(Slot(Slot_M2) - JogSpeed, M2min, M2max) EndIf Case 3 If Key("Up") Slot(Slot_M3) = Limit(Slot(Slot_M3) + JogSpeed, M3min, M3max) EndIf If Key("Down") Slot(Slot_M3) = Limit(Slot(Slot_M3) - JogSpeed, M3min, M3max) EndIf EndSelect ' PrintValues EnableMotors 'YellowOn UpdateButtons Return ' ╔════════════════════════════════════════════╗ ▀▀█▀ █▀▀█ █▀▀▀ █▄ ▄█ █▀▀█ ▀▀█▀▀ ' ║ MOTOR SELECTION FOR JOG ║ █ █ █ █ ▄▄ █ ▀ █ █ █ █ ' ╚════════════════════════════════════════════╝ █▄█ █▄▄█ █▄▄█ █ █ █▄▄█ █ Variable Numeric MotorToEdit Label defaultcolors Button BtnCoord_M1 Color LightBlue Button BtnCoord_M2 Color LightBlue Button BtnCoord_M3 Color LightBlue Return Label BtnCoord_M1 MotorToEdit = 1 defaultcolors Button BtnCoord_M1 Color Blue Return Label BtnCoord_M2 MotorToEdit = 2 defaultcolors Button BtnCoord_M2 Color Blue Return Label BtnCoord_M3 MotorToEdit = 3 defaultcolors Button BtnCoord_M3 Color Blue Return ' ==================================================================== ' PRINT COORDINATES AND UPDATE COORDINATE BUTTONS ' ==================================================================== Label PrintValues s1 = "Move_M1M2M3 " + Format(Slot(Slot_M1), "0.00") s1 = s1 + " " + Format(Slot(Slot_M2), "0.00") s1 = s1 + " " + Format(Slot(Slot_M3), "0.00") Print CRLF + s1 Return Label UpdateButtons Button BtnCoord_M1 Text "M1=" + Format(Slot(Slot_M1) - Slot(Slot_M1 + 1), "0.00") Button BtnCoord_M2 Text "M2=" + Format(Slot(Slot_M2) - Slot(Slot_M2 + 1), "0.00") Button BtnCoord_M3 Text "M3=" + Format(Slot(Slot_M3) - Slot(Slot_M3 + 1), "0.00") Return '-------------------------------------------------------------- 'Index Name Culture Gender Age '-------------------------------------------------------------- '1 Microsoft David Desktop en-US Male Adult '2 Microsoft Zira Desktop en-US Female Adult '3 Microsoft Elsa Desktop it-IT Female Adult '4 Microsoft Huihui Desktop zh-CN Female Adult '-------------------------------------------------------------- ' ============================= HARDWARE/HAL SET UP DVR8825 ' Motor M1 current 200 mA ' Microstep "-B-" Speed 5000 Acc 200 Step/mm 9.5 ' Motor M2 current 200 mA ' Microstep "-B-" 32 Speed 50000 Acc 250 Step/mm 74.2 reduction ratio 4:1 ' Motor Z current 200 mA ' Microstep " BC" 8 Speed 2000 Acc 100 Step 400 leadscrew: 4mm turn '' ' ============================================================================= ' Folder Demo Programs\SlotText Commands\OLD EXAMPLES\LEO examples ' File RoboAnnoCOBOT_V02.txt ' ============================================================================= '╔═════════════════════════════════════════════════════════╗ '║ Name: RobotAnnoCOBOT_V02.txt Date: 30 Jun 2022 ║ '║ Author: Leonardo ║ '║ Scope: Test the functionality of Palletized arm ║ '╠═════════════════════════════════════════════════════════╣ '║Hardware: RobotAnno model: ║ '╟─────────────────────────────────────────────────────────╢ '║ Note: Cobot version 28 Jun 2022 ║ '║ ║ '╚═════════════════════════════════════════════════════════╝ Option Speed 9 Beep "2500 100, 1500 100" 'Variable Numeric Debug = 0 ' 1 = DEBUG 0 = NORMAL RestoreVars 'Load images\PalletArmBlack.jpg 'Beep "2500 200, 1500 200, 2500 300, 0500, 1500 300" 'TTS SelectVoice Language TTS SetVolume 100 '0 = mute TTS SetSpeed -1 ' ╔══════════════════════════════════════════╗ ' ║ SLOT TEXT for COMMANDS and RESPONSES ║ ' ╚══════════════════════════════════════════╝ Variable Numeric Slot_CommandsToCobot = 51 Variable Numeric Slot_ResponsesFromCobot = 52 Variable Numeric Slot_CommandsFromCobot = 53 ' ╔══════════════════════════════════════════╗ █ █ █▀▀█ █▀▀▀█ ' ║ VARIABLE INITIALIZATIONS & ASSIGNEMENTS ║ █ █ █▄▄█ █▄▄▄█ ' ╚══════════════════════════════════════════╝ ▀▄▀ █ █ █ ▀▄ 'Variable Numeric NumCycle 'Variable Numeric StartTime 'Variable String Result 'Variable Numeric Slot_Emergency Variable Numeric Slot_M1 = 101 Variable Numeric Slot_M2 = 201 Variable Numeric Slot_M3 = 301 Variable Numeric Slot_M4 = 401 Variable Numeric Slot_M5 = 501 Variable Numeric Slot_M6 = 601 Variable Numeric Slot_M7 = 701 'Variable Numeric Slot_EnableMotors = 11 Variable Numeric Slot_AnalogBut = 4 Variable Numeric Slot_LedR = 19 Variable Numeric Slot_LedG = 20 Variable Numeric Slot_LedB = 21 Variable Numeric Slot_SignalScope = 13 ' -------------------------------------- Software limits Variable Numeric M1max = 0 Variable Numeric M1min = 360 Variable Numeric M2max = 0 Variable Numeric M2min = 360 Variable Numeric M3max = 0 Variable Numeric M3min = 360 Variable Numeric M4max = 0 Variable Numeric M4min = 360 Variable Numeric M5max = 0 Variable Numeric M5min = 360 Variable Numeric M6max = 0 Variable Numeric M6min = 360 Variable Numeric M7max = 10 Variable Numeric M7min = 170 Key 1 BtnCoord_M1 Key 2 BtnCoord_M2 Key 3 BtnCoord_M3 Key 4 BtnCoord_M4 Key 5 BtnCoord_M5 Key 6 BtnCoord_M6 Key 7 BtnCoord_M7 ' ╔══════════════════════════════════════════╗ █▀▀▄ █ █ ▀▀█▀▀ ' ║ BUTTONS ║ █▀▀█ █ █ █ ' ╚══════════════════════════════════════════╝ █▄▄█ █▄▄█ █ Button 1 Text HardHome Button HardHome Color Coral Button 2 Text "BtnCoord_M1" Button BtnCoord_M1 Text "M1 = ?" Button BtnCoord_M1 Color LightBlue Button 3 Text "BtnCoord_M2" Button BtnCoord_M2 Text "M2 = ?" Button BtnCoord_M2 Color LightBlue Button 4 Text "BtnCoord_M3" Button BtnCoord_M3 Text "M3 = ?" Button BtnCoord_M3 Color LightBlue Button 5 Text "BtnCoord_M4" Button BtnCoord_M4 Text "M4 = ?" Button BtnCoord_M4 Color LightBlue Button 6 Text "BtnCoord_M5" Button BtnCoord_M5 Text "M5 = ?" Button BtnCoord_M5 Color LightBlue Button 7 Text "BtnCoord_M6" Button BtnCoord_M6 Text "M6 = ?" Button BtnCoord_M6 Color LightBlue Button 7 Text "BtnCoord_M7" Button BtnCoord_M7 Text "M7= ?" Button BtnCoord_M7 Color LightBlue Button 17 Text YELLOW Button Yellow Color Yellow Button 18 Text BLUE Button Blue Color Blue Button 19 Text RED Button Red Color Red Button 20 Text GREEN Button Green Color Green Button 21 Text WHITE Button White Color White Button 22 Text BLACK Button Black Color Black Button 23 Text SafePos Button SafePos Text "90 90 90" Button SafePos Color Bisque Button 24 Text ColorButton Button ColorButton Text "COLOR BUTTON" Button ColorButton Color Plum Button 25 Text ExecCobot Button ExecCobot Text "Exec Cobot" Button ExecCobot Color Cyan Button 27 Text MotorTest Button MotorTest Text "MotorTest" Button MotorTest Color Orange Button 16 Text CloseAll Button CloseAll Text "CLOSE ALL" Button CloseAll Color Red ' 'Button 17 Text RepTest 'Button RepTest Text " "REPET.TEST"" 'Button RepTest Color Khaki 'Button 16 Text Emergency 'Button Emergency Text "EMERGENCY" 'Button Emergency Color Red 'Button Emergency Slot Slot_Emergency 'Button 17 Text RedOn 'Button RedOn Color Red 'Button 18 Text GreenOn 'Button GreenOn Color Green 'Button 19 Text YellowOn 'Button YellowOn Color Yellow 'Button 20 Text BlueOn 'Button BlueOn Color MediumBlue 'Button 21 Text WhiteOn 'Button GreenOn Color Green 'Button 22 Text RgbOff 'Button RgbOff Color Black ' -------------------------------------- KEYS Key Right Gosub ExecKeys Key Left Gosub ExecKeys Key Up Gosub ExecKeys Key Down Gosub ExecKeys Key Pageup Gosub ExecKeys Key Pagedown Gosub ExecKeys ' ╔══════════════════════════════════════════╗ █ █▀▀█ █▀▀█ █▀▀▄ ' ║ LOAD APPS ║ █ █ █ █▄▄█ █ █ ' ╚══════════════════════════════════════════╝ █▄▄ █▄▄█ █ █ █▄▄█ Load Theremino_HAL.exe Load Theremino_SlotViewer.exe Load Theremino_SlotViewer_Strings.exe Load Theremino_Cobot.exe 'Load Theremino_SignalScope.exe ' ╔══════════════════════════════════════════╗ █▀▀▀ ▀▀█▀▀ █▀▀▀█ █▀▀▀█ ▀▀█▀▀ ' ║ START FROM HERE ║ ▀▀▀█ █ █▀▀▀█ █▀█▀▀ █ ' ╚══════════════════════════════════════════╝ ▄▄▄█ █ █ █ █ ▀▄ █ 'EnableMotors Controls OpenTextBox DisableAllButtons Controls ClearTextBox GreenOn Print TTSvoices EnableAllButtons 'HardHome Load Hide 'Loop Stop ' ╔══════════════════════════════════════════╗ █ █▀▀█ █▀▀█ █▀▀█ ' ║ LOOP ║ █ █ █ █ █ █▄▄█ ' ╚══════════════════════════════════════════╝ █▄▄ █▄▄█ █▄▄█ █ Label Loop ' ------------------------------------------ ' 0.02 sec. or more to allow time for keys and other tasks Wait Seconds 0.02 ' --------------------------------------------------------- Goto Loop ' ╔══════════════════════════════════════════╗ ' ║ ENABLE/DISABLE BUTTONS ║ ' ╚══════════════════════════════════════════╝ Label EnableAllButtons For v1 = 1 To 16 Button v1 Enabled Next Return Label DisableAllButtons For v1 = 1 To 16 Button v1 Disabled Next Return ' ╔══════════════════════════════════════════╗ ' ║ SAVE LOAD VARS ║ ' ╚══════════════════════════════════════════╝ Label SaveVars Save Vars Print CRLF + "SAVED SEQUENCENAME = " + s1 + CRLF Return Label RestoreVars Load Vars Return ' ╔══════════════════════════════════════════╗ █▀▀ █ █▀▀█ █▀▀▀ █▀▀▀ ' ║ CLOSE ALL ║ █ █ █ █ ▀▀▀█ █▀▀ ' ╚══════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█ ▄▄▄█ █▄▄▄ Label CloseAll RedOn SaveVars StopCobot Window Sizable Slot(Slot_SignalScope) = 0 TTS Speak "End Of Program." SafePos Load CloseApps Return ' ╔════════════════════════════════════════════╗ █▀▀▀ ▀▀█▀▀ █▀▀█ █▀▀█ ' ║ STOP EVENT (when pressing stop button) ║ ▀▀▀█ █ █ █ █▄▄█ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █▄▄█ █ Label EventStop SaveVars RedOn StopCobot EnableAllButtons Window Sizable Slot(Slot_SignalScope) = 0 TTS Speak "End Of Program." SafePos End ' ╔══════════════════════════════════════════╗ █ █ █▀▀█ █▀▀█ █▀▀▄ █ █ █▀▀█ █▄ ▄█ █▀▀▀ ' ║ HARD HOME ALL 3 STEPPERS ║ █▀▀█ █▀▀█ ██▀▀ █ █ █▀▀█ █ █ █ ▀ █ █▀▀ ' ╚══════════════════════════════════════════╝ █ █ █ █ █ ▀▄ █▄▄█ █ █ █▄▄█ █ █ █▄▄▄ Label HardHome HomeM1 HomeM2 HomeM3 HomeM4 HomeM5 HomeM6 HomeM7 Return ' ============================================================ ' Wait until the rotation motor is stopped ' ============================================================ Label HomeM1 Slot(Slot_M1) = Reset Wait Seconds 0.1 Slot(Slot_M1) = 90 Wait Seconds 0.1 'Gosub PrintValues Slot(Slot_M1) = 90 Return Label HomeM2 Slot(Slot_M2) = Reset Wait Seconds 0.1 Slot(Slot_M2) = 90 Wait Seconds 0.1 'Gosub PrintValues Slot(Slot_M2) = 90 Return Label HomeM3 Slot(Slot_M3) = Reset Wait Seconds 0.1 Slot(Slot_M3) = 90 Wait Seconds 0.1 'Gosub PrintValues Slot(Slot_M3) = 90 Return Label HomeM4 Slot(Slot_M4) = Reset Wait Seconds 0.1 Slot(Slot_M4) = 90 Wait Seconds 0.1 'Gosub PrintValues Slot(Slot_M4) = 90 Return Label HomeM5 Slot(Slot_M5) = Reset Wait Seconds 0.1 Slot(Slot_M5) = 90 Wait Seconds 0.1 'Gosub PrintValues Slot(Slot_M5) = 90 Return Label HomeM6 Slot(Slot_M6) = Reset Wait Seconds 0.1 Slot(Slot_M6) = 90 Wait Seconds 0.1 'Gosub PrintValues Slot(Slot_M6) = 90 Return Label HomeM7 Slot(Slot_M7) = Reset Wait Seconds 0.1 Slot(Slot_M7) = 500 Wait Seconds 0.1 'Gosub PrintValues Slot(Slot_M6) = 500 Return ' ╔══════════════════════════════════════════╗ █ █ █▀▀█ █ ▀▀█▀▀ ' ║ WAIT ALL MOTOR until stopped ║ █ █ █▄▄█ █ █ ' ╚══════════════════════════════════════════╝ ▀▄▀▄▀ █ █ █ █ Label WaitAllMotors Variable Numeric WAM1 Wait Seconds 0.1 For WAM1 = 1 To Infinity If Abs(Slot(Slot_M1 + 1)) < 0.01 If Abs(Slot(Slot_M2 + 1)) < 0.01 If Abs(Slot(Slot_M3 + 1)) < 0.01 If Abs(Slot(Slot_M4 + 1)) < 0.01 If Abs(Slot(Slot_M5 + 1)) < 0.01 If Abs(Slot(Slot_M6 + 1)) < 0.01 Exit EndIf EndIf EndIf EndIf EndIf EndIf Wait Seconds 0.05 UpdateButtons Next Return ' ╔══════════════════════════════════════════╗ ' ║ EMERGENCY ║ ' ╚══════════════════════════════════════════╝ Label Emergency ' DisableAllButtons ' Button 15 Enabled ' Button 15 Color Flashing7 Yellow Red ' For v1 = 1 To Infinity ' RedOn ' Wait Seconds 0.4 ' RgbOff ' Wait Seconds 0.4 ' Load sound\Alarm10b.wav ' Next Stop ' ╔══════════════════════════════════════════╗ █ █▀▀ █▀▀▄ ' ║ LED COLORS ║ █ █▀ █ █ ' ╚══════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█ Label RedOn TTS Speak "Status red." Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Wait TTSready Return Label MagentaOn Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label YellowOn TTS Speak "Status yellow." Slot Slot_LedR = 900 Slot Slot_LedG = 400 Slot Slot_LedB = 0 Wait TTSready Return Label GreenOn TTS Speak "Status green." Slot Slot_LedR = 0 Slot Slot_LedG = 1000 Slot Slot_LedB = 0 Wait TTSready Return Label BlueOn TTS Speak "Status blue." Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Wait TTSready Return Label WhiteOn TTS Speak "Status white." Slot Slot_LedR = 1000 Slot Slot_LedG = 1000 Slot Slot_LedB = 1000 Wait TTSready Return Label RgbOff TTS Speak "Status black." Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Wait TTSready Return Label RedBlink RedOn WhiteOn Return ' ╔══════════════════════════════════════════╗ █▀▀▀ █▀▀█ █ █▀▀▄ █ █ ▀▀█▀▀ ' ║ COLOR BUTTON ║ █ █ █ █ █▀▀█ █ █ █ ' ╚══════════════════════════════════════════╝ █▄▄▄ █▄▄█ █▄▄▄ █▄▄█ █▄▄█ █ Label ColorButton Button ColorButton Color Flashing7 Black White For v1 = 1 To Infinity If Int(Slot(Slot_AnalogBut)) = 0 And Slot(Slot_AnalogBut) < 2 YELLOW EndIf If Int(Slot(Slot_AnalogBut)) > 43 And Slot(Slot_AnalogBut) < 49 BLUE EndIf If Int(Slot(Slot_AnalogBut)) > 244 And Slot(Slot_AnalogBut) < 250 RED EndIf If Slot(Slot_AnalogBut) > 128 And Slot(Slot_AnalogBut) < 134 GREEN EndIf If Int(Slot(Slot_AnalogBut)) > 521 And Slot(Slot_AnalogBut) < 527 WHITE EndIf Wait Seconds 0.01 Next Return ' ╔══════════════════════════════════════════╗ █▀▀█ █▀▀█ █▄ ▄█ █▀▀▀ █▀▀█ █ ' ║ ARM COLOR POSITION ║ █▄▄█ █▄▄█ █ ▀ █ █ █ █ █ ' ╚══════════════════════════════════════════╝ █ █ █ ▀▄ █ █ █▄▄▄ █▄▄█ █▄▄▄ Label MotorTest Variable Numeric MO1 For MO1 = 1 To Infinity Slot(Slot_M1) = 0 Slot(Slot_M2) = 0 Slot(Slot_M3) = 0 Slot(Slot_M4) = 0 Slot(Slot_M5) = 45 Slot(Slot_M6) = 0 Slot(Slot_M7) = 100 WaitAllMotors Slot(Slot_M6) = 180 WaitAllMotors Slot(Slot_M6) = 0 WaitAllMotors ' Wait Seconds 0.5 Slot(Slot_M1) = 90 Slot(Slot_M2) = 90 Slot(Slot_M3) = 180 Slot(Slot_M4) = 180 Slot(Slot_M5) = 135 Slot(Slot_M6) = 180 Slot(Slot_M7) = 900 WaitAllMotors Wait Seconds 0.5 Next Return Label YELLOW TTS Speak "Going to yellow dear Kemiao." SafePos Slot(Slot_M1) = 66 Slot(Slot_M2) = 67.35 Slot(Slot_M3) = 72.50 WaitAllMotors Return Label BLUE TTS Speak "Going to blue." SafePos Slot(Slot_M1) = 84 Slot(Slot_M2) = 69.49 Slot(Slot_M3) = 68.75 WaitAllMotors Return Label RED TTS Speak "Going to red." SafePos Slot(Slot_M1) = 93 Slot(Slot_M2) = 69 Slot(Slot_M3) = 62 WaitAllMotors Return Label GREEN TTS Speak "Going to green." SafePos Slot(Slot_M1) = 69 Slot(Slot_M2) = 70.20 Slot(Slot_M3) = 64.27 WaitAllMotors Return Label BLACK TTS Speak "Going to black." SafePos Slot(Slot_M1) = 122 Slot(Slot_M2) = 70 Slot(Slot_M3) = 68 WaitAllMotors Return Label WHITE TTS Speak "Going to white." SafePos Slot(Slot_M1) = 104 Slot(Slot_M2) = 69.49 Slot(Slot_M3) = 68.75 WaitAllMotors Return Label SafePos Slot(Slot_M1) = 90 Slot(Slot_M2) = 90 Slot(Slot_M3) = 90 Slot(Slot_M4) = 90 Slot(Slot_M5) = 90 Slot(Slot_M6) = 90 Slot(Slot_M7) = 170 WaitAllMotors Return Label RepTest For v99 = 1 To Infinity Slot(Slot_M1) = 70 Slot(Slot_M2) = 90 Slot(Slot_M3) = 90 WaitAllMotors Slot(Slot_M1) = 110 Slot(Slot_M2) = 90 Slot(Slot_M3) = 90 WaitAllMotors Slot(Slot_M1) = 90 Slot(Slot_M2) = 76 Slot(Slot_M3) = 82 WaitAllMotors Wait Seconds 0.2 Slot(Slot_M1) = 90 Slot(Slot_M2) = 76 Slot(Slot_M3) = 76 WaitAllMotors Wait Seconds 1.3 Slot(Slot_M1) = 90 Slot(Slot_M2) = 76 Slot(Slot_M3) = 82 WaitAllMotors Next Return Label SayYellow TTS Speak "Going Yellow target." Wait TTSready Return Label SayGreen TTS Speak "Going Green target, time interpolate 1 second." Wait TTSready Return Label SayBlue TTS Speak "RobotANNO Going Blue target." Wait TTSready ClearCommand Return Label SayRed TTS Speak "Going Red target, time interpolate 2 value." Wait TTSready Return Label SayWhite TTS Speak "Going White target, time interpolate 2.5 value." Wait TTSready Return Label SayBlack TTS Speak "Going Black target, time interpolate 3 value." Wait TTSready Return Label SayFastRndMove TTS Speak "Making random movement at high speed." Wait TTSready Return ' ===================================================================== ' STEPPER-MOTORS MOVE SLOW ' ===================================================================== Variable Numeric MSV1 Variable Numeric MSV2 Variable Numeric MSV3 Variable Numeric MSV4 Variable Numeric MSV5 ' ===================================================================== ' MOVE SLOW ' ===================================================================== Variable Numeric MoveSlow_DestM1 ' destination in mm Variable Numeric MoveSlow_DestM2 ' destination in mm Variable Numeric MoveSlow_DestM3 ' destination in mm Variable Numeric MoveSlow_Speed ' speed in mm/sec Label MoveSlowM1 ' ----------------------------------- test for out of limit Slot(Slot_M1) = Limit(Slot(Slot_M1), M1min, M1max) ' ----------------------------------- test for very low speed If MoveSlow_Speed < 0.1 MoveSlow_Speed = 1 EndIf ' ----------------------------------- calc the movement in mm MSV1 = MoveSlow_DestM1 - Slot(Slot_M1) MSV1 = Abs(MSV1) ' ----------------------------------- calc the loops count MSV4 = MSV1 / 0.01 '<<< loop time MSV4 = Int(MSV4 / MoveSlow_Speed) ' ----------------------------------- too much speed ? If MSV4 = 0 Slot(Slot_M1) = Limit(MoveSlow_DestM1, M1min, M1max) Return EndIf ' ----------------------------------- prepare the increment MSV1 = (MoveSlow_DestM1 - Slot(Slot_M1)) / MSV4 ' ----------------------------------- loop for v4 times For MSV3 = 1 To MSV4 ' ------------------------------- increment, move and wait Slot(Slot_M1) = Limit(Slot(Slot_M1) + MSV1, M1min, M1max) Wait Seconds 0.01 '<<< loop time Next Gosub WaitAllMotors Return Label MoveSlowM2 ' ----------------------------------- test for out of limit Slot(Slot_M2) = Limit(Slot(Slot_M2), M2min, M2max) ' ----------------------------------- test for very low speed If MoveSlow_Speed < 0.1 MoveSlow_Speed = 1 EndIf ' ----------------------------------- calc the movement in mm MSV1 = MoveSlow_DestM2 - Slot(Slot_M2) MSV1 = Abs(MSV1) ' ----------------------------------- calc the loops count MSV4 = MSV1 / 0.01 '<<< loop time MSV4 = Int(MSV4 / MoveSlow_Speed) ' ----------------------------------- too much speed ? If MSV4 = 0 Slot(Slot_M2) = Limit(MoveSlow_DestM2, M2min, M2max) Return EndIf ' ----------------------------------- prepare the increment MSV1 = (MoveSlow_DestM2 - Slot(Slot_M2)) / MSV4 ' ----------------------------------- loop for v4 times For MSV3 = 1 To MSV4 ' ------------------------------- increment, move and wait Slot(Slot_M2) = Limit(Slot(Slot_M2) + MSV1, M2min, M2max) Wait Seconds 0.01 '<<< loop time Next Gosub WaitAllMotors Return Label MoveSlowM3 ' ----------------------------------- test for out of limit Slot(Slot_M3) = Limit(Slot(Slot_M3), M3min, M3max) ' ----------------------------------- test for very low speed If MoveSlow_Speed < 0.1 MoveSlow_Speed = 1 EndIf ' ----------------------------------- calc the movement in mm MSV1 = MoveSlow_DestM3 - Slot(Slot_M3) MSV1 = Abs(MSV1) ' ----------------------------------- calc the loops count MSV4 = MSV1 / 0.01 '<<< loop time MSV4 = Int(MSV4 / MoveSlow_Speed) ' ----------------------------------- too much speed ? If MSV4 = 0 Slot(Slot_M3) = Limit(MoveSlow_DestM3, M3min, M3max) Return EndIf ' ----------------------------------- prepare the increment MSV1 = (MoveSlow_DestM3 - Slot(Slot_M3)) / MSV4 ' ----------------------------------- loop for v4 times For MSV3 = 1 To MSV4 ' ------------------------------- increment, move and wait Slot(Slot_M3) = Limit(Slot(Slot_M3) + MSV1, M3min, M3max) Wait Seconds 0.01 '<<< loop time Next Gosub WaitAllMotors Return Label MoveSlowM1M2 ' ----------------------------------- test for out of limit Slot(Slot_M1) = Limit(Slot(Slot_M1), M1min, M1max) Slot(Slot_M2) = Limit(Slot(Slot_M2), M2min, M2max) ' ----------------------------------- test for very low speed If MoveSlow_Speed < 0.1 MoveSlow_Speed = 1 EndIf ' ----------------------------------- calc the movement in mm MSV1 = MoveSlow_DestM1 - Slot(Slot_M1) MSV2 = MoveSlow_DestM2 - Slot(Slot_M2) MSV3 = MSV1 * MSV1 MSV3 = MSV3 + MSV2 * MSV2 MSV3 = Sqrt(MSV3) ' ----------------------------------- calc the loops count MSV4 = MSV3 / 0.01 '<<< loop time MSV4 = Int(MSV4 / MoveSlow_Speed) ' ----------------------------------- too much speed ? If MSV4 = 0 Slot(Slot_M1) = Limit(MoveSlow_DestM1, M1min, M1max) Slot(Slot_M2) = Limit(MoveSlow_DestM2, M2min, M2max) Return EndIf ' ----------------------------------- prepare the increments MSV1 = (MoveSlow_DestM1 - Slot(Slot_M1)) / MSV4 MSV2 = (MoveSlow_DestM2 - Slot(Slot_M2)) / MSV4 ' ----------------------------------- loop for v4 times For MSV3 = 1 To MSV4 ' ------------------------------- increment, move and wait Slot(Slot_M1) = Limit(Slot(Slot_M1) + MSV1, M1min, M1max) Slot(Slot_M2) = Limit(Slot(Slot_M2) + MSV2, M2min, M2max) Wait Seconds 0.01 '<<< loop time Next Gosub WaitAllMotors Return Label MoveSlowM1M2M3 ' ----------------------------------- test for out of limit Slot(Slot_M1) = Limit(Slot(Slot_M1), M1min, M1max) Slot(Slot_M2) = Limit(Slot(Slot_M2), M2min, M2max) Slot(Slot_M3) = Limit(Slot(Slot_M3), M3min, M3max) ' ----------------------------------- test for very low speed If MoveSlow_Speed < 0.1 MoveSlow_Speed = 1 EndIf ' ----------------------------------- calc the movement in mm MSV1 = MoveSlow_DestM1 - Slot(Slot_M1) MSV2 = MoveSlow_DestM2 - Slot(Slot_M2) MSV3 = MoveSlow_DestM3 - Slot(Slot_M3) MSV3 = MSV1 * MSV1 + MSV2 * MSV2 + MSV3 * MSV3 MSV3 = Sqrt(MSV3) ' ----------------------------------- calc the loops count MSV4 = MSV3 / 0.01 '<<< loop time MSV4 = Int(MSV4 / MoveSlow_Speed) ' ----------------------------------- too much speed ? If MSV4 = 0 Slot(Slot_M1) = Limit(MoveSlow_DestM1, M1min, M1max) Slot(Slot_M2) = Limit(MoveSlow_DestM2, M2min, M2max) Slot(Slot_M3) = Limit(MoveSlow_DestM3, M3min, M3max) Return EndIf ' ----------------------------------- prepare the increments MSV1 = (MoveSlow_DestM1 - Slot(Slot_M1)) / MSV4 MSV2 = (MoveSlow_DestM2 - Slot(Slot_M2)) / MSV4 MSV3 = (MoveSlow_DestM3 - Slot(Slot_M3)) / MSV4 ' ----------------------------------- loop for v4 times For MSV5 = 1 To MSV4 ' ------------------------------- increment, move and wait Slot(Slot_M1) = Limit(Slot(Slot_M1) + MSV1, M1min, M1max) Slot(Slot_M2) = Limit(Slot(Slot_M2) + MSV2, M2min, M2max) Slot(Slot_M3) = Limit(Slot(Slot_M3) + MSV3, M3min, M3max) Wait Seconds 0.01 '<<< loop time Next Gosub WaitAllMotors Return ' ==================================================================== ' CONFIGURATION FILE '===================================================================== Label EditConfigVars Variable String VarsFilePathAndName Variable String EditorFolder Variable String EditorApp ' EditorFolder = ".\Theremino_HAL\Theremino_Notepad\" ' EditorApp = EditorFolder + "Theremino_Notepad.exe" ' VarsFilePathAndName = EditorFolder + "ConfigVars.txt" ' Load EditorApp + " " + VarsFilePathAndName Return ' ╔══════════════════════════════════════════╗ ▀▀█▀ █▀▀█ █▀▀█ █ █ █▀▀▀ █ █ ' ║ JOG WITH KEYBOARD ║ █ █ █ █ ▄▄ █▄▀ █▀▀ ▀▄▀ ' ╚══════════════════════════════════════════╝ █▄█ █▄▄█ █▄▄█ █ ▀▄ █▄▄▄ █ Label ExecKeys Variable Numeric JogSpeed = 1 Select True Case Key("SHIFT") JogSpeed = JogSpeed * 0.1 Case Key("CTRL") JogSpeed = JogSpeed * 0.01 EndSelect ' Select MotorToEdit Case 1 If Key("Up") Slot(Slot_M1) = Limit(Slot(Slot_M1) - JogSpeed, M1min, M1max) EndIf If Key("Down") Slot(Slot_M1) = Limit(Slot(Slot_M1) + JogSpeed, M1min, M1max) EndIf Case 2 If Key("Up") Slot(Slot_M2) = Limit(Slot(Slot_M2) + JogSpeed, M2min, M2max) EndIf If Key("Down") Slot(Slot_M2) = Limit(Slot(Slot_M2) - JogSpeed, M2min, M2max) EndIf Case 3 If Key("Up") Slot(Slot_M3) = Limit(Slot(Slot_M3) + JogSpeed, M3min, M3max) EndIf If Key("Down") Slot(Slot_M3) = Limit(Slot(Slot_M3) - JogSpeed, M3min, M3max) EndIf Case 4 If Key("Up") Slot(Slot_M4) = Limit(Slot(Slot_M4) - JogSpeed, M1min, M1max) EndIf If Key("Down") Slot(Slot_M4) = Limit(Slot(Slot_M4) + JogSpeed, M4min, M4max) EndIf Case 5 If Key("Up") Slot(Slot_M5) = Limit(Slot(Slot_M5) + JogSpeed, M5min, M5max) EndIf If Key("Down") Slot(Slot_M5) = Limit(Slot(Slot_M5) - JogSpeed, M5min, M5max) EndIf Case 6 If Key("Up") Slot(Slot_M6) = Limit(Slot(Slot_M6) + JogSpeed, M6min, M6max) EndIf If Key("Down") Slot(Slot_M6) = Limit(Slot(Slot_M6) - JogSpeed, M6min, M6max) EndIf Case 7 If Key("Up") Slot(Slot_M7) = Limit(Slot(Slot_M7) - JogSpeed, M7min, M7max) EndIf If Key("Down") Slot(Slot_M7) = Limit(Slot(Slot_M7) + JogSpeed, M7min, M7max) EndIf EndSelect ' PrintValues 'EnableMotors YellowOn UpdateButtons Return ' ╔══════════════════════════════════════════╗ ▀▀█▀ █▀▀█ █▀▀▀ █▄ ▄█ █▀▀█ ▀▀█▀▀ ' ║ MOTOR SELECTION FOR JOG ║ █ █ █ █ ▄▄ █ ▀ █ █ █ █ ' ╚══════════════════════════════════════════╝ █▄█ █▄▄█ █▄▄█ █ █ █▄▄█ █ Variable Numeric MotorToEdit Label defaultcolors Button BtnCoord_M1 Color LightBlue Button BtnCoord_M2 Color LightBlue Button BtnCoord_M3 Color LightBlue Return Label BtnCoord_M1 MotorToEdit = 1 defaultcolors Button BtnCoord_M1 Color Blue Return Label BtnCoord_M2 MotorToEdit = 2 defaultcolors Button BtnCoord_M2 Color Blue Return Label BtnCoord_M3 MotorToEdit = 3 defaultcolors Button BtnCoord_M3 Color Blue Return Label BtnCoord_M4 MotorToEdit = 4 defaultcolors Button BtnCoord_M4 Color Blue Return Label BtnCoord_M5 MotorToEdit = 5 defaultcolors Button BtnCoord_M5 Color Blue Return Label BtnCoord_M6 MotorToEdit = 6 defaultcolors Button BtnCoord_M6 Color Blue Return Label BtnCoord_M7 MotorToEdit = 7 defaultcolors Button BtnCoord_M7 Color Blue Return ' ==================================================================== ' PRINT COORDINATES AND UPDATE COORDINATE BUTTONS ' ==================================================================== Label PrintValues s1 = "Move_M1M2M3 " + Format(Slot(Slot_M1), "0.00") s1 = s1 + " " + Format(Slot(Slot_M2), "0.00") s1 = s1 + " " + Format(Slot(Slot_M3), "0.00") Print CRLF + s1 Return Label UpdateButtons Button BtnCoord_M1 Text "M1=" + Format(Slot(Slot_M1) - Slot(Slot_M1 + 1), "0.00") Button BtnCoord_M2 Text "M2=" + Format(Slot(Slot_M2) - Slot(Slot_M2 + 1), "0.00") Button BtnCoord_M3 Text "M3=" + Format(Slot(Slot_M3) - Slot(Slot_M3 + 1), "0.00") Button BtnCoord_M4 Text "M4=" + Format(Slot(Slot_M4) - Slot(Slot_M4 + 1), "0.00") Button BtnCoord_M5 Text "M5=" + Format(Slot(Slot_M5) - Slot(Slot_M5 + 1), "0.00") Button BtnCoord_M6 Text "M6=" + Format(Slot(Slot_M6) - Slot(Slot_M6 + 1), "0.00") Button BtnCoord_M7 Text "M7=" + Format(Slot(Slot_M7) - Slot(Slot_M7 + 1), "0.00") Return ' ╔══════════════════════════════════════════╗ █▀▀▀ █▀▀█ █▄ ▄█ █▄ ▄█ █▀▀▀ ▀▄ ▄▀ █▀▀▀ █▀▀▀ ' ║ COMMANDS FROM COBOT ║ █ █ █ █ ▀ █ █ ▀ █ █▀▀ █ █▀ █ ' ╚══════════════════════════════════════════╝ █▄▄▄ █▄▄█ █ █ █ █ █▄▄▄ ▄▀ ▀▄ █▄▄▄ █▄▄▄ Label Event_CommandsFromCobot ' ------------------------------------------------------ Do not print lines containing '' Print " Exec: " + CommandText + CRLF ' ------------------------------------------------------ Select CommandText ' ---------------------------------------------- ACTIONS Case "HardHome" HardHome Case "WaitAllMotors" WaitAllMotors ' -------------------------------------------- Motor movementD COLO Case "Red" RED Case "Green" GREEN Case "Blue" BLUE Case "Yellow" YELLOW Case "BLACK" BLACK ' -------------------------------------------- Speaking Case "SayYellow" SayYellow Case "SayGreen" SayGreen Case "SayBlue" SayBlue Case "SayRed" SayRed Case "SayWhite" SayWhite Case "SayBlack" SayBlack Case "SayFastRndMove" SayFastRndMove ' ---------------------------------------------- LED COLORS Case "RedOn" RedOn Case "GreenON" GreenOn Case "MagentaOn" MagentaOn Case "GreenON" GreenOn Case "BlueOn" BlueOn Case "YellowOn" YellowOn Case "WhiteOn" WhiteOn Case "RGBOFF" RgbOff Case "Pause" Wait Seconds GetSeparatedString(CommandText, 1) CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + CommandText + CRLF Beep Stop ' EndSelect ClearCommand Return Label ClearCommand SlotText(Slot_CommandsFromCobot) = "" Return ' ==================================================================== ' COMMANDS TO Cobot ' ==================================================================== Variable String Command Label SendCommand SlotText Slot_CommandsToCobot = "" Wait Seconds 0.05 SlotText Slot_CommandsToCobot = Command Wait Seconds 0.05 Return Label ExecCobot Variable Numeric EC1 For EC1 = 1 To Infinity Command = "DisableRepeat" SendCommand Command = "SelectLine 1" SendCommand Command = "StartExecution" SendCommand WaitCobotReady Next Return Label StopCobot Command = "StopExecution" SendCommand Return Label WaitCobotReady Variable Numeric WCR1 For WCR1 = 1 To Infinity UpdateButtons Wait Seconds 0.05 If SlotText(Slot_ResponsesFromCobot) = "Ready" Exit EndIf Next Return '-------------------------------------------------------------- 'Index Name Culture Gender Age '-------------------------------------------------------------- '1 Microsoft David Desktop en-US Male Adult '2 Microsoft Zira Desktop en-US Female Adult '3 Microsoft Elsa Desktop it-IT Female Adult '4 Microsoft Huihui Desktop zh-CN Female Adult '-------------------------------------------------------------- ' ============================================================================= ' Folder Demo Programs\SlotText Commands\OLD EXAMPLES\LEO examples ' File RoboAnnoStepArm_V00.txt ' ============================================================================= '╔═════════════════════════════════════════════════════════╗ '║ Name: RobotAnnoStepArm_V00.txt Date: 01 Jul 2022 ║ '║ Author: Leonardo ║ '║ Scope: Test the overall functionality ║ '╠═════════════════════════════════════════════════════════╣ '║Hardware: RobotAnno model: ║ '╟─────────────────────────────────────────────────────────╢ '║ Note: First day 28 Jun 2022 ║ '║ ║ '╚═════════════════════════════════════════════════════════╝ Option Speed 9 Beep "2500 100, 1500 100" 'Variable Numeric Debug = 0 ' 1 = DEBUG 0 = NORMAL RestoreVars 'Load images\PalletArmBlack.jpg 'Beep "2500 200, 1500 200, 2500 300, 0500, 1500 300" 'TTS SelectVoice Language TTS SetVolume 100 '0 = mute TTS SetSpeed -1 ' ╔══════════════════════════════════════════╗ ' ║ SLOT TEXT for COMMANDS and RESPONSES ║ ' ╚══════════════════════════════════════════╝ Variable Numeric Slot_CommandsToCobot = 51 Variable Numeric Slot_ResponsesFromCobot = 52 Variable Numeric Slot_CommandsFromCobot = 53 ' ╔══════════════════════════════════════════╗ █ █ █▀▀█ █▀▀▀█ ' ║ VARIABLE INITIALIZATIONS & ASSIGNEMENTS ║ █ █ █▄▄█ █▄▄▄█ ' ╚══════════════════════════════════════════╝ ▀▄▀ █ █ █ ▀▄ 'Variable Numeric NumCycle 'Variable Numeric StartTime 'Variable String Result 'Variable Numeric Slot_Emergency Variable Numeric Slot_M1 = 101 Variable Numeric Slot_M2 = 201 Variable Numeric Slot_M3 = 301 Variable Numeric Slot_M4 = 401 Variable Numeric Slot_M5 = 501 Variable Numeric Slot_M6 = 601 Variable Numeric Slot_M7 = 701 'Variable Numeric Slot_EnableMotors = 11 Variable Numeric Slot_AnalogBut = 11 Variable Numeric Slot_LedR = 19 Variable Numeric Slot_LedG = 20 Variable Numeric Slot_LedB = 21 Variable Numeric Slot_SignalScope = 13 ' -------------------------------------- Software limits Variable Numeric M1max = 0 Variable Numeric M1min = 360 Variable Numeric M2max = 0 Variable Numeric M2min = 360 Variable Numeric M3max = 0 Variable Numeric M3min = 360 Variable Numeric M4max = 0 Variable Numeric M4min = 360 Variable Numeric M5max = 0 Variable Numeric M5min = 360 Variable Numeric M6max = 0 Variable Numeric M6min = 360 Variable Numeric M7max = 10 Variable Numeric M7min = 170 Key 1 BtnCoord_M1 Key 2 BtnCoord_M2 Key 3 BtnCoord_M3 Key 4 BtnCoord_M4 Key 5 BtnCoord_M5 Key 6 BtnCoord_M6 Key 7 BtnCoord_M7 ' ╔══════════════════════════════════════════╗ █▀▀▄ █ █ ▀▀█▀▀ ' ║ BUTTONS ║ █▀▀█ █ █ █ ' ╚══════════════════════════════════════════╝ █▄▄█ █▄▄█ █ Button 1 Text HardHome Button HardHome Color Coral Button 2 Text "BtnCoord_M1" Button BtnCoord_M1 Text "M1 = ?" Button BtnCoord_M1 Color LightBlue Button 3 Text "BtnCoord_M2" Button BtnCoord_M2 Text "M2 = ?" Button BtnCoord_M2 Color LightBlue Button 4 Text "BtnCoord_M3" Button BtnCoord_M3 Text "M3 = ?" Button BtnCoord_M3 Color LightBlue Button 5 Text "BtnCoord_M4" Button BtnCoord_M4 Text "M4 = ?" Button BtnCoord_M4 Color LightBlue Button 6 Text "BtnCoord_M5" Button BtnCoord_M5 Text "M5 = ?" Button BtnCoord_M5 Color LightBlue Button 7 Text "BtnCoord_M6" Button BtnCoord_M6 Text "M6 = ?" Button BtnCoord_M6 Color LightBlue Button 8 Text "BtnCoord_M7" Button BtnCoord_M7 Text "M7= ?" Button BtnCoord_M7 Color LightBlue Button 17 Text YELLOW Button Yellow Color Yellow Button 18 Text BLUE Button Blue Color Blue Button 19 Text RED Button Red Color Red Button 20 Text GREEN Button Green Color Green Button 21 Text WHITE Button White Color White Button 22 Text BLACK Button Black Color Black Button 23 Text SafePos Button SafePos Text "90 90 90" Button SafePos Color Bisque Button 24 Text ColorButton Button ColorButton Text "COLOR BUTTON" Button ColorButton Color Plum Button 25 Text ExecCobot Button ExecCobot Text "Exec Cobot" Button ExecCobot Color Cyan Button 27 Text MotorTest Button MotorTest Text "MotorTest" Button MotorTest Color Orange Button 16 Text CloseAll Button CloseAll Text "CLOSE ALL" Button CloseAll Color Red ' 'Button 17 Text RepTest 'Button RepTest Text " "REPET.TEST"" 'Button RepTest Color Khaki 'Button 16 Text Emergency 'Button Emergency Text "EMERGENCY" 'Button Emergency Color Red 'Button Emergency Slot Slot_Emergency 'Button 17 Text RedOn 'Button RedOn Color Red 'Button 18 Text GreenOn 'Button GreenOn Color Green 'Button 19 Text YellowOn 'Button YellowOn Color Yellow 'Button 20 Text BlueOn 'Button BlueOn Color MediumBlue 'Button 21 Text WhiteOn 'Button GreenOn Color Green 'Button 22 Text RgbOff 'Button RgbOff Color Black ' -------------------------------------- KEYS Key Right Gosub ExecKeys Key Left Gosub ExecKeys Key Up Gosub ExecKeys Key Down Gosub ExecKeys Key Pageup Gosub ExecKeys Key Pagedown Gosub ExecKeys ' ╔══════════════════════════════════════════╗ █ █▀▀█ █▀▀█ █▀▀▄ ' ║ LOAD APPS ║ █ █ █ █▄▄█ █ █ ' ╚══════════════════════════════════════════╝ █▄▄ █▄▄█ █ █ █▄▄█ Load Theremino_HAL.exe Load Theremino_SlotViewer.exe Load Theremino_SlotViewer_Strings.exe Load Theremino_Cobot.exe 'Load Theremino_SignalScope.exe ' ╔══════════════════════════════════════════╗ █▀▀▀ ▀▀█▀▀ █▀▀▀█ █▀▀▀█ ▀▀█▀▀ ' ║ START FROM HERE ║ ▀▀▀█ █ █▀▀▀█ █▀█▀▀ █ ' ╚══════════════════════════════════════════╝ ▄▄▄█ █ █ █ █ ▀▄ █ 'EnableMotors Controls OpenTextBox DisableAllButtons Controls ClearTextBox GreenOn Print TTSvoices EnableAllButtons 'HardHome Load Hide 'Loop Stop ' ╔══════════════════════════════════════════╗ █ █▀▀█ █▀▀█ █▀▀█ ' ║ LOOP ║ █ █ █ █ █ █▄▄█ ' ╚══════════════════════════════════════════╝ █▄▄ █▄▄█ █▄▄█ █ Label Loop ' ------------------------------------------ ' 0.02 sec. or more to allow time for keys and other tasks Wait Seconds 0.02 ' --------------------------------------------------------- Goto Loop ' ╔══════════════════════════════════════════╗ ' ║ ENABLE/DISABLE BUTTONS ║ ' ╚══════════════════════════════════════════╝ Label EnableAllButtons For v1 = 1 To 16 Button v1 Enabled Next Return Label DisableAllButtons For v1 = 1 To 16 Button v1 Disabled Next Return ' ╔══════════════════════════════════════════╗ ' ║ SAVE LOAD VARS ║ ' ╚══════════════════════════════════════════╝ Label SaveVars Save Vars Print CRLF + "SAVED SEQUENCENAME = " + s1 + CRLF Return Label RestoreVars Load Vars Return ' ╔══════════════════════════════════════════╗ █▀▀ █ █▀▀█ █▀▀▀ █▀▀▀ ' ║ CLOSE ALL ║ █ █ █ █ ▀▀▀█ █▀▀ ' ╚══════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█ ▄▄▄█ █▄▄▄ Label CloseAll RedOn SaveVars StopCobot Window Sizable Slot(Slot_SignalScope) = 0 TTS Speak "End Of Program." SafePos Load CloseApps Return ' ╔════════════════════════════════════════════╗ █▀▀▀ ▀▀█▀▀ █▀▀█ █▀▀█ ' ║ STOP EVENT (when pressing stop button) ║ ▀▀▀█ █ █ █ █▄▄█ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █▄▄█ █ Label EventStop SaveVars RedOn StopCobot EnableAllButtons Window Sizable Slot(Slot_SignalScope) = 0 TTS Speak "End Of Program." SafePos End ' ╔══════════════════════════════════════════╗ █ █ █▀▀█ █▀▀█ █▀▀▄ █ █ █▀▀█ █▄ ▄█ █▀▀▀ ' ║ HARD HOME ALL 3 STEPPERS ║ █▀▀█ █▀▀█ ██▀▀ █ █ █▀▀█ █ █ █ ▀ █ █▀▀ ' ╚══════════════════════════════════════════╝ █ █ █ █ █ ▀▄ █▄▄█ █ █ █▄▄█ █ █ █▄▄▄ Label HardHome HomeM1 HomeM2 HomeM3 HomeM4 HomeM5 HomeM6 HomeM7 Return ' ============================================================ ' Wait until the rotation motor is stopped ' ============================================================ Label HomeM1 Slot(Slot_M1) = Reset Wait Seconds 0.1 Slot(Slot_M1) = 90 Wait Seconds 0.1 'Gosub PrintValues Slot(Slot_M1) = 90 Return Label HomeM2 Slot(Slot_M2) = Reset Wait Seconds 0.1 Slot(Slot_M2) = 90 Wait Seconds 0.1 'Gosub PrintValues Slot(Slot_M2) = 90 Return Label HomeM3 Slot(Slot_M3) = Reset Wait Seconds 0.1 Slot(Slot_M3) = 90 Wait Seconds 0.1 'Gosub PrintValues Slot(Slot_M3) = 90 Return Label HomeM4 Slot(Slot_M4) = Reset Wait Seconds 0.1 Slot(Slot_M4) = 90 Wait Seconds 0.1 'Gosub PrintValues Slot(Slot_M4) = 90 Return Label HomeM5 Slot(Slot_M5) = Reset Wait Seconds 0.1 Slot(Slot_M5) = 90 Wait Seconds 0.1 'Gosub PrintValues Slot(Slot_M5) = 90 Return Label HomeM6 Slot(Slot_M6) = Reset Wait Seconds 0.1 Slot(Slot_M6) = 90 Wait Seconds 0.1 'Gosub PrintValues Slot(Slot_M6) = 90 Return Label HomeM7 Slot(Slot_M7) = Reset Wait Seconds 0.1 Slot(Slot_M7) = 500 Wait Seconds 0.1 'Gosub PrintValues Slot(Slot_M7) = 500 Return ' ╔══════════════════════════════════════════╗ █ █ █▀▀█ █ ▀▀█▀▀ ' ║ WAIT ALL MOTOR until stopped ║ █ █ █▄▄█ █ █ ' ╚══════════════════════════════════════════╝ ▀▄▀▄▀ █ █ █ █ Label WaitAllMotors Variable Numeric WAM1 Wait Seconds 0.1 For WAM1 = 1 To Infinity If Abs(Slot(Slot_M1 + 1)) < 0.01 If Abs(Slot(Slot_M2 + 1)) < 0.01 If Abs(Slot(Slot_M3 + 1)) < 0.01 If Abs(Slot(Slot_M4 + 1)) < 0.01 If Abs(Slot(Slot_M5 + 1)) < 0.01 If Abs(Slot(Slot_M6 + 1)) < 0.01 Exit EndIf EndIf EndIf EndIf EndIf EndIf Wait Seconds 0.05 UpdateButtons Next Return ' ╔══════════════════════════════════════════╗ ' ║ EMERGENCY ║ ' ╚══════════════════════════════════════════╝ Label Emergency ' DisableAllButtons ' Button 15 Enabled ' Button 15 Color Flashing7 Yellow Red ' For v1 = 1 To Infinity ' RedOn ' Wait Seconds 0.4 ' RgbOff ' Wait Seconds 0.4 ' Load sound\Alarm10b.wav ' Next Stop ' ╔══════════════════════════════════════════╗ █ █▀▀ █▀▀▄ ' ║ LED COLORS ║ █ █▀ █ █ ' ╚══════════════════════════════════════════╝ █▄▄ █▄▄ █▄▄█ Label RedOn TTS Speak "Status red." Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Wait TTSready Return Label MagentaOn Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Return Label YellowOn TTS Speak "Status yellow." Slot Slot_LedR = 900 Slot Slot_LedG = 400 Slot Slot_LedB = 0 Wait TTSready Return Label GreenOn TTS Speak "Status green." Slot Slot_LedR = 0 Slot Slot_LedG = 1000 Slot Slot_LedB = 0 Wait TTSready Return Label BlueOn TTS Speak "Status blue." Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 1000 Wait TTSready Return Label WhiteOn TTS Speak "Status white." Slot Slot_LedR = 1000 Slot Slot_LedG = 1000 Slot Slot_LedB = 1000 Wait TTSready Return Label RgbOff TTS Speak "Status black." Slot Slot_LedR = 0 Slot Slot_LedG = 0 Slot Slot_LedB = 0 Wait TTSready Return Label RedBlink RedOn WhiteOn Return ' ╔══════════════════════════════════════════╗ █▀▀▀ █▀▀█ █ █▀▀▄ █ █ ▀▀█▀▀ ' ║ COLOR BUTTON ║ █ █ █ █ █▀▀█ █ █ █ ' ╚══════════════════════════════════════════╝ █▄▄▄ █▄▄█ █▄▄▄ █▄▄█ █▄▄█ █ Label ColorButton Button ColorButton Color Flashing7 Black White For v1 = 1 To Infinity If Int(Slot(Slot_AnalogBut)) = 0 And Slot(Slot_AnalogBut) < 2 YELLOW EndIf If Int(Slot(Slot_AnalogBut)) > 43 And Slot(Slot_AnalogBut) < 49 BLUE EndIf If Int(Slot(Slot_AnalogBut)) > 244 And Slot(Slot_AnalogBut) < 250 RED EndIf If Slot(Slot_AnalogBut) > 128 And Slot(Slot_AnalogBut) < 134 GREEN EndIf If Int(Slot(Slot_AnalogBut)) > 521 And Slot(Slot_AnalogBut) < 527 WHITE EndIf Wait Seconds 0.01 Next Return ' ╔══════════════════════════════════════════╗ █▀▀█ █▀▀█ █▄ ▄█ █▀▀▀ █▀▀█ █ ' ║ ARM COLOR POSITION ║ █▄▄█ █▄▄█ █ ▀ █ █ █ █ █ ' ╚══════════════════════════════════════════╝ █ █ █ ▀▄ █ █ █▄▄▄ █▄▄█ █▄▄▄ Label MotorTest Variable Numeric MO1 For MO1 = 1 To Infinity Slot(Slot_M1) = 0 Slot(Slot_M2) = 0 Slot(Slot_M3) = 0 Slot(Slot_M4) = 0 Slot(Slot_M5) = 45 Slot(Slot_M6) = 0 Slot(Slot_M7) = 100 WaitAllMotors Slot(Slot_M6) = 180 WaitAllMotors Slot(Slot_M6) = 0 WaitAllMotors ' Wait Seconds 0.5 Slot(Slot_M1) = 90 Slot(Slot_M2) = 90 Slot(Slot_M3) = 180 Slot(Slot_M4) = 180 Slot(Slot_M5) = 135 Slot(Slot_M6) = 180 Slot(Slot_M7) = 900 WaitAllMotors Wait Seconds 0.5 Next Return Label YELLOW TTS Speak "Going to yellow dear Kemiao." SafePos Slot(Slot_M1) = 66 Slot(Slot_M2) = 67.35 Slot(Slot_M3) = 72.50 WaitAllMotors Return Label BLUE TTS Speak "Going to blue." SafePos Slot(Slot_M1) = 84 Slot(Slot_M2) = 69.49 Slot(Slot_M3) = 68.75 WaitAllMotors Return Label RED TTS Speak "Going to red." SafePos Slot(Slot_M1) = 93 Slot(Slot_M2) = 69 Slot(Slot_M3) = 62 WaitAllMotors Return Label GREEN TTS Speak "Going to green." SafePos Slot(Slot_M1) = 69 Slot(Slot_M2) = 70.20 Slot(Slot_M3) = 64.27 WaitAllMotors Return Label BLACK TTS Speak "Going to black." SafePos Slot(Slot_M1) = 122 Slot(Slot_M2) = 70 Slot(Slot_M3) = 68 WaitAllMotors Return Label WHITE TTS Speak "Going to white." SafePos Slot(Slot_M1) = 104 Slot(Slot_M2) = 69.49 Slot(Slot_M3) = 68.75 WaitAllMotors Return Label SafePos Slot(Slot_M1) = 90 Slot(Slot_M2) = 90 Slot(Slot_M3) = 90 Slot(Slot_M4) = 90 Slot(Slot_M5) = 90 Slot(Slot_M6) = 90 Slot(Slot_M7) = 170 WaitAllMotors Return Label RepTest For v99 = 1 To Infinity Slot(Slot_M1) = 70 Slot(Slot_M2) = 90 Slot(Slot_M3) = 90 WaitAllMotors Slot(Slot_M1) = 110 Slot(Slot_M2) = 90 Slot(Slot_M3) = 90 WaitAllMotors Slot(Slot_M1) = 90 Slot(Slot_M2) = 76 Slot(Slot_M3) = 82 WaitAllMotors Wait Seconds 0.2 Slot(Slot_M1) = 90 Slot(Slot_M2) = 76 Slot(Slot_M3) = 76 WaitAllMotors Wait Seconds 1.3 Slot(Slot_M1) = 90 Slot(Slot_M2) = 76 Slot(Slot_M3) = 82 WaitAllMotors Next Return Label SayYellow TTS Speak "Going Yellow target." Wait TTSready Return Label SayGreen TTS Speak "Going Green target, time interpolate 1 second." Wait TTSready Return Label SayBlue TTS Speak "RobotANNO Going Blue target." Wait TTSready ClearCommand Return Label SayRed TTS Speak "Going Red target, time interpolate 2 value." Wait TTSready Return Label SayWhite TTS Speak "Going White target, time interpolate 2.5 value." Wait TTSready Return Label SayBlack TTS Speak "Going Black target, time interpolate 3 value." Wait TTSready Return Label SayFastRndMove TTS Speak "Making random movement at high speed." Wait TTSready Return ' ===================================================================== ' STEPPER-MOTORS MOVE SLOW ' ===================================================================== Variable Numeric MSV1 Variable Numeric MSV2 Variable Numeric MSV3 Variable Numeric MSV4 Variable Numeric MSV5 ' ===================================================================== ' MOVE SLOW ' ===================================================================== Variable Numeric MoveSlow_DestM1 ' destination in mm Variable Numeric MoveSlow_DestM2 ' destination in mm Variable Numeric MoveSlow_DestM3 ' destination in mm Variable Numeric MoveSlow_Speed ' speed in mm/sec Label MoveSlowM1 ' ----------------------------------- test for out of limit Slot(Slot_M1) = Limit(Slot(Slot_M1), M1min, M1max) ' ----------------------------------- test for very low speed If MoveSlow_Speed < 0.1 MoveSlow_Speed = 1 EndIf ' ----------------------------------- calc the movement in mm MSV1 = MoveSlow_DestM1 - Slot(Slot_M1) MSV1 = Abs(MSV1) ' ----------------------------------- calc the loops count MSV4 = MSV1 / 0.01 '<<< loop time MSV4 = Int(MSV4 / MoveSlow_Speed) ' ----------------------------------- too much speed ? If MSV4 = 0 Slot(Slot_M1) = Limit(MoveSlow_DestM1, M1min, M1max) Return EndIf ' ----------------------------------- prepare the increment MSV1 = (MoveSlow_DestM1 - Slot(Slot_M1)) / MSV4 ' ----------------------------------- loop for v4 times For MSV3 = 1 To MSV4 ' ------------------------------- increment, move and wait Slot(Slot_M1) = Limit(Slot(Slot_M1) + MSV1, M1min, M1max) Wait Seconds 0.01 '<<< loop time Next Gosub WaitAllMotors Return Label MoveSlowM2 ' ----------------------------------- test for out of limit Slot(Slot_M2) = Limit(Slot(Slot_M2), M2min, M2max) ' ----------------------------------- test for very low speed If MoveSlow_Speed < 0.1 MoveSlow_Speed = 1 EndIf ' ----------------------------------- calc the movement in mm MSV1 = MoveSlow_DestM2 - Slot(Slot_M2) MSV1 = Abs(MSV1) ' ----------------------------------- calc the loops count MSV4 = MSV1 / 0.01 '<<< loop time MSV4 = Int(MSV4 / MoveSlow_Speed) ' ----------------------------------- too much speed ? If MSV4 = 0 Slot(Slot_M2) = Limit(MoveSlow_DestM2, M2min, M2max) Return EndIf ' ----------------------------------- prepare the increment MSV1 = (MoveSlow_DestM2 - Slot(Slot_M2)) / MSV4 ' ----------------------------------- loop for v4 times For MSV3 = 1 To MSV4 ' ------------------------------- increment, move and wait Slot(Slot_M2) = Limit(Slot(Slot_M2) + MSV1, M2min, M2max) Wait Seconds 0.01 '<<< loop time Next Gosub WaitAllMotors Return Label MoveSlowM3 ' ----------------------------------- test for out of limit Slot(Slot_M3) = Limit(Slot(Slot_M3), M3min, M3max) ' ----------------------------------- test for very low speed If MoveSlow_Speed < 0.1 MoveSlow_Speed = 1 EndIf ' ----------------------------------- calc the movement in mm MSV1 = MoveSlow_DestM3 - Slot(Slot_M3) MSV1 = Abs(MSV1) ' ----------------------------------- calc the loops count MSV4 = MSV1 / 0.01 '<<< loop time MSV4 = Int(MSV4 / MoveSlow_Speed) ' ----------------------------------- too much speed ? If MSV4 = 0 Slot(Slot_M3) = Limit(MoveSlow_DestM3, M3min, M3max) Return EndIf ' ----------------------------------- prepare the increment MSV1 = (MoveSlow_DestM3 - Slot(Slot_M3)) / MSV4 ' ----------------------------------- loop for v4 times For MSV3 = 1 To MSV4 ' ------------------------------- increment, move and wait Slot(Slot_M3) = Limit(Slot(Slot_M3) + MSV1, M3min, M3max) Wait Seconds 0.01 '<<< loop time Next Gosub WaitAllMotors Return Label MoveSlowM1M2 ' ----------------------------------- test for out of limit Slot(Slot_M1) = Limit(Slot(Slot_M1), M1min, M1max) Slot(Slot_M2) = Limit(Slot(Slot_M2), M2min, M2max) ' ----------------------------------- test for very low speed If MoveSlow_Speed < 0.1 MoveSlow_Speed = 1 EndIf ' ----------------------------------- calc the movement in mm MSV1 = MoveSlow_DestM1 - Slot(Slot_M1) MSV2 = MoveSlow_DestM2 - Slot(Slot_M2) MSV3 = MSV1 * MSV1 MSV3 = MSV3 + MSV2 * MSV2 MSV3 = Sqrt(MSV3) ' ----------------------------------- calc the loops count MSV4 = MSV3 / 0.01 '<<< loop time MSV4 = Int(MSV4 / MoveSlow_Speed) ' ----------------------------------- too much speed ? If MSV4 = 0 Slot(Slot_M1) = Limit(MoveSlow_DestM1, M1min, M1max) Slot(Slot_M2) = Limit(MoveSlow_DestM2, M2min, M2max) Return EndIf ' ----------------------------------- prepare the increments MSV1 = (MoveSlow_DestM1 - Slot(Slot_M1)) / MSV4 MSV2 = (MoveSlow_DestM2 - Slot(Slot_M2)) / MSV4 ' ----------------------------------- loop for v4 times For MSV3 = 1 To MSV4 ' ------------------------------- increment, move and wait Slot(Slot_M1) = Limit(Slot(Slot_M1) + MSV1, M1min, M1max) Slot(Slot_M2) = Limit(Slot(Slot_M2) + MSV2, M2min, M2max) Wait Seconds 0.01 '<<< loop time Next Gosub WaitAllMotors Return Label MoveSlowM1M2M3 ' ----------------------------------- test for out of limit Slot(Slot_M1) = Limit(Slot(Slot_M1), M1min, M1max) Slot(Slot_M2) = Limit(Slot(Slot_M2), M2min, M2max) Slot(Slot_M3) = Limit(Slot(Slot_M3), M3min, M3max) ' ----------------------------------- test for very low speed If MoveSlow_Speed < 0.1 MoveSlow_Speed = 1 EndIf ' ----------------------------------- calc the movement in mm MSV1 = MoveSlow_DestM1 - Slot(Slot_M1) MSV2 = MoveSlow_DestM2 - Slot(Slot_M2) MSV3 = MoveSlow_DestM3 - Slot(Slot_M3) MSV3 = MSV1 * MSV1 + MSV2 * MSV2 + MSV3 * MSV3 MSV3 = Sqrt(MSV3) ' ----------------------------------- calc the loops count MSV4 = MSV3 / 0.01 '<<< loop time MSV4 = Int(MSV4 / MoveSlow_Speed) ' ----------------------------------- too much speed ? If MSV4 = 0 Slot(Slot_M1) = Limit(MoveSlow_DestM1, M1min, M1max) Slot(Slot_M2) = Limit(MoveSlow_DestM2, M2min, M2max) Slot(Slot_M3) = Limit(MoveSlow_DestM3, M3min, M3max) Return EndIf ' ----------------------------------- prepare the increments MSV1 = (MoveSlow_DestM1 - Slot(Slot_M1)) / MSV4 MSV2 = (MoveSlow_DestM2 - Slot(Slot_M2)) / MSV4 MSV3 = (MoveSlow_DestM3 - Slot(Slot_M3)) / MSV4 ' ----------------------------------- loop for v4 times For MSV5 = 1 To MSV4 ' ------------------------------- increment, move and wait Slot(Slot_M1) = Limit(Slot(Slot_M1) + MSV1, M1min, M1max) Slot(Slot_M2) = Limit(Slot(Slot_M2) + MSV2, M2min, M2max) Slot(Slot_M3) = Limit(Slot(Slot_M3) + MSV3, M3min, M3max) Wait Seconds 0.01 '<<< loop time Next Gosub WaitAllMotors Return ' ==================================================================== ' CONFIGURATION FILE '===================================================================== Label EditConfigVars Variable String VarsFilePathAndName Variable String EditorFolder Variable String EditorApp ' EditorFolder = ".\Theremino_HAL\Theremino_Notepad\" ' EditorApp = EditorFolder + "Theremino_Notepad.exe" ' VarsFilePathAndName = EditorFolder + "ConfigVars.txt" ' Load EditorApp + " " + VarsFilePathAndName Return ' ╔══════════════════════════════════════════╗ ▀▀█▀ █▀▀█ █▀▀█ █ █ █▀▀▀ █ █ ' ║ JOG WITH KEYBOARD ║ █ █ █ █ ▄▄ █▄▀ █▀▀ ▀▄▀ ' ╚══════════════════════════════════════════╝ █▄█ █▄▄█ █▄▄█ █ ▀▄ █▄▄▄ █ Label ExecKeys Variable Numeric JogSpeed = 1 Select True Case Key("SHIFT") JogSpeed = JogSpeed * 0.1 Case Key("CTRL") JogSpeed = JogSpeed * 0.01 EndSelect ' Select MotorToEdit Case 1 If Key("Up") Slot(Slot_M1) = Limit(Slot(Slot_M1) - JogSpeed, M1min, M1max) EndIf If Key("Down") Slot(Slot_M1) = Limit(Slot(Slot_M1) + JogSpeed, M1min, M1max) EndIf Case 2 If Key("Up") Slot(Slot_M2) = Limit(Slot(Slot_M2) + JogSpeed, M2min, M2max) 'Breakpoint EndIf If Key("Down") Slot(Slot_M2) = Limit(Slot(Slot_M2) - JogSpeed, M2min, M2max) EndIf Case 3 If Key("Up") Slot(Slot_M3) = Limit(Slot(Slot_M3) + JogSpeed, M3min, M3max) EndIf If Key("Down") Slot(Slot_M3) = Limit(Slot(Slot_M3) - JogSpeed, M3min, M3max) EndIf Case 4 If Key("Up") Slot(Slot_M4) = Limit(Slot(Slot_M4) - JogSpeed, M4min, M4max) EndIf If Key("Down") Slot(Slot_M4) = Limit(Slot(Slot_M4) + JogSpeed, M4min, M4max) EndIf Case 5 If Key("Up") Slot(Slot_M5) = Limit(Slot(Slot_M5) + JogSpeed, M5min, M5max) EndIf If Key("Down") Slot(Slot_M5) = Limit(Slot(Slot_M5) - JogSpeed, M5min, M5max) EndIf Case 6 If Key("Up") Slot(Slot_M6) = Limit(Slot(Slot_M6) + JogSpeed, M6min, M6max) EndIf If Key("Down") Slot(Slot_M6) = Limit(Slot(Slot_M6) - JogSpeed, M6min, M6max) EndIf Case 7 If Key("Up") Slot(Slot_M7) = Limit(Slot(Slot_M7) - JogSpeed, M7min, M7max) EndIf If Key("Down") Slot(Slot_M7) = Limit(Slot(Slot_M7) + JogSpeed, M7min, M7max) EndIf EndSelect ' PrintValues 'EnableMotors 'YellowOn UpdateButtons Return ' ╔══════════════════════════════════════════╗ ▀▀█▀ █▀▀█ █▀▀▀ █▄ ▄█ █▀▀█ ▀▀█▀▀ ' ║ MOTOR SELECTION FOR JOG ║ █ █ █ █ ▄▄ █ ▀ █ █ █ █ ' ╚══════════════════════════════════════════╝ █▄█ █▄▄█ █▄▄█ █ █ █▄▄█ █ Variable Numeric MotorToEdit Label defaultcolors Button BtnCoord_M1 Color LightBlue Button BtnCoord_M2 Color LightBlue Button BtnCoord_M3 Color LightBlue Button BtnCoord_M4 Color LightBlue Button BtnCoord_M5 Color LightBlue Button BtnCoord_M6 Color LightBlue Button BtnCoord_M7 Color LightBlue Return Label BtnCoord_M1 MotorToEdit = 1 defaultcolors Button BtnCoord_M1 Color Blue Return Label BtnCoord_M2 MotorToEdit = 2 defaultcolors Button BtnCoord_M2 Color Blue Return Label BtnCoord_M3 MotorToEdit = 3 defaultcolors Button BtnCoord_M3 Color Blue Return Label BtnCoord_M4 MotorToEdit = 4 defaultcolors Button BtnCoord_M4 Color Blue Return Label BtnCoord_M5 MotorToEdit = 5 defaultcolors Button BtnCoord_M5 Color Blue Return Label BtnCoord_M6 MotorToEdit = 6 defaultcolors Button BtnCoord_M6 Color Blue Return Label BtnCoord_M7 MotorToEdit = 7 defaultcolors Button BtnCoord_M7 Color Blue Return ' ==================================================================== ' PRINT COORDINATES AND UPDATE COORDINATE BUTTONS ' ==================================================================== Label PrintValues s1 = "MoveTo " + Format(Slot(Slot_M1), "0.00") s1 = s1 + " " + Format(Slot(Slot_M2), "0.00") s1 = s1 + " " + Format(Slot(Slot_M3), "0.00") s1 = s1 + " " + Format(Slot(Slot_M4), "0.00") s1 = s1 + " " + Format(Slot(Slot_M5), "0.00") s1 = s1 + " " + Format(Slot(Slot_M6), "0.00") s1 = s1 + " " + Format(Slot(Slot_M7), "0.00") Print CRLF + s1 Return Label UpdateButtons Button BtnCoord_M1 Text "M1=" + Format(Slot(Slot_M1) - Slot(Slot_M1 + 1), "0.00") Button BtnCoord_M2 Text "M2=" + Format(Slot(Slot_M2) - Slot(Slot_M2 + 1), "0.00") Button BtnCoord_M3 Text "M3=" + Format(Slot(Slot_M3) - Slot(Slot_M3 + 1), "0.00") Button BtnCoord_M4 Text "M4=" + Format(Slot(Slot_M4) - Slot(Slot_M4 + 1), "0.00") Button BtnCoord_M5 Text "M5=" + Format(Slot(Slot_M5) - Slot(Slot_M5 + 1), "0.00") Button BtnCoord_M6 Text "M6=" + Format(Slot(Slot_M6) - Slot(Slot_M6 + 1), "0.00") Button BtnCoord_M7 Text "M7=" + Format(Slot(Slot_M7) - Slot(Slot_M7 + 1), "0.00") Return ' ╔══════════════════════════════════════════╗ █▀▀▀ █▀▀█ █▄ ▄█ █▄ ▄█ █▀▀▀ ▀▄ ▄▀ █▀▀▀ █▀▀▀ ' ║ COMMANDS FROM COBOT ║ █ █ █ █ ▀ █ █ ▀ █ █▀▀ █ █▀ █ ' ╚══════════════════════════════════════════╝ █▄▄▄ █▄▄█ █ █ █ █ █▄▄▄ ▄▀ ▀▄ █▄▄▄ █▄▄▄ Label Event_CommandsFromCobot ' ------------------------------------------------------ Do not print lines containing '' Print " Exec: " + CommandText + CRLF ' ------------------------------------------------------ Select CommandText ' ---------------------------------------------- ACTIONS Case "HardHome" HardHome Case "WaitAllMotors" WaitAllMotors ' -------------------------------------------- Motor movementD COLO Case "Red" RED Case "Green" GREEN Case "Blue" BLUE Case "Yellow" YELLOW Case "BLACK" BLACK ' -------------------------------------------- Speaking Case "SayYellow" SayYellow Case "SayGreen" SayGreen Case "SayBlue" SayBlue Case "SayRed" SayRed Case "SayWhite" SayWhite Case "SayBlack" SayBlack Case "SayFastRndMove" SayFastRndMove ' ---------------------------------------------- LED COLORS Case "RedOn" RedOn Case "GreenON" GreenOn Case "MagentaOn" MagentaOn Case "GreenON" GreenOn Case "BlueOn" BlueOn Case "YellowOn" YellowOn Case "WhiteOn" WhiteOn Case "RGBOFF" RgbOff Case "Pause" Wait Seconds GetSeparatedString(CommandText, 1) CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + CommandText + CRLF Beep Stop ' EndSelect ClearCommand Return Label ClearCommand SlotText(Slot_CommandsFromCobot) = "" Return ' ==================================================================== ' COMMANDS TO Cobot ' ==================================================================== Variable String Command Label SendCommand SlotText Slot_CommandsToCobot = "" Wait Seconds 0.05 SlotText Slot_CommandsToCobot = Command Wait Seconds 0.05 Return Label ExecCobot Variable Numeric EC1 For EC1 = 1 To Infinity Command = "DisableRepeat" SendCommand Command = "SelectLine 1" SendCommand Command = "StartExecution" SendCommand WaitCobotReady Next Return Label StopCobot Command = "StopExecution" SendCommand Return Label WaitCobotReady Variable Numeric WCR1 For WCR1 = 1 To Infinity UpdateButtons Wait Seconds 0.05 If SlotText(Slot_ResponsesFromCobot) = "Ready" Exit EndIf Next Return '-------------------------------------------------------------- 'Index Name Culture Gender Age '-------------------------------------------------------------- '1 Microsoft David Desktop en-US Male Adult '2 Microsoft Zira Desktop en-US Female Adult '3 Microsoft Elsa Desktop it-IT Female Adult '4 Microsoft Huihui Desktop zh-CN Female Adult '-------------------------------------------------------------- ' ============================================================================= ' Folder Demo Programs\SlotText Commands\TEST External commands ' File ExternalCommands_Event_RECEIVE.txt ' ============================================================================= ' ========================================================== ' EXTERNAL COMMANDS EXAMPLE ' ========================================================== Variable Numeric Slot_ExternalCommands = 1 Wait Slot(3) > 500 Beep 1000 100 Beep 1500 100 Beep 2000 100 Stop Label Event_ExternalCommands ' --------------------------------- Extract first word Select GetSeparatedString(CommandText, 0) Case "" ' ----------------------------- Case "Beep" Beep 440 300 ClearCommand ' ----------------------------- Case "Beep_Multiple" ExecBeepMultiple ClearCommand ' ----------------------------- Case "WaitSlot3" ClearCommand Wait Slot(3) > 500 Beep 1000 100 Beep 800 100 Beep 500 100 ' --------------------- Commands with parameters Case "Say" TTS Speak Mid(CFE1, 5) Wait TTSready ClearCommand ' ------------------------- Unrecognized command CaseElse Wait Seconds 0.5 Beep 200 500 Print "Unrecognized command: " + CommandText Wait Seconds 0.5 ClearCommand EndSelect Return Label ClearCommand SlotText(Slot_ExternalCommands) = "" Return Label ExecBeepMultiple For v1 = 1 To 3 Beep 880 400 Wait Seconds 0.5 Next Return ' ============================================================================= ' Folder Demo Programs\SlotText Commands\TEST External commands ' File ExternalCommands_Event_SEND.txt ' ============================================================================= ' ========================================================== ' EXTERNAL COMMANDS TESTER --- SEND ' ========================================================== Variable Numeric Slot_ExternalCommands = 1 Button 1 Label Beep Button 2 Label WaitSlot3 Button 3 Label Command3 Stop ' ============================================================= ' SEND COMMAND (default timeout = 0.5 Sec) ' ============================================================= Label SendCommand Variable Numeric SC1 '<-- Parameter Destinat.-Slot Variable String SC2 '<-- Parameter Command-String Variable Numeric SC3 = 0.5 '<-- The timeout in seconds Variable Numeric SC4 SlotText SC1 = SC2 For SC4 = 0.1 To SC3 Step 0.1 If SlotText(SC1) = "" Exit EndIf Wait Seconds 0.1 Next Return ' ---------------------------------------------- ' COMMANDS ' ---------------------------------------------- Label Beep SendCommand(Slot_ExternalCommands)("Beep") Return Label WaitSlot3 SendCommand(Slot_ExternalCommands)("WaitSlot3") Return Label Command3 SendCommand(Slot_ExternalCommands)("Command3") Return ' ============================================================================= ' Folder Demo Programs\SlotZero Commands ' File ReadSlotZeroCommands.txt ' ============================================================================= Button 1 Label Recognize Slot 0 = Recognize Stop Label Recognize Slot 0 = Recognize Return Label EventTimer Print Slot(0) + " " + DecodeCommandSlot(0) Return ' ============================================================================= ' Folder Demo Programs\SlotZero Commands ' File SlotZeroCommands 1.txt ' ============================================================================= Button 1 Text Recognize Stop Label Recognize Slot 0 = Recognize Return Label EventTimer Gosub TestMasterCount Return Variable Numeric MasterErrorsCounter Label TestMasterCount If Slot(0) <> 2 MasterErrorsCounter = MasterErrorsCounter + 1 Else MasterErrorsCounter = 0 EndIf If MasterErrorsCounter > 15 End EndIf Return ' ============================================================================= ' Folder Demo Programs\SlotZero Commands ' File SlotZeroCommands 2.txt ' ============================================================================= Button 1 Text Recognize Slot 0 = Recognize Stop Label Recognize Slot 0 = Recognize Return Label EventTimer If DecodeCommandSlot(0) = "Master disconnected ERROR" End EndIf Return ' ============================================================================= ' Folder Demo Programs\SlotZero Commands ' File SlotZeroCommands 3.txt ' ============================================================================= Button 1 Label Recognize Slot 0 = Recognize Stop Label Recognize Slot 0 = Recognize Return Label EventTimer If Right(DecodeCommandSlot(0), 5) = "ERROR" End EndIf Return ' ============================================================================= ' Folder Demo Programs\SPEED TEST ' File Commands_to_CNC.txt ' ============================================================================= Button 1 Text CmdRun Button 2 Text CmdStep Button 3 Text CmdPause Button 4 Text CmdRewind Button 5 Text CmdStop Button 7 Text Rapid500 Button 8 Text Rapid2000 Button 9 Text Feed100 Button 10 Text Feed1000 Button 11 Text Speed0 Button 12 Text Speed20000 Button 17 Text TestLowZ Button 18 Text GotoZero Button 19 Text GotoHome Button 20 Text GotoBottomLeft Button 21 Text GotoTopRight Button 23 Text SetZetaHome Button 24 Text CalibrateXY Button 25 Text CalibrateZ Button 26 Text CalibrateAB Button 28 Text MoveTo_10_20_30 Button 29 Text MoveTo_20_30_10 Button 33 Text ZeroX Button 34 Text ZeroY Button 35 Text ZeroZ Button 36 Text ZeroA Button 37 Text ZeroB Button 39 Text GotoLine5 Button 40 Text GotoLine50 Button 41 Text GotoLine9999 Button 43 Text LoadMaster Button 44 Text LoadPmtAdapter Button 46 Text ErrorTest Variable Numeric SlotCommands = 1 Variable Numeric SlotStatus = 2 Loop Stop Label Loop Print SlotText(SlotStatus) Goto Loop Label SendCommand Variable String SC1 SlotText SlotCommands = SC1 Wait SlotText(SlotCommands) = "" Return Label CmdRun SendCommand(CmdRun) Return Label CmdStep SendCommand(CmdStep) Return Label CmdPause SendCommand(CmdPause) Return Label CmdRewind SendCommand(CmdRewind) Return Label CmdStop SendCommand(CmdStop) Return Label Rapid500 SendCommand(Rapid 500) Return Label Rapid2000 SendCommand(Rapid 2000) Return Label Feed100 SendCommand(Feed 100) Return Label Feed1000 SendCommand(Feed 1000) Return Label Speed0 SendCommand(Speed 0) Return Label Speed20000 SendCommand(Speed 20000) Return Label TestLowZ SendCommand(TestLowZ) Return Label GotoZero SendCommand(GotoZero) Return Label GotoHome SendCommand(GotoHome) Return Label GotoBottomLeft SendCommand(GotoBottomLeft) Return Label GotoTopRight SendCommand(GotoTopRight) Return Label SetZetaHome SendCommand(SetZetaHome) Return Label CalibrateXY SendCommand(CalibrateXY) Return Label CalibrateZ SendCommand(CalibrateZ) Return Label CalibrateAB SendCommand(CalibrateAB) Return Label MoveTo_10_20_30 SendCommand(MoveTo 10 20 30) Return Label MoveTo_20_30_10 SendCommand(MoveTo 20 30 10) Return Label ZeroX SendCommand(ZeroX) Return Label ZeroY SendCommand(ZeroY) Return Label ZeroZ SendCommand(ZeroZ) Return Label ZeroA SendCommand(ZeroA) Return Label ZeroB SendCommand(ZeroB) 'Breakpoint Return Label GotoLine5 SendCommand(GotoLine 5) Return Label GotoLine50 SendCommand(GotoLine 50) Return Label GotoLine9999 SendCommand(GotoLine 9999) Return Label LoadMaster SendCommand(LoadGcode PCB Large\MasterDIL-V3.gc) Return Label LoadPmtAdapter SendCommand(LoadGcode PCB Large\PmtAdapter.gc) Return Label ErrorTest SendCommand(Error Test) Return ' ============================================================================= ' Folder Demo Programs\SPEED TEST ' File Commands_to_CNC_WithGosub.txt ' ============================================================================= Button 1 Text CmdRun Button 2 Text CmdStep Button 3 Text CmdPause Button 4 Text CmdRewind Button 5 Text CmdStop Button 7 Text Rapid500 Button 8 Text Rapid2000 Button 9 Text Feed100 Button 10 Text Feed1000 Button 11 Text Speed0 Button 12 Text Speed20000 Button 17 Text TestLowZ Button 18 Text GotoZero Button 19 Text GotoHome Button 20 Text GotoBottomLeft Button 21 Text GotoTopRight Button 23 Text SetZetaHome Button 24 Text CalibrateXY Button 25 Text CalibrateZ Button 26 Text CalibrateAB Button 28 Text MoveTo_10_20_30 Button 29 Text MoveTo_20_30_10 Button 33 Text ZeroX Button 34 Text ZeroY Button 35 Text ZeroZ Button 36 Text ZeroA Button 37 Text ZeroB Button 39 Text GotoLine5 Button 40 Text GotoLine50 Button 41 Text GotoLine9999 Button 43 Text LoadMaster Button 44 Text LoadPmtAdapter Button 46 Text ErrorTest Variable Numeric SlotCommands = 1 Variable Numeric SlotStatus = 2 Loop Stop Label Loop Print SlotText(SlotStatus) Goto Loop Label SendCommand Variable String SC1 SlotText SlotCommands = SC1 Wait SlotText(SlotCommands) = "" Return Label CmdRun Gosub SendCommand(CmdRun) Return Label CmdStep Gosub SendCommand(CmdStep) Return Label CmdPause Gosub SendCommand(CmdPause) Return Label CmdRewind Gosub SendCommand(CmdRewind) Return Label CmdStop Gosub SendCommand(CmdStop) Return Label Rapid500 Gosub SendCommand(Rapid 500) Return Label Rapid2000 Gosub SendCommand(Rapid 2000) Return Label Feed100 Gosub SendCommand(Feed 100) Return Label Feed1000 Gosub SendCommand(Feed 1000) Return Label Speed0 Gosub SendCommand(Speed 0) Return Label Speed20000 Gosub SendCommand(Speed 20000) Return Label TestLowZ Gosub SendCommand(TestLowZ) Return Label GotoZero Gosub SendCommand(GotoZero) Return Label GotoHome Gosub SendCommand(GotoHome) Return Label GotoBottomLeft Gosub SendCommand(GotoBottomLeft) Return Label GotoTopRight Gosub SendCommand(GotoTopRight) Return Label SetZetaHome Gosub SendCommand(SetZetaHome) Return Label CalibrateXY Gosub SendCommand(CalibrateXY) Return Label CalibrateZ Gosub SendCommand(CalibrateZ) Return Label CalibrateAB Gosub SendCommand(CalibrateAB) Return Label MoveTo_10_20_30 Gosub SendCommand(MoveTo 10 20 30) Return Label MoveTo_20_30_10 Gosub SendCommand(MoveTo 20 30 10) Return Label ZeroX Gosub SendCommand(ZeroX) Return Label ZeroY Gosub SendCommand(ZeroY) Return Label ZeroZ Gosub SendCommand(ZeroZ) Return Label ZeroA Gosub SendCommand(ZeroA) Return Label ZeroB Gosub SendCommand(ZeroB) Return Label GotoLine5 Gosub SendCommand(GotoLine 5) Return Label GotoLine50 Gosub SendCommand(GotoLine 50) Return Label GotoLine9999 Gosub SendCommand(GotoLine 9999) Return Label LoadMaster Gosub SendCommand(LoadGcode PCB Large\MasterDIL-V3.gc) Return Label LoadPmtAdapter Gosub SendCommand(LoadGcode PCB Large\PmtAdapter.gc) Return Label ErrorTest Gosub SendCommand(Error Test) Return ' ============================================================================= ' Folder Demo Programs\SPEED TEST ' File Commands_to_COBOT.txt ' ============================================================================= ' ---------------------------------------------- ' COMMANDS ' ---------------------------------------------- ' "ExitFromEdit" (exit from editing state) ' "StartExecution" (auto-exit from editing) ' "StopExecution" (auto-exit from editing) ' "GotoHome" (auto-exit from editing) ' "GotoCenter" (auto-exit from editing) ' "EnableRepeat" ' "DisableRepeat" ' "SelectLine nnn" ' "ExecuteSelectedLine" ' "EnableCollaborative ' "DisableCollaborative ' "AddNewPosition ' "SetHomePosition ' "SetCenterPosition ' "SetHoldingTorque nnn" ' "SetSafeTorqueLimit nnn" ' "SetTorque nnn" ' "SetAcceleration nnn" ' "SetSpeed nnn" ' "LoadSequence SeqName.seq" (without spaces) ' ---------------------------------------------- ' RESPONSES ' ---------------------------------------------- ' "Ready" ' "Execution running at line nnn" ' "Motors disconnected" ' "Human detected - Speed reduced" ' "Human too near - Execution stopped" ' "Too much torque - Execution stopped" ' "Motors disconnected - Execution stopped" ' ---------------------------------------------- ' SLOT TEXT for COMMANDS and RESPONSES ' ---------------------------------------------- Variable Numeric SlotCommands = 51 Variable Numeric SlotResponses = 52 ' ---------------------------------------------- ' BUTTONS ' ---------------------------------------------- Button 1 Text ExitFromEdit Button 3 Text StartExecution Button 4 Text StopExecution Button 6 Text GotoHome Button 7 Text GotoCenter Button 9 Text EnableRepeat Button 10 Text DisableRepeat Button 12 Text SelectLine3 Button 13 Text SelectLine6 Button 14 Text ExecuteSelectedLine Button 17 Text EnableCollaborative Button 18 Text DisableCollaborative Button 20 Text AddNewPosition Button 22 Text SetHomePosition Button 23 Text SetCenterPosition Button 25 Text SetHoldingTorque9 Button 26 Text SetSafeTorqueLimit9 Button 27 Text SetTorque9 Button 28 Text SetAcceleration9 Button 29 Text SetSpeed9 Button 31 Text SetAllparamsToMin Button 32 Text SetAllparamsToMax Loop Stop ' ---------------------------------------------- ' LOOP ' ---------------------------------------------- Label Loop Variable String Response Response = SlotText(SlotResponses) Print Response Wait Seconds 0.1 ' ------------------------------- how to test partial strings If StringContains(Response, "stopped") Beep EndIf Goto Loop ' ---------------------------------------------- ' COMMANDS ' ---------------------------------------------- Label SendCommand Variable String SC1 SlotText SlotCommands = SC1 Wait SlotText(SlotCommands) = "" Return Label ExitFromEdit SendCommand(ExitFromEdit) Return Label StartExecution SendCommand(StartExecution) Return Label StopExecution SendCommand(StopExecution) Return Label EnableRepeat SendCommand(EnableRepeat) Return Label DisableRepeat SendCommand(DisableRepeat) Return Label GotoHome SendCommand(GotoHome) Return Label GotoCenter SendCommand(GotoCenter) Return Label SelectLine3 SendCommand(SelectLine 3) Return Label SelectLine6 SendCommand(SelectLine 6) Return Label ExecuteSelectedLine SendCommand(ExecuteSelectedLine) Return Label EnableCollaborative SendCommand(EnableCollaborative) Return Label DisableCollaborative SendCommand(DisableCollaborative) Return Label AddNewPosition SendCommand(AddNewPosition) Return Label SetHomePosition SendCommand(SetHomePosition) Return Label SetCenterPosition SendCommand(SetCenterPosition) Return Label SetHoldingTorque9 SendCommand(SetHoldingTorque 9) Return Label SetSafeTorqueLimit9 SendCommand(SetSafeTorqueLimit 9) Return Label SetTorque9 SendCommand(SetTorque 9) Return Label SetAcceleration9 SendCommand(SetAcceleration 9) Return Label SetSpeed9 SendCommand(SetSpeed 9) Return Label SetAllparamsToMin SendCommand(SetHoldingTorque 0) SendCommand(SetSafeTorqueLimit 0) SendCommand(SetTorque 0) SendCommand(SetAcceleration 0) SendCommand(SetSpeed 0) Return Label SetAllparamsToMax SendCommand(SetHoldingTorque 999) SendCommand(SetSafeTorqueLimit 999) SendCommand(SetTorque 999) SendCommand(SetAcceleration 999) SendCommand(SetSpeed 99999) Return ' ============================================================================= ' Folder Demo Programs\SPEED TEST ' File Commands_to_COBOT_WithGosub.txt ' ============================================================================= ' ---------------------------------------------- ' COMMANDS ' ---------------------------------------------- ' "ExitFromEdit" (exit from editing state) ' "StartExecution" (auto-exit from editing) ' "StopExecution" (auto-exit from editing) ' "GotoHome" (auto-exit from editing) ' "GotoCenter" (auto-exit from editing) ' "EnableRepeat" ' "DisableRepeat" ' "SelectLine nnn" ' "ExecuteSelectedLine" ' "EnableCollaborative ' "DisableCollaborative ' "AddNewPosition ' "SetHomePosition ' "SetCenterPosition ' "SetHoldingTorque nnn" ' "SetSafeTorqueLimit nnn" ' "SetTorque nnn" ' "SetAcceleration nnn" ' "SetSpeed nnn" ' "LoadSequence SeqName.seq" (without spaces) ' ---------------------------------------------- ' RESPONSES ' ---------------------------------------------- ' "Ready" ' "Execution running at line nnn" ' "Motors disconnected" ' "Human detected - Speed reduced" ' "Human too near - Execution stopped" ' "Too much torque - Execution stopped" ' "Motors disconnected - Execution stopped" ' ---------------------------------------------- ' SLOT TEXT for COMMANDS and RESPONSES ' ---------------------------------------------- Variable Numeric SlotCommands = 51 Variable Numeric SlotResponses = 52 ' ---------------------------------------------- ' BUTTONS ' ---------------------------------------------- Button 1 Text ExitFromEdit Button 3 Text StartExecution Button 4 Text StopExecution Button 6 Text GotoHome Button 7 Text GotoCenter Button 9 Text EnableRepeat Button 10 Text DisableRepeat Button 12 Text SelectLine3 Button 13 Text SelectLine6 Button 14 Text ExecuteSelectedLine Button 17 Text EnableCollaborative Button 18 Text DisableCollaborative Button 20 Text AddNewPosition Button 22 Text SetHomePosition Button 23 Text SetCenterPosition Button 25 Text SetHoldingTorque9 Button 26 Text SetSafeTorqueLimit9 Button 27 Text SetTorque9 Button 28 Text SetAcceleration9 Button 29 Text SetSpeed9 Button 31 Text SetAllparamsToMin Button 32 Text SetAllparamsToMax Gosub Loop Stop ' ---------------------------------------------- ' LOOP ' ---------------------------------------------- Label Loop Variable String Response Response = SlotText(SlotResponses) Print Response Wait Seconds 0.1 ' ------------------------------- how to test partial strings If StringContains(Response, "stopped") Beep EndIf Goto Loop ' ---------------------------------------------- ' COMMANDS ' ---------------------------------------------- Label SendCommand Variable String SC1 SlotText SlotCommands = SC1 Wait SlotText(SlotCommands) = "" Return Label ExitFromEdit Gosub SendCommand(ExitFromEdit) Return Label StartExecution Gosub SendCommand(StartExecution) Return Label StopExecution Gosub SendCommand(StopExecution) Return Label EnableRepeat Gosub SendCommand(EnableRepeat) Return Label DisableRepeat Gosub SendCommand(DisableRepeat) Return Label GotoHome Gosub SendCommand(GotoHome) Return Label GotoCenter Gosub SendCommand(GotoCenter) Return Label SelectLine3 Gosub SendCommand(SelectLine 3) Return Label SelectLine6 Gosub SendCommand(SelectLine 6) Return Label ExecuteSelectedLine Gosub SendCommand(ExecuteSelectedLine) Return Label EnableCollaborative Gosub SendCommand(EnableCollaborative) Return Label DisableCollaborative Gosub SendCommand(DisableCollaborative) Return Label AddNewPosition Gosub SendCommand(AddNewPosition) Return Label SetHomePosition Gosub SendCommand(SetHomePosition) Return Label SetCenterPosition Gosub SendCommand(SetCenterPosition) Return Label SetHoldingTorque9 Gosub SendCommand(SetHoldingTorque 9) Return Label SetSafeTorqueLimit9 Gosub SendCommand(SetSafeTorqueLimit 9) Return Label SetTorque9 Gosub SendCommand(SetTorque 9) Return Label SetAcceleration9 Gosub SendCommand(SetAcceleration 9) Return Label SetSpeed9 Gosub SendCommand(SetSpeed 9) Return Label SetAllparamsToMin Gosub SendCommand(SetHoldingTorque 0) Gosub SendCommand(SetSafeTorqueLimit 0) Gosub SendCommand(SetTorque 0) Gosub SendCommand(SetAcceleration 0) Gosub SendCommand(SetSpeed 0) Return Label SetAllparamsToMax Gosub SendCommand(SetHoldingTorque 999) Gosub SendCommand(SetSafeTorqueLimit 999) Gosub SendCommand(SetTorque 999) Gosub SendCommand(SetAcceleration 999) Gosub SendCommand(SetSpeed 99999) Return ' ============================================================================= ' Folder Demo Programs\SPEED TEST ' File Commands_to_GPS.txt ' ============================================================================= Button 1 Text Average30 Button 2 Text Average120 Button 4 Text Minimize Button 5 Text Maximize Button 6 Text Normal Button 8 Text Main Button 9 Text Raw Button 10 Text Sat Button 11 Text Pos Button 12 Text Map Button 17 Text MapToLocal Button 18 Text MapTo Button 20 Text Image Button 21 Text ImageTime Button 22 Text ImageName Variable Numeric SlotCommands = 1 Stop Label SendCommand Variable String SC1 SlotText SlotCommands = SC1 Wait SlotText(SlotCommands) = "" Return Label Average30 SendCommand(Average 30) Return Label Average120 s1 = "Average 120" SendCommand(s1) Return Label Minimize SendCommand(Minimize) Return Label Maximize SendCommand(Maximize) Return Label Normal SendCommand(Normal) Return Label Main SendCommand(Main) Return Label Raw SendCommand(Raw) Return Label Sat SendCommand(Sat) Return Label Pos SendCommand(Pos) Return Label Map SendCommand(Map) Return Label MapToLocal SendCommand(MapToLocal) Return Label MapTo SendCommand(MapTo 45.470690 7.945215 30) Return Label Image SendCommand(Image) Return Label ImageTime SendCommand(ImageTime) Return Label ImageName SendCommand("ImageName" + " TestImage_" + Format(Now, "yyyy_MM_dd_HH_mm_ss")) Return ' ============================================================================= ' Folder Demo Programs\SPEED TEST ' File Commands_to_GPS_WithGosub.txt ' ============================================================================= Button 1 Text Average30 Button 2 Text Average120 Button 4 Text Minimize Button 5 Text Maximize Button 6 Text Normal Button 8 Text Main Button 9 Text Raw Button 10 Text Sat Button 11 Text Pos Button 12 Text Map Button 17 Text MapToLocal Button 18 Text MapTo Button 20 Text Image Button 21 Text ImageTime Button 22 Text ImageName Variable Numeric SlotCommands = 1 Stop Label SendCommand Variable String SC1 SlotText SlotCommands = SC1 Wait SlotText(SlotCommands) = "" Return Label Average30 Gosub SendCommand(Average 30) Return Label Average120 s1 = "Average 120" Gosub SendCommand(s1) Return Label Minimize Gosub SendCommand(Minimize) Return Label Maximize Gosub SendCommand(Maximize) Return Label Normal Gosub SendCommand(Normal) Return Label Main Gosub SendCommand(Main) Return Label Raw Gosub SendCommand(Raw) Return Label Sat Gosub SendCommand(Sat) Return Label Pos Gosub SendCommand(Pos) Return Label Map Gosub SendCommand(Map) Return Label MapToLocal Gosub SendCommand(MapToLocal) Return Label MapTo Gosub SendCommand(MapTo 45.470690 7.945215 30) Return Label Image Gosub SendCommand(Image) Return Label ImageTime Gosub SendCommand(ImageTime) Return Label ImageName Gosub SendCommand("ImageName" + " TestImage_" + Format(Now, "yyyy_MM_dd_HH_mm_ss")) Return ' ============================================================================= ' Folder Demo Programs\SPEED TEST ' File TestSpeed_Parameters.txt ' ============================================================================= Option Speed 9 Gosub Loop1 Stop ' ---------------------------------------------- ' TEST SECTION - LOOP 1 ' ---------------------------------------------- ' AUTOMATION ' VERSION MICROSECS ' ---------------------------------------------- ' 7.4.18 222 ... 232 ' ---------------------------------------------- v1 = 0 v2 = 0 Label Loop1 ' parameter separators are allowed to contain spaces and tabs FunctionWithParams(Rnd) (-Rnd) (Int(100 * Rnd) + " Dogs") ' ----------------------------------------------------------- If v2 > 1000 v2 = 0 Print Format((ElapsedTime - v1) * 1000, "0.0") + " uS" v1 = ElapsedTime EndIf Goto Loop1 Label FunctionWithParams Variable Numeric Param1 Variable Numeric Param2 Variable String Param3 v3 = Param1 + Param2 + Param3 v2 = v2 + 1 Return ' ============================================================================= ' Folder Demo Programs\SPEED TEST ' File TestSpeed_WithGosub.txt ' ============================================================================= Option Speed 9 Gosub Loop4 Stop ' Ensure debug window closed or without watch lines ' LOAD PROGRAM TIME = 156 mS ' If LABELS_WITHOUT_GOSUB = False then all times are the same ' The test sections 2 and 3 are at the end of the file ' ---------------------------------------------- ' TEST SECTION - LOOP 1 ' ---------------------------------------------- ' AUTOMATION ' VERSION MICROSECS ' ---------------------------------------------- ' 7.4.18 80 ... 85 ' ---------------------------------------------- v1 = 0 v2 = 0 Label Loop1 v2 = v2 + 1 If v2 > 1000 v2 = 0 Print Format((ElapsedTime - v1) * 1000, "0.0") + " uS" v1 = ElapsedTime EndIf Goto Loop1 ' ---------------------------------------------- ' TEST SECTION - LOOP 2 ' ---------------------------------------------- ' AUTOMATION ' VERSION MICROSECS ' ---------------------------------------------- ' 7.4.18 140 ... 142 ' ---------------------------------------------- v1 = 0 v2 = 0 Label Loop2 Gosub FunctionL2 If v2 > 1000 v2 = 0 Print Format((ElapsedTime - v1) * 1000, "0.0") + " uS" v1 = ElapsedTime EndIf Goto Loop2 Label FunctionL2 v2 = v2 + 1 Return ' ---------------------------------------------- ' Addition of Labels and variables ' ---------------------------------------------- Variable Numeric Dummy1 = 1 Variable Numeric Dummy2 = 1 Variable Numeric Dummy3 = 1 Variable Numeric Dummy4 = 1 Variable Numeric Dummy5 = 1 Variable Numeric Dummy6 = 1 Variable Numeric Dummy7 = 1 Variable Numeric Dummy8 = 1 Variable Numeric Dummy9 = 1 Variable String Str1 = 1 Variable String Str2 = 1 Variable String Str3 = 1 Variable String Str4 = 1 Variable String Str5 = 1 Variable String Str6 = 1 Variable String Str7 = 1 Variable String Str8 = 1 Variable String Str9 = 1 Variable Numeric SlotCommands = 51 Label SendCommand Variable String SC1 SlotText SlotCommands = SC1 Wait SlotText(SlotCommands) = "" Return Label ExitFromEdit Gosub SendCommand(ExitFromEdit) Return Label StartExecution Gosub SendCommand(StartExecution) Return Label StopExecution Gosub SendCommand(StopExecution) Return Label EnableRepeat Gosub SendCommand(EnableRepeat) Return Label DisableRepeat Gosub SendCommand(DisableRepeat) Return Label GotoHome Gosub SendCommand(GotoHome) Return Label GotoCenter Gosub SendCommand(GotoCenter) Return Label SelectLine3 Gosub SendCommand(SelectLine 3) Return Label SelectLine6 Gosub SendCommand(SelectLine 6) Return Label ExecuteSelectedLine Gosub SendCommand(ExecuteSelectedLine) Return Label EnableCollaborative Gosub SendCommand(EnableCollaborative) Return Label DisableCollaborative Gosub SendCommand(DisableCollaborative) Return Label AddNewPosition Gosub SendCommand(AddNewPosition) Return Label SetHomePosition Gosub SendCommand(SetHomePosition) Return Label SetCenterPosition Gosub SendCommand(SetCenterPosition) Return Label SetHoldingTorque9 Gosub SendCommand(SetHoldingTorque 9) Return Label SetSafeTorqueLimit9 Gosub SendCommand(SetSafeTorqueLimit 9) Return Label SetTorque9 Gosub SendCommand(SetTorque 9) Return Label SetAcceleration9 Gosub SendCommand(SetAcceleration 9) Return Label SetSpeed9 Gosub SendCommand(SetSpeed 9) Return Label SetAllparamsToMin Gosub SendCommand(SetHoldingTorque 0) Gosub SendCommand(SetSafeTorqueLimit 0) Gosub SendCommand(SetTorque 0) Gosub SendCommand(SetAcceleration 0) Gosub SendCommand(SetSpeed 0) Return Label SetAllparamsToMax Gosub SendCommand(SetHoldingTorque 999) Gosub SendCommand(SetSafeTorqueLimit 999) Gosub SendCommand(SetTorque 999) Gosub SendCommand(SetAcceleration 999) Gosub SendCommand(SetSpeed 99999) Return ' ---------------------------------------------- ' TEST SECTION - LOOP 3 ' ---------------------------------------------- ' AUTOMATION ' VERSION MICROSECS ' ---------------------------------------------- ' 7.4.18 100 ... 109 ' ---------------------------------------------- v1 = 0 v2 = 0 Label Loop3 v2 = v2 + 1 If v2 > 1000 v2 = 0 Print Format((ElapsedTime - v1) * 1000, "0.0") + " uS" v1 = ElapsedTime EndIf Goto Loop3 ' ---------------------------------------------- ' TEST SECTION - LOOP 4 ' ---------------------------------------------- ' AUTOMATION ' VERSION MICROSECS ' ---------------------------------------------- ' 7.4.18 140 ... 143 ' ---------------------------------------------- v1 = 0 v2 = 0 Label Loop4 Gosub FunctionL4 If v2 > 1000 v2 = 0 Print Format((ElapsedTime - v1) * 1000, "0.0") + " uS" v1 = ElapsedTime EndIf Goto Loop4 Label FunctionL4 v2 = v2 + 1 Return ' ============================================================================= ' Folder Demo Programs\SPEED TEST ' File TestSpeed_WithoutGosub.txt ' ============================================================================= Option Speed 9 Loop4 Stop ' Ensure debug window closed or without watch lines ' LOAD PROGRAM TIME = 156 mS ' If calling functions without then all times are the same ' The test sections 2 and 3 are at the end of the file ' ---------------------------------------------- ' TEST SECTION - LOOP 1 ' ---------------------------------------------- ' AUTOMATION ' VERSION MICROSECS ' ---------------------------------------------- ' 7.4.18 80 ... 85 ' ---------------------------------------------- v1 = 0 v2 = 0 Label Loop1 v2 = v2 + 1 If v2 > 1000 v2 = 0 Print Format((ElapsedTime - v1) * 1000, "0.0") + " uS" v1 = ElapsedTime EndIf Goto Loop1 ' ---------------------------------------------- ' TEST SECTION - LOOP 2 ' ---------------------------------------------- ' AUTOMATION ' VERSION MICROSECS ' ---------------------------------------------- ' 7.4.18 140 ... 142 ' ---------------------------------------------- v1 = 0 v2 = 0 Label Loop2 FunctionL2 If v2 > 1000 v2 = 0 Print Format((ElapsedTime - v1) * 1000, "0.0") + " uS" v1 = ElapsedTime EndIf Goto Loop2 Label FunctionL2 v2 = v2 + 1 Return ' ---------------------------------------------- ' Addition of Labels and variables ' ---------------------------------------------- Variable Numeric Dummy1 = 1 Variable Numeric Dummy2 = 1 Variable Numeric Dummy3 = 1 Variable Numeric Dummy4 = 1 Variable Numeric Dummy5 = 1 Variable Numeric Dummy6 = 1 Variable Numeric Dummy7 = 1 Variable Numeric Dummy8 = 1 Variable Numeric Dummy9 = 1 Variable String Str1 = 1 Variable String Str2 = 1 Variable String Str3 = 1 Variable String Str4 = 1 Variable String Str5 = 1 Variable String Str6 = 1 Variable String Str7 = 1 Variable String Str8 = 1 Variable String Str9 = 1 Variable Numeric SlotCommands = 51 Label SendCommand Variable String SC1 SlotText SlotCommands = SC1 Wait SlotText(SlotCommands) = "" Return Label ExitFromEdit SendCommand(ExitFromEdit) Return Label StartExecution SendCommand(StartExecution) Return Label StopExecution SendCommand(StopExecution) Return Label EnableRepeat SendCommand(EnableRepeat) Return Label DisableRepeat SendCommand(DisableRepeat) Return Label GotoHome SendCommand(GotoHome) Return Label GotoCenter SendCommand(GotoCenter) Return Label SelectLine3 SendCommand(SelectLine 3) Return Label SelectLine6 SendCommand(SelectLine 6) Return Label ExecuteSelectedLine SendCommand(ExecuteSelectedLine) Return Label EnableCollaborative SendCommand(EnableCollaborative) Return Label DisableCollaborative SendCommand(DisableCollaborative) Return Label AddNewPosition SendCommand(AddNewPosition) Return Label SetHomePosition SendCommand(SetHomePosition) Return Label SetCenterPosition SendCommand(SetCenterPosition) Return Label SetHoldingTorque9 SendCommand(SetHoldingTorque 9) Return Label SetSafeTorqueLimit9 SendCommand(SetSafeTorqueLimit 9) Return Label SetTorque9 SendCommand(SetTorque 9) Return Label SetAcceleration9 SendCommand(SetAcceleration 9) Return Label SetSpeed9 SendCommand(SetSpeed 9) Return Label SetAllparamsToMin SendCommand(SetHoldingTorque 0) SendCommand(SetSafeTorqueLimit 0) SendCommand(SetTorque 0) SendCommand(SetAcceleration 0) SendCommand(SetSpeed 0) Return Label SetAllparamsToMax SendCommand(SetHoldingTorque 999) SendCommand(SetSafeTorqueLimit 999) SendCommand(SetTorque 999) SendCommand(SetAcceleration 999) SendCommand(SetSpeed 99999) Return ' ---------------------------------------------- ' TEST SECTION - LOOP 3 ' ---------------------------------------------- ' AUTOMATION ' VERSION MICROSECS ' ---------------------------------------------- ' 7.4.18 100 ... 109 ' ---------------------------------------------- v1 = 0 v2 = 0 Label Loop3 v2 = v2 + 1 If v2 > 1000 v2 = 0 Print Format((ElapsedTime - v1) * 1000, "0.0") + " uS" v1 = ElapsedTime EndIf Goto Loop3 ' ---------------------------------------------- ' TEST SECTION - LOOP 4 ' ---------------------------------------------- ' AUTOMATION ' VERSION MICROSECS ' ---------------------------------------------- ' 7.4.18 140 ... 143 ' ---------------------------------------------- v1 = 0 v2 = 0 Label Loop4 FunctionL4 If v2 > 1000 v2 = 0 Print Format((ElapsedTime - v1) * 1000, "0.0") + " uS" v1 = ElapsedTime EndIf Goto Loop4 Label FunctionL4 v2 = v2 + 1 Return ' ============================================================================= ' Folder Demo Programs\SplitIntegers ' File Split_32bit_Test1.txt ' ============================================================================= Controls OpenTextBox v1 = MouseX * 65536 * 2 ' ---------------------------------- Split a 32 bit integer in two 16 bit (V2 = H / v3 = L) v1 = Int(v1) v2 = Int(v1 / 65536) v3 = v1 And 65535 ' ---------------------------------- Recompose the original 32 bit integer v4 = Int(v2 * 65536 + v3) If v4 <> v1 Print PadRight(Str(v1), 10) + PadRight(Str(v2), 10) + PadRight(Str(v3), 10) + PadRight(Str(v4), 10) + CRLF EndIf Slot 1 = v2 Slot 2 = v3 ' ============================================================================= ' Folder Demo Programs\StepperMotors ' File Stepper_FindZero_MultipleMotors.txt ' ============================================================================= ' ========================================================== ' Program: Stepper_FindZero.txt ' Usage: Homing for multiple stepper motors ' ========================================================== Option Speed 9 Button 1 Text HomeM0 Button 2 Text HomeM1 Button 3 Text HomeM2 Button 4 Text HomeAllMotors Stop ' ========================================================== ' HOME MOTORS ' ========================================================== Label HomeAllMotors Gosub HomeM0 Gosub HomeM1 Gosub HomeM2 Return Label HomeM0 SlotMotor = 1 SlotSensor = 7 SpeedSearch = -0.5 ' direction and speed SpeedReturn = +0.05 ' direction and speed DeclaredZero = 0 InitialPosition = 1 ' relative to DeclaredZero Gosub Home Return Label HomeM1 SlotMotor = 3 SlotSensor = 8 SpeedSearch = -0.5 ' direction and speed SpeedReturn = +0.05 ' direction and speed DeclaredZero = 0 InitialPosition = 1 ' relative to DeclaredZero Gosub Home Return Label HomeM2 SlotMotor = 5 SlotSensor = 9 SpeedSearch = +0.5 ' direction and speed SpeedReturn = -0.05 ' direction and speed DeclaredZero = 0 InitialPosition = -1 ' relative to DeclaredZero Gosub Home Return ' ========================================================== ' Home the Motor(SlotMotor) to the Sensor(SlotSensor) ' ========================================================== Variable Numeric SlotMotor Variable Numeric SlotSensor Variable Numeric SpeedSearch Variable Numeric SpeedReturn Variable Numeric DeclaredZero Variable Numeric InitialPosition Label Home ' ------------------------- detach if sensor is active If Slot(SlotSensor) > 500 Slot(SlotMotor) = Slot(SlotMotor) + SpeedReturn EndIf ' ------------------------- search the sensor Label SearchHome Slot(SlotMotor) = Slot(SlotMotor) + SpeedSearch Wait Seconds 0.001 If Slot(SlotSensor) > 500 Gosub WaitMotor Goto DetachSensor EndIf Goto SearchHome ' ------------------------- detach from the sensor Label DetachSensor Slot(SlotMotor) = Slot(SlotMotor) + SpeedReturn Wait Seconds 0.001 If Slot (SlotSensor) < 500 Gosub WaitMotor Goto AssignZero EndIf Goto DetachSensor ' ------------------------- reset and move to InitialPos Label AssignZero Slot(SlotMotor) = Reset Wait Seconds 0.08 Slot(SlotMotor) = DeclaredZero Gosub WaitMotor Slot(SlotMotor) = InitialPosition Return ' ========================================================== ' Wait until the motor(SlotMotor) is stopped ' ========================================================== Label WaitMotor Wait Seconds 0.1 Label Wait1 If Abs(Slot(SlotMotor + 1)) < 0.01 Return EndIf Wait Seconds 0.005 Goto Wait1 Goto WaitMotor ' ============================================================================= ' Folder Demo Programs\StepperMotors ' File Stepper_FindZero_SingleMotor.txt ' ============================================================================= ' ================================================== ' Program: Stepper_FindZero_SingleMotor.txt ' Usage: Homing for a single stepper motor ' ================================================== Option Speed 9 Button 1 Text HomeMotor Stop ' ========================================================== ' HOME SINGLE MOTOR ' ========================================================== Label HomeMotor SlotMotor = 1 SlotSensor = 7 SpeedSearch = -0.5 ' direction and speed SpeedReturn = +0.05 ' direction and speed DeclaredZero = 0 InitialPosition = 1 ' relative to DeclaredZero Gosub Home Return ' ========================================================== ' Home the Motor(SlotMotor) to the Sensor(SlotSensor) ' ========================================================== Variable Numeric SlotMotor Variable Numeric SlotSensor Variable Numeric SpeedSearch Variable Numeric SpeedReturn Variable Numeric DeclaredZero Variable Numeric InitialPosition Label Home ' ------------------------- detach if sensor is active If Slot(SlotSensor) > 500 Slot(SlotMotor) = Slot(SlotMotor) + SpeedReturn EndIf ' ------------------------- search the sensor Label SearchHome Slot(SlotMotor) = Slot(SlotMotor) + SpeedSearch Wait Seconds 0.001 If Slot(SlotSensor) > 500 Gosub WaitMotor Goto DetachSensor EndIf Goto SearchHome ' ------------------------- detach from the sensor Label DetachSensor Slot(SlotMotor) = Slot(SlotMotor) + SpeedReturn Wait Seconds 0.001 If Slot (SlotSensor) < 500 Gosub WaitMotor Goto AssignZero EndIf Goto DetachSensor ' ------------------------- reset and move to InitialPos Label AssignZero Slot(SlotMotor) = Reset Wait Seconds 0.08 Slot(SlotMotor) = DeclaredZero Gosub WaitMotor Slot(SlotMotor) = InitialPosition Return ' ========================================================== ' Wait until the motor(SlotMotor) is stopped ' ========================================================== Label WaitMotor Wait Seconds 0.1 Label Wait1 If Abs(Slot(SlotMotor + 1)) < 0.01 Return EndIf Wait Seconds 0.005 Goto Wait1 Goto WaitMotor ' ============================================================================= ' Folder Demo Programs\Strings ' File GetSeparatedString Example 1.txt ' ============================================================================= ' ---------------------------------------------------------- ' GetSeparatedString example ' ---------------------------------------------------------- ' Press RUN and then move the cursor on the function names ' ---------------------------------------------------------- s1 = "AAA BBB CCC , DD , EE" s2 = GetSeparatedString(s1, 1) s2 = GetSeparatedStringCount(s1) s2 = GetSeparatedString(s1, 1, " ") s2 = GetSeparatedStringCount(s1, " ") s2 = GetSeparatedString(s1, 1, ",") s2 = GetSeparatedStringCount(s1, ",") Stop ' ============================================================================= ' Folder Demo Programs\Strings ' File GetSeparatedString Example 2.txt ' ============================================================================= ' ---------------------------------------------------------- ' GetSeparatedString example ' ---------------------------------------------------------- ' Press RUN and then move the cursor on the function names ' ---------------------------------------------------------- s1 = COM_PortNames s1 = GetSeparatedStringCount(COM_PortNames) s1 = GetSeparatedString(COM_PortNames, 3) s1 = GetSeparatedStringCount("john,jerry ,Jake", ",") s1 = GetSeparatedString("john,jerry ,Jake", 1, ",") Stop ' ============================================================================= ' Folder Demo Programs\Strings ' File GetSeparatedString Example 3.txt ' ============================================================================= Variable Numeric Slot_ExternalCommands = 53 Label Event_ExternalCommands ' ------------------------------------------------------ Do not print lines containing '' 'Print " Exec: " + CommandText + CRLF ' ------------------------------------------------------ Select GetSeparatedString(CommandText, 0) ' ---------------------------------------------- ACTIONS Case "Say" TTS Speak Mid(CommandText, 5) Wait TTSready ClearCommand Case "RedOn" ClearCommand Case "GreenOn" ClearCommand Case "BlueOn" ClearCommand Case "WhiteOn" ClearCommand Case "MagentaOn" ClearCommand Case "YellowOn" ClearCommand Case "Beep" Beep 880-100 ClearCommand Case "StartPump" ClearCommand Case "StopPump" ClearCommand CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + CommandText + CRLF Beep ClearCommand EndSelect Return Label ClearCommand SlotText(Slot_ExternalCommands) = "" Return ' ============================================================================= ' Folder Demo Programs\Strings ' File Left and Right.txt ' ============================================================================= s1 = "This is a long string" Print Left(s1, 4) Wait Seconds 2 Print Mid(s1, 11, 4) Wait Seconds 2 Print Right(s1, 6) Stop ' ============================================================================= ' Folder Demo Programs\Strings ' File PadLeft.txt ' ============================================================================= Label loop s3 = Format(Rnd * 100, "0") s3 = PadLeft(s1, 5) s2 = Format(Rnd * 100, "0") s2 = PadLeft(s2, 5) s1 = s2 + PadLeft("End", 5) Print s1 Save StringToFile s1 "TestFile.txt" Wait Seconds 0.1 Goto loop ' ============================================================================= ' Folder Demo Programs\Strings ' File String Length.txt ' ============================================================================= s1 = "" Label loop s1 = s1 + "ABCDEFGHIJKLMNOPQRSTUVWXYZ " s1 = s1 + "ABCDEFGHIJKLMNOPQRSTUVWXYZ " s1 = s1 + "ABCDEFGHIJKLMNOPQRSTUVWXYZ " + CRLF Print Len(s1) Goto loop ' ============================================================================= ' Folder Demo Programs\Strings ' File StringConversions.txt ' ============================================================================= 'Controls OpenTextBox Label loop s1 = Format(Rnd * 100, "0") s1 = PadRight(s1, 5) s2 = Format(Rnd * 100, "0") s2 = PadRight(s1, 5) s1 = s1 + s2 + "END" Print s1 + CRLF Save StringToFile s1 "TestFile.txt" Wait Seconds 0.1 Goto loop ' ============================================================================= ' Folder Demo Programs\TextBox ' File Controls OpenTextBox 1.txt ' ============================================================================= Controls OpenTextBox Controls ClearTextBox For v1 = 1 To 50 Print Rnd + " " Wait Seconds 0.05 Next Stop ' ============================================================================= ' Folder Demo Programs\TextBox ' File Controls OpenTextBox 2.txt ' ============================================================================= Button 1 Text OpenTextBox Button 2 Text CloseTextBox Button 3 Text ClearTextBox Controls OpenTextBox Controls ClearTextBox Label loop Print Rnd + " " Wait Seconds 0.04 Goto loop Label OpenTextBox Controls OpenTextBox Return Label CloseTextBox Controls CloseTextBox Return Label ClearTextBox Controls ClearTextBox 'Print CLS ' Alternative method to clear the textbox 'Print Chr(12) ' Alternative method to clear the textbox Return ' ============================================================================= ' Folder Demo Programs\TextBox ' File TextBox example.txt ' ============================================================================= Controls OpenTextBox Print "Donald Duck" 'risultato: Donald Duck Print CRLF S1 = "PI = " S2 = Format(Math_PI, "") Print S1 + S2 'risultato: PI = 3.14159265358979 Print CRLF Print "Duck" = "Cat" 'risultato: False Print CRLF Print Mid("Duck", 4, 1) = "k" 'risultato: True Stop ' ============================================================================= ' Folder Demo Programs\TextBox ' File TextBox RND.txt ' ============================================================================= Controls OpenTextBox v1 = 1 Label loop v1 = Rnd * 10 s1 = Format(v1, "0.00000000000000") + CRLF Print s1 'Wait Seconds 0.001 Goto loop ' ============================================================================= ' Folder Demo Programs\Time Functions ' File ElapsedTime.txt ' ============================================================================= Controls CloseTextBox s1 = Now Print s1 + " " + ElapsedTime ' ============================================================================= ' Folder Demo Programs\Time Functions ' File ElapsedTime_Reset.txt ' ============================================================================= Controls CloseTextBox Button 1 Label ResetTime Label Loop Print "Seconds " + Format(ElapsedTime - StartTime, "0.000000") Goto Loop Variable Numeric StartTime Label ResetTime StartTime = ElapsedTime Return ' ============================================================================= ' Folder Demo Programs\Time Functions ' File Now direct and Now in formula.txt ' ============================================================================= Controls CloseTextBox ' ------------------------- DAY MONTH YEAR s1 = Format(Now, "dd/MM/yyyy HH:mm:ss") ' ------------------------- DAY MONTH YEAR s2 = Now ' ------------------------- MONTH DAY YEAR s3 = Now + " " Print s1 + " " + s2 + " " + s3 ' ============================================================================= ' Folder Demo Programs\Time Functions ' File Now Formats.txt ' ============================================================================= Controls CloseTextBox ' ------------------------- DAY MONTH YEAR s1 = Format(Now, "dd/MM/yyyy HH:mm:ss") ' ------------------------- DAY MONTH YEAR s2 = Now ' ------------------------- MONTH DAY YEAR s3 = Now + " " Print s1 + " " + s2 + " " + s3 ' ============================================================================= ' Folder Demo Programs\TTS ' File TTS_Functions.txt ' ============================================================================= ' ------------------------------ VOICES s1 = TTSvoices ' Please install Windows-Voices TTS SetSpeed 0 ' Speed -10 to 10 TTS SetVolume 100 ' Volume 0 to 100 (0 = Disable speak) TTS SelectVoice "ENG F" 'ENG F / ENG M / ITA Say("TTS started and immediately stopped") SayStop Say("Executing the GO function") Stop ' ============================================== ' VOICE FUNCTIONS ' ============================================== Label Say Variable String SayText TTS Speak SayText Return Label SayAndWait Variable String SayWText TTS Speak SayWText Wait TTSready Return Label SayStop TTS Stop Return ' ============================================================================= ' Folder Demo Programs\TTS ' File TTS_LongExample.txt ' ============================================================================= '╔══════════════════════════════════════════════════════════════╗ '║ Name: WinGoSCARA_ZM1M2_V3.txt Date: 11 Mar 2022 ║ '║ Author: Leonardo DE PALO Ph.D. ║ '║ Scope: SCARA management ║ '╟──────────────────────────────────────────────────────────────╢ '║ Hardware: Standard Master and stepper driver ║ '║ Limit switches ║ '║ Vacumm motor, valve and sensor ║ '║ Red/Green light ║ '║ Voice messages ║ '╚══════════════════════════════════════════════════════════════╝ ' ============================= HARDWARE ' MicroStepper stepper 1/32 stepper as step for run ' Gear ratio for M0 and M1 1:4 Step x mm = 800 x 360 / 360 = 59.556 ??????????? ' Leadscrew: 4mm for one turn ' ' ============================= HARDWARE SET UP DVR8825 ' Motor M1 current 200 mA ' Microstep "ABC" 32 Speed 40000 Acc 250 Step/mm 74.2 reduction ratio 4:1 ' Motor M2 current 200 mA ' Microstep "ABC" 32 Speed 50000 Acc 250 Step/mm 74.2 reduction ratio 4:1 ' Motor Z current 200 mA ' Microstep " BC" 8 Speed 3000 Acc 100 Step 400 leadscrew: 4mm for one turn Load SCARA_Z_M1_M2.jpg TTS SelectVoice "ENG M" TTS SetVolume 100 ' Set the volume to zero to disable Speak TTS SetSpeed -1 s1 = TTSvoices StartRobotOperations Wait Seconds 0.5 Controls OpenTextBox Option Speed 9 RestoreVars DisableAllButtons Button 1 Label Home Button Home Text "Home" Button Home Color SkyBlue Button 2 Label HomeMZ Button HomeMZ Text "Home MZ" Button HomeMZ Color SkyBlue Button 3 Label HomeM1 Button HomeM1 Text "Home M1" Button HomeM1 Color SkyBlue Button 4 Label HomeM2 Button HomeM2 Text "Home M2" Button HomeM2 Color SkyBlue 'Button 5 Text Joy 'Button Joy Text "Joy" Button 6 Label StartPump Button StartPump Text "Start Pump" Button 7 Label StopPump Button StopPump Text "Stop Pump" Button 8 Label EnableMotors Button EnableMotors Text "Enable Motors" Button 9 Label DisableMotors Button DisableMotors Text "Disable Motors" Button 10 Label EditSequence Button EditSequence Text "Edit sequence" Button EditSequence Color PaleGreen Button 11 Label RunSequence Button RunSequence Text "RUN SEQUENCE" Button RunSequence Color Aqua Button 12 Label SelectSequence Button SelectSequence Text "Select Sequence" Button SelectSequence Color PowderBlue Button 15 Label CloseAll Button CloseAll Text "CLOSE ALL" Button CloseAll Color Red Load Theremino_HAL\Theremino_HAL.exe Load Theremino_HAL\theremino_SlotViewer.exe 'Load Theremino_HAL\theremino_Gamepad.exe ' ---------------------------------------- Software limits M1max = 277 M1min = 86 M2max = 320 M2min = 38 MZmax = 159 MZmin = 61 ' -------------------------------------- KEYS Key Right Gosub ExecKeys Key Left Gosub ExecKeys Key Up Gosub ExecKeys Key Down Gosub ExecKeys Key Pageup Gosub ExecKeys Key Pagedown Gosub ExecKeys Key M Gosub EnableMotors ShowSequenceName 'DisableMotors EnableAllButtons StopPump Button DisableMotors Disabled Load Hide Stop ' ' ╔════════════════════════════════════════════╗ ' ║ INITIALIZATIONS ║ ' ╚════════════════════════════════════════════╝ Variable Numeric Slot_MotorM1 = 1 Variable Numeric Slot_MotorM2 = 3 Variable Numeric Slot_MotorMZ = 7 Variable Numeric Slot_Vacuum = 5 Variable Numeric Slot_LedR = 6 Variable Numeric Slot_LedG = 9 Variable Numeric Slot_EnableMotors = 10 Variable Numeric Slot_Pump = 11 Variable Numeric Slot_Limits = 12 Variable Numeric Slot_SignalScope = 13 Variable Numeric M1max Variable Numeric M1min Variable Numeric M2max Variable Numeric M2min Variable Numeric MZmax Variable Numeric MZmin ' ╔════════════════════════════════════════════╗ ' ║ CLOSE ALL ║ ' ╚════════════════════════════════════════════╝ Label CloseAll SaveVars Window Sizable Load CloseApps 'DisableMotors End ' ' ╔════════════════════════════════════════════╗ ' ║ STOP EVENT (when pressing stop button) ║ ' ╚════════════════════════════════════════════╝ Label EventStop SayEndOfProgram SaveVars EnableAllButtons Window Sizable 'DisableMotors Slot(Slot_SignalScope) = 0 End ' ' ╔════════════════════════════════════════════╗ ' ║ SAVE LOAD and CLEAR VARS ║ ' ╚════════════════════════════════════════════╝ Label SaveVars S1 = SequenceName Save Vars Return Label RestoreVars Load Vars SequenceName = S1 Return ' ╔════════════════════════════════════════════╗ ' ║ ENABLE/DISABLE BUTTONS ║ ' ╚════════════════════════════════════════════╝ Label EnableAllButtons For v1 = 1 To 32 Button v1 Enabled Next Return Label DisableAllButtons For v2 = 1 To 32 Button v2 Disabled Next Return ' ╔════════════════════════════════════════════╗ ' ║ LED COLORS ║ ' ╚════════════════════════════════════════════╝ Label RedOn TTS Speak "Status red." Slot Slot_LedR = 1000 Slot Slot_LedG = 0 Wait TTSready Return Label GreenOn TTS Speak "Status green." Slot Slot_LedR = 0 Slot Slot_LedG = 1000 Wait TTSready Return Label RgbOff Slot Slot_LedR = 0 Slot Slot_LedG = 0 Return Label RedBlink RedOn GreenOn Return ' ╔════════════════════════════════════════════╗ ' ║ HOME MOTORS ║ ' ╚════════════════════════════════════════════╝ Label Home HomeMZ Slot Slot_MotorM2 = Slot(Slot_MotorM2) - 30 HomeM1 HomeM2 Return ' ╔════════════════════════════════════════════╗ ' ║ HOME MOTOR -Z- -M1- -M2- ║ ' ╚════════════════════════════════════════════╝ Label HomeMZ SayHomeProcedureIsStarted EnableMotors SlotMotor = Slot_MotorMZ SlotSensor = Slot_Limits SpeedSearch = +0.2 SpeedReturn = -0.01 DeclaredSwitchPos = 95 InitialPosition = 94 HomeMotor PrintValues Return ' ╔════════════════════════════════════════════╗ ' ║ HOME MOTOR -M1- ║ ' ╚════════════════════════════════════════════╝ Label HomeM1 EnableMotors SlotMotor = Slot_MotorM1 SlotSensor = Slot_Limits SpeedSearch = +0.1 SpeedReturn = -0.01 DeclaredSwitchPos = 280 InitialPosition = 180 HomeMotor PrintValues Return ' ╔════════════════════════════════════════════╗ ' ║ HOME MOTOR -M2- ║ ' ╚════════════════════════════════════════════╝ Label HomeM2 EnableMotors SlotMotor = Slot_MotorM2 SlotSensor = Slot_Limits SpeedSearch = +0.2 SpeedReturn = -0.01 DeclaredSwitchPos = 322 InitialPosition = 180 HomeMotor PrintValues Return ' ╔════════════════════════════════════════════╗ ' ║ HOME MOTOR ║ ' ╚════════════════════════════════════════════╝ Variable Numeric SlotMotor Variable Numeric SlotSensor Variable Numeric SpeedSearch Variable Numeric SpeedReturn Variable Numeric DeclaredSwitchPos Variable Numeric InitialPosition Label HomeMotor DisableAllButtons EnableMotors Button 15 Enabled ' ------------------------- detach if sensor is active If Slot(SlotSensor) > 500 Or Key("CTRL") Slot(SlotMotor) = Slot(SlotMotor) + SpeedReturn EndIf ' ------------------------- search the sensor Label SearchHome Slot(SlotMotor) = Slot(SlotMotor) + SpeedSearch Wait Seconds 0.001 If Slot(SlotSensor) > 500 Or Key("CTRL") Slot(SlotMotor) = Reset Wait Seconds 0.1 Slot(SlotMotor) = 0 Wait Seconds 0.1 Goto DetachSensor EndIf Goto SearchHome ' ------------------------- detach from the sensor Label DetachSensor Slot(SlotMotor) = Slot(SlotMotor) + SpeedReturn Wait Seconds 0.001 If Slot(SlotSensor) < 500 Slot(SlotMotor) = Reset Wait Seconds 0.1 Slot(SlotMotor) = DeclaredSwitchPos Wait Seconds 0.1 Goto SetFinalValues EndIf Goto DetachSensor ' ------------------------- reset and move to InitialPos Label SetFinalValues Slot(SlotMotor) = InitialPosition WaitAllMotors EnableAllButtons Return ' ╔════════════════════════════════════════════╗ ' ║ WAIT ALL MOTOR - Wait until motors stopped ║ ' ╚════════════════════════════════════════════╝ Label WaitAllMotors Wait Seconds 0.1 ' <<< ensures that motors are really started Variable Numeric WAM1 For WAM1 = 1 To Infinity If Abs(Slot(Slot_MotorM1 + 1)) < 0.01 If Abs(Slot(Slot_MotorM2 + 1)) < 0.01 If Abs(Slot(Slot_MotorMZ + 1)) < 0.01 Exit EndIf EndIf EndIf Wait Seconds 0.01 Next Return ' ╔════════════════════════════════════════════╗ ' ║ JOG with keyboard ║ ' ╚════════════════════════════════════════════╝ Label ExecKeys Variable Numeric JogSpeed = 10 ' Select True Case Key("SHIFT") JogSpeed = JogSpeed * 0.1 Case Key("CTRL") JogSpeed = JogSpeed * 0.01 Case Key("ALT") JogSpeed = JogSpeed * 0.001 CaseElse ' EndSelect ' If Key("Right") Slot(Slot_MotorM1) = Limit(Slot(Slot_MotorM1) - JogSpeed, M1min, M1max) EndIf If Key("Left") Slot(Slot_MotorM1) = Limit(Slot(Slot_MotorM1) + JogSpeed, M1min, M1max) EndIf ' If Key("Up") Slot(Slot_MotorM2) = Limit(Slot(Slot_MotorM2) + JogSpeed, M2min, M2max) EndIf If Key("Down") Slot(Slot_MotorM2) = Limit(Slot(Slot_MotorM2) - JogSpeed, M2min, M2max) EndIf ' If Key("PageUp") Slot(Slot_MotorMZ) = Limit(Slot(Slot_MotorMZ) + JogSpeed, MZmin, MZmax) EndIf If Key("PageDown") Slot(Slot_MotorMZ) = Limit(Slot(Slot_MotorMZ) - JogSpeed, MZmin, MZmax) EndIf PrintValues EnableMotors 'YellowOn Return ' ╔════════════════════════════════════════════╗ ' ║ JOYSTICK MANAGEMENT ║ ' ╚════════════════════════════════════════════╝ Label Joy EnableMotors v3 = Slot(13) If v3 > 550 'move to Right M0 Slot(1) = Slot(1) - (v3 - 550) * 0.01 'incremental move EndIf If v3 < 450 'move to Left M0 Slot(1) = Slot(1) + (450 - v3) * 0.01 'incremental move EndIf v3 = Slot(14) If v3 > 550 'move to left M1 Slot(3) = Slot(3) - (v3 - 550) * 0.01 'incremental move EndIf If v3 < 450 'move to right M1 Slot(3) = Slot(3) + (450 - v3) * 0.01 'incremental move EndIf v3 = Slot(15) If v3 > 550 'move to up M2 (Z) Slot(5) = Slot(5) + (450 - v3) * 0.001 'incremental move EndIf 'nota: joy Z verticale difettoso If v3 < 450 'move to down M2 (Z) Slot(5) = Slot(5) - (v3 - 550) * 0.001 'incremental move EndIf If Slot(23) < 550 Slot(12) = 0 'stop pump Else Slot(12) = 1000 'start pump EndIf If Slot(26) > 500 'Button 4 to exit joy mode Return EndIf Goto Joy Return ' ╔═════════════════════════════════════════════════════╗ ' ║ S U B R O U T I N E A R E A ║ ' ╚═════════════════════════════════════════════════════╝ ' ╔════════════════════════════════════════════╗ ' ║ ENABLE / DISABLE MOTORS ║ ' ╚════════════════════════════════════════════╝ ' ╔════════════════════════════════════════════╗ ' ║ ENABLE / DISABLE PUMP ║ ' ╚════════════════════════════════════════════╝ Label StartPump Slot(Slot_SignalScope) = 1000 Wait Seconds 0.1 Slot(Slot_Pump) = 1000 Button StartPump Disabled Button StopPump Enabled Wait Seconds 0.8 If Slot(Slot_Vacuum) > 55 ' Beep "500, 300, 0, 300" ' SayVacuumProblem ' RedOn ' StopPump ' Print "Vacuum Problem" + CRLF ' Print "Execution stopped" + CRLF ' RedBlink ' End EndIf Return Label StopPump Slot(Slot_Pump) = 0 Button StopPump Disabled Button StartPump Enabled Return Label EnableMotors Slot(Slot_EnableMotors) = 1000 Button EnableMotors Disabled Button DisableMotors Enabled 'Wait Seconds 0.1 Return Label DisableMotors Slot(Slot_EnableMotors) = 0 Wait Seconds 0.1 Button DisableMotors Disabled Button EnableMotors Enabled Return Label SignalScope_ON Slot (Slot_SignalScope) = 1000 Return Label SignalScope_OFF Slot (Slot_SignalScope) = 0 Return ' ╔════════════════════════════════════════════╗ █▀█ ' ║ SEQUENCES ║ █ █ ' ╚════════════════════════════════════════════╝ █▄█ Label InitSequencePaths Variable String EditorFolder Variable String EditorApp Variable String SequencePathAndName Variable String SequenceName ' EditorFolder = ".\Apps\Theremino_Editor\" ' EditorApp = EditorFolder + "Theremino_Editor.exe" ' SequencePathAndName = EditorFolder + "Sequences\" + SequenceName Return Label RunSequence SayStartCoinRoutine Controls ClearTextBox DisableAllButtons Button EditSequence Enabled Button CloseAll Enabled InitSequencePaths Button RunSequence Color Flashing8 Yellow Orange SequenceToExecute = SequencePathAndName SignalScope_ON Home Variable Numeric ExitFromSequenceLoop For v4 = 1 To 9e99 ExecSequence If ExitFromSequenceLoop > 0 ExitFromSequenceLoop = 0 Exit EndIf Next Button RunSequence Color Aqua EnableAllButtons Return Label EditSequence InitSequencePaths If FileExists(SequencePathAndName) Load EditorApp + " " + SequencePathAndName EndIf Return Label SelectSequence InitSequencePaths s1 = SelectFile(EditorFolder + "Sequences\") If s1 <> "" SequenceName = s1 ShowSequenceName EndIf Return Label ShowSequenceName Button SelectSequence Text "Sequence" + CRLF + SequenceName Return ' ███████████████████████████████████████████████████████████████ ' ██ SEQUENCE LOADING AND EXECUTION ██ ' ███████████████████████████████████████████████████████████████ Variable String SequenceToExecute Variable String Sequence Variable String SequenceCmd Variable Numeric SequenceIndex Variable Numeric SequenceLength Variable Numeric N1 Label ExecSequence Load Sequence SequenceToExecute If Len(Sequence) = 0 Controls OpenTextBox Print CRLF + " Sequence file not found: " + SequenceToExecute Beep Stop EndIf ' Print CRLF + "Sequence " + GetFileNameWithoutPath(SequenceToExecute) Print " started at " + Format(Now, "HH:mm:ss") + CRLF + Chars("-", 65) + CRLF ' ---------------------------------------------------------- Variable Numeric ExecSequenceStartTime ExecSequenceStartTime = ElapsedTime ' ---------------------------------------------------------- SequenceLength = GetSeparatedStringCount(Sequence, CRLF) For SequenceIndex = 0 To SequenceLength - 1 ' ------------------------------------------------------ SequenceCmd = GetSeparatedString(Sequence, SequenceIndex, CRLF) SequenceCmd = Replace(SequenceCmd, Chr(9), " ") 'TABS to SPACES ' ------------------------------------------------------ Do not print lines containing '' If GetSeparatedStringCount(SequenceCmd, "''") < 2 Print " Exec: " + SequenceCmd + CRLF EndIf ' ------------------------------------------------------ Trim and remove comments SequenceCmd = Trim(RemoveComments(SequenceCmd)) ' ------------------------------------------------------ If SequenceCmd <> "" Select GetSeparatedString(SequenceCmd, 0) ' ---------------------------------------------- End sequence Case "EndSeq" Exit ' ---------------------------------------------- STOP Case "Stop" ExitFromSequenceLoop = 1 Exit ' ---------------------------------------------- ACTIONS Case "WaitAllMotors" WaitAllMotors ' ---------------------------------------------- LED COLORS Case "RedOn" RedOn Case "GreenON" GreenOn Case "RGBOFF" RgbOff '' ---------------------------------------------- VACUUM PUMP Case "StartPump" StartPump Case "StopPump" StopPump ' ---------------------------------------------- Enable/Disable motors Case "EnableMotors" EnableMotors Case "DisableMotors" DisableMotors ' -------------------------------------------- Motor fixed angles Case "Home" Home Case "HomeMZ" HomeMZ Case "HomeM1" HomeM1 Case "HomeM2" HomeM2 ' -------------------------------------------- With parameters Case "WriteSlot" N1 = GetSeparatedString(SequenceCmd, 1) Slot(N1) = GetSeparatedString(SequenceCmd, 2) Case "ResetStepper" N1 = GetSeparatedString(SequenceCmd, 1) Slot(N1) = Reset Wait Seconds 0.05 Slot(N1) = GetSeparatedString(SequenceCmd, 2) Wait Seconds 0.05 Slot(N1) = GetSeparatedString(SequenceCmd, 3) Case "Move_MZ" Slot(Slot_MotorMZ) = GetSeparatedString(SequenceCmd, 1) WaitAllMotors Case "Move_M1" Slot(Slot_MotorM1) = GetSeparatedString(SequenceCmd, 1) WaitAllMotors Case "Move_M2" Slot(Slot_MotorM2) = GetSeparatedString(SequenceCmd, 1) WaitAllMotors Case "MOVE_M1M2" Slot(Slot_MotorM1) = GetSeparatedString(SequenceCmd, 1) Slot(Slot_MotorM2) = GetSeparatedString(SequenceCmd, 2) WaitAllMotors Case "MOVE_M1M2MZ" Slot(Slot_MotorM1) = GetSeparatedString(SequenceCmd, 1) Slot(Slot_MotorM2) = GetSeparatedString(SequenceCmd, 2) 'Wait Seconds 0.005 Slot(Slot_MotorMZ) = GetSeparatedString(SequenceCmd, 3) WaitAllMotors Case "Pause" Wait Seconds GetSeparatedString(SequenceCmd, 1) CaseElse Controls OpenTextBox Print CRLF + " Unrecognized command: " + SequenceCmd + CRLF Beep Stop ' EndSelect EndIf Next Print Chars("-", 63) + CRLF + "Sequence " + GetFileNameWithoutPath(SequenceToExecute) Print " executed in " + Format(ElapsedTime - ExecSequenceStartTime, "0.00") + " sec" + CRLF Return ' ==================================================================== ' PRINT COORDINATES ' ==================================================================== Label PrintValues s1 = "MZ=" + Format(Slot(Slot_MotorMZ), "0.000") s1 = s1 + " M1=" + Format(Slot(Slot_MotorM1), "0.000") s1 = s1 + " M2=" + Format(Slot(Slot_MotorM2), "0.000") Print CRLF + s1 Return ' ╔════════════════════════════════════════════╗ █▀▀▀ █▀▀█ █▀▀█ ' ║ SPOKEN MESSAGES ║ ▀▀▀█ █▀▀▀ █ █ ' ╚════════════════════════════════════════════╝ ▄▄▄█ █ █▄▄█ Label SayPowerSwIsOn Select TTSlanguage Case "ENG" TTS Speak "Power switch is on?" Case "FRA" TTS Speak "L'interrupteur d'alimentation est allumé ?" Case "ITA" TTS Speak "Hai acceso l'alimentazione?" Case "ZHO" TTS Speak "电源开关是否打开?" EndSelect Wait TTSready Return Label StartRobotOperations Select TTSlanguage Case "ENG" TTS Speak "Start robot operations." Case "FRA" TTS Speak "Démarrez les opérations du robot." Case "ITA" TTS Speak "Avviata la disponibilta del robot." Case "ZHO" TTS Speak "启动机器人动作序列。" EndSelect 'Wait TTSready Return Label SayStartBallRoutine Select TTSlanguage Case "ENG" TTS Speak "Start sequence of pick and place of ping pong ball." Case "FRA" TTS Speak "Commencez la séquence de sélection et de placement de la balle de ping-pong." Case "ITA" TTS Speak "Avvia la sequenza di prelievo e posizionamento della pallina da ping pong." Case "ZHO" TTS Speak "开始乒乓球的取放顺序。" EndSelect 'Wait TTSready Return Label SayStartCoinRoutine Select TTSlanguage Case "ENG" TTS Speak "Coin sequence management has been launched." Case "FRA" TTS Speak "La gestion des séquences de pièces a commencé." Case "ITA" TTS Speak "Avviata la gestione della sequenza della moneta." Case "ZHO" TTS Speak "硬币顺序管理开始。" EndSelect 'Wait TTSready Return Label SayHomeProcedureIsStarted Select TTSlanguage Case "ENG" TTS Speak "Home procedure is started." Case "FRA" TTS Speak "La procédure d'accueil est lancée." Case "ITA" TTS Speak "La procedura di azzeramento è iniziata." Case "ZHO" TTS Speak "家庭程序开始。" EndSelect 'Wait TTSready Return Label SayVacuumProblem Select TTSlanguage Case "ENG" TTS Speak "Vacuum Problem." Case "FRA" TTS Speak "Problème de vide." Case "ITA" TTS Speak "Problema con la pompa del vuoto." Case "ZHO" TTS Speak "真空问题。" EndSelect 'Wait TTSready Return Label SayEndOfProgram Select TTSlanguage Case "ENG" TTS Speak "The program is terminated." Case "FRA" TTS Speak "Le programme est terminé." Case "ITA" TTS Speak "Il programma è terminato." Case "ZHO" TTS Speak "程序终止。" EndSelect 'Wait TTSready Return Label SayNowTheLanguageIsEnglish TTS Speak "Now the language is English." Wait TTSready Return Label SayNowTheLanguageIsItalian TTS Speak "Ora parla Italiano." Wait TTSready Return Label SayNowTheLanguageIsChinese TTS Speak "现在语言是中文" Wait TTSready Return ' ============================================================================= ' Folder Demo Programs\TTS ' File TTS_Tester.txt ' ============================================================================= Controls OpenTextBox Controls ClearTextBox Print TTSvoices TTS SetVolume 100 ' Set the volume to zero to disable Speak TTS SetSpeed -3 TTS SelectVoice "ENG M" TTS Speak 19 Wait TTSready TTS SelectVoice "ENG F" TTS Speak "19" Wait TTSready TTS SelectVoice "ITA" TTS Speak "19" Wait TTSready TTS SelectVoice "FRA" TTS Speak "19" Wait TTSready TTS SelectVoice "CHI" TTS Speak "19" Wait TTSready Stop ' ---------------------------- TTS commands TTS SelectVoice 1 ' 1 to n TTS SetVolume 1 ' 0 to 100 TTS SetSpeed 1 ' -10 to 10 TTS Speak "" ' text string TTS Stop TTS Pause TTS Resume ' ---------------------------- TTS functions v1 = TTSvoices v1 = TTSready v1 = TTSpaused v1 = TTSspeaking ' ============================================================================= ' Folder Demo Programs\TTS ' File TTS_TestWithLongText.txt ' ============================================================================= Controls OpenTextBox Controls ClearTextBox Print TTSvoices TTS SetVolume 100 ' Set the volume 0 to 100 (0 = Disable speak) TTS SetSpeed 0 'TTS SelectVoice "ITA" 'TTS Speak "Nel mezzo del cammin di nostra vita mi ritrovai per una selva oscura." 'Wait TTSready 'TTS SelectVoice "ENG M" 'TTS Speak "The long and winding road." 'Wait TTSready TTS SelectVoice "ENG F" TTS Speak "The long and winding road." Wait TTSready TTS SelectVoice "FRA" TTS Speak "19" Wait TTSready TTS SelectVoice "ZHO" TTS Speak "19" Wait TTSready Stop ' ---------------------------- TTS commands TTS SelectVoice 1 ' 1 to n TTS SetVolume 1 ' 0 to 100 TTS SetSpeed 1 ' -10 to 10 TTS Speak "" ' text string TTS Stop TTS Pause TTS Resume ' ---------------------------- TTS functions v1 = TTSvoices v1 = TTSready v1 = TTSpaused v1 = TTSspeaking ' ============================================================================= ' Folder Demo Programs\Vars ' File SaveAndRestoreVars.txt ' ============================================================================= ' ---------------------------------------- INIT VARS Array1 = 0, 111, 222, 333 Array1(6) = 666 Array1(9) = 999 Numeric Num1 = 111 Numeric Num2 = 222 String Str1 = "s111" String Str2 = "s222" ' ---------------------------------------- SAVE VARS TO FILE String SavedVarsFile = SavedVars.txt SaveVars ' ---------------------------------------- CLEAR VARS ArrayClear(1) Num1 = 0 Num2 = 0 Str1 = 0 Str2 = 0 ' ---------------------------------------- LOAD VARS FROM FILE VarsFromFile SavedVarsFile ' ---------------------------------------- PRINT AND STOP VarsToS1 Print s1 Stop Label VarsToS1 s1 = "" s1 = s1 + ArrayToString(1) + CRLF s1 = s1 + Num1 + " " s1 = s1 + Num2 + " " s1 = s1 + Str1 + " " s1 = s1 + Str2 Return Label VarsWithNamesToS1 s1 = "" s1 = s1 + "Array1 = " + Replace( ArrayToString(1), " " , ",") + CRLF s1 = s1 + "Num1 = " + Num1 + CRLF s1 = s1 + "Num2 = " + Num2 + CRLF s1 = s1 + "Str1 = " + Str1 + CRLF s1 = s1 + "Str2 = " + Str2 Return Label SaveVars VarsWithNamesToS1 Save DeleteFile SavedVarsFile Save StringToFile s1 SavedVarsFile Return ' ============================================================================= ' Folder Demo Programs\Vars ' File SaveVars_Test.txt ' ============================================================================= SetVars Save Vars 'PrintVars ClearVars Load Vars Controls OpenTextBox PrintVars Stop Label SetVars v1 = 1111111111111 s1 = "ssss1" + CRLF + "ssss1" Array1 = 000.1, 111, 222, 333 Array1(6) = 666 Array1(9) = 999 Array2(99) = 222222 Numeric num1 = 111 Numeric num2 = 222 Numeric num3 = 333 String str1 = "aaa" String str2 = "bbb" + LF + "bbb" String str3 = "ccc" + CRLF + "ccc" Return Label ClearVars v1 = 0 s1 = "" ArrayClear(1) ArrayClear(2) num1 = 0 num2 = 0 num3 = 0 str1 = "" str2 = "" str3 = "" Return Label PrintVars s99 = "" s99 = s99 + v1 + " " + s1 + " " + CRLF s99 = s99 + num1 + " " + num2 + " " + num3 s99 = s99 + " " + str1 + " " + str2 + " " + str3 s99 = s99 + CRLF + ArrayToString(1) Print s99 Return ' ============================================================================= ' Folder Demo Programs\Vars ' File Test - S1 = V1 plus string.txt ' ============================================================================= Controls OpenTextBox V1 = 1.234 S1 = V1 & 56 Print CRLF + S1 Stop ' ============================================================================= ' Folder Demo Programs\Vars ' File Test - S1 = V1.txt ' ============================================================================= Controls OpenTextBox V1 = 1.234 S1 = V1 Print CRLF + S1 Stop ' ============================================================================= ' Folder Demo Programs\Vars ' File Test - V1_Slot.txt ' ============================================================================= Controls OpenTextBox v1 = Slot(1) Print CRLF + v1 ' ============================================================================= ' Folder Demo Programs\Vars ' File VarsFromFile.txt ' ============================================================================= Option Speed 9 Variable Numeric Slot_LedR Variable Numeric Slot_LedG Variable Numeric Slot_LedB Variable Numeric Slot_ClampM1 Variable Numeric Slot_ClampM2 Variable Numeric Slot_ClampM3 Variable String StringVar1 Variable String StringVar2 Controls OpenTextBox Controls ClearTextBox Gosub PrintVars VarsFromFile VFF_Example.txt ' This file is in the "Files" folder Gosub PrintVars Stop Label PrintVars Print PadRight(Format(Slot_LedR), 8) Print PadRight(Format(Slot_LedG), 8) Print PadRight(Format(Slot_LedB), 8) Print PadRight(Format(Slot_ClampM1, "0.000"), 10) Print PadRight(Format(Slot_ClampM2, "0.000"), 10) Print PadRight(Format(Slot_ClampM3, "0.000"), 10) Print "---" + StringVar1 + "---" + StringVar2 + "---" Print CRLF Return ' ============================================================================= ' Folder Demo Programs\Vars UserVars ' File ERROR Demo - Named Vars.txt ' ============================================================================= Variable Numeric nnn Variable Numeric Pluto Variable String Caio Variable String Piro Goto loop1 Stop Label loop1 nnn = Slot(1) Slot(2) = nnn Select Pluto Case 2 Beep Case 3 Print 3 EndSelect Goto loop1 ' ============================================================================= ' Folder Demo Programs\Vars UserVars ' File Named Vars - Test1.txt ' ============================================================================= v1 = 323 Variable Numeric att Variable String ss12 Variable String ss12 ss12 = Sin(33) s1 = "pippo" Stop ' ============================================================================= ' Folder Demo Programs\Vars UserVars ' File Test gosub goto.txt ' ============================================================================= Gosub pippo Stop Label pippo v1 = 323 Variable Numeric n12345 n12345 = Sin(33) Goto pippo ' ============================================================================= ' Folder Demo Programs\Vars UserVars ' File Test vars 3.txt ' ============================================================================= Variable Numeric n33 n33 = 3 Stop ' ============================================================================= ' Folder Demo Programs\Vars UserVars ' File Test vars 4.txt ' ============================================================================= '================ THE LOG FILE NAME ========================= s2 = "LogTest_256_ustep_1000_delta.txt" '============================================================ Variable Numeric DigitTime Variable Numeric NumCycles Variable String Info DigitTime = 0.9 DigitTime = 1.2 NumCycles = NumCycles + 1 S9 = "- Date - " + " - TIME - " + " Cycle " + " Init." + " Delta " + " Dest. " + " Delta" ' 9/11/2019 13:23:32 0002 -1.001 -0.001 -5.998 0.002 Save StringToFile s9 s2 Info = Now Info = Info + " " + Format(NumCycles, "000") Info = Info + " " Print Info ' ============================================================================= ' Folder Demo Programs\Vars UserVars ' File Test vars 5.txt ' ============================================================================= Variable Numeric NumCycles Variable String Info Info = Info + " " Print Info Print NumCycles NumCycles = NumCycles + 3 'Stop ' ============================================================================= ' Folder Demo Programs\Vars UserVars ' File Test vars 6.txt ' ============================================================================= Print "Pippo" Variable Numeric n1 Variable String str1 Variable String String1 str1 = "loop" + 1 String1 = 1 v9 = 1 Label loop1 n1 = n1 + 1 If n1 > 1000 n1 = 0 Print (ElapsedTime - v1) * 1000 + " uS" v1 = ElapsedTime EndIf Goto loop1 ' ============================================================================= ' Folder Demo Programs\Vars UserVars ' File TestSpeed.txt ' ============================================================================= Variable Numeric n1 Label loop1 n1 = n1 + 1 If n1 > 1000 n1 = 0 Print (ElapsedTime - v1) * 1000 + " uS" v1 = ElapsedTime EndIf Goto Loop1 ' ============================================================================= ' Folder Demo Programs\Wait ' File Demo - Wait.txt ' ============================================================================= Wait Seconds 1 Button 1 Label "Button1" Wait Button Button1 Wait Slot(4) > 500 Stop ' ============================================================================= ' Folder Demo Programs\Wait ' File Wait Application 1.txt ' ============================================================================= ' ------------------------------------------------------------- ' "Load" and "Wait Application" example ' ------------------------------------------------------------- ' The "Load" waits until the application is opened ' The "Wait Application" waits until the application is closed ' ------------------------------------------------------------- s1 = "Theremino_SlotViewer.exe" Load s1 Wait Application s1 Beep Stop ' ============================================================================= ' Folder Demo Programs\Wait ' File Wait Application 2.txt ' ============================================================================= ' ------------------------------------------------------------- ' "Load" and "Wait Application" example ' ------------------------------------------------------------- ' The "Load" waits until the application is opened ' The "Wait Application" waits until the application is closed ' ------------------------------------------------------------- Load "Theremino_SlotViewer.exe" Wait Application "Theremino_SlotViewer.exe" Beep Stop ' ============================================================================= ' Folder Demo Programs\Wait ' File Wait Applications Open-Close.txt ' ============================================================================= ' AppRunning is explained in the help-file at page 61 and 77 Load Theremino_SlotViewer.exe Wait AppRunning("Theremino_SlotViewer.exe") Beep Load CloseApps Theremino_SlotViewer.exe Wait Not AppRunning("Theremino_SlotViewer.exe") Beep Stop ' ============================================================================= ' Folder Demo Programs\Wait ' File Wait Buttons Initial.txt ' ============================================================================= ' Theremino Automation demo program ' Demonstrating "Partial button names" and "Wait Button" Button 1 Text "sTrAnGe nAmE" Button 2 Text "five" Label Start Wait Button Strange Slot(1) = 1000 Slot(1) = 0 Wait Button Five Slot(2) = 1000 Slot(2) = 0 Goto Start ' ============================================================================= ' Folder Demo Programs\Wait ' File Wait Buttons.txt ' ============================================================================= Button 1 Text "Button1" Button 2 Text "Button2" Label Start Wait Button Button1 Slot(1) = 1000 Slot(1) = 0 Wait Button Button2 Slot(2) = 1000 Slot(2) = 0 Goto Start ' ============================================================================= ' Folder Demo Programs\Wait ' File Wait Key.txt ' ============================================================================= ' Valid key names (uppercase or lowercase) ' ---------------------------------------- ' left right up down pageup pagedown ' space esc home end ' 0 1 2 3 4 5 6 7 8 9 ' a b c d e f g h i j k l m n ' o p q r s t u v w x y z ' f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 ' ---------------------------------------- Wait Key("Space") Beep Wait Key("X") Beep Wait Not Key("X") Beep Wait Key("x") Beep Wait Not Key("x") Beep Wait Key("Left") Beep Wait Key("Right") Beep Wait Key("'") Beep Wait Key("+") Beep Wait Seconds 1 Beep ' ============================================================================= ' Folder Demo Programs\Wait ' File Wait Seconds With Expressions.txt ' ============================================================================= Slot(1) = 10 Wait Seconds Slot(1) Slot(1) = 0.5 Wait Seconds Slot(1) * 2 Slot(1) = 30 Wait Seconds Slot(1) / 30 ' ============================================================================= ' Folder Demo Programs\Wait ' File Wait Slot.txt ' ============================================================================= Wait Slot(1) < 300 Wait Slot(1) > 700 ' ============================================================================= ' Folder Demo Programs\Windows and Web ' File Demo - BM_Foundation1.txt ' ============================================================================= ' Theremino Automation ' Demo program for: "Load" (images, video, sounds, programs and web pages) ' In this demo the filename depends from the Slot1 value ' the complete name is composed in the string s1 ' and the media file is loaded ' To test the demo use the application SlotViewer ' and change the Slot1 value from 0 to 15 Slot(1) = 0 Label Loop1 s1 = "BM_Foundation" + Slot(1) + ".jpg" Print s1 Load s1 Wait Seconds 0.1 Goto Loop1 ' ============================================================================= ' Folder Demo Programs\Windows and Web ' File Demo - BM_Foundation2.txt ' ============================================================================= ' Theremino Automation ' Demo program for: "Load" (images, video, sounds, programs and web pages) ' In this demo the filename depends from the v1 value ' The v1 value is increased up to 15 ' the complete name is composed in the string s1 ' and the media file is loaded Label Loop1 v1 = v1 + 1 If v1 > 15 v1 = 0 EndIf s1 = "BM_Foundation" + v1 + ".jpg" Print s1 Load s1 Wait Seconds 0.3 Goto Loop1 ' ============================================================================= ' Folder Demo Programs\Windows and Web ' File Demo - BM_Foundation3.txt ' ============================================================================= ' Theremino Automation ' Demo program for: "Load" (images, video, sounds, programs and web pages) ' In this demo the filename depends from the v1 value ' The v1 value is increased up to 15 ' the complete name is composed in the Load line ' and the media file is loaded Label Loop1 v1 = v1 + 1 If v1 > 15 v1 = 0 EndIf Load "BM_Foundation" + v1 + ".jpg" Wait Seconds 0.3 Goto Loop1 ' ============================================================================= ' Folder Demo Programs\Windows and Web ' File Demo - WebBrowser.txt ' ============================================================================= Load https://www.theremino.com/en Stop Load s1 + "www.theremino.com/en" s1 = "https://www.theremino.com/en" Load s1 ' ============================================================================= ' Folder Demo Programs\Windows and Web ' File Demo - Windows 1.txt ' ============================================================================= Key 1 Goto MinSize Key 2 Goto Sizable Key 3 Goto Maximized Key 4 Goto FullScreen Button 1 Text MinSize Button 2 Text Sizable Button 3 Text Maximized Button 4 Text FullScreen Button 5 Text Hide Load Hide Stop Label MinSize Window MinSize Load Hide Stop Label Sizable Window Sizable Load "BM_Foundation0.JPG" Stop Label Maximized Window Maximized Load "BM_Foundation1.JPG" Stop Label FullScreen Window FullScreen Load "BM_Foundation15.JPG" Stop Label Hide Load Hide Return ' ============================================================================= ' Folder Demo Programs\Windows and Web ' File Demo - Windows 2.txt ' ============================================================================= Button 1 Text Video Button 2 Text Image Button 3 Text WEB Window FullScreen Load Hide Stop Label Video Load "Video1.avi" Stop Label Image Load "BM_Foundation0.JPG" Stop Label WEB Load https://www.theremino.com Stop ' ============================================================================= ' Folder Demo Programs\XML ' File Demo - DecodeXML - Debug Immediate Test.txt ' ============================================================================= ' ---------------------------------------------------------- ' Decode XML example ' ---------------------------------------------------------- ' Press RUN and then move the cursor on each "DecodeXML" ' ---------------------------------------------------------- Load XML "NotebookTest.xml" XML = FormatXML(XML) Stop ' DECODING EXAMPLES Variable String XML XML = DecodeXML(XML, "WinSAT") XML = DecodeXML(XML, "ProgramInfo") XML = DecodeXML(XML, "Version") XML = DecodeXML(XML, "WinSAT") XML = DecodeXML(XML, "SystemEnvironment") XML = DecodeXML(XML, "ExecDateTOD") XML = DecodeXML(XML, "WinSAT") XML = DecodeXML(XML, "Metrics") XML = DecodeXML(XML, "GraphicsMetrics") XML = DecodeXML(XML, "VideoMemBandwidth") ' ============================================================================= ' Folder Demo Programs\XML ' File Demo - DecodeXML from DiskC.txt ' ============================================================================= Button 1 Text GetVersion Button 2 Text GetExecDateTOD Button 3 Text GetVideoMemBandwith Stop Variable String XML Label GetVersion Load XML "C:\WXM\formal.xml" XML = DecodeXML(XML, "WinSAT") XML = DecodeXML(XML, "ProgramInfo") XML = DecodeXML(XML, "Version") Print XML Return Label GetExecDateTOD Load XML "C:\WXM\formal.xml" XML = DecodeXML(XML, "WinSAT") XML = DecodeXML(XML, "SystemEnvironment") XML = DecodeXML(XML, "ExecDateTOD") Print XML Return Label GetVideoMemBandwith Load XML "C:\WXM\formal.xml" XML = DecodeXML(XML, "WinSAT") XML = DecodeXML(XML, "Metrics") XML = DecodeXML(XML, "GraphicsMetrics") XML = DecodeXML(XML, "VideoMemBandwidth") Print XML Return ' ============================================================================= ' Folder Demo Programs\XML ' File Demo - DecodeXML from FilesPath.txt ' ============================================================================= Button 2 Text GetVersion Button 3 Text "GetExecDate" + CRLF + "TOD" Button 4 Text "GetVideoMem" + CRLF + "Bandwith" Stop Variable String XML Label GetVersion Load XML "NotebookTest.xml" XML = DecodeXML(XML, "WinSAT") XML = DecodeXML(XML, "ProgramInfo") XML = DecodeXML(XML, "Version") Print XML Return Label GetExecDate Load XML "NotebookTest.xml" XML = DecodeXML(XML, "WinSAT") XML = DecodeXML(XML, "SystemEnvironment") XML = DecodeXML(XML, "ExecDateTOD") Print XML Return Label GetVideoMem Load XML "NotebookTest.xml" XML = DecodeXML(XML, "WinSAT") XML = DecodeXML(XML, "Metrics") XML = DecodeXML(XML, "GraphicsMetrics") XML = DecodeXML(XML, "VideoMemBandwidth") Print XML Return ' ============================================================================= ' Folder Demo Programs\XML ' File Demo - DecodeXML Monitors.txt ' ============================================================================= Controls OpenTextBox Gosub GetMonitors Gosub GetMonitor1 Gosub GetMonitor2 Stop Variable String XML Label GetMonitors Print "--- GetMonitors ---" + CRLF Load XML "NotebookTest.xml" XML = FormatXML(XML) XML = DecodeXML(XML, "WinSAT") XML = DecodeXML(XML, "SystemConfig") XML = DecodeXML(XML, "Monitors") Print XML Return Label GetMonitor1 Print CRLF + "--- GetMonitor1 ---" + CRLF Load XML "NotebookTest.xml" XML = FormatXML(XML, 1) XML = DecodeXML(XML, "WinSAT") XML = DecodeXML(XML, "SystemConfig") XML = DecodeXML(XML, "Monitors") XML = DecodeXML(XML, "Monitor", 1) Print XML Return Label GetMonitor2 Print CRLF + "--- GetMonitor2 ---" + CRLF Load XML "NotebookTest.xml" XML = FormatXML(XML, 1) XML = DecodeXML(XML, "WinSAT") XML = DecodeXML(XML, "SystemConfig") XML = DecodeXML(XML, "Monitors") XML = DecodeXML(XML, "Monitor", 2) Print XML Return ' ============================================================================= ' Folder Demo Programs\XML ' File Demo - DecodeXML Planes.txt ' ============================================================================= Controls OpenTextBox Gosub GetPlanes Stop Variable String XML Variable String XML2 Label GetPlanes Load XML "Planes.xml" XML = FormatXML(XML) XML = DecodeXML(XML, "Planes") For v9 = 1 To 9e99 XML2 = DecodeXML(XML, "plane", v9) If XML2 <> "" XML2 = Replace(XML2, " ", "") Print XML2 Else Exit EndIf Next Return ' ============================================================================= ' Folder Demo Programs\XML ' File Demo - DecodeXML Planes2.txt ' ============================================================================= Controls OpenTextBox Gosub GetPlanes Print CRLF Gosub GetPlanesYear Stop Variable String XML Variable String XML2 Label GetPlanes Load XML "Planes.xml" XML = FormatXML(XML) XML = DecodeXML(XML, "Planes") For v1 = 1 To 9e99 XML2 = DecodeXML(XML, "plane", v1) If XML2 <> "" XML2 = Replace(XML2, " ", "") Print XML2 Else Exit EndIf Next Return Label GetPlanesYear Load XML "Planes.xml" XML = DecodeXML(XML, "planes") For v1 = 1 To 9e99 XML2 = DecodeXML(XML, "plane", v1) If XML2 <> "" XML2 = DecodeXML(XML2, "year") Print Trim(XML2) + CRLF Else Exit EndIf Next Return ' ============================================================================= ' Folder Demo Programs\XML ' File Demo - DecodeXML Plants.txt ' ============================================================================= Controls OpenTextBox Gosub GetPlanes Stop Variable String XML Variable String XML2 Variable String XML3 Variable String XML4 Label GetPlanes Load XML "PlantCatalog.xml" XML = DecodeXML(XML, "catalog") For v9 = 1 To 9e99 XML2 = DecodeXML(XML, "plant", v9) If XML2 <> "" XML3 = DecodeXML(XML2, "common") XML4 = DecodeXML(XML2, "price") Print PadRight(XML3, 24) + XML4 + CRLF Else Exit EndIf Next Return ' ============================================================================= ' Folder Demo Programs\XML ' File Demo - DecodeXML Single Value.txt ' ============================================================================= Controls OpenTextBox Gosub GetFirstPlantName Stop Variable String XML Label GetFirstPlantName Load XML "PlantCatalog.xml" XML = DecodeXML(XML, "catalog") XML = DecodeXML(XML, "plant") XML = DecodeXML(XML, "common") Print XML Return ' ============================================================================= ' Folder Demo Programs\XML ' File Demo - FormatXML 1.txt ' ============================================================================= ' =============================================================== ' FORMAT XML DEMO ' =============================================================== Controls OpenTextBox Button 1 Text ORIGINAL XML Button 3 Text Format_WithReplace Button 4 Text Format_DefaultSpaces Button 5 Text Format_0-Spaces Button 6 Text Format_5-Spaces Stop Variable String XML Label ORIGINAL XML Load XML "NotebookTest.xml" Controls ClearTextBox Print XML Return Label Format_WithReplace Load XML "NotebookTest.xml" XML = Replace(XML, "><", ">" + CRLF + "<") Controls ClearTextBox Print XML Return Label Format_DefaultSpaces Load XML "NotebookTest.xml" XML = FormatXML(XML) Controls ClearTextBox Print XML Return Label Format_0-Spaces Load XML "NotebookTest.xml" XML = FormatXML(XML, 0) Controls ClearTextBox Print XML Return Label Format_5-Spaces Load XML "NotebookTest.xml" XML = FormatXML(XML, 5) Controls ClearTextBox Print XML Return ' ============================================================================= ' Folder Demo Programs\XML ' File Demo - FormatXML 2.txt ' ============================================================================= ' =============================================================== ' FORMAT XML DEMO ' =============================================================== Controls OpenTextBox Button 1 Text ORIGINAL XML Button 3 Text Format_WithReplace Button 4 Text Format_DefaultSpaces Button 5 Text Format_0-Spaces Button 6 Text Format_5-Spaces Stop Variable String XML Label ORIGINAL XML Load XML "Planes.xml" Controls ClearTextBox Print XML Return Label Format_WithReplace Load XML "Planes.xml" XML = Replace(XML, "><", ">" + CRLF + "<") Controls ClearTextBox Print XML Return Label Format_DefaultSpaces Load XML "Planes.xml" XML = FormatXML(XML) Controls ClearTextBox Print XML Return Label Format_0-Spaces Load XML "Planes.xml" XML = FormatXML(XML, 0) Controls ClearTextBox Print XML Return Label Format_5-Spaces Load XML "Planes.xml" XML = FormatXML(XML, 5) Controls ClearTextBox Print XML Return ' ============================================================================= ' Folder Demo Programs\XML ' File Demo - FormatXML 3.txt ' ============================================================================= ' =============================================================== ' FORMAT XML DEMO ' =============================================================== Controls OpenTextBox Gosub Format_5-Spaces Stop Variable String XML Label Format_5-Spaces Load XML "Planes.xml" XML = FormatXML(XML, 5) Controls ClearTextBox Print XML Return ' ============================================================================= ' Folder Simple Programs ' File Simple_Program_1.txt ' ============================================================================= ' ---------------------------------- ' Simple Program 1 ' ---------------------------------- ' Please open the Debug window ' with the Right mouse button ' and use the "Single step" button ' ---------------------------------- v1 = 10 v2 = 20 v3 = v1 + v2 v4 = v3 * 12 Slot(1) = Sqrt(v4) Slot(2) = Rnd * 1000 ' ============================================================================= ' Folder Simple Programs ' File Simple_Program_2.txt ' ============================================================================= ' ---------------------------------- ' Simple Program 2 ' ---------------------------------- ' Please open the Debug window ' with the Right mouse button ' and use the "Single step" button ' ---------------------------------- v1 = Rnd If v1 > 0.5 Beep Print "" Else Print "The v1 value is : " + v1 EndIf ' ============================================================================= ' Folder Simple Programs ' File Simple_Program_3.txt ' ============================================================================= ' ---------------------------------- ' Simple Program 3 ' ---------------------------------- ' Please open the Debug window ' with the Right mouse button ' and use the "Single step" button ' ---------------------------------- ' This program toggles v1 to 0 and 1000 values If v1 < 500 v1 = 1000 Else v1 = 0 EndIf ' ============================================================================= ' Folder Simple Programs ' File Simple_Program_4.txt ' ============================================================================= ' ---------------------------------- ' Simple Program 4 ' ---------------------------------- ' Please test this with "RUN" ' And experiment with "Speed" ' ---------------------------------- ' This program increases v1 from 0 to 10 v1 = v1 + 1 If v1 >= 10 v1 = 0 Beep EndIf Slot(1) = v1 ' ============================================================================= ' Folder Simple Programs ' File Simple_Program_5.txt ' ============================================================================= ' ---------------------------------- ' Simple Program 5 ' ---------------------------------- ' Please test this with "RUN" ' And experiment with "Speed" ' ---------------------------------- ' Prepare a random integer from 0 to 9 v1 = Int(Rnd * 10) ' Select v1 values 1, 2 and 3 Select v1 Case 1 Print "v1 = 1" Case 2 Print "v1 = 2" Case 3 Print "v1 = 3" EndSelect ' ============================================================================= ' Folder Simple Programs ' File Simple_Program_6.txt ' ============================================================================= Print Rnd