LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Visa port speed

Solved!
Go to solution

The main difference between the LabVIEW program and the interactive window test is that in LabVIEW the command timing is tightly bound to the string read: the command is sent just after the reading, which may not be good for the Arduino program for some reason I cannot guess about.

Furthermore, as I understand the Arduino program, only one command per cycle is read and executed. Immediately after command execution, the program calls Serial.flush() which possibly clears the input buffer (or not?). In any case, either the other commands are discarded, or they are executed one by one at the loop frequency (this fact may explain why you see such long delays).

Paolo
-------------------
LV 7.1, 2011, 2017, 2019
0 Kudos
Message 11 of 28
(170 Views)

Hi Paolo

 

The arduino code has something strange

It define looptime at beginning I let it on 100ms

 

#define valveswitch 9
#define pump1speed 5
#define LOOPTIME 100
unsigned long oldTime= 0;
unsigned long lastMilli = 0;
unsigned long lastMilliPrint = 0;

..................................

}
void loop() {
delay (LOOPTIME);
getParam();
pulseCounter1();

....................................

Near the end has lastMilliPrint and let it 100ms too

 

void printinfo(){

if((millis()-lastMilliPrint) >= 100) {
lastMilliPrint = millis();

 

 

With this I get data in labview each 100ms but for send the commands this not work

 

Before it, and originally the arduino has LOOPTIME=100ms and lastMilliPrint) >= 1000

 

 

Now I change LOOPTIME=20ms and lastMilliPrint) >= 100 and now it receives commands from labview

 

Strange...

 

Best regards

cpalka

 

0 Kudos
Message 12 of 28
(157 Views)

It's not that strange. The (millis()-lastMilliPrint) >= 1000) condition was there to partially decouple the output rate from the input rate. The input time (LOOPTIME) should always be small to allow a prompt response to commands. On the other side, printing should not be too frequent. One print per second is probably a good choice, although I don't know what the output is sent for.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019
0 Kudos
Message 13 of 28
(140 Views)

Hi Princpanter

 

Thanks for your information.

 

In fact with LOOPTIME=50ms and Print with 100ms it works so far

This is for measure data frome a trailer in speed, and sample interval with 1 sec shows to be poor.

I want to try 100ms.

 

My interface VI now I can send the commands but it takes some 5 sec to change the state in arduino.

The curious thing is the last command stops working after about 30 or 40sec, thats why i change the order in vi, because one command needs only to start at the beggining.

 

Best

cpalka

0 Kudos
Message 14 of 28
(122 Views)

No, it does not work. You are still sending too many commands to Arduino.

Actually, you send at least 3 commands (sometimes 4) at every print, that is every 100 ms.

But Arduino processes a single command at each loop, that is every 50 ms. This means that every second Arduino processes about 20 commands, but you are sending at least 30 commands. Thus Arduino cannot keep up and its answer is of course delayed. And its serial buffer will be full soon or later.

Furthermore, it's useless to send the very same command, say "q", over and over again. Send commands only at the first iteration or when buttons change their state.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019
0 Kudos
Message 15 of 28
(110 Views)

Hi Princpanter

 

Many thanks for the help.

 

Yes, you are right, and I was thinking on that, but I think that arduino could receive many "q" or other...

 

I need to think in other way to send this commands to turn ON and OFF.

The "+" and "-" warks fine because it sends one each time is pressed.

 

Do you have some ideia?

I will duplicate the cases strucutures, 1 case for each letter...I cannot see other solution.

But the buttons cannot turn green or red any more, I need to choose in mechanical action for "Latch when pressed"

Or a text box and send one command each time in front panel

The problem is that I need to open and close a water valve during the tests.

 

Best regards

cpalka

0 Kudos
Message 16 of 28
(109 Views)

Consider using an event structure which may catch and service the Value change events of your buttons without changing the mechanical action.

The event structure should have a very small timeout and should be put in a While Loop to service multiple clicks; the Timeout case would trigger the end of the While Loop. For every occurred Value change you should concatenate a proper command character to the command string.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019
0 Kudos
Message 17 of 28
(96 Views)

Hi Paolo

 

Could you put a picture from this change (only 1 example)...using my vi?

 

Only if you have time 

 

best regards

cpalka

0 Kudos
Message 18 of 28
(89 Views)

Here it is. I noticed that some of your controls has no Label: this is a very bad idea!

I only managed one latch button and one switch button. I'm letting you complete the job.

In the latch button Value Change event, you don't need to manage the False value, because the button is automatically released without generating another Value Change.

The Val(Sgnl) property node on the left makes you sure that the PUMP button is pressed "by code" and the proper command is sent to Arduino.

If you know nothing about Event structures and Property nodes, well, it's time to learn! They are very useful!

Paolo
-------------------
LV 7.1, 2011, 2017, 2019
0 Kudos
Message 19 of 28
(77 Views)

@pincpanter wrote:

Here it is. I noticed that some of your controls has no Label: this is a very bad idea!

<snip>

I used to think that it was a bad idea simply because it makes it harder for humans to understand, but there is evidence that it could confuse the compiler as well!

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 20 of 28
(71 Views)