Usint thread to control PWM loop

Hi am new to Java and am struggling with a probelm.
The application is to control 4 motors connected to the parallel port. When the user presses a button the motor is set to a certain speed (byte output to port). Once the button is released the port outputs to stop the motors, i also have it working so multiple motors can be driven at the same time (multiple buttons held down) i have the code working ok, but at present the program just outputs a byte of data when its worked out what buttons are pressed/released.
The problem is i want to drive one of the motors using a crude form of PWM (output an 'on' byte, wait 1 second, output an 'off' byte, wait one second, ect)
This is clearly going to have to be performed in a loop that is basically an infinite loop untill the key is released. However the program also need to be listening for other key inputs to turn on other motors.
I think the best way to do it is to create a thread for the PWM that sleeps, allowing the program to do other things, and breaks out when it recieves an interrupt (triggered by another key press), however i am have major difficultly converting the code. at present the code looks like this:
private void DebugKeyReleased(java.awt.event.KeyEvent evt) {
int c;
c = evt.getKeyCode();
switch (c)
case 83: Control(100);
break;
case 68: Control(80);
break;
case 65: Control(40);
break;
case 87: Control(20);
break;
private void DebugKeyPressed(java.awt.event.KeyEvent evt) {
int c;
c = evt.getKeyCode();
switch (c)
case 83: Control(1);
break;
case 68: Control(8);
break;
case 65: Control(4);
break;
case 87: Control(2);
break;
private void Control(int direction){
switch (direction)
case 1: forwards = 1;
break;
case 100: forwards = 0;
break;
case 2: backwards = 1;
break;
case 20: backwards = 0;
break;
case 4: right = 1;
break;
case 40: right = 0;
break;
case 8: left = 1;
break;
case 80: left = 0;
break;
global_direction = forwards*1+(backwards*2)+(left*8)+(right*4);
if(global_direction == 0)
moving = "Stopped";
short stop = 255;
lpt.output(Addr,stop);
else if(global_direction == 1)
moving = "Backwards";
short Back = 239;
lpt.output(Addr,Back);
ECT, there are alot more if statements that account for all possibilities.
i want the backwards and forwards cases to enter loops that output data on and off for certain time periods.
can anybody suggest the best way to convert the code?
thanks for any info / help
cheers John

A finite state machine is an abstraction in which you have a finite collection of states, and a set of transitions between states. One state is active at a time. So a traffic light might have red, green, and yellow states, and transitions between green to yellow, yellow to red, and red to green. There can be multiple transitions out of a single state.
So for your app, each state might be a kind of signal or a kind of sequences of signals set to the motors, and the transitions would be taken when you need to change the signals. You could send the key events and time events to whatever state currently is active. That active state would then decide what transition to take based on the event.
I'm sure there will be an entry in Wikipedia about it.
If the code works, that's great, but (1) it's obviously not working entirely because you're posting here, and (2) code like this can get hairy very fast and thus hard to maintain and thus bug-prone. So if you can simplify it, it will only help.
If you want to use a thread, you can. You basically have that now. But instead of Thread.interruped as you have it now, you could just have the key press event change the value of the flag to one that will stop the loop.
(for example, you'd have a "running" boolean field, a "while(running) {" in your run() method, an the event can change the value of "running" from true to false to cause the thread to stop.

Similar Messages

  • Using a seperate thread to control motors

    Hi am new to Java and am struggling with a probelm.
    The application is to control 4 motors connected to the parallel port. When the user presses a button the motor is set to a certain speed (byte output to port). Once the button is released the port outputs to stop the motors, i also have it working so multiple motors can be driven at the same time (multiple buttons held down) i have the code working ok, but at present the program just outputs a byte of data when its worked out what buttons are pressed/released.
    The problem is i want to drive one of the motors using a crude form of PWM (output an 'on' byte, wait 1 second, output an 'off' byte, wait one second, ect)
    This is clearly going to have to be performed in a loop that is basically an infinite loop untill the key is released. However the program also need to be listening for other key inputs to turn on other motors.
    I think the best way to do it is to create a thread for the PWM that sleeps, allowing the program to do other things, and breaks out when it recieves an interrupt (triggered by another key press), however i am have major difficultly converting the code. at present the code looks like this:
    private void DebugKeyReleased(java.awt.event.KeyEvent evt) {                                 
    int c;
    c = evt.getKeyCode();
    switch (c)
    case 83:     Control(100);
                   break;
         case 68:     Control(80);
                   break;
         case 65:     Control(40);
                   break;
         case 87:     Control(20);
                   break;
    private void DebugKeyPressed(java.awt.event.KeyEvent evt) {                                
    int c;
    c = evt.getKeyCode();
    switch (c)
    case 83:     Control(1);
                   break;
    case 68:     Control(8);
                   break;
    case 65:     Control(4);
                   break;
    case 87:     Control(2);
                   break;
    private void Control(int direction){
    switch (direction)
         case 1:      forwards = 1;
                   break;
         case 100:     forwards = 0;
    break;
         case 2: backwards = 1;
                   break;
         case 20: backwards = 0;
    break;
         case 4:          right = 1;
                   break;
         case 40: right = 0;
    break;
         case 8:          left = 1;
                   break;
         case 80:     left = 0;
    break;
         global_direction = forwards*1+(backwards*2)+(left*8)+(right*4);
    if(global_direction == 0)
    moving = "Stopped";
    short stop = 255;
    lpt.output(Addr,stop);
         else if(global_direction == 1)
    moving = "Backwards";
    short Back = 239;
    lpt.output(Addr,Back);
    ECT, there are alot more if statements that account for all possibilities.
    i want the backwards and forwards cases to enter loops that output data on and off for certain time periods.
    can anybody suggest the best way to convert the code?
    thanks for any info / help
    cheers John

    A finite state machine is an abstraction in which you have a finite collection of states, and a set of transitions between states. One state is active at a time. So a traffic light might have red, green, and yellow states, and transitions between green to yellow, yellow to red, and red to green. There can be multiple transitions out of a single state.
    So for your app, each state might be a kind of signal or a kind of sequences of signals set to the motors, and the transitions would be taken when you need to change the signals. You could send the key events and time events to whatever state currently is active. That active state would then decide what transition to take based on the event.
    I'm sure there will be an entry in Wikipedia about it.
    If the code works, that's great, but (1) it's obviously not working entirely because you're posting here, and (2) code like this can get hairy very fast and thus hard to maintain and thus bug-prone. So if you can simplify it, it will only help.
    If you want to use a thread, you can. You basically have that now. But instead of Thread.interruped as you have it now, you could just have the key press event change the value of the flag to one that will stop the loop.
    (for example, you'd have a "running" boolean field, a "while(running) {" in your run() method, an the event can change the value of "running" from true to false to cause the thread to stop.

  • Establishment of XA "Thread of Control" in a Tuxedo application

    Hello there,
    I am assigned the task of developing an XA compliant resource manager so that a client can use the C interface to our JMS messaging system from a Tuxedo application and have the application's transactions managed by it. The query I have here is abbout establishing the "thread of control" in a Tuxedo context. I'll set out my understanding and the particular queries that I have in the hope that you can confirm whether my understanding is correct and maybe point me in the right direction.
    The XA Specification clearly sets out the requirements for
    successful distributed transaction processing, and the important roles within this for the three participants: the application programme (AP), the resource manager (RM) and the transaction manager (TM). The key concept in XA is the Thread of Control as described in section 2.2.8 of
    the specification. Here is the paragraph describing the pivotal role that identification of thread of control has in transaction coordination:
    <quot>The thread concept is central to the TM's coordination on RMs. APs call RMs to request work
    while TMs call RMs to delineate transaction branches. The way the RM knows that a given work request pertains to a given branch is that the AP and the TM both call it from the same thread of control. For example, an AP thread calls the TM to declare the start of a global
    transaction. The TM records this fact and informs RMs. After the AP regains control it uses the native interface of one or more RMs to do work. The RM receives the calls from the AP and TM in the same thread of control.
    Certain XA routines, therefore, must be called from a particular thread.</quot>
    In developing a RM the key question is what should be used to identify thread of control so that work can be properly assigned to the correct transaction or more specifically XID. The obvious choice here is the thread identifier itself (such as would be returned by
    PRThread* PR_GetCurrentThread(void) when using the Netscape Portable Runtime library).
    As long as AP, RM and TM are all in one process this is not a difficult problem, however many threads may
    be created. It will also work for in our messaging system in the case where branches of the same transaction are executed in separate processes of this type. This is because "transaction assembly" occurs on the "server" when JMS messages are received there. A Message is assigned to a transaction on an individual basis. This also gives us the flexibility to implement various connection pooling mechanisms or use a single connection to transfer messages
    for many different transactions along with messages not participating in an XA transaction at all.
    However, Tuxedo presents a challenge as there cannot be a single thread in this sense as the participants are distributed across several processes. These processes are respectively, client; server and RM; TMS. There are at least two TMS to avoid blocking problems and potentially very many server-RMs. Given this situation how then is it possible for the RM to match up units of work requested by various services with the XIDs that it has been informed of by the TMS? One assumes that a different thread will run in the server/RM process for:
    a) TMS to indicate to RM that a transaction has started, ended, etc., one distinct thread for each of these calls.
    b) service execution, one distinct thread for each call, where there may be many of these making up
    the work of one transaction
    It is obviously preferable from our point of view that our RM should not have to use Tuxedo specific code, but if this is unavoidable then we shall have to live with it.
    BTW in case it is relevant I'm assuming that the RM will not use dynamic registration.
    Thanks for any help,
    Gillian Horne

    Gillian,
    When Tuxedo issues an xa_start() call, the matching xa_end() call will
    always be executed in the same thread of the same process.
    If another xa_start() is executed at a later point for the same transaction,
    that call could be made in a different process, in a different thread of the
    same process, or in the same thread of the same process.
    Tuxedo will call xa_end() with the TMSUSPEND|TMMIGRATE flag pair only for
    certain CORBA transactions. If your application does not use CORBA, then it
    would be acceptable to develop an RM with the TMNOMIGRATE flag set in the RM
    switch. Tuxedo does not use asynchronous XA operations, so you do not ened
    to develop an RM with the TMUSEASYNC flag set.
    The xa_prepare() call for a particular transaction branch can be made in
    different process or thread from the xa_commit() or xa_rollback() call that
    follows it.
    Except in the case of transactions started with the Tuxedo AUTOTRAN feature,
    the xa_prepare() and xa_commit() calls for a particular transaction branch
    will almost always be made in different processes from the processes that
    performed xa_start()/xa_end() calls for that transaction branch.
    There shouldn't be any need to write special RM code for Tuxedo. Popular
    RMs such as Oracle, Informix, DB2, MQ Series, and others have all been able
    to work with Tuxedo, with the former Top End product, with Encina, and with
    other transaction monitors.
    I hope this information is of help in implementing your RM.
    Ed
    <Gillian Horne> wrote in message news:[email protected]...
    Hello there,
    I am assigned the task of developing an XA compliant resource manager so
    that a client can use the C interface to our JMS messaging system from a
    Tuxedo application and have the application's transactions managed by it.
    The query I have here is abbout establishing the "thread of control" in a
    Tuxedo context. I'll set out my understanding and the particular queries
    that I have in the hope that you can confirm whether my understanding is
    correct and maybe point me in the right direction.
    The XA Specification clearly sets out the requirements for
    successful distributed transaction processing, and the important roles
    within this for the three participants: the application programme (AP), the
    resource manager (RM) and the transaction manager (TM). The key concept in
    XA is the Thread of Control as described in section 2.2.8 of
    the specification. Here is the paragraph describing the pivotal role that
    identification of thread of control has in transaction coordination:
    <quot>The thread concept is central to the TM's coordination on RMs. APs
    call RMs to request work
    while TMs call RMs to delineate transaction branches. The way the RM knows
    that a given work request pertains to a given branch is that the AP and the
    TM both call it from the same thread of control. For example, an AP
    thread calls the TM to declare the start of a global
    transaction. The TM records this fact and informs RMs. After the AP regains
    control it uses the native interface of one or more RMs to do work. The RM
    receives the calls from the AP and TM in the same thread of control.
    Certain XA routines, therefore, must be called from a particular
    thread.</quot>
    In developing a RM the key question is what should be used to identify
    thread of control so that work can be properly assigned to the correct
    transaction or more specifically XID. The obvious choice here is the thread
    identifier itself (such as would be returned by
    PRThread* PR_GetCurrentThread(void) when using the Netscape Portable Runtime
    library).
    As long as AP, RM and TM are all in one process this is not a difficult
    problem, however many threads may
    be created. It will also work for in our messaging system in the case where
    branches of the same transaction are executed in separate processes of this
    type. This is because "transaction assembly" occurs on the "server" when JMS
    messages are received there. A Message is assigned to a transaction on an
    individual basis. This also gives us the flexibility to implement various
    connection pooling mechanisms or use a single connection to transfer
    messages
    for many different transactions along with messages not participating in an
    XA transaction at all.
    However, Tuxedo presents a challenge as there cannot be a single thread in
    this sense as the participants are distributed across several processes.
    These processes are respectively, client; server and RM; TMS. There are at
    least two TMS to avoid blocking problems and potentially very many
    server-RMs. Given this situation how then is it possible for the RM to match
    up units of work requested by various services with the XIDs that it has
    been informed of by the TMS? One assumes that a different thread will run in
    the server/RM process for:
    a) TMS to indicate to RM that a transaction has started, ended, etc., one
    distinct thread for each of these calls.
    b) service execution, one distinct thread for each call, where there may be
    many of these making up
    the work of one transaction
    It is obviously preferable from our point of view that our RM should not
    have to use Tuxedo specific code, but if this is unavoidable then we shall
    have to live with it.
    BTW in case it is relevant I'm assuming that the RM will not use dynamic
    registration.
    Thanks for any help,
    Gillian Horne

  • Using timer/counter with PCI-6221/USB-6210 to control timed-loop VI

    Dear all,
    I need to ask about two devices and one of their functionalities, PCI-6221 and USB-6210. For our NI-based system, we need to control some timings in a Timed-Loop vi, for that currently we are using PCI-6221 and we give external TTL signal (at 1 kHz) to it,
    recenntly we need to make some changes and for that we found USB 6210 DAQ to be more suitable, but we need to clear ourselves on some specific things.
    Can the counter/timers functions available in the either PCI 6221 or USB 6210 can be used to control the Timed-loop VI by giving external clock or by using their own internal clock source?
    Although we are using external clock with the PCI 6221 but we want to know about the usage of their internal clock, also are controlling timed-loop also possible for USB-6210
    Also... What if we use the RTOS, are they still able to control the timed-loop VI  without giving any 'EXTERNAL CLOCK' and using the internal clock sources of the DAQs
    Waiting for reply,
    Bests,
    RaJaf
    Solved!
    Go to Solution.

    Ben,
    I having read previous email which I send earlier with general overview, we discussed in more detail within our team and I am giviing the specific answers.
    Please check in RED the most recent answers. Blue are the questions/suggestions by your side.
    1.    Using Internal hardware clock of PCI-6221 would enable us get rid of external clock, but how to divert the internal hardware clock to the current settings. Any idea  (can you provide us with some reference manul for otherwise). I mean is there some flag-bit etc. or VI
    2.       Is it also meant that with the installation of RTOS the timed-loop can directly get the timing source from the internal hardware clock PCI-6221? --- How???
    3.       In order to make desktop to work as RT system, what is the hardware (motherboard, processor, etc..) requirement? What are the LabVIEW modules (specific name) that needed to be installed? Our platform is LabVIEW 8.6. (Currently we have windows-7 with i7 core processor)
    What kind of application are you intending for this system? ---- high-speed laser scanning system.
    Are you most concerned about accuracy, speed, or responsiveness? To control the laser mirror scanner to move at 1 kHz or 2 kHz speed. On the other hands, using PCI-5105 (128 MB memory) as a DAQ for real-time/on-the-fly data processing.
    Bests,
    RAJAF

  • Control & Simulation Loop failed to compile

    Dear Forum Members,
    I have a problem with a Control & Simulation Loop program (attached) that just doesn't compile & run.  I believe that the problem is associated with the 'Feedback Node' at the bottom of this Control & Simulation Frame since if this is taken out the program will run ok.
    Can anyone please advise me if this 'Feedback Node' is incorrectly used or in violation of anything.  I have tried various ways to overcome the problem i.e. initialising it at the start but nothing works.  The error message that I received just says "VI failed to compile".
    Appreciate any help with this.

    Hello bunnykins, 
    The Feedback node really isn't a supported function in control design and simulation. The behavior you're reporting, and the work around are both documented in the know issues of the module here: 
    201449
    Return
    A Feedback Node on a Simulation Diagram causes the VI to fail to compile
    The Feedback Node does not make sense semantically within a Simulation Diagram, due to the fact that most ODE Solvers will execute the diagram multiple times per iteration and may need to reject steps and try again, filling the Feedback Node with bad data.
    Workaround: Use the Memory block from the Simulation Utility palette. If a delay of greater than 1 is desired you can chain multiple memory blocks in sequence.
    Reported Version: 8.5
    Resolved Version: N/A
    Added: 07/31/2010
    Applications Engineer
    National Instruments
    CLD Certified

  • [SOLVED] Control PWM frequency of LED-backlight in Thinkpad laptops

    Hi.
    I'm seeking for a person who is eager to make a contribution to opensource
    Recently I've got Lenovo X220 laptop and noticed that it makes me sick. Eventually I discovered a screen flickering that is caused by low PWM frequency (backlight brightness is controlled with PWM).
    This issue is so ubiquitous, that some folk created simple utility for Windows to adjust PWM frequency by interacting with Intel driver.
    http://pastebin.com/6iirMbfc
    It's only 50 lines of code. So I hope that accomplishing the same under linux won't be very hard.
    As you might have guessed, I don't have any experience nor knowledge in C. Thus I'm asking here for help.
    So... anyone eager to create similar utility for linux?
    Hails and beer for the author implied
    P.S. Of course, I would be very glad to hear, that my question is non-sense because our belowed linux already provides handy ways to control PWM frequency (though, I was not able to find anything like this).
    UPD: that damn screen flickering made me not only sick, but also dull.
    I've just found this in archwiki
    https://wiki.archlinux.org/index.php/Ba … at_care.29
    Seems like it does the same, that mentioned utility does. Though, some background knowledge is required. Appreciate any help with this.
    Solution
    Thank you all, folks.
    Solution is an wiki already.
    https://wiki.archlinux.org/index.php/Ba … 15_only.29
    Last edited by eDio (2013-04-21 16:22:23)

    I've found some patch to fix default PWM frequency in i915
    http://web.archiveorange.com/archive/v/ … BgDr5oIynd
    From the code of this patch I've got an address of a register that controls PWM frequency 0xc8254. I was not able to determine anything else. That patch seems to be applicable to an old kernel so I had no any context (new kernel in the Linus's github repo doesn't look very similar). Also, my "native" programming language is java so I'm a little bit scared by C syntax .
    To manipulate Intel GPU registers one can use intel_reg_read and intel_reg_write programs from the community/intel-gpu-tools.
    By default, register contained value
    0 x 12 28 12 28
    Experimentally I was able to determine, that register controls the period of PWM modulation (1/frequency).
    The most comfortable value for me is *0x03000000*.
    I'm going to put this info to the wiki on the weekend. I'm sure it'll be useful for others.
    C+Linux programming adepts are welcome to write an application for user-friendly PWM modulation frequency adjustment
    P.S. forgot to mention that Linux rocks! I can't imagine investigations like this in other OSes.
    Last edited by eDio (2013-03-21 22:16:18)

  • Simple counter within Control & Simulation Loop

    Does anyone know a simple way of creating an incremental counter within the Control & Simulation Loop ? It's not possible to have a For loop within the Control & Simulation Loop hence the shift register method is out.

    The "simulation parameters" function on the utilities pallete outputs a "Timestep Index" that is incremented each step. That's the simplest option. Alternatively, you could use a sub VI that executes on major steps and contains a for loop.

  • Extract Signal Tone Information in Control & Simulation Loop

    Hi,
    I have a simple Block Diagram to try Control & Simulation Loop. I added a Sine Wave signal and a Waveform Chart connected to it. They work just fine.
    I tried to add a Extract Single Tone Information , from Signal Processing, and connect it to the output of the Sine Wave generator but I do not know how to create a proper Time Signal.
    I thought of storing the output of the Sine Wave in an array but I was unsuccessful since I could not add any shift register to this type of control loops.
    Any help or suggestions?
    Thanks
    Attachments:
    Control_n_Sim_Test.PNG ‏9 KB

    Hi Siamak,
    Thanks for your reply mate.
    However, when I built a same BD as you posted on, it somehow didn't work. I also attached a photo of my BD here.  I used the gauge to measure when I run the programme. The gauge shows there is no signal output after the "collector"VI (gauge no.13). would you please check it for me? Many thanks!
    BR
    Floyd
    Attachments:
    tone info extraction.png ‏134 KB

  • Why does Labview VI pause intermittently during motor control while loop?

    I'm performing some biomechanical testing using Labview to control stepper motor actuators. I have a PCI-7334 controller card and a MID-7604 driver. The testing is run in load control using a while loop that sends a number of steps to the stepper motor that is proportional to the difference between the actual and desired load. The VI intermittently pauses though and sits in active for several seconds (~5 sec to 20 sec). What could cause this problem?
    Thank you in advance for your assistance.

    Without the subVIs it is hard to see what is going on.
    Some general comments:
    1. Block diagrams should be limited to the size of one screen.  Yours is over 4 times as wide as my 27" screen.
    2. Sequence structures should be avoided.  LabVIEW is a datflow language and only rarely are sequence structures required. There is almost certainly a way to write your program without them.
    3. The use of local variables should be avoided.  Again, they have a place but most likely they are not needed in your program. They are prone to race conditions, make extra data copies, and force execution in the UI thread.
    4. Floating point data types are not recommended as case selectors. They will be rounded and coerced to integers.
    5. Learn about the Producer/Consumer Design Pattern and state machines.  
    One possible cause of your slowdown is having the Write to Spreadsheet File.vi inside the while loop. This VI is convenient to use but it opens, writes, and closes the file each time it is called.  I have no way to tell how much data you write on each iteration but as the file grows the OS may need to re-allocate space for the file or fragment the file. These operations can be slow.
    Do you really want to Abort the program in the False case?  This will leave any outputs in the last state they had been set. This could have your motor(s) running, clutch engaged, ...  In programs which control physical hardware an orderly shutdown procedure is usually better: set all outputs to a safe condition, close files, close DAQ tasks, and indicate the status to the user.  Calling Stop allows none of this to happen.
    Lynn

  • Thread Groups control

    Hi,
    How could I control the complete thread group? What I mean is to suspend and resume all threads within one group at the same time. As far as I know, suspend() and resume() are deprecated. This means, no control options by these methods. Any ideas appreciated. I know how to do it per each thread, but I'm looking for more convenient, simple solution for the group.
    thank you

    The basic technique for controlling a thread is to put the control in the Runnable's run loop. The most common flag that's checked is one that says "stop, you're done now" which causes the run loop to stop, the run() method comes to completion and the Thread dies gracefully.
    Another one is a flag that says "wait". So maybe you want a class that extends ThreadGroup, adding a "wait" flag. Then extend Thread, adding a class that checks the group's "wait" flag. Then your Runnable can ask its Thread if it needs to wait.

  • Control PWM idle state

    I need to be able to turn off and on the pwm with 1ms intervals, is this possible?
    Presently, I can control the wdiths of the pulses at that resolution, but I cannot turn the pwm off.  How do you do this?

    Hi Kevin -
    Thanks for the expanation and tips.  I'd like to elaborate a little bit to help TEster out:
    A software-timed task (one that turns the pulses on and off using commands in the program) will be very slow, event with the LabVIEW Real-Time OS.  The Windows OS has a jitter of about 10 ms.  This means that if you want to turn a pulse on, then off every 1 ms, it could take up to 11 ms to perform.  LVRT is deterministic, so it executes a timed loop in exactly the same amount of time, every time.  But it isn't necessarily faster than Windows.  This Developer Zone article discusses LVRT benchmarks in detail: Benchmarking Single-Point Performance on National Instruments Real-Time Hardware
    As you said, a DAQ or counter/timer device has onboard counters that can be paired to generate a hardware-timed PWM signal.  This is a MUCH faster output with deterministic timing, since it's driven entirely in hardware.  A simple modification to a DAQmx shipping example yields the result (attached).
    David Staab, CLA
    Staff Systems Engineer
    National Instruments
    Attachments:
    Gen Dig Pulse Train-Continuous-PWM.vi ‏38 KB

  • How to control the looping time of the for loop in 10 microseconds in labview?

    I need to create a +/- 9 volt square wave with period of 20us using a D/A card (Not NI card). I can write command to the card using outport provide by Labview. Right now, I can generate square wave with 4ms period which is limited by the resolution of the wait until next ms icon I used inside the for loop. Could anyone tell me how to control the execution time of the for loop to about 10 us? Your help would be much appreciated.

    I'm not sure if this will hep, but this answer seems to answer this question
    http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=50650000000800000029410000&UCATEGORY_0=_30_%24_12_&UCATEGORY_S=0&USEARCHCONTEXT_QUESTION_0=microsecond+resolution+1ms&USEARCHCONTEXT_QUESTION_S=0

  • Using labview cosimulation, how to control PWM duty cycle in multisim

    I am new to using Multisim with LabVIEW using cosimulation. I want to ask if there is a PWM component in Multisim that can have its duty cycle be controlled using LabVIEW? I have an algorithm in LabVIEW that outputs duty cycle values from 0 to 1, representing duty cycle percentages.
    How do I control the PWM duty cycle in Multisim using LabVIEW cosimulation?
    Many thanks,
    SPECTRE
    Solved!
    Go to Solution.

    Hi Spectre,
    In Multisim, search for the parts base on functionality, there are some PWM models in the database.  Have a look at this knowledge base  if you don't know how to search for parts:
    http://digital.ni.com/public.nsf/allkb/7309A5CABC677296862577ED006EC99E
    Aslo, have a look at this knowledgebase:
    http://digital.ni.com/public.nsf/allkb/EF391C48CF71AE4F862571B900644F84
    This article shows how you can get Mutlisim and LabVIEW to co-simiualte:
    http://www.ni.com/white-paper/13663/en
    I hope this helps
    Tien P.
    National Instruments

  • Stopping a Thread (no control on run method)

    Hi,
    How can we stop a Thread like in the following scenario. If we are in the aMethod() and the stopped variable is set to true by some other thread now how can we return from this run method and stop executing the aMethod(). Any tips are helpful.
    public void run()
    if (stopped)
    return;
    someOtherClass.aMethod();
    Thanks

    I miss the scenario here, where a thread is blocked inside a call to some operating system resource (such as accept() or read() or write()).
    In this case an InterruptedException travels like pacman up the stack, until it's caught, and I think that it should be a scenario in all cases, because it can apply to the blocking call (where it applies already), the predictable loop (try { while() { } } catch (InterruptedException ie) { }), and the one-off algorithm, even though in the latter case, if it's extremely important that we know exactly what we were doing when we were interrupted, it's difficult to avoid either a) many try-catch-blocks, or b) a very good way of examining the stack at the moment of interruption.
    This is, in fact, so important, that I would like to urge Sun to change the API for java.lang.Runnable into
    public interface Runnable {
      public abstract void run() throws InterruptedException;
    }Because, in this way, any thread will always have an endpoint. If you choose to rethrow the exception you still mess up the JVM, of course, like it was, causing it to exit. But at least you must provide yourself with the opportunity to let threads not end, or always die softly.

  • Hiding SWF Sound Control & Spanning Loop Across Site Pages

    Hi All,
    New here and first post with two questions:
    Is it possible to hide the play/stop SWF sound control on a
    page? I have one on a page and the client doesn't want it visible
    on the page. They want the music loop to always play. I have looked
    and can't find a way to set its property to
    &quot;invisible&quot; or anything like that.
    Second question, related somewhat to the first. They want the
    loop to play across all pages on a site and not be interrupted or
    restarted on page changes (which would happen if I embedded on
    every page). Is that possible? Just a thought...could I put it in a
    CSS sheet that applies to the entire site? Doubt it...but thought
    it would be a desireable goal ;)

    I seem to have the same problem. The sound would play in some programs, would not in others, and in all of them when I stop playing, it would repeat the last half second endlessly. Could anybody shed some light on this problem?
    in dmesg:
    AC'97 1 does not respond - RESET
    AC'97 1 access is not valid [0xffffffff], removing mixer.
    ali mixer 1 creating error.
    and in errors.log:
    May 13 09:14:22 aconarch ali15x3_smbus 0000:00:06.0: ALI15X3_smb region uninitialized - upgrade BIOS or use force_addr=0xaddr
    May 13 09:14:22 aconarch ali15x3_smbus 0000:00:06.0: ALI15X3 not detected, module not inserted.
    May 13 09:14:22 aconarch AC'97 1 access is not valid [0xffffffff], removing mixer.
    May 13 09:14:22 aconarch ali mixer 1 creating error.
    EDIT: 'lsmod | grep snd'
    snd_seq_oss 29056 0
    snd_seq_midi_event 6528 1 snd_seq_oss
    snd_seq 46800 4 snd_seq_oss,snd_seq_midi_event
    snd_seq_device 6796 2 snd_seq_oss,snd_seq
    snd_pcm_oss 38816 0
    snd_mixer_oss 14336 1 snd_pcm_oss
    snd_ali5451 19212 1
    snd_ac97_codec 95396 1 snd_ali5451
    ac97_bus 2432 1 snd_ac97_codec
    snd_pcm 68484 3 snd_pcm_oss,snd_ali5451,snd_ac97_codec
    snd_timer 19076 2 snd_seq,snd_pcm
    snd 44388 11 snd_seq_oss,snd_seq,snd_seq_device,snd_pcm_oss,snd_mixer_oss,snd_ali5451,snd_ac97_codec,snd_pcm,snd_timer
    soundcore 6496 1 snd
    snd_page_alloc 7816 1 snd_pcm
    Last edited by bender02 (2007-05-13 15:41:04)

Maybe you are looking for

  • Use of 0MAT_UNIT to display attributes

    Has anyone successfully used 0MAT_UNIT in a query to display material atributes such as the "height" of a material in a specific alternate unit of measure, such as "Case".  The "height" in 0MATERIAL refers to the base unit (i.e. EA) so we cannot use

  • Can't add files or folders

    I am trying to add files in folders other than iTunes into the iTunes library. Some work OK (mp3) but others are just ignored (aac). Can anyone suggest what is wrong? Thanks Mike

  • Old G4 iMac can see aluminum iMac, not vice versa

    I've got a wireless setup, and my older computer can "see" and mount my newer iMac. (I just transferred a file with no problem.) But what I want to do is access files from the older computer via the newer one -- and the G4 iMac is not showing up. I'v

  • Can I create a message broker channel CounterMonitor mbean?

    Hi All, I'm trying to write an app which sends notifications when certain events occur in our WLI system. I am using mbean notification listeners and countermonitors for most things. I would like to setup a notification for the error count and dead l

  • How Can I access a file within that is part of my jpx

    The file is part of my JPX but I don't know how to access it. I use the following code for images ImageIcon backImage = new ImageIcon(OpeningUI.class.getResource("myImage.gif"));This doesn't work.with BufferReader because the constructor doesn't acce