Discussion:
Efficient way to do multiple dynamic read/write with 6541
(too old to reply)
gv2000
2008-07-17 21:40:13 UTC
Permalink
Hi,I have a device that has a single data/address bus and 80 registers. I am developing software to configure/use it using a NI-6541. The software is working, but it is very slow when I read the values of the registers (~30s to read all registers).To read a register value I do the following:1. Write the address of the register that I want (using niHSDIO_InitGenerationSession, niHSDIO_AssignDynamicChannels,...,niHSDIO_WriteNamedWaveformU32, niHSDIO_CommitDynamic, niHSDIO_Initiate). Data bus is writing.2. Start another generation session with appropriate control signals to read, and an acquisition session to read the register value. For this step I am following the DynamicAcqAndGen-SourceSynchronous example that comes with the NI software, which calls the same functions of step 1 for the generation, and calls niHSDIO_InitAcquisitionSession, niHSDIO_AssignDynamicChannels, niHSDIO_ConfigureAcquisitionSize, niHSDIO_Initiate, niHSDIO_FetchWaveformU32). Data bus is reading.3. Repeat steps 1 & 2 80 times.Is there a better/faster/more efficient way to read the registers of our device using the NI-6541?Thanks in advance for your help,GVMessage Edited by gv2000 on 07-17-2008 04:17 PM
Steve_B
2008-07-21 02:10:07 UTC
Permalink
Hi GV,
You may want to take a look at combining your generation into one task and setting up a scripted generation and triggered acquisition. There are script triggers that you can generate from software or from a physical line to progress through a script. There a some examples of scripted generation in the Example Finder. You may want to put some timing into your program to determine which areas are taking to most amount of time. Communicating to each of the registers may be taking up a large portion of the time and the only way to speed that up is to communicate over multiple lines.
gv2000
2008-07-21 23:10:05 UTC
Permalink
Hi Steve, Thanks for your reply. I thought about the option of using a script. The problem is that I have not found a way to make the data bus lines tri-state after writing the register address so that I can then read the register data (the device that I am "talking" to has a share data/address bus). This is also why I have two generation sessions. In the first one, data lines (ch 0-12) are being driven with the address of the register (generation channel list is "0-15", 13-15 are control lines). In the second generation session, ch 0-12 become the acquisition channels, and the rest are generation channels.Is there a way, from a script, to have some lines tri-stated for a certain number of cycles, or certain amount of time? I know that if the generation is paused, the channels will go to their idle state, but it appears that I need an external hardware trigger for that. Is there a way to do this from software? If so, how do I synchronize the software with the script.Thanks for your help,GV
Steve_B
2008-07-22 23:10:22 UTC
Permalink
Hi GV,
You are correct with tristating your device, it would be necessary for your application but the 6541 does not support per cycle tristating. Have you tried implementing some timing into your program to determine what areas are taking a long period of time?
gv2000
2008-08-01 21:10:09 UTC
Permalink
Hi Steve, Although I did not measure execution time within the program, it appears that the functions to initialize the acquisition (niHSDIO_InitAcquisitionSession) and generation (niHSDIO_InitGenerationSession) sessions are the ones that are taking a long time to complete. I recoded the application so that it calls those functions only once, and then in a loop goes through the calls to generate (niHSDIO_AssignDynamicChannels,...,niHSDIO_WriteNamedWaveformU32, niHSDIO_CommitDynamic, niHSDIO_ConfigureWaveformToGenerate, niHSDIO_Initiate) and acquire (niHSDIO_InitAcquisitionSession,
niHSDIO_AssignDynamicChannels, niHSDIO_ConfigureAcquisitionSize,
niHSDIO_Initiate, niHSDIO_FetchWaveformU32) data, and the execution time went from ~30s to ~3s.Thanks for your help,GV
JuanCarlos
2008-08-01 21:40:10 UTC
Permalink
GV, Here are a couple of suggestions that can help you optimize your code.
1.- Consider static I/O for this application: static IO allows you to change the state of your digital lines based on a software command, including tristate. If I understand correctly you could do a static write to set the address, another couple of writes to request the read, another call to tristate and another one to read the response. This may look pedestrian, but if you need only a few writes, followed by a tristate and a read you should get better performance that reconfiguring a dynamic generation. There are some shipping examples on static IO.
2.- Consider the Initial/Idle states: you are right, after a generation the board goes to the Idle state, you can configure the idle state to be tristate on the data lines. Now the problem here is with the control lines, you could again use static IO while you board is in an idle state to request the read. Using scripts and script triggers (even software script triggers) you can control when the board goes to idle or moves on with the generation.
3.- Consider a 6551: if you happen to have a 6551 around, you could add tristate to your data set directly, the 6551 allows you to tristate/enable any channel for any amount of samples. Sorry for the long response, but I hope it helps. Regards, Juan CarlosMessage Edited by JuanCarlos on 08-01-2008 04:14 PM
Continue reading on narkive:
Loading...