10-25-2007 05:00 PM
Ravens Fan,
I tried per your sugestion with line 0:7 and it gives me another error:
Error -200463 occurred at DAQmx Write (Digital Wfm 1Chan NSamp).vi
Possible reason(s):
Measurements: Specified read or write operation failed, because the number of lines in the data for a channel does not match the number of lines in the channel.
If you are using the Digital Waveform datatype, make sure the number of lines in the digital waveform matches the number of lines in the channel. If you are using boolean data, make sure the array dimension for lines in the data matches the number of lines in the channel.
Number of Lines in Channel: 8
Number of Lines in Data: 16
Task Name: _unnamedTask<59D>
I think the reason is because I am using Dev2/Port0_16 which means P0 and P1, a total of 16 lines. . .
I got this far and is working fine, I only need an example from Jaced as to how to call these port's lines one at the time so that I can send a 100us pulse at port0 line 0; then another pulse to P0 line 1, P0 line 2, and all the way to P1 line 8 (per previous attached vi). The time in between pulses is not critical as a software delay (~100ms) will be fine. Right now I can do this by manually selecting the proper bolean array position and then running this vi. The question is how to do it programmatically? Jaced has suggested a viable approach but I don't quite understand how to do it per his instructions. Hopefully he will post a modification to my last attached vi. Thanks,
Frank
10-25-2007 06:41 PM - edited 10-25-2007 06:41 PM
I meant the control input would be Dev2/Port0/line0:7,Dev2/Port1/line0:7. That should be 16 lines. But I don't have a way to verify if that syntax would work. If Dev2/Port0_16 (or would it be 0-15?) works that's great. Like I said before, it gets really confusing as to the different ways these lines can be addressed.
@Fvalenzu wrote:
The time in between pulses is not critical as a software delay (~100ms) will be fine. Right now I can do this by manually selecting the proper boolean array position and then running this vi. The question is how to do it programmatically?
As I understand, you want a 100 microsecond pulse on line 0, wait 100 msec. Then a 100 microsecond pulse on line 1, wait 100 msec, 100 microsecond on 2, etc through your 16 lines. The boolean array creates your waveform for each line. Column 0 is for line 0, column 1 is for line 1, .... Each row represents a given instant in time. So if the waveform is set up with a 100 microsecond dt, then row 0 would be the first 100 usec, row 1 would be the next.
I am going to assume that we are working with 1 100 msec period with each data point being 0.1 msec (100 usec). with a pulse on a given channel for 1 sample, then turned off for the next 999 (the math is easiest as opposed to a 1000 sample off time.) Then repeat for the next channel. So what you need to do is build a boolean array with 16 columns, and 16000 rows full of falses, then replace given elements with a true according to that pattern. You do that once at the beginning of the program and feed the results into the boolean/digital waveform conversion and ultimately into the write VI. The earliest LV version I have at home is LV8.2 so I will attach that. But it is simple code so I will attach a screenshot.
Now it is possible I got the rows vs. columns mixed up in this array as to what relates to channels vs. samples. So if that is the case, a transpose array, or just reworking the code to swap column vs. row inputs should work. Don't forget to set the sample rate and/or dt so that a single value represents 100 microseconds.
Edit: That constant of 100 in the loop should actually be 1000 and the 1600 outside of the loop should be 16000! I wrote the code before I reread the message and saw the 0.1 ms to 100 msec ration which is 1:1000 rather than 1:100. Hopefully this will give you the idea.
Message Edited by Ravens Fan on 10-25-2007 07:46 PM
10-26-2007 01:09 PM
10-26-2007 01:16 PM
Jaced,
Ravens Fan and I still having issues to try to make this code work. Could you please give us a hand? Thanks,
Frank
10-26-2007 01:44 PM
10-26-2007 01:54 PM - edited 10-26-2007 01:54 PM
Message Edited by Ravens Fan on 10-26-2007 02:58 PM
Message Edited by Ravens Fan on 10-26-2007 03:01 PM
10-26-2007 03:40 PM
10-26-2007 03:54 PM
I'm glad to hear progress is being made. Can you post this latest VI? Of course make sure any controls or indicators have their latest values saved by doing a "Make current values default" from the Edit menu before saving.
One thing that has worried me that even if the code runs without errors, that the real hardware may behave different from the way I think it would. Does the bit pattern that gets turned into a digital waveform ultimately trigger the digital lines like I would think? I know that you can write to ports by using writing U8 values. So writing a 255 would turn on all lines. Writing a 128 would turn on lines 0 and 7. Stuff like that.
But before we get into anything like that which would be a different programming path, please post what you have now.
10-26-2007 04:11 PM
Ravens Fan,
Here is the latest vi, sa,e as yours: Frank
10-26-2007 04:49 PM - edited 10-26-2007 04:49 PM
Now I'm really getting stumped. I noticed you added a constant of one channel for all lines that wasn't there before. But I saw this is the default for that VI, so I don't think this is any real difference. I tried changing that to one channel for each line, but am really struggling getting the right combination of waveforms, arrays, 1-D vs. 2-D to get it to wire correctly, or if it does wire, then it throws an error saying the task is 16 channels but the data is only one. I give up!
I did come across 1 way to make that setting work, see the attached picture. (For argument's sake, I made the data 160 samples at the front, and a constant of 1 in the loop just to make it easier to see the display on the front panel arrays. Switch it back to 16000 and 1000 for your final code.) Maybe having it go in as individual waveforms will make it behave the way you want.
If this doesn't work, perhaps Jaced is following and can provide any insight to your latest code.
Note: It is Array Subset in that new For loop, the i is wired to the 3rd terminal and the constant 1 is wired to the last. And for the purists out there, I am sure this can be combined with the first for loop, but for incremental programming attempts (building on something that works without changing too much) this is what you get.
Message Edited by Ravens Fan on 10-26-2007 05:53 PM