I am a PhD student in marine geochemistry who has a big problem (I have 0 knowledge on computers/electronics). Hopefully one of you computer geniuses can help me. I have an iron measuring system with a photon multiplier tube (PMT, a light sensor), 1 2-way 6-port valve and 1 6-position valve. I have been given a .bas file that is opened with qbasic which follows a specific sequence at pre-determined times. What I want to do is add another 6-position valve that would change position after going through the existing loop.
Although I cannot offer any of you any money, since I am a PhD students (aka poor slave), I will thank you in my thesis which will be presented in 3-years, plus in the acknowledgements of any article I write running this system (about 60% of the work I have to do in the next 3 years).
This is how it works.
V1 is he 2-way valve
V2 is the 6-position valve, although only positions 1 and 2 are needed (in the current version 1-3 are used, though 1 and 3 carry the same reagent).
V3 would be the new valve, and it would change every cycle though the system
Plus the sensor data has to be saved to a document (1 column with the values every 0.1s (ideally) - 0.5s (lowest resolution) is enough). saving the file as year-month-day-identifier (eg. 20171019001))
Current:
Step V1 V2 Time (s)
1 2 1 60
2 1 2 120
3 1 3 60
4 2 3 120
Ideally:
Step V1 V2 Time (s)
1 2 1 60
2 1 2 120
3 1 1 60
4 2 1 120
repeat steps 2-4 two more times
then change V3 to the next position.
The current code is:
Expand|Select|Wrap|Line Numbers
- DECLARE SUB arretpm ()
- '*******************************************************************
- ' PROGRAMME DE FLOW INJECTION ANALYSIS
- ' stockage des donnees dans un fichier s‚quentiel lisible sous EXCEL
- ' possibilite d'impression des int‚grales du signal
- '*******************************************************************
- DECLARE SUB ACQUIRE (donnee$, byte)
- DECLARE SUB CONVERT (donnee$, count)
- DECLARE SUB MOTCOMMU (com$)
- DECLARE SUB MOTINJ (inj$)
- DECLARE SUB INJECTION (tempinj%, delai%)
- DECLARE SUB SAUVEGARDE (fichier$)
- DECLARE SUB IMPRESSION (drapimp$)
- DECLARE SUB integration (donnee(), findo%, drapimp$, enrfichier$, MAX)
- DECLARE SUB EXECUTION (reac$(), tempcom%(), tempinj%, delai%, fichier$, drapimp$)
- DECLARE SUB COMMUTATION (posi%(), reac$(), tempcom%())
- DECLARE SUB modification (i)
- DECLARE SUB ACQUISITION (n%, donnee(), CHRONO, t(), ini, FIN%)
- DIM SHARED reac$(6), tempcom%(6), posi%(6), donnee(3000), t(3000), donneec(3000)
- DEFINT E
- DEFINT F
- 'TYPE typeenreg
- ' t AS INTEGER
- ' donnee AS DOUBLE
- 'END TYPE
- 'DIM SHARED enregistre AS typeenreg
- SCREEN 9
- 'Initialisation du port serie RS232C
- ' Set up initial du M1131
- ' adresse : 2
- ' baud rate : 9600
- ' no linefeed
- ' no parity
- ' alarm of
- ' no echo
- ' 2 characters delay
- 'OPEN COM2
- ' lecture valeur analogique $RD1
- ' commande rotation moteur
- ' rotation moteur commutation $1DO02 + $1DO03 :' ss programme MOTCOM
- ' rotation moteur injection $1DO01 + $1DO03 :' ss programme MOTINJ
- ' rotation moteur commutation et moteur injection $1DO00 + $1DO03 :' ss programme MOTEURS
- 'lecture des paramŠtres de commmande de la vanne de commutation
- FOR i = 1 TO 6
- posi%(i) = i
- READ reac$(i), tempcom%(i)
- NEXT i
- READ tempinj%
- READ delai%
- READ fichier$
- DO
- VIEW
- CLS
- LOCATE 2, 5
- PRINT "Programme H2O2"
- LOCATE 3, 5
- PRINT "UMR CNRS 6539"
- 'affichage des valeurs par d‚faut
- LINE (10, 60)-(280, 300), , B
- LINE (300, 10)-(635, 300), , B
- LINE (10, 10)-(280, 50), , B
- LINE (50, 320)-(580, 340), , B
- LOCATE 3, 40: PRINT "Param‚trage de la vanne de s‚lection"
- LOCATE 5, 40: PRINT "Nø"
- LOCATE 5, 49: PRINT "r‚actif"
- LOCATE 5, 64: PRINT "temps (s)"
- FOR i = 1 TO 6
- LOCATE 7 + 2 * (i - 1), 40
- PRINT posi%(i)
- LOCATE 7 + 2 * (i - 1), 49
- PRINT reac$(i)
- LOCATE 7 + 2 * (i - 1), 64
- PRINT tempcom%(i)
- NEXT i
- LOCATE 19, 40: PRINT "Param‚trage injection et acquisition "
- LOCATE 21, 40: PRINT "Dur‚e : "; tempinj%; " s "; "Fr‚quence : "; 100 / delai%; " Hz"
- LOCATE 24, 10: PRINT "nom du fichier de sauvegarde des donn‚es : "; fichier$;
- 'ecran menu principal
- LOCATE 7, 1: PRINT " 1 Programmation de la commutation"
- LOCATE 9, 1: PRINT " 2 Programmation de l'injection "
- LOCATE 11, 1: PRINT " 3 Sauvegarde des donn‚es"
- LOCATE 13, 1: PRINT " 4 Impression des r‚sultats"
- IF drapimp$ = "imp" THEN LOCATE 13, 28: PRINT " active"
- LOCATE 15, 1: PRINT " 5 Ex‚cution"
- LOCATE 17, 1: PRINT " 6 Quitter"
- LOCATE 19, 7: PRINT " Entrez le choix";
- INPUT j
- SELECT CASE j
- CASE 1
- CALL COMMUTATION(posi%(), reac$(), tempcom%())
- CASE 2
- CALL INJECTION(tempinj%, delai%)
- CASE 3
- CALL SAUVEGARDE(fichier$)
- CASE 4
- CALL IMPRESSION(drapimp$)
- CASE 5
- CALL EXECUTION(reac$(), tempcom%(), tempinj%, delai%, fichier$, drapimp$)
- CASE 6
- EXIT DO
- CASE ELSE
- BEEP
- END SELECT
- LOOP
- DATA MQ,60,ech,120, , , , , , ,MQ,60,120,10,NA
- END
- DEFSNG E-F
- SUB ACQUIRE (donnee$, byte)
- WHILE LOC(1) < byte: WEND
- donnee$ = INPUT$(byte, #1)
- END SUB
- SUB ACQUISITION (n%, donnee(), CHRONO, t(), ini, FIN%)
- byte = 4
- 'envoi message lecture
- 'WHILE TIMER < t: WEND
- PRINT #1, "S"
- CALL ACQUIRE(donnee$, byte)
- CALL CONVERT(donnee$, count)
- donnee(n%) = count
- WRITE #4, donnee(n%)
- ' PRINT DONNEE(n%)
- CHRONO = TIMER * 100
- END SUB
- DEFINT E
- SUB arretpm
- PRINT #1, "V" + CHR$(0) + CHR$(0)
- CALL ACQUIRE(donnee$, byte)
- WHILE INKEY$ <> ""
- BEEP
- WEND
- END
- END SUB
- DEFSNG E
- SUB COMMUTATION (posi%(), reac$(), tempcom%())
- CLS
- 'affichage des paramŠtres
- LOCATE 2, 5: PRINT " PROGRAMMATION DE LA VANNE DE COMMUTATION"
- LOCATE 4, 11: PRINT "Nø"
- LOCATE 4, 20: PRINT "r‚actif"
- LOCATE 4, 35: PRINT "temps (s)"
- FOR i = 1 TO 6
- LOCATE 6 + 2 * (i - 1), 10
- PRINT posi%(i)
- LOCATE 6 + 2 * (i - 1), 20
- PRINT reac$(i)
- LOCATE 6 + 2 * (i - 1), 35
- PRINT tempcom%(i)
- NEXT i
- 'modification des paramŠtres de commandes
- DO
- LOCATE 21, 5: PRINT "pour modifier taper le numero de la position ou 0 pour quitter"
- LOCATE 23, 5: INPUT i
- SELECT CASE i
- CASE 1 TO 6
- CALL modification(i)
- CASE 0
- EXIT DO
- CASE ELSE
- BEEP
- END SELECT
- LOOP
- CLS
- END SUB
- DEFINT E
- SUB CONVERT (donnee$, count)
- 'PRINT donnee$
- 'WHILE INKEY$ = "": WEND
- B3 = ASC(LEFT$(donnee$, 1))
- IF B3 > 128 THEN BEEP: PRINT "OVERFLOW": CALL arretpm
- B2 = ASC(MID$(donnee$, 2, 1))
- 'PRINT B2
- B1 = ASC(MID$(donnee$, 3, 1))
- 'PRINT B1
- B0 = ASC(MID$(donnee$, 4, 1))
- 'PRINT B0
- 'WHILE INKEY$ = "": WEND
- count = (B3 * 256 ^ 3 + B2 * 256 ^ 2 + B1 * 256 + B0)
- 'ELSE COLOR 4: PRINT "OVERFLOW!!!": BEEP: COLOR 7
- 'END IF
- END SUB
- DEFSNG E
- '
- SUB EXECUTION (reac$(), tempcom%(), tempinj%, delai%, fichier$, drapimp$)
- 'repetition de la sequence d'analyse
- 'incrementation du fichier
- numfichier = 0
- OPEN "COM1:9600,N,8,1,CS,DS" FOR RANDOM AS #1
- byte = 2
- PRINT #1, "P" + CHR$(100)
- CALL ACQUIRE(donnee$, byte)
- PRINT #1, "R" + CHR$(1)
- CALL ACQUIRE(donnee$, byte)
- PRINT #1, "D"
- CALL ACQUIRE(donnee$, byte)
- t = TIMER + 2: WHILE TIMER < t: WEND
- byte = 4
- PRINT #1, "S"
- CALL ACQUIRE(donnee$, byte)
- 'PRINT donnee$
- 'WHILE INKEY$ = "": WEND
- CALL CONVERT(donnee$, count)
- 'PRINT count
- DO UNTIL INKEY$ <> ""
- numfichier = numfichier + 1
- enrfichier$ = "c:" + fichier$ + LTRIM$(STR$(numfichier)) + ".dat"
- OPEN "COM2: 9600, N,8,1,RS,CS0,DS0,CD0" FOR RANDOM AS #2
- PRINT #2, "@01"
- SLEEP 1
- PRINT #2, "@02"
- SLEEP 1
- 'OPEN enrfichier$ FOR RANDOM AS #1 LEN = LEN(enregistre)
- OPEN enrfichier$ FOR OUTPUT AS #4
- 'FIN% = 0
- VIEW
- visible = TIMER + 15
- WHILE TIMER < visible
- WEND
- CLS
- inj$ = "01g1"
- CALL MOTINJ(inj$)
- temp = TIMER
- WHILE TIMER < temp + 2
- WEND
- LOCATE 2, 5
- PRINT "Programme FIAGS1PM"
- LOCATE 3, 5
- PRINT "UMR CNRS 6539 "; enrfichier$
- LINE (10, 10)-(280, 50), , B
- LINE (10, 260)-(280, 260)
- LINE (10, 60)-(280, 310), , B
- FOR i = 1 TO 6
- f = 48 + i
- PRINT #2, "02g" + CHR$(f)
- 'CALL MOTCOMMU(com$)
- TEMPS = TIMER + tempcom%(i)
- LOCATE 5, 2: PRINT "Nø"
- LOCATE 5, 11: PRINT "r‚actif"
- LOCATE 5, 26: PRINT "temps (s)"
- LOCATE 7 + 2 * (i - 1), 2
- PRINT posi%(i)
- LOCATE 7 + 2 * (i - 1), 11
- PRINT reac$(i)
- LOCATE 7 + 2 * (i - 1), 26
- PRINT tempcom%(i)
- WHILE TIMER < TEMPS
- LOCATE 20, 10: PRINT "temps restant "; INT(TEMPS - TIMER); " s"
- WEND
- NEXT i
- LOCATE 20, 3: PRINT "‚lution et acquisition ";
- PRINT tempinj%; " s"
- TEMPS = TIMER + tempinj%
- CHRONO = INT(TIMER * 100): 'CHRONO=temps initial relatif en 100Šme de s
- ini = INT(TIMER * 100): 'temps initial absolu
- n% = 0
- ' FIN% = LOF(1) / LEN(enregistre)
- ' rotation vanne injection en elution
- inj$ = "01g2"
- CALL MOTINJ(inj$)
- MAX = 0: SOMME = 0:
- WHILE TIMER < TEMPS
- TEMPRES = TEMPS - TIMER
- LOCATE 22, 3: PRINT INT(TEMPRES):
- LOCATE 22, 6: PRINT "s"
- LOCATE 22, 10: PRINT " Nbr acquisitions :"; n%
- ' IF INT(TIMER * 100) > CHRONO + delai% THEN
- n% = n% + 1
- byte = 4
- t = TIMER
- CALL ACQUISITION(n%, donnee(), CHRONO, t(), ini, FIN%)
- IF donnee(n%) > MAX THEN MAX = donnee(n%)
- LOCATE 3, 50: PRINT "base line:"; donnee(1)
- LOCATE 5, 50: PRINT "valeur max:"; MAX
- ' SOMME = SOMME + donnee(n%)
- WEND
- ' PRINT SOMME
- ' PRINT enrfichier$
- findo% = n%
- ' FIN% = LOF(1) / LEN(enregistre)
- ' ecriture marqueur fin enregistrement -10,0
- ' enregistre.t = -10
- ' enregistre.donnee = 0
- ' marqueur = FIN% + 1
- ' PUT #1, marqueur, enregistre
- ' rotation vanne injection en concentration
- ' CALL MOTINJ
- 'int‚gration
- CALL integration(donnee(), findo%, drapimp$, enrfichier$, MAX)
- CLOSE #4
- CLOSE #2
- LOOP
- CLOSE #1
- CLOSE #3
- END SUB
- SUB IMPRESSION (drapimp$)
- CLS
- PRINT "pour activer l'imprimante taper imp"
- INPUT drapimp$
- IF drapimp$ = "imp" THEN OPEN "lpt1" FOR OUTPUT AS #3
- END SUB
- SUB INJECTION (tempinj%, delai%)
- CLS
- LOCATE 3, 3
- PRINT "le temps d'‚lution est de "; tempinj%; " s"
- LOCATE 5, 3
- PRINT "taper la nouvelle valeur ( min 51s) ou 0 pour quitter ";
- INPUT i
- IF i <> 0 THEN tempinj% = i
- LOCATE 7, 3
- PRINT "le delai d'acquisition est de "; delai%; "100Šme de s"
- LOCATE 9, 3
- PRINT " taper la nouvelle valeur ou 0 pour quitter"
- INPUT j
- IF j <> 0 THEN delai% = j
- CLS
- END SUB
- DEFINT E
- SUB integration (donnee(), findo%, drapimp$, enrfichier$, MAX)
- 'calcul de l'integrale et tracer de la courbe
- 'findo% = nombre d'acquisition
- ' CLS
- ' VIEW (330, 0)-(610, 340), , 0
- ' LINE (0, 0)-(280, 330), , B
- ' LINE (0, 170)-(280, 170)
- ' INTEGRALE = 0
- ' integralec = 0
- 'calcul ligne de base
- ' somini = 0: somfin = 0
- ' FOR n% = 1 TO 10
- ' somini = somini + donnee(n%)
- ' NEXT n%
- ' FOR n% = findo% - 9 TO findo%
- ' somfin = somfin + donnee(n%)
- ' NEXT n%
- ' moyini = somini / 10: moyfin = somfin / 10
- 'pente de la ligne de base entre 10 et findo%-9
- ' pente = (moyfin - moyini) / (findo% - 20)
- 'ordonnee a l'origine de la ligne de base
- ' ordonnee = moyini
- ' LOCATE 5, 4: PRINT "pente de la ligne de base :"
- ' LOCATE 6, 4: PRINT pente
- ' LOCATE 8, 4: PRINT "ordonnee de la ligne de base :"
- ' LOCATE 9, 4: PRINT ordonnee
- ' PSET (11 * 280, (170 - ordonnee))
- ' FOR n% = 11 TO findo% - 10
- ' calcul int‚grale brute
- ' INTEGRALE = INTEGRALE + donnee(n%)
- ' LOCATE 11, 4: PRINT "int‚grale brute:";
- ' PRINT INTEGRALE
- ' 'calcul int‚grale corrig‚e
- ' donneec(n%) = donnee(n%) - (pente * (n% - 10) + ordonnee)
- ' integralec = integralec + donneec(n%)
- ' LOCATE 14, 4: PRINT "integrale corrigee:";
- ' PRINT integralec
- '
- ' NEXT n%
- 'calcul de l'int‚grale corrig‚e version 2
- ' integralecc = 0
- ' FOR n% = findo% - 10 TO findo% - 50 STEP -1
- ' integralecc = integralecc + donneec(n%)
- ' NEXT n%
- ' n% = n% - 1
- ' WHILE donneec(n%) > 0
- ' integralecc = integralecc + donneec(n%)
- ' n% = n% - 1
- ' WEND
- ' LOCATE 17, 4: PRINT "integrale corrigee 2: ";
- ' PRINT integralecc
- ' trace dela courbe
- ' PSET (1, (170 - donnee(1)))
- ' FOR n% = 1 TO findo%
- ' LINE -(n% / findo% * 280, (170 - donnee(n%)))
- ' NEXT n%
- ' trace de la ligne de base
- ' LINE (10 / findo% * 280, (170 - moyini))-((findo% - 9) / findo% * 280, (170 - moyfin))
- ' impression des integrales
- IF drapimp$ = "imp" THEN PRINT drapimp$: PRINT #3, enrfichier$, MAX
- END SUB
- DEFSNG E
- SUB modification (i)
- LOCATE 6 + 2 * (i - 1), 10: PRINT i
- LOCATE 6 + 2 * (i - 1), 20: PRINT " "
- LOCATE 6 + 2 * (i - 1), 35: PRINT " "
- LOCATE 6 + 2 * (i - 1), 20: INPUT reac$(i)
- LOCATE 6 + 2 * (i - 1), 35: INPUT tempcom%(i)
- END SUB
- DEFINT E
- SUB MOTCOMMU (com$)
- PRINT #2, "01gF"
- SLEEP 1
- END SUB
- SUB MOTINJ (inj$)
- PRINT #2, inj$
- END SUB
- DEFSNG E
- SUB SAUVEGARDE (fichier$)
- CLS
- LOCATE 10, 10
- PRINT "nom du fichier de sauvegarde"
- INPUT fichier$
- END SUB