Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Programming 6534 in Borland C++builder

Hi all

I am very new to both Borland C++ builder and the NI PCI 6534 I/O board. What i basically need to do is send three signal as outputs which are shown in the pic below.


The code is meant to send a pulse at active low for a short period, and once that is pressed, the other two pulses are sent as seen in the picture.
I have viewed the example code and constructed some code to how i think it should be, yet was wondering if this is the way to write it, the code can be seen below, if anyone has any hints or help, it would be greatly appreciated.

Thankyou in advanced

simon

Download All
0 Kudos
Message 1 of 10
(4,984 Views)
Hi Simon,

In your post you said that you want to have some sort of sync pulse that will then trigger a continuous pulse train that looks like you showed in the image on two of the lines.  It sounds like what you are trying to do would best be accomplished by a counter/timer board (Counter/Timers).  Those boards would allow you to easily do a single pulse generation on one line and then on two of the other lines allow you to set the initial delay that you need and then make those pulse trains with the specified pulse characteristics.  This would be pretty easy to program and sounds like the best case for your conditions.

However, since you stated that you are working with the 6534, then I understand that you may be limited to that hardware.  If that's the case, then you will need to write the data, but be fairly careful about how it's done.  One thing to keep in mind is that by default, the board will regenerate the data that you send it; however, since you need the different pulse specs at the beginning you will have to use the following command:

int32 __CFUNC DAQmxGetWriteRegenMode(TaskHandle taskHandle, int32 *data);

where int32 =
DAQmx_Val_DoNotAllowRegen 10158 Do not allow NI-DAQmx to regenerate samples the device previously generated. When you choose this value, NI-DAQmx waits for you to write more samples to the buffer or until the timeout expires.

Your code will then have to look something like this:
  1. Create the Channel
  2. Set to Non-Regeneration Mode
  3. Set the Sample Clock to Continuous mode
  4. Write the first chunk of data where there are the initial conditions for your pulses. (You will have to create this array.)
  5. Then begin a loop
    1. Inside this loop you will need to keep writing the data for your pulse trains.
  6. Have a way to stop the loop
  7. Clear the task.
You will have to make the data that you want to write and have it as a 2D Array with one row of the array for each channel.

While the above method should work, I would still recommend the Counter/Timer board as it will make your life much simpler because it is designed specifically for the type of pulse train generation that you are attempting to do.

Regards,
Message 2 of 10
(4,968 Views)
Hi Otis

Thanks heaps for that, I'll give that a try and i will get back to you. I have just started working on the project and they had already brought the 6534 board, so I'm a bit limited but I'll make it work.

Thanks again

Simon

0 Kudos
Message 3 of 10
(4,959 Views)
Hi Otis,

I have began to write the code as you explained yet I am having a couple of errors. Ive included my new source code, where I want the sync button to perform that sync active low pulse, and then I have a trig button which I want to perform the rest of the  pulse trains at a specified pulse  repretition interval. I'm still a bit confussed about the layout of the code for the two things I want to do and I was wondering if you could provide me with some more help. That would be greatly appreciated, I have included the code below.

Thankyou in advanced for helping.

Simon

0 Kudos
Message 4 of 10
(4,955 Views)
Sorry bout the annoying posts, however i have just found a copy of the function library and thats going to help out a lot so dont worry about replying to the previous posts. I'll give it a bit more of a try and get back to you. Thanks again
Simon

0 Kudos
Message 5 of 10
(4,950 Views)
Hi Otis

I have contructed the code to write the sync pulse and the trig and tx pulse yet it is not working corectly. If i have the following data to transmit with a row for each line:-
      uInt8       data1[2][8]= {1,1,1,0,0,0,0,0,
                                          0,0,0,1,1,1,1,1};
      DAQmxErrChk (DAQmxCreateDOChan(taskHandle1,"Dev1/port0/line1:2","",DAQmx_Val_ChanForAllLines));

How do i write this data to the two digital output lines, i tried:-

      DAQmxErrChk (DAQmxWriteDigitalLines(taskHandle1,1,1,10.0,DAQmx_Val_GroupByChannel,data1[2],NULL,NULL));

but that doesn't work, if you could help that would be great.

Thankyou

Simon

0 Kudos
Message 6 of 10
(4,921 Views)
Hi Simon,

From what you sent in you email, it looks like you may be writing the wrong data.

I took a look at one of our shipping examples (C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Digital\Generate Values\Cont Write Dig Port-Ext Clk) and as you can see in there the data is written like this:

uInt32      data[8]={1,2,4,8,16,32,64,128};

As you can tell, that means that the data is written as an unsigned integer and the data is written as a port value (since a port is 8-bits, all high would be 255).  In your case you want to have 3 lines of data, so you will need to write an array of data that corresponds with the proper value.  (See image below)


After you write the initial value you will have to keep writing the data over and over again because you turned on the non-regeneration of the data.

Try doing it this way and you should have better results.  It might be a good idea to try running the example first though, just to make sure that you are setting everything up properly.

Regards,

Message Edited by Otis [DE] on 12-19-2005 03:37 PM

Message Edited by Otis [DE] on 12-19-2005 03:38 PM

Message 7 of 10
(4,914 Views)
Hi,

Thankyou heaps for that help late last year that helped me a great deal. I have writen the program with other parts added also, with it working correctlly the only thing in which i need to do is now to get the data for the tx pulse and the trig pulse into the onboad memory and repeated the transmision of the data out the output. I have tried a few ways yet cannot seem to acheive the data to be continuouslly sent. I have included the code and when button two is clicked the pulses should be continuouslly sent untill the exit button (button three) is clicked.

If you have any ideas that would be great, Thankyou again,

Simon


0 Kudos
Message 8 of 10
(4,827 Views)

Hi Otis,

I have again updated my code as seen below yet need to use pattern generation with onboard looping, this is for the data in the button two click (It has a coment above the two lines that are writing the data). I need to continuouslly send this out, but cant figure out how to enable the onboard looping feature or completelly configure the port for the continuous looping.

If you could help that would be great.

Thankyou heaps

Simon

0 Kudos
Message 9 of 10
(4,762 Views)

Hi Simon,

As stated in an earlier post, if you want this type of behavior then you would be best suited to using a counter/timer board.  However, since you need to use digital lines, you will have to use the Non-Regeneration property in order to not keep repeating the Sync pulse in your output operation.  That means that you cannot begin outputting the pulse with the onboard information, so you will have to keep writing new data to your output.

If you decided to just use onboard regeneration, then you can either not include the DAQmxGetWriteRegenMode(TaskHandle taskHandle, int32 *data); line of code, or set the data to DAQmx_Val_AllowRegen.

Regards,

0 Kudos
Message 10 of 10
(4,749 Views)