Forum Italiano sui Prodotti NI

cancel
Showing results for 
Search instead for 
Did you mean: 

Stringhe selezionate alternativamente

Ciao a tutti, devo sviluppare un progetto dove una fabbrica ha 3 prodotti differenti A,B e C, ognuno con un numero di serie differente con formato: (anno-mese-prodotto – 4 numeri) es. 202102B0021. Solo si può produrre un prodotto alla volta e è necessario registrare quanto ha impiegato ogni unità a fabbricarsi. L’informazione deve essere salvata su un archivio txt.

Bisogna inserire:

Actual unit: unità che si sta fabbricando attualmente

Lasted time: indica il tempo che impiega a fabbricarsi

Start: per avviare il sistema

Stop: per fermare il sistema

Dovrei inserire anche una barra di progresso della produzione. Quindi in definitiva devo stampare una stringa che sia:

202103A0001

202103B0001

202103C0001

202103A0002

202103B0002

E così via. Il mio problema per adesso è sapere come faccio a selezionare nei differenti cicli prima A, poi B e poi C. Un'altra cosa che credo di non saper fare è l’avanzamento della barra col passare del tempo. Allego immagine del VI svolto fino ad ora e della schermata che dovrei ottenere.

 
Download All
0 Kudos
Message 1 of 12
(2,627 Views)

Un altro problema che sto avendo, è che quando stampo i 4 numero che vanno dopo la lettera, invece di stampare ad esempio 0009, come dovrebbe essere, stampo solo 9. Come posso definire la lunghezza della stringa/numero e che questa si riempia di zeri se non arriva ai 4 numeri? Allego immagine.

0 Kudos
Message 2 of 12
(2,618 Views)

@andrea080690 wrote:

Un altro problema che sto avendo, è che quando stampo i 4 numero che vanno dopo la lettera, invece di stampare ad esempio 0009, come dovrebbe essere, stampo solo 9. 

 

numeri


 

Here's what you should do.

 

altenbach_0-1616515469194.png

 

 

 

 

0 Kudos
Message 3 of 12
(2,591 Views)

Thank you, but in this case I am missing the code in the middle. It should be like:

202103A0001

202103B0001

202103C0001

202103A0002

202103B0002

202103C0002

202103A0003

...

 

How can I use alternatively the letter A, B and C?

0 Kudos
Message 4 of 12
(2,575 Views)

Try this (Of course you could use a slow while loop too. The time formatting can go before the loop if you can guarantee that the month and year does not change during run. Can you?):

 

 

 

altenbach_0-1616532839838.png

 

0 Kudos
Message 5 of 12
(2,570 Views)

Non ho ben capito questo secondo codice, il problema è che devo stampare linea a linea i vari valori; la traccia dice questo:
Sviluppa un progetto in LabVIEW che simuli una situazione come la seguente:
Una fabbrica ha 3 diversi prodotti (A, B e C), ognuno con un numero di serie diverso con il formato: [ANNO-MESE-4 CIFRE CONTATORE] -> (es: 202101A1234)
Esiste solo la capacità di produrre un'unità alla volta e si desidera registrare il tempo impiegato da ciascuna unità per la produzione. Le informazioni devono essere salvate in un file "Log.txt"

Dove:
- Unità effettiva: indica l'unità corrente che viene prodotta
- Lasted Time: indica il tempo necessario per la produzione
- Avvia: avvia il sistema quando tutto è pronto
- Stop: arresto di emergenza
Sono stati aggiunti una barra di avanzamento opzionale e un indicatore di uscita dall'errore.

Punti da tenere in considerazione durante lo svolgimento dell'esercizio:
Questo esercizio può essere svolto in diversi modi, sebbene preferibilmente si cerchi una struttura di base della macchina a stati.
Eventuali aggiunte extra che migliorano la funzionalità del programma di esempio saranno molto apprezzate.
Saranno valutati la chiarezza del codice e il suo controllo degli errori, nonché i suoi commenti e la documentazione.

0 Kudos
Message 6 of 12
(2,567 Views)

Finally, I have done this machine state, but I have still three problems. The first one is that When I stop the code, it saves me just the last 3 values, how can I save all of it? 
The second is that I want a progress bar to go from 0 to the top following the end of the time out which is random.
Third, I want to use a start button to start the machine, how can I do it?

0 Kudos
Message 7 of 12
(2,564 Views)

First of all, you need to do some tutorial and actually do a state machine as requested.

 

There is no need for any sequence structures or local variables!

 

The attached code shows just how to accumulate a string in a shift register. First try to fully understand it, then expand it to add all the other functionality needed. Note that if a unit takes more than a fraction of a second, you should use two loops and separate the UI code and the processing. If you don't know the final number of units or time, it is not clear how you want to scale the progress bar.

 

 

altenbach_2-1616570289060.png

 

 

 

0 Kudos
Message 8 of 12
(2,551 Views)

Thank you, I have solved how to save continuously the data. But I still have two problems:
1) I want a progress bar to go from 0 to the top following the end of the time out which is random.
2) I want to use a start button to start the machine, how can I do it?

0 Kudos
Message 9 of 12
(2,548 Views)

When I try to use a case true false to put a start button, I have errors in the code, instead of having 202103A0001 I have  202103AXXXX where XXXX are random numbers.

0 Kudos
Message 10 of 12
(2,535 Views)