LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to outputs values of 1 and 0 sequentially for some time?

Solved!
Go to solution

I want to write low(0) and high(1) sequentially to an Arduino pin via Labview.

So essentially I want the labview to do this with the arduino:

 

void loop() {
  for (int i=0; i<6400; i++)
  {
    digitalWrite(DIR,LOW);
    digitalWrite(ENA,HIGH);
    digitalWrite(PUL,HIGH);
    delayMicroseconds(50);
    digitalWrite(PUL,LOW);
    delayMicroseconds(50);
  }
}

 

The trouble is, I can set the delay between low to high, but I dont know how to set delay between high to low.

0 Kudos
Message 1 of 11
(3,355 Views)

Use the Wait function inside of a Flat Sequence Structure.  Do note that you are not going to get into the microsecond range of delay on a PC.  Even the millisecond range will be unreliable.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 11
(3,321 Views)

Thank you, now it works.

And yes, wait.vi cannot go below 1ms, which is not optimal. Is there a way to over come this?

0 Kudos
Message 3 of 11
(3,316 Views)

All you need is a FOR loop with a 50us delay and alternate the data based on bitwise operation of the iteration terminal. Spin it twice as many times. 😄

 

If you have hardware time IO, I would generate the 01 array once using an autoindexing output tunnel and write the array afterwards using properly configured IO. To get the desired speed, you probably would need to run this natively on the arduino.

 

 Writeo0101etc

0 Kudos
Message 4 of 11
(3,309 Views)

@altenbach wrote:

All you need is a FOR loop with a 50us delay and alternate the data based on bitwise operation of the iteration terminal. Spin it twice as many times. 😄

 

If you have hardware time IO, I would generate the 01 array once using an autoindexing output tunnel and write the array afterwards using properly configured IO. To get the desired speed, you probably would need to run this natively on the arduino.

 

 Writeo0101etc


how does the wait(ms) function wait 50us (microseconds)?

i have never observed that.

 

Update: i guess that was a typo, otherwise i would really be interested


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 5 of 11
(3,276 Views)

No, the code shown will wait 50ms. I could have placed a black box with the letters 50us on it... :). On LabVIEW RT/FPGA we have other waits that allow much higher resolution.

We cannot have sub-ms waits on windows. One rough approximation would be to wait 1ms every 20 iterations, but that still would get very jittery on a multipurpose OS.

I don't know what kind of waits are available on Arduino when running deployed LabVIEW code.

 

My other suggestions was to remove the wait, autoindex the signal at the right loop boundary, and "play" the resulting array hardware timed at once (no loop). Not sure if that's available on Arduino.

0 Kudos
Message 6 of 11
(3,259 Views)

sorry i took you literal .. somehow i misunderstood, that this was an example, but you haven't used the proper RT equivalent .. my bad

thx for clearing that up


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 7 of 11
(3,256 Views)

I would have, but only plain LabVIEW on this rig here. I guess I could have copy/pasted an image of the right wait from the online help. 🙂

0 Kudos
Message 8 of 11
(3,250 Views)

Thank you people! Since wait.vi dosnt support higher precision, I will try another method. Namely to send a boolean to Arduino and if it gives HIGH, then run a piece of code from a sketch. Which means I am no longer generating pulse signal from Labview, but from the Arduino it self instead.

0 Kudos
Message 9 of 11
(3,241 Views)

You might want to check out these Timer libraries: https://playground.arduino.cc/Code/Timer1 if you have a Mega. I remember doing some PWM with an Arduino at one point and those were useful, though it was a long time ago so I don't remember much.

0 Kudos
Message 10 of 11
(3,235 Views)