Controlling a digital PWM output with a PID control - Need ideas

Here is the scenario.
Am using LV 8.6 to run a test stand.  I special product needs to be tested at certain levels of [brushless] motor power consumption (watts).
The power consumption is manipulated by adjusting the PWM of the onboard controller using a pulsed logic signal. (using a counter/timer @ 20kHz tuning to between ~20 to 100% duty cycle)
I then read the current from the primary power supply and calculate the motor power consumption. Then feed this into a PID function and I use the ouput value to adjust the PWM input up or down.  I am running the output through some math to get an adjustment that isn't severe so it doesn't just reciprocate the level from high end to low end.
I am using the advanced PID function to try and tweak the control to be smooth and accurate.  It seems that even tiny changes in the PID values, specially the integral and derivative have a huge impact on the output.
Another option I have used before and am likely to have to use on this is to be able to select a different set of PID (and perhaps other) values dependent on the wattage range I am trying to achieve. This may go further and also be dependent on the driving voltage.  I am using this technique to select PID values for a third party pressure regulator (Tescom ER3000) and it works very well. Depending on the pressure range I need to achieve, I use different PID values to optimize the response.
Anyhow, I have attached the code and am just looking for any thoughts or ideas from anyone who has experience with the PID functions that might shorten my development time some.
I could upgrade to the latest version if there is a justifiable reason that would help me with this particular condition but as it would be a change on the test system, I would have to perform some level of re-validation and I don't want to spend time doing that if I don't have to.
 Thanks for any assistance
Doug
Doug
"My only wish is that I am capable of learning each and every day until my last breath."
Attachments:
Wattage Control Loop Trial.vi ‏20 KB

OK, I decided to regroup a little on this.  I started by reviewing the basic approach of the Ziegler-Nichols formulas and found a short tutorial that in layman terms, gave me a process for the tuning.  I did indeed start out with no integral or derivative values and adjusted the proportional value up and down until I got a smooth change with virtually no oscillation.
It seemed at this point, making adjustments to the Int. or Der. actually worsened my response. Even miniscule values in the range of .0001 - .0005 would have a detrimental effect.
I also went through and did an iteration modifying the input to a percentage and the output from a percentage and it really ended up doing about the same thing as entering the set point directly and using my little math sequence to manipulate the output.
Back to the root of things, by using just the Pro., I can get a relatively smooth, albeit slower than desired, transition to the desired set point.  This is as long as the motor [air pump] is under no loading.  As soon as I start to add load, I get significant oscillation at the beginning and it is much slower in finally leveling out.  Because I have to start and stop the pump as we3ll as open and close valves during the test sequence, there is a lot of load changing that occurs during the sequence and if my set point response for this variable is too slow, it affects the results of my other readings during the test (air flow, back pressure, etc.)
I have not tried the built in auto tuning sequence yet but my gut tells me this will not work since I am intentionally modifying my process and conditions throughout the test.
You mentioned that perhaps PID was not my best option.  I’m not sure what other options are available unless I create my own pseudo PID routine.  I could certainly do this but am not sure it would be as efficient as the built in PID functions.
Making slow progress but still accepting ideas…..
Thanks
Doug
Doug
"My only wish is that I am capable of learning each and every day until my last breath."

Similar Messages

  • Looking for sample code of pwm output with Labview 7

    we are looking for sample code in LabView 7 for producing a pwm output. We are current using a 3rd party digital I/O board and just want to generate a pwm output on several of the bits.

    Hi Ray,
    There are several ways to do this, and in the example I created, I actually did not end up using shift registers. I've attached some example code that basically multiplies the period by the duty cycle percentage to achieve the number of milliseconds to be high and low.
    You would just need to insert your DIO code in each frame of the sequence structure.
    Hope that helps. Kind regards,
    -Sam F, DAQ Marketing Manager
    Learn about measuring temperature
    Learn how to take voltage measurements
    Learn how to measure current
    Attachments:
    70_PWM_Example.vi ‏23 KB

  • More myRIO PWM outputs via FPGA

    I'm working on a project with the myRIO that requires 9 servo PWM signals. I know that the PWM Express VI operates on 8 different pins among the 3 connector ports on the myRIO. After spending a few hours researching FPGA, I was getting no where since a lot of it is beyond my skill level/understanding. 
    So my question is: what is the simplest way to create more PWM signals with controllable duty cycles on the myRIO FPGA? I wanted to have all the servos attached to pins on one connector for simplicity (e.g., all on MXP-A).
    My initial thought was to create more instances of the DIO/PWM mappings under MXP-A in the shipping personality. But then I had a vague feeling that this segment of the VI makes these pins compatible with the PWM Express VI and doesn't actually produce PWM signals. Is that what this does? Or is it possible to make copies of this and rename the registers PWM.A_3..., PWM.A_4...., PWM.A_5..., etc.?
    I looked at PWM Output With LabVIEW FPGA, but that didn't make any sense to me considering it has no documentation. I also found Developing a PWM Interface using LabVIEW FPGA, but I couldn't see a simple way to adapt it to my needs, while keeping the standard functions of the pins on the other connectors.
    Thanks.
    Bob

    Sorry for the delay Sam. I figured out how to add the PWM outputs via FPGA and it works. Then I tried to accomplish this while still retaining the functions of the other connectors. My method was to go into the FPGA personality and replace all of DIO-A's FPGA with my PWM code while keeping all of the FPGA code for the other connectors intact. The files are attached.
    My issue is: in RT Main, I also tried to run something from the MXP-B connector (PWM Express for example) in a parallel while loop while still running my custom PWM on MXP-A. This produced nothing. I read the PWM Express signal on B/AI0 and it was a flatline at zero. However, when I created a new VI that just uses PWM Express on MXP-B, it works fine.
    Is there a reason why the express VIs aren't working on the other connectors simultaneously?
    Thanks,
    Bob
    Attachments:
    myRIO-1900 Customized FPGA.vi ‏388 KB
    RT Main.vi ‏506 KB

  • How can I wire two PWM outputs of Accelerometer into PCI-MIO-16E boad with SC-2043-SG?

    I have been using counter/timer pin since the accelerometer (ADXL202AE, Analog Device) provides about 550Hz PWM signal. The purpose of the project is:
    - To acquire PWM signals with Full cycle(ms) and Posity duty cycle(ms) generated in Accelerometer.
    - To convert the cycles into acceleration value.
    By using counte/timer(GPCTR0_Source) and Trigger(Trig1) on SC-2043-SG board, the signal was obtained.
    However, after converting the PWM signal to acceleration value and plotting with labview on-line, the sampling rate was pretty low (26-28samples/sec).
    Then, I began to doubt that there is a wrong wire connection. Even though I am using one counter/timer pin, the sampling rate
    was low. The purpose of using the acceleration was to obtain two output using two counter/timer pins.
    Could anyone help me wire pins and solve the problem?
    GINO.

    Gino,
    You should definitely be getting many more values in your buffer. You should actually be getting 500,000 values every second because a measurement is being taken for every pulse. I found a couple knowledgebases that describe error -10920 and how to remedy it. One is pasted below and the other can be found through the link.
    But I'm not sure if you're going to be able to fix this problem because you're measuring pulses at a very high rate. What is happening is every time a pulse width measurement is taken it is put into an onboard (DAQ board) FIFO buffer that is 9 samples long. The computer then reads these samples out of the FIFO and into an a buffer that you can see in LabVIEW. I think the FIFO is filling up too fast and the computer is not able to read the data out fast enough. Therefore you are losing samples because they are being overwritten. This is all dependent on your system.
    Here are some benchmarks for pulse measurements:
    The following numbers were derived from a Gateway with 128 MB-RAM and an Athlon 700 for ONE counter of the PCI-6602. The number of counters you are using will affect these numbers.
    Finite Buffer
    Buff Period - 7.25 MHz
    Buff Pulse Width - 7.25 MHz
    Buff Semi-Period - 3.35 MHz
    Continuous Buffer
    Buff Period - 250 kHz
    Buff Pulse Width - 250 kHz
    Buff Semi-Period - 140 kHz
    You should still be getting many more samples than 26 though. Try using this example with a very slow frequency pulse to make sure it operates correctly. Then start speeding up the pulse and determine when you get error -10920.
    Here is an internal knowledgebase that may help you:
    Title:
    After Long Periods of Acquisition with AI and Counters, a -10920 Error Occurs
    Problem:
    A customer has a PCI-MIO-16E-4 and his application is acquiring analog input signals and performing event counting with the buffered event counting mode. The problem is that the buffered event counting is at some arbitrary amount of time (e.g., after 2 days) getting an error with the number -10920. The questions are:
    1. Why is he getting this error?
    2. Do you know how big the FIFO is for this buffered event counting?
    3. When he shares a DMA channel with the floppy controller, how can we make sure they use separate DMA channels?
    Solution :
    Here are the answers to the above questions:
    1. There is probably just some noise on the signal line coming in at some point. The STC is VERY sensitive, so if there is any fast glitching, it will attempt to transfer all of these. This can also happen if the signal does not ramp up fast enough, resulting in double-triggering in the middle region. Use a filter, or a Schmidt trigger*, to clean up the signals. Another suggestion is to use the PCI-6602 with filtering.
    2. There is no FIFO used for the counters. The mMite has its own FIFO, but it is only about 9 samples long.
    3. PCI does not "share" DMA channels. It may technically be the same DMA channel number, but this is just for reference. PCI cards use Bus Mastering. With Bus Mastering, the operating system gives up control of the PCI bus so that the hardware (in this case, our DAQ board) can handle its own data streaming, eliminating the extra step of having the OS monitor the transfers. The DMA channel numbers are just the "channels" that are supported by the mMite chip. You can have 3 PCI cards in the PC, each with DMA 1, 2, 3, and none of them will actually be sharing any resources.
    And another knowledgebase about error -10920
    http://digital.ni.com/public.nsf/websearch/8FB9091CB9BB452B8525642000554799?OpenDocument
    Hopefully this all helps,
    Erick D.
    NI Applications Engineer

  • Trouble with digital PWM using an M-series Daq

    Hello,
    I am trying to control 8 independent digitally pulse width modulated Thermoelectric Peltier couples using the 6221 daq. I have tried using the digital PWM for M-series daq example that is available, but can only get the first line to output a signal.  When different lines are selected using the drop down menu, they create no output signal.  What am I doing wrong? 
    Would this program (with some modifications) capable of running 8 different lines of signal?  All 8 signals will be run at the same frequency, with only the duty cycle needing to be independently changed, so I assume I will only need to use one counter? 
    I have struggled with the example program for several hours, and cannot figure out why only the first line will output a signal. It says it was posted only a few days ago so I wonder if there is something wrong with it.
    Any help will be GREATLY appreciated because I am at a standstill until I get this resolved 
    Thank You
    -Gabe 

    Hey,
    I found an example which you could use to build up on it. It works on 8 lines.
    Christian
    Attachments:
    pwmwithmseries[1].vi ‏61 KB

  • Digital Output With Timer (Simulation)

    Hello everyone, I just learned how to make LabVIEW program a week ago. I try to make a simulation of Digital Output by LabVIEW (my attachment). In this simulation I have a slider as an input (0-10 V), two numeric control (upper limit and bottom limit), a waveform chart that plot those 3 value, and two boolean LED (P0.0 and P0.1) as an indicator. In this simulation you can fill any number (between 0-10) in the numeric control as a limit for your slider input. If the input from a slider exceed those upper and bottom limit then the boolean LED will turn on, P0.0 if exceed upper limit and P0.1 if exceed bottom limit. The problem is I don't know how to make timer for those boolean LED. As example:
    1) Make an input from slider,
    2) If input (1) exceed the upper limit,P0.0 will turn on for 5 second,then turn of for 10 second,
    3) If in that 10 second you change the input back to normal (between upper and bottom limit) then P0.0 will stay turn of until the input from slider exceed the upper limit again,
    4)If in that 10 second you didn't change the input (stay exceed the upper limit) then P0.0 will repeat the process (2) until you the input from slider back to normal.
    (Same process for input that exceed the bottom limit).
    Can you help me to make this timer? Thank You (I'm sorry I made a double post):newbie
    Regards
    Juventom
    Attachments:
    Digital Output With Timer.vi ‏16 KB

    Hello Juventom,
    As I understand it you want to be continuously checking the value of the sliding bar and comparing that to the upper and lower limit controls whilest also chaning the LED booleans to true for 5 seconds then false for 10 seconds if the sliding bar value is outside of the limits.
    To do this you would probably be best using a parallel loop design, where you have 3 while loops in place of the one you have currently. Each one of these while loops would be responsible for a part of your program (e.g. the top one would display your values on the graph and the second one who check the sliding bar value against the upper limit and then turn on the LED, etc)
    I've found this tutorial about multiple loop programs and I think you should look at the section entitled "Parallel Execution"
    http://zone.ni.com/devzone/cda/tut/p/id/3749
    This way you can use normal delay VIs but when they run they only pause that loop rather than the whole program.
    Please let me know how you get on with this, and ask me if you need further help.
    James W
    Controls Systems Engineer
    STFC

  • DAQmx: Digital - Continuous Output.vi example with PCI-6519 (error -200077)

    Bonjour everyone,
    Main goal :
    I want to use 1 digital output of the PCI-6519 harware to make  a staked light indicator blink when user is needed to operate the test station. 
    What I am trying:
    I open the labview 2013 wxample "DAQmx: Digital - Continuous Output.vi" to learn how I could use a DAQmx task to perform this blink instead of using a dynamic call of a VI changing the output in 'while loop'.
    The example states that my hardware should be able to run it but I always get an error -200077 right at the beginning with the DAQmx Timing.vi mentionning that my PORT2, line 0 does not support the 'Sample Clock' property which is hard coded in the example. I can't find a different property that this example will accept to try to change the status of my digital output on a time basis.  Does the PCI-6519 device support timing for a digital output or not?
    If anyone has a better or simplier idea to achieve such a simple goal, feel free to suggest.  I am using DAQmx for the first time and I don't know much about what my options are.
    Thanks 

    Hi Nienscecco,
    Unfortunately PCI-6519 doesn't support HW timing, I've just tried with a simulate PCI-6519 device and I confirm you that you must specify an external clock in order to use this example.
    Do you have some kind of frequency generator to provide it ? Or maybe another NI board with embedded counters in order to build it ?
    Thanks in advance for your answers.
    Mathieu_T
    Certified LabVIEW Developer
    Certified TestStand Developer
    National Instruments France
    #adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
    LabVIEW Tour
    Journées Techniques dans 10 villes en France, du 4 au 20 novembre 2014

  • How to address digital input & output, analogue input & output when communicate with mitsubishi fx1n plc

    dear all,
    i am new to labview, how to code or address digital input & output, analogue input & output when communicate with mitsubishi fx1n plc or crouzet plc.
    pls help.
    HM

    http://search.mywebsearch.com/mywebsearch/redirect.jhtml?searchfor=mitsubishi+fx1n&cb=ZO&p2=%5EZO%5E...
    Try the above link. I know it is a screen-full, but is a search result for Matrikon. They have a whole slew of OPC servers/clients you can try out. Personally, I would go with their OPC server for the Mitsubishi, and use Labview Datasockets. That would be the simplest with the lowest learning curve.
    Otherwise, if you wish to use Modbus, you would have to get the commands/syntax from Mitsubishi; might be in their user manual, but I wouldn't lay bets on it. With the Matrikon stuff, the syntax is all built in.
    Good luck which ever way you decide to go.
    Dave

  • DC motor control via ctr1/ctr0 pwm output stops outputting after one loop through.

    Working on this project to control an H-bridge controlled
    motor using pwm output from ctr0/ctr1 for ccw and cw on the motor. A sensor detects where it is at and each cycle goes from black to white. For some reason, the motor only turns on once and then nothing comes out of the ctr outputs after that. Anytime the program is stopped and restarted it works for one cycle. Or if just the program is run at the skipcolor sub-vi. this can be run multiple time to control it properly. During the actual run it doesn't work. Any implementation device would be great. I am using the PCI-MIO-16E controller.
    Programs attached for reference.
    Attachments:
    SkipColor1.vi ‏111 KB
    MotorControl2.vi ‏99 KB
    PROJECT 2a2.vi ‏18 KB

    Hey suspencefull,
    You are probably going to have to think about re-designing your code. Your pulse train is not continually generating because you do not have it in a loop. When you use the DAQ Assistant to create a continuous pulse train, LabVIEW will prompt you if you want it to automatically add the loop. You must have deleted it or chosen not to add the loop.
    There will, however, be problems though when you add the loop back in. The SkipColor sub VI will not finishing executing until the loop is finished and therefore you will never move out of the first frame of your sequence. I would suggest redesigning your code so that these thing can occur in parallel.
    Please let me know if you have further questions.
    Regards,
    Chris Delvizis
    National Instruments

  • Is it possible to use part of Port0 on a 6363 as line controlled and part as digital wave output?

    I've filled the DIO on Port1 and Port2 of a PCIe and need to use port0 for both line controlled (toggle) and digital waveform output.  I'm using Measurement Studio 14 and C#.  I can make the call:
    NITask.DOChannels.CreateChannel("MyMIO/port0/line8​:11", "myTask",ChannelLineGrouping.OneChannelForAllLines​);
    and run the waveform without issue.  The problem is that the unselected lines are cleared.
    I can kludge around the problem by maintaining the state of all lines on Port0 and accounting for them in the waveform.  That is kind of a pain, adds code, and I'm lazy.  Is there a way to isolate the wave to only the lines selected when creating the task?
    Thanks,
    Derek Hopkins,
    Pacific Northwest National Laboratory

    Hello Derek,
    Could you explain the impact of having the unused lines cleared in your program? I'm not sure I understand the impact that behavior is having on the system.
    Siana A.
    Application Engineering
    National Instruments

  • Motion Assistant and PXI-7354 PWM output

    Hello,
    I have a PXI-7354 Motion Controller in a PXI-1033 rack and I'm trying to prototype a product which has a digital motor controller IC, A3906 by Allegro. The IC is controlled with PWM signals by varying the duty cycle. Now, in the NI 7350 User Manual on page 5-17, it says that "These signals (PWM) are configured in software and are in no way associated with the PID servo control loop." My question is, can I programmatically associate the output of the control loop with a PWM output duty cycle?
    I'm new to Motion Assistant and PXI motion controllers and I appreciate any input.
    Regards,
    Miika Lönnqvist
    Electronics designer, CLAD
    Biohit Oyj R&D

    Miika,
    thank you for the information, but there is no way for the 7354 to drive control signals directly in this fashion. So here are some alternative approaches that could help:
    The 7354 outputs a +/- 10 V control signal. You could build your own circuitry to adapt this signal to the control input requirements of your drive (two voltage to PWM converters; one driven by positive voltage values, the other one driven by negative voltage values).
    Replace the 7354 with an R-Series board. The FPGA on these devices can be programmed graphically with LabVIEW FPGA and it provides both, real-time control and complete flexibility in terms of I/O mapping and control algorithms. Motion control with special requirements is a typcial usecase for these devices.
    You can select from a variety of R-Series boards with different FPGA sizes and I/O setups. If you don't need any analog inputs or outputs, the reasonable lowest cost entry point for your application is probably a PXI-7811R
    Both approaches add some complexity to your current setup. While the first approach is hardware centric, the second approach adds some complexity on the software side. My personal preference is option two, as this provides the highest level of flexibility, which is typically very desirable for a prototyping system.
    In any case I recommend to contact your local NI contact for a more detailed consulting.
    Kind regards,
    Jochen

  • Digital sound output only after using Headphones

    i used my MacbookPro 17 2.66
    with headphones to listen to music and after i removed headphones there is a red light in the headphone port and only digital sound output option in system preferences control panel
    If i reinsert headphones, headphone output reappears
    Where are my internal speaker option gone
    i have a time machine backup
    Can i just replace sound preferences
    Thanks

    Generally that means your headphones' plug is not exactly to dimensional stands and has jammed the internal connector in the jack to the "mute" position. The plug's tip-to-shoulder distance seems to be the variable.
    I've found with my MBP that, with non-standard plugs, inserting them only until they function--not until the "stop shoulder" hits the MBP case--prevents this. I have an old and cheap set of external speakers whose plug works perfectly. A patch cable I use to connect to my desktop sound system has a non-standard plug, and I have to leave the plug slightly out of the jack to prevent the problem you see. Again, insert until you hear proper sound to the device, not by feel. I've no problems with the plugs falling out using this technique.
    The "official" fix is a new logic board but most people are able to free the internal contact by inserting a plus into the jack and gently wiggling it in the horizontal plane. One person recently said he freed his with a wooden toothpick.
    If you use anything other than a standard plug to manipulate the jack, be certain it's non-conductive. BTW, if you use the "Search Discussion" option in the upper right of this page and search for "red light" (use the quotes) you will see a number of threads here on the subject.

  • Example: "Digital - Conitinuous Output" How does it work?

    I have to generate a sequence on three channels (with my NI 9375 Digital Output card on a cDAQ9188).
    In 1 second, the sequence consists of, for example:
    channel 1: starting low .. on 15 ms high .. on 865 ms low again
    channel 2: starting high .. on 115 ms low .. on 650 ms high again
    channel 3: starting low .. on 85 ms high .. on 920 ms low again
    This have to be conituously generated and hardware timed.
    For this application, they advised me to work with the example "Digital - Continuous Output". Can anyone explain to me how I get this sequence with the "Data To Write" Controls-box on the Front Panel? And how can I visualise my generated sequence?
    Thanks in advance!
    Solved!
    Go to Solution.

    Hello Hannes,
    There are 2 major things that you have to keep in mind in this case regarding the example you're using:
    - The sample rate you're going to use has to be high enough.
    In your case the minimum sample rate has to be 200 Hz (seeing that your smallest step is 5 ms).
    Of course you could also use any multiple of this.
    - At the other side you have to check how the array of unsigned integers in the Data to Write is related to your digital outputs.
    Depending on which Digital Outputs you're using one of the bits in your unsigned integer will correspond to one of your Digital Ouputs.
    This mentioned the "difficult" part starts:
    Seeing the period is 1 second and if you have selected 200 Hz (5 ms period sampleclock) as the sample rate, then:
    - For channel 1:
    the first 3 bits should be 0, the next 170 [= (865-15)/5] should be 1, the remaining 27 (200-173) bits should be 0.
    - For channel 2:
    the first 23 bits should be 1, the next 107 [= (650-115)/5] should be 0, the remaining 70 (200-130) bits should be 1.
    - For channel 3:
    the first 17 bits should be 0, the next 167 [= (920-85)/5] should be 1, the remaining 16 (200-184) bits should be 0.
    To represent this visually the best thing you can do is to use 3 arrays of 200 booleans for the 3 channels.
    These arrays can be easily shown in a Digital graph
    You then have to make a very simple conversion algorythm to convert these 3 arrays of 200 bits/booleans to 1 array of 200 unsigned integers.
    Is my explanation a bit clear to you?
    Note: Here we took 1 as high and 0 as low.
    Kind Regards,
    Thierry C - Applications Engineering Specialist Northern European Region - National Instruments
    CLD, CTA
    If someone helped you, let them know. Mark as solved and/or give a kudo.

  • Strange output of the PID module

    Dear all, 
    I meet a problem when using the PID module. I am only set P and use the PID as a linear gain. I found in some of my VIs , the output of the PID module is the opposite value, while in other VIs, the output is normal. In these case, I used to set the linearity of the PID as -1. Even though the VI can run normally in this way, I want to figure out what shall be the wrong about the PID module. Could you help me explain about the strange behavior about the PID module?
    Please see the attached file, I add some probes like 24 and 25 to show the values that represent this problem.
    Thanks
    best
    Attachments:
    PID module opposite output.png ‏193 KB

    Your set point is set to zero, your process variable appears to be 8.181 i.e. too high and error (SP-PV) is negative, so the output of your controller should be negative (-8.181 x Kp). The controller output is clamped to be between 0.5 and -0.5, and it is -0.5V, which is what you would expect if your Kp is the 0.1 one (I can't see which set of gains it is).
    So it appears to be correct ?
    Note: linearity should be between 0 and 1 (read the manual). Keep this set to 1 until you know things are working and only change if you need nonlinearity with error.
    Consultant Control Engineer
    www-isc-ltd.com

  • Continuous in- and output with PCI-6229

    Hi All,
    I'm currently evaluating a PCI-6229 card on RTX (and maybe InTime later on). The main goal of the evaluation is to prove we can get hard real-time, deterministic behaviour from this system in order to use it to replace our current DSP-based solution.
    To do so, I'm setting up a rather simple program that should
    - continuously acquire 1 channel @ 20kHz
    - have a processing loop of 5mSec, ie 100 samples; this loop should be entered every 5mSec as exactly as possible
    - do some simple processing in the loop (thresholding the signal)
    - bring out the result on an analog output (low signal if signal is under threshold, high signal for all samples above the threshold)
    I could get the basics working pretty quickly: continuous input, continous output, continuous input with dma, input using interrupts.
    Trying to combine everything isn't really working out however.. Normally I'd try and try until knowing the device inside-out but now I have a rather strict timeframe so hopefully someone here can provide some insight.
    Questions:
    1. For the input, I can get an SC_TC interrupt each time one frame is scanned. I measured this on a scope by toggling a digital output on the card, and there's no noticable jitter on the squarewave which is a good sign.
    However I'd like to combine this with DMA, but the DMA is lagging a bit on the interrupt so I end up having to poll the DMA after all in the ISR, so there's no use using the interrupt in the first place.
    Is there a way to set up continuous DMA servicing and get an interrupt from the DMA system itself after 100 samples are transferred?
    2. For the output, I cannot get continuous mode working with DMA, only by writing to the FIFO manually. I can preload a couple of frames with the dma, but after calling aoStart(), tDMAChannel::write() works once, but all calls afterwards return kBufferUnderflow. Any ideas?
    I probably have to check when exactly to write to the DMA, but I have no idea which of the many status functions to use. Tried with AO_Status_1.readAO_FIFO_Half_Full_St() but that's not it. tried to write it on each UC_TC interrupt but that didn't work either.
    3. DMA is, to my understanding, a more performant way of getting samples into the host and doesn't require to call AI_FIFO_Data.readRegister() in a loop and vice-versa for the output side. But are there really benefits in using DMA?
    4. I made a basic program to bring everything together the simplest way possible: preload 100 samples in the output FIFO, start analog input, start analog output, have the ISR copy all values directly from input to output FIFO.
    Putting both analog signals on a scope, I expected to see the input and about (see question5) 5mSec later the same signal on the output, with no jitter.
    However what I see is the output is just floating around, in other words there is no fixed delay between output and input! How is this possible? I use the same divisor for in-and output. Is there any sample code available that achieves what I want?
    5. Is there a way to start both input and output at the exact same time, eg at the same edge of a certain clock pulse? How are input and output synchronized? Can I be sure they never go out of sync?
    Solved!
    Go to Solution.

    update: looking at the DAQmx control samples, it seems some of them set the start trigger for the AO to the AI start trigger. I mimicked this using kAO_START1_SelectAI_START_1 with the aoTrigger method, and the sync seems better now: the output starts exactly 10mSec after the input (or 5, if I preload only one frame) and stays in sync for about 25mSec. That it goes wrong.
    At the moment I'm using no DMA, just one simple interrupt routine that basically does
    board->Interrupt_A_Ack.writeAI_SC_TC_Interrupt_Ack( 1 );
    board->Interrupt_A_Ack.flush();
    toggle ^= 1;
    board->Static_Digital_Output.writeRegister( toggle ? 0x00 : 0xff );
    for( u32 i = 0 ; i < numSamples ; ++i )
      const u32 val = board->AI_FIFO_Data.readRegister();
      board->AO_FIFO_Data.writeRegister( val );
    In the screenshot in the attachment you can see this goes wrong: cursor A shows the position of the input signal (=AI 0, yellow) that should be shown 10mSec later at the output (blue line=AO). Cursor B shows this 10mSec later position, and you can see there's some garbage right after the cursor. This is the data that was written to the AO FIFO in the fifth interrupt (interrupt position show in purple).
    Trying to figure out where that comes from, I put board->AI_Status_1.readAI_FIFO_Empty_St() in the interrupt loop. And effectively, when trying to read the 500th sample, it reports that the FIFO is empty. Consequently the data written to the AO FIFO does not make sense anymore. But I do not understand how can this ever happen? The SC_TC interrupt is fired whenever 100 samples are read from the input. So after this interrupt occurs, the FIFO should always contain at least 100 samples, no?
    Attachments:
    tek00000.png ‏22 KB

Maybe you are looking for

  • Apache and mod_plsql

    Hi all, I just installed 10.0.2 and was surprised to find that there isn't an Apache directory in my Oracle home? Is this normal, and if so, is mod_plsql still available to run plsql web applications? I looked over the documentation which showed a si

  • Error configuration forms 11.1.1 : Creating WEbLogic domain fails

    I am trying installing Oracle Forms and Reports on Windows XP pro with an Oracle 10G database but cannot get it done. This is what I did: - Installed WebLogic Server 11 gR1 (from wls1033_oepe111150_win32.exe) - Installed Oracle Fusion Middelware (wit

  • Swap image from down state

    How do I return the down state of an image to the up state onClick? I tried Swap Image Restore, that doesn't work. I want a button that contains two states, an up and a down state. When you click on the image in the up state, it goes to the down stat

  • Error in  PO release strategy

    Hi everyone,    I am facing an error in PO release strategy ie;  '  purchasing document (pdocno)  not subject to release strategey'. pls help me in solving this. Thanks, Archana.

  • Online demo server for practicing XI

    hi is there any online or demo system for practicing xi. regards mano