LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

programming paradigm for ``bit banging''?

Suppose I want to send a clocked data signal out on a pair of digital lines via Labview+LINX+Arduino (or Labview+USB-6008).  What's the "best" way to write out a synchronized signal from a vi?  Right now, the easiest tool seems like a flat sequence (movie) structure, with one frame per clock cycle.  Since I'm just twiddling a pair of bits, is there a text-base way to propagate the signal (ie, via formula or mathscript node?)  

 

If you'd like a concrete application - lets say I want to drive an i2c protocol for a 16bit ADC, and for the sake of learning I don't want to use the canned i2c module in LINX.

 

Yes, I realize that LINX+Arduino isn't reliable for waits of less than 15ms! I'm mostly just trying to figure out what the best way to write out adigital signal.  

 

Nathan

 

 

0 Kudos
Message 1 of 6
(3,318 Views)

If you want to set bits from text, you might want to switch to a text-based language. In LabVIEW, I would do this using a state machine - a while loop, containing a case structure, with a shift register around the while loop that stores the current/next state. Alternatively, if you can precompute the series of bits to be sent, you could store them in an array, then use a for loop to write them out one at a time with a fixed delay for every loop iteration.

0 Kudos
Message 2 of 6
(3,300 Views)

If you want to do I2C you need digital lines that can tristate.

 

The best way to go about this that I know is either:

-8452: https://www.ni.com/en-us/shop/model/usb-8452.html

-LabVIEW FPGA: https://forums.ni.com/t5/Examples-and-IP-for-Software/I2C-IP/ta-p/3491271

-HSDIO Card

The biggest issue you're going to have is that standard DAQ cards either can't tristate their digital lines, or can't tristate them fast enough.

Craig H. | CLA CTA CLED | Applications Engineer | NI Employee 2012-2023
0 Kudos
Message 3 of 6
(3,281 Views)
You also don't have a clock with the 6008. It is strictly software timed.

While better than a stacked sequence, the flat sequence structure is of little utility here. Dataflow will control execution order.
0 Kudos
Message 4 of 6
(3,261 Views)

I believe the term "bit banging" implies a software timed system. Sometimes it's good enough.

0 Kudos
Message 5 of 6
(3,207 Views)
I also suggest the state machine.  Avoid "movie frames" by using more scalable designs.
0 Kudos
Message 6 of 6
(3,174 Views)