LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

writing multiple addresses as serial data

Hi There,

 

Im am quite new to the Labwiev programming. I know quite a lot of C and hence I have the algorithm (in C) in my head and on paper. Its just a matter of implementing it in Labview.

 

The problem is as follows.

 

My aim is to write an 8 bit data stream to a board. The board has 8 potentiometers and I want to create a program that the user can select which pot to test. I have put 8 switches on the block diagram and wired them to form an array. I was able to get some of the code working, but the result was that the pots were being read randomly. I made some changes to the program and now I cannot get it to work as before. This is the algorithm I have written for the first test.

 

While(TRUE)

{

  For n = 0 to 8

  {

    Load button array data() 

   if (CLK = TRUE) -- look for the positive edge of the clock.

     {

        Serial Data = Switch Array[n]

     }Else

     {

      Serial Data = Serial Data

     }

  }Next n

 

Once I load the data into the array, I use the index array function to index each element and then apply it to the DAQ pins.

 

The second method I tried to use was by using Time Division multiplexing and I think this might be a better way to do that.

 

Given below is the pseudo code.

 

While (True)

 For n = 0 to 511

 Check if Clock edge is positive.

  if TRUE, then increment count by 1

  {

    convert the numeric count to boolean equivalent

    Apply boolean data onto the DAQ pin

   }

My aim is to cycle through each pot at a particular rate and then read the data from the pots.

 

I tried working on this for almost 2 weeks but with no major result.

What do you think abt this? Do you think there is another easier way to do this?

 

Thanks

 

Labmat

Download All
0 Kudos
Message 1 of 8
(2,778 Views)

Hi Labmat,


I don’t understand your application or what you are trying to achieve; can you give me more details on what you are trying to achieve? What are you inputs and outputs of your program?


What is your device under test (DUT)? How do you test the DUT and how is it connected? Is it just a single DIO line for each DUT?


What do you mean by “Check if Clock edge is positive”? Looking at your code, I can see that you are only executing your code on every other iteration of your while loop. What is the reason for doing this?

 

You attached 2 VIs. What is each one and which one are you working on?

 

What do you mean by “convert the numeric count to Boolean equivalent”? Have you seen the Number To Boolean Array Function?


Are you familer with Auto-Indexing? You can automatically pull elements from an array in order with each iteration of a For Loop. The For Loop will run for the length of your array or from the N terminal, whichever is smaller.

Lewis Gear CLA
LabVIEW UAV

0 Kudos
Message 2 of 8
(2,752 Views)

Hi Lewis,

 

Thanks for the reply. Ill answer all of these questions.

 

Number 1: The system that I am testing has 3 inputs.

               a) POT_MPX_LOAD - This is the signal that will load the address of the potentiometer to the parallel output of the SIPO (Serial In Parallel OUT)

               b). POT_MPX_DATA: This is the data that has the address of each potentiometer.

               c). POT_MPX_CLK: This is the main clock pulse

 

The DUT is a PCB that consists of a set of potentiometers. (4 x Gain Pots) and 4x Pan pots, giving a total umber of 8.

The Serial Data (POT_MPX_DATA) consists of the address of each potentiometer.

The SIPO chip is a 74HC595D. the POT_MPX_DATA line is connected to the DS input of the SIPO chip.

In actual sense, it will be another board controlling the SIPO chip. My job is to do the work of the other board and control the SIPO chip.

The DUT has a 26 pin header and the other end of the 26 pin ribbon cable is connected to MYDAQ.

In the MYDAQ, I am using the DIO port 0 for the POT_MPX_LOAD, port 1 for the POT_MPX_DATA and port 2 for POT_MPX_CLK and the analog data from the pot is read through the AI (0+ and 1+ pins) because each pot has two wipers placed at 90 degrees apart hence giving a precise value.  So in essence I am controlling the board using 3 lines and getting data using 2 analog lines.

 

With regards to the Clock Edge, the data is to be shifted out every positive clock cycle (This is the LOAD signal) and hence the CASE Statement. that is the reason why it is running every other time.

 

With regards to the numeric to boolean conversion, This is for the TIME DIVISION MULTIPLEXING. What I am planning to do is to simulate a TDM pot read. So I would cycle through each of the 8 pots at a particular frequency (which can be chosen as required). The end result is a GUI which will allow the user to test each pot separately.

 

I have used each VI for each pin so I will have 4 VIs (I am not so sure abt this as this might be very inefficient. Is there another way I can do this task by using a lower number of VIs?)

 

Hope this  helps. Im able to explain further if required.

 

thanks #

LABMAT

0 Kudos
Message 3 of 8
(2,734 Views)

Hi there,

Since the last time, Ive made some changes to the code.

Now I am able to generate a sequence of outputs in serial and apply that to the DAQ and I am seeing the data being transmitted.

What this code would do is keep a track of the number of iterations of the while loop and then that number is converted from a numeric value to a boolean array. This is then passed through a FOR loop and by using the auto indexing feature, I can write this array data as serial to the reuired port.

 

My next step is to find a way to clock the data (8 positive edge clocks) to shift the data from the serial channel to the parallel outputs of the SIPO shift register.

 

Can you guys help me out here?

 

Please note that I need to have 8 clock pulses after each serial bit.

 

Im uploading my code here FYI.

 

thanks

 

LABMAT

0 Kudos
Message 4 of 8
(2,714 Views)

Hi LABMAT,

 

Am I correct in thinking that you would like to perform some kind of correlated DIO?  Look here for what correlated DIO is.

 

Do you want to output a bit on each clock pulse?

 

What do you mean when you say you I need to have 8 clock pulses after each serial bit?

 

Do you have a diagram of how you would like the clock and data bits to be related?  Is this what you would like to see?


Lewis Gear CLA
LabVIEW UAV

0 Kudos
Message 5 of 8
(2,696 Views)

Hi Lewis, Thanks for replying back to me.

 

You are right in the snese that I do need to do a correlated DIO. As you might know the operation of a shift register is that on each positive clock edge, the serial data is loaded into the shift register. Then when the LOAD is held high, the serial data is shifted to the parallel  output. Yes, so what you said is true. I want all the 3 lines to be synchronized. Im attaching a datasheet here FYI,

 

The diagram on page 6 is the main timing diagram.

 

All I want to do is

1. Generate Clock

2. On each positive clock edge, shift one bit of the data to the register.

3. After 8 bits are loaded into the shift register, apply 8 positive edged clocks to put the data to the parallel outputs.

4. Repeat this again but in this time, apply a different data (8 bits).

 

Im guessing that this is a TDM technique. So, I can go through all the pots by just changing the data.

 

Apologies for the previous post, I dont want 8 clock pulses after each bit. I only want 8 positive clock pulses after all the 8 bits are loaded into the register.

 

Look at pic FYI.

 

 

Hope this helps.

 

Thanks

LABMAT 

 

 

Download All
0 Kudos
Message 6 of 8
(2,690 Views)

Hi LABMAT,

 

I have written a little code that works on my NI PCI-6251 that performs the functionality you describe.  I built it based on these examples for you to take a look:

 

Boolean Array to Digital Waveform

NES Controller

Correlated Digital Write With Counter 

 Correlated Digital Output using Counter with additional Delayed Pulse

 

I would recommend reading these articles so you are able to understand the code I sent.




Lewis Gear CLA
LabVIEW UAV

0 Kudos
Message 7 of 8
(2,663 Views)

Hi Lewis,

 

thanks very much for your valuable input. I will look into this and then let you know how I didt it. I think I might have a different way to do that. Maybe that is more complicated than this is or vice versa.

 

But once again thanks very much for you input into this. Ill post my solution as soon as I implement it (along with other problems and questions LOL).

 

thank You,

 

Kind Regards,

 

LABMAT

0 Kudos
Message 8 of 8
(2,643 Views)