Counter speed myrio

Hi,
I'm using a myRIO for a school project and we have to measure an quadrature encoder. There is only one problem, when we calculate how much state changes it would undergo in 1 second it's 8.400.000, so my question is, will the myRIO build-in counter be able to count that fast?
Thanks for the reply, Laseros

Hi Laseros,
If you take a look at page 23 of the MyRIO manual (http://www.ni.com/pdf/manuals/376047a.pdf ) you will find that the max frequency for Quadrature encoder input is 100kHz. If you create a "MyRIO custom FPGA project," you can actually have a look at the FPGA code that was implemented to read the encoder signal. 
Best,
Jos

Similar Messages

  • How to Measure Position and Velocity with a Single Counter with myrio

    Hi Everyone , I need your help .
    I got myrio a few days ago for my project which is a electric vehicle drived by wireless mode so first problem faces me that I have encoder and it give me counts (decreasing or icreasing) which I can't convert it to veolcity any one may help , I will be grateful ???????????????????

    Hey Hesham92,
    As you mentioned the myRIO encoder counts pulses.  These pulses will typically come from some type of encode such as a quadrature encoder.
    Look at your encoder datasheet and it should explain how it works (which mode it uses) and the resolution (ie rotation per pulse).    If the encoder is attached to a wheel you can use some simple math to determine how many cm the wheel moves per encoder pulse.
    Let us know if you have questions about this (please also post more info about your setup such as the encoder, what it's attached to and what you need to measure).
    Thanks!
    -Sam K
    LabVIEW Hacker
    Join / Follow the LabVIEW Hacker Group on google+

  • 2 Conky Problems-Suddenly scrunched formatting and IP set to 127.0.0.1

    I have 2 problems with conky, I'm not sure if they are related. First, conky started displaying all scrunched up with much of the formatting wrong. I did not make any configuration changes at the time. I'm sure that I can go through my conkyrc and adjust everything so that it's looking correct again, but I'd rather not unless I have no other choice.
    Second, a while after starting conky, the IP changes from my correct IP, to 127.0.0.1.
    I've exhausted my google-fu and I don't know what is wrong. Thanks ahead of time for any help!
    Screenshot:
    Conkyrc:
    # Conky configuration
    # Configuration Section #
    # Boolean value, if true, Conky will be forked to background when started.
    background no
    # Use Xft (anti-aliased font and stuff)
    use_xft yes
    xftfont sans:size=7:bold
    update_interval .75
    total_run_times 0
    own_window yes
    own_window_transparent yes
    own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
    double_buffer yes
    minimum_size 280 1900
    draw_shades yes
    draw_outline no
    draw_borders no
    draw_graph_borders no
    stippled_borders 8
    # The next line appears to be depricated
    # border_margin 4
    border_width 1
    # Default colors and also border colors
    default_color white
    default_shade_color black
    default_outline_color black
    default_bar_size 155 10
    alignment top_left
    gap_x 0 #gap from left
    gap_y 0 #gap from top
    no_buffers yes
    uppercase no
    cpu_avg_samples 3
    net_avg_samples 3
    override_utf8_locale no
    text_buffer_size 512
    # Main Layout Section #
    TEXT
    # Arch Image
    ${image /home/tim/Pictures/Arch.png -s 50x47 -f 5000}
    # Top Info Line#
    ${voffset -12}${offset 30}Arch Linux
    ${offset 36}Uptime: $uptime
    ${offset 42}$nodename - $sysname $kernel on $machine
    ${offset 48}Pacman: ${execpi 1000 /home/tim/Scripts/pacupdate.pl} #This is the pacman update line. This requires a cron job run regularly. Currently a copy can be found in /home/tim/Scripts/pacmansync.sh. The Cron copy in at /etc/cron.hourly/pacmansynch.sh
    # Main Bar: CPU
    ${voffset -5}${font sans:size=15}${color lightgrey}C${font sans:size=11:bold}PU${voffset 3}${hr 2}${font}
    $alignr${voffset -20}AMD Phenom II
    ${voffset 5}CPU 1:
    CPU 2:
    CPU 3:
    ${alignr}${voffset -48}${offset -150}${cpu cpu1}%
    ${alignr}${offset -150}${cpu cpu2}%
    ${alignr}${offset -150}${cpu cpu3}%
    ${alignr}${voffset -48}${offset -190}${freq 1}MHz
    ${alignr}${offset -190}${freq 2}MHz
    ${alignr}${offset -190}${freq 3}MHz
    ${alignr}${voffset -24}${offset -80}${color #cc2222}Total=${cpu cpu0}%
    ${alignr}${voffset -12}${color}Temp=${hwmon temp 2}C
    ${voffset -5}${cpugraph cpu0 000000 cc2222}
    ${color cc2222}${voffset -7}${cpubar cpu1 7,90}${offset 5}${cpubar cpu2 7,90}${offset 5}${cpubar cpu3 7,90}
    # Main Bar: Memory
    ${font sans:size=15}${color lightgrey}M${font sans:size=11:bold}EMORY${voffset 3}${hr 2}${font}
    ${alignr}${voffset -20}$memperc% - $mem/$memmax
    # RAM Usage Bar
    ${voffset 7}${color lightgrey}RAM:
    ${voffset -12}${offset 35}${color DarkSlateGray}${membar 10,245}
    # SWAP Usage Bar
    ${color lightgrey}Swap:
    ${voffset -12}${offset 35}${color DarkSlateGray}${swapbar 10,40}
    # Main Bar: Processes
    ${font sans:size=15}${color lightgrey}P${font sans:size=11:bold}ROCESSES${voffset 3}${hr 2}${font}
    ${alignr}${voffset -20}${color lightgrey}$color$running_processes ${color grey}of $color$processes ${color grey}processes running
    ${voffset 5}${color}Name
    ${alignr}${voffset -12}${offset -100}PID
    ${alignr}${voffset -12}${offset -50}CPU %
    ${alignr}${voffset -12}MEM %
    # Process List: Top CPU
    ${color orange}CPU usage${color}
    # Line 1
    ${color FFBF40} ${top name 1}
    ${alignr}${voffset -12}${offset -100}${top pid 1}
    ${alignr}${voffset -12}${offset -50}${top cpu 1}%
    ${alignr}${voffset -12}${top mem 1}%
    # Line 2
    ${color FFD580} ${top name 2}
    ${alignr}${voffset -12}${offset -100}${top pid 2}
    ${alignr}${voffset -12}${offset -50}${top cpu 2}%
    ${alignr}${voffset -12}${top mem 2}%
    # Line 3
    ${color FFEABF} ${top name 3}
    ${alignr}${voffset -12}${offset -100}${top pid 3}
    ${alignr}${voffset -12}${offset -50}${top cpu 3}%
    ${alignr}${voffset -12}${top mem 3}%
    # Line 4
    ${color FFFFFF} ${top name 4}
    ${alignr}${voffset -12}${offset -100}${top pid 4}
    ${alignr}${voffset -12}${offset -50}${top cpu 4}%
    ${alignr}${voffset -12}${top mem 4}%
    # Process List: Top Memory
    ${color orange}Mem usage${color}
    # Line 1
    ${color FFBF40} ${top_mem name 1}
    ${alignr}${voffset -12}${offset -100}${top_mem pid 1}
    ${alignr}${voffset -12}${offset -50}${top_mem cpu 1}%
    ${alignr}${voffset -12}${top_mem mem 1}%
    # Line 2
    ${color FFD580} ${top_mem name 2}
    ${alignr}${voffset -12}${offset -100}${top_mem pid 2}
    ${alignr}${voffset -12}${offset -50}${top_mem cpu 2}%
    ${alignr}${voffset -12}${top_mem mem 2}%
    # Line 3
    ${color FFEABF} ${top_mem name 3}
    ${alignr}${voffset -12}${offset -100}${top_mem pid 3}
    ${alignr}${voffset -12}${offset -50}${top_mem cpu 3}%
    ${alignr}${voffset -12}${top_mem mem 3}%
    # Line 4
    ${color FFFFFF} ${top_mem name 4}
    ${alignr}${voffset -12}${offset -100}${top_mem pid 4}
    ${alignr}${voffset -12}${offset -50}${top_mem cpu 4}%
    ${alignr}${voffset -12}${top_mem mem 4}%
    # Main Bar: Disks
    ${font sans:size=15}${color lightgrey}D${font sans:size=11:bold}ISKS${voffset 3}${hr 2}${font}
    #List of Disks w/ usage bars
    ${color Red}Root:${color white}${fs_free /} f/o ${fs_size /}
    ${voffset -12}${offset 125}${color DarkRed}${fs_bar 10,5 /}
    ${color Orange}home:${color white}${fs_free /ubuntu} f/o ${fs_size /ubuntu}
    ${voffset -12}${offset 125}${color DarkOrange}${fs_bar 10,27 /ubuntu}
    ${color LightSlateGray}tc1:${color white}${fs_free /media/truecrypt1} f/o ${fs_size /media/truecrypt1}
    ${voffset -12}${offset 125}${color DarkSlateGray}${fs_bar 10,80 /media/truecrypt1}
    ${color LightSlateGray}tc2:${color white}${fs_free /media/truecrypt2} f/o ${fs_size /media/truecrypt2}
    ${voffset -12}${offset 125}${color DarkSlateGray}${fs_bar 10,80 /media/truecrypt2}
    ${color LightSlateGray}tc3:${color white}${fs_free /media/truecrypt3} f/o ${fs_size /media/truecrypt3}
    ${voffset -12}${offset 125}${color DarkSlateGray}${fs_bar 10,80 /media/truecrypt3}
    ${color LightSlateGray}tc4:${color white}${fs_free /media/truecrypt4} f/o ${fs_size /media/truecrypt4}
    ${voffset -12}${offset 125}${color DarkSlateGray}${fs_bar 10,155 /media/truecrypt4}
    ${color LightSlateGray}tc5:${color white}${fs_free /media/truecrypt5} f/o ${fs_size /media/truecrypt5}
    ${voffset -12}${offset 125}${color DarkSlateGray}${fs_bar 10,155 /media/truecrypt5}
    ${color LightSlateGray}tc6:${color white}${fs_free /media/truecrypt6} f/o ${fs_size /media/truecrypt6}
    ${voffset -12}${offset 125}${color DarkSlateGray}${fs_bar 10,3 /media/truecrypt6}
    ${color LightSlateGray}tc7:${color white}${fs_free /media/truecrypt7} f/o ${fs_size /media/truecrypt7}
    ${voffset -12}${offset 125}${color DarkSlateGray}${fs_bar 10,135 /media/truecrypt7}
    ${color LightSlateGray}tc8:${color white}${fs_free /media/truecrypt8} f/o ${fs_size /media/truecrypr8}
    ${voffset -12}${offset 125}${color DarkSlateGray}${fs_bar 10,135 /media/truecrypt8}
    ${if_mounted /media/truecrypt9}${color LightSlateGray}tc9:${color white}${fs_free /media/truecrypt9} f/o ${fs_size /media/truecrypt9}
    ${voffset -12}${offset 125}${color DarkSlateGray}${fs_bar 10,135 /media/truecrypt9}${voffset 12}${endif}${voffset -12}
    ${color LightSlateGray}Dropbox:${color white}${execi 60 ~/Scripts/dropbox_size.sh} Used of 6G
    ${voffset -12}${offset 125}${color SlateGray}${execibar 60 ~/Scripts/dropbox_size_p.sh}
    # Main Bar: Networking
    ${font sans:size=15}${color lightgrey}N${font sans:size=11:bold}ETWORK${voffset 3}${hr 2}${font}
    ${alignr}${voffset -20}${color}${font} In:${tcp_portmon 1 32767 count} Out:${tcp_portmon 32768 61000 count} ALL: ${tcp_portmon 1 65535 count}
    # Speed Graphs
    ${voffset 5}$alignc${addr eth0}
    ${color DarkGreen}${downspeedgraph eth0 30,140 006400 006400 3400}${alignr}${color DarkRed}${upspeedgraph eth0 30,140 8B0000 8B0000 175}
    ${alignr}${voffset -3}${offset -140}${color DarkGreen} ${downspeed eth0}/s
    ${voffset -12}${offset 140}${color DarkRed} ${upspeed eth0}/s
    ${voffset -12}${color DarkGreen}Dn${color LightGray} ${alignr}${color DarkRed}Up${color}
    # Main Bar: Weather
    # overlandpark=USKS0450
    # Find new locations with the following Command
    ${font sans:size=15}${color lightgrey}W${font sans:size=11:bold}EATHER${voffset 3}${hr 2}${font}
    Location: ${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --datatype=CN}
    Conditions: ${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --datatype=CC}
    # Now Conditions
    ${color SkyBlue}${font ConkyWeather:size=36}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --datatype=WF}${font}${color}
    # Column 1
    ${voffset -40}${offset 50}Temp: ${color orange}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --datatype=HT -iux}${iconv_start UTF-8 ISO_8859-1}°${iconv_stop}F${color}
    ${offset 50}Bar: ${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --datatype=BR -i}
    ${offset 50}Bar: ${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --datatype=BD -i}
    # Column 2
    ${voffset -37}${offset 125}Wind: ${color orange}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --datatype=WS -i}${color}
    ${offset 125}From the ${color orange}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --datatype=WD -i}.${color}
    ${offset 125}Gust: ${color orange}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --datatype=WG -i}${color}
    # Column 3
    ${voffset -37}${offset 200}UV: ${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --datatype=UI}
    ${offset 200}Rise: ${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --datatype=SR}
    ${offset 200}Set: ${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --datatype=SS}
    ${voffset 10}Tomorrow
    ${color SkyBlue}${font ConkyWeather:size=36}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=1 --endday=1 --datatype=WF}${font}${color}
    # Column 1
    ${voffset -40}${offset 50}High: ${color orange}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=1 --endday=1 --datatype=HT -iux}${iconv_start UTF-8 ISO_8859-1}°${iconv_stop}F${color}
    ${offset 50}Low: ${color LightSkyBlue}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=1 --endday=1 --datatype=LT -iux}${iconv_start UTF-8 ISO_8859-1}°${iconv_stop}F${color}
    ${offset 50}Rain: ${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=1 --endday=1 --datatype=PC}
    # Column 2
    ${voffset -37}${offset 125}Wind: ${color orange}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=1 --endday=1 --datatype=WS -i}${color}
    ${offset 125}From the ${color orange}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=1 --endday=1 --datatype=WD -i}.${color}
    ${offset 125}Gust: ${color orange}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=1 --endday=1 --datatype=WG -i}${color}
    # Column 3
    ${voffset -37}${offset 200}UV: ${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=1 --endday=1 --datatype=UI}
    ${offset 200}Rise: ${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --datatype=SR}
    ${offset 200}Set: ${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --datatype=SS}
    ${voffset 10}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=2 --endday=2 --spaces=5 --datatype=DW}
    ${color SkyBlue}${font ConkyWeather:size=36}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=2 --endday=2 --datatype=WF}${font}${color}
    # Column 1
    ${voffset -40}${offset 50}High: ${color orange}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=2 --endday=2 --datatype=HT -iux}${iconv_start UTF-8 ISO_8859-1}°${iconv_stop}F${color}
    ${offset 50}Low: ${color LightSkyBlue}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=2 --endday=2 --datatype=LT -iux}${iconv_start UTF-8 ISO_8859-1}°${iconv_stop}F${color}
    ${offset 50}Rain: ${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=2 --endday=2 --datatype=PC}
    # Column 2
    ${voffset -37}${offset 125}Wind: ${color orange}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=2 --endday=2 --datatype=WS -i}${color}
    ${offset 125}From the ${color orange}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=2 --endday=2 --datatype=WD -i}.${color}
    ${offset 125}Gust: ${color orange}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=2 --endday=2 --datatype=WG -i}${color}
    # Column 3
    ${voffset -37}${offset 200}UV: ${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=2 --endday=2 --datatype=UI}
    ${offset 200}Rise: ${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --datatype=SR}
    ${offset 200}Set: ${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --datatype=SS}
    ${voffset 10}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=3 --endday=3 --spaces=5 --datatype=DW}
    ${color SkyBlue}${font ConkyWeather:size=36}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=3 --endday=3 --datatype=WF}${font}${color}
    # Column 1
    ${voffset -40}${offset 50}High: ${color orange}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=3 --endday=3 --datatype=HT -iux}${iconv_start UTF-8 ISO_8859-1}°${iconv_stop}F${color}
    ${offset 50}Low: ${color LightSkyBlue}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=3 --endday=3 --datatype=LT -iux}${iconv_start UTF-8 ISO_8859-1}°${iconv_stop}F${color}
    ${offset 50}Rain: ${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=3 --endday=3 --datatype=PC}
    # Column 2
    ${voffset -37}${offset 125}Wind: ${color orange}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=3 --endday=3 --datatype=WS -i}${color}
    ${offset 125}From the ${color orange}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=3 --endday=3 --datatype=WD -i}.${color}
    ${offset 125}Gust: ${color orange}${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=3 --endday=3 --datatype=WG -i}${color}
    # Column 3
    ${voffset -37}${offset 200}UV: ${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --startday=3 --endday=3 --datatype=UI}
    ${offset 200}Rise: ${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --datatype=SR}
    ${offset 200}Set: ${execi 3600 conkyForecast -C ~/Scripts/Files/conkyForecast.config --datatype=SS}
    # Conky Cant Render Much More than This.
    tmp1 ${hwmon temp 1}
    CPU ${hwmon temp 2}
    tmp2 ${hwmon temp 3}

    Gusar wrote:The scrunching is a change in freetype. It's intended. So you'll have to readjust all voffsets. No idea about the IP.
    Thanks, I spent some time reformatting everything. It's good to know that this wasn't a bug

  • Basic animation - moving cards

    Hi all,
    As I'm fairly new to java programming for games I thought I would try my hand at something simple like a 2D card game. The card game I picked was Canasta although you probably don't need to know that it might help you understand my method.
    The code sample is from one class of many called GameWindow which basically does what it says on the tin. What I want to do is create a simple animation where I can move a card positioned at point A in the frame to point B in x number of seconds, for example if I was dealing a card to a player across the table. In Flash this would be the equivalent of a motion-tween as I want to give the impression the card is moving otherwise I could just repaint the card at Point B on the screen but that wouldn't look all that nice! I had a hunt around Google and found a class called Move which appeared to do just that (http://www.ssw.uni-linz.ac.at/Services/OnlineTools/Games/PSW2/BlackJack/doc/javadoc/Move.html) but I couldn't figure out how to get it to work in my environment. I also hunted around for other ways to create an animation to do this but the only code I found was hundreds of lines long so I'm thinking there must be s simple way to do what I wish to accomplish.
    Here is the code for the class. I know it won't compile on its own but it should at least help you to have some sort of visual in your head of what is going on.
    import java.awt.*;
    import javax.swing.*;
    import org.apache.log4j.Logger;
    public class GameWindow extends JApplet
        public static int i = 0;
        public static int d = 0;
        public static boolean newUserName = false;
        public static boolean isPainted = false;
        public static boolean isAvPainted = false;
        public static int comp1_score;
        public static int player1_score;
        public static int card_count;
        static Logger log = Logger.getLogger(GameWindow.class.getName());
        public Image loadImage(String name)
          Image result = null;
          MediaTracker tracker = new MediaTracker(this);
          Toolkit toolkit = Toolkit.getDefaultToolkit();
          result = toolkit.getImage(name);
          tracker.addImage(result, 0);
              try
            tracker.waitForID(0);
          } catch (InterruptedException e)
            return null;
          return result;
        public void paint(Graphics g)
            log.info("Loading background image into memory");
            Image background = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\new_bg.jpg");
            log.info("Displaying main image");
            g.drawImage(background, 0, 0, null);
            if (isAvPainted == true) {
                log.info("Load and display avatars");
                Image bot_av_bg = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\bot_bg_test_none2.gif");
                g.drawImage(bot_av_bg, 192, 4, null);
                Image bot_av_norm = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\bot_norm.jpg");
                g.drawImage(bot_av_norm, 193, 5, null);
                Image player_av_bg = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\player_av_bg.gif");
                g.drawImage(player_av_bg, 180, 313, null);
                Image player_av_happy = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\player_happy2.jpg");
                g.drawImage(player_av_happy, 183, 316, null);
                g.drawString("Mr. Meld", 270, 18);
                //scores
                log.info("Display scores");
                String comp1_score_string = Integer.toString(comp1_score);
                g.drawString(comp1_score_string, 384, 123);
                String player1_score_string = Integer.toString(player1_score);
                g.drawString(player1_score_string, 156, 121);
                //card count
                log.info("Display card count");
                String card_count_string = Integer.toString(card_count);
                g.drawString("(" + card_count_string + ")", 147, 230);
                Image card0 = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\card0.gif");
                Image card1 = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\card1.gif");
                Image card2 = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\card2.gif");
                Image card3 = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\card3.gif");
                Image card4 = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\card4.gif");
                Image card5 = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\card5.gif");
                g.drawImage(card0, 180, 175, null);
                g.drawImage(card1, 185, 175, null);
                g.drawImage(card2, 190, 175, null);
                g.drawImage(card3, 195, 175, null);
                g.drawImage(card4, 200, 175, null);
                g.drawImage(card5, 205, 175, null);
            g.drawString(StartWindow.getUserName(), 250, 357);
            log.info("Image background is now displayed");
            log.debug("VALUE OF i BEFORE for loop is " + i + "!!!");
            for (; i < 1; i++) {
                log.debug("VALUE OF i IN FOR loop is " + i + "!!!");
                log.info("Loading title image into memory");
                Image title = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\title.gif");
                g.drawImage(title, 111, 120, null);
                log.info("Image title is now displayed");
                log.info("Start the opening sound sequence");
                //try { Thread.sleep(1000); } catch (InterruptedException e) {} // add initial delay for JBuilder workaround
                new SoundApplet("sounds/C_Start2.au");
                try {
                    Thread.sleep(3400);
                } catch (InterruptedException e) {}
                repaint();
            log.debug("VALUE OF i AFTER IF loop is " + i + "!!!");
            if (newUserName == true && isPainted == false) {
                newUserName = false;
                isPainted = true;
                repaint();
            if (isPainted == true && isAvPainted == false) {
                isAvPainted = true;
                Main.StartGame();
                repaint();
    }This probably isn't the best piece of code in the world so if anyone has some constructive criticism about it, feel free to elaborate.
    Thanks in advance

    Yup that worked.
    I've now tried integrating the code into my existing frame and everything seems to be fine except when the repaint() command is called from the CardTable class it's using the paint method from GameWindow class and not the paintComponent method from the CardTable class like I would expect it to.
    This is the code I now have.
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import java.util.*;
    import java.util.List;
    import javax.imageio.ImageIO;
    import org.apache.log4j.Logger;
    public class GameWindow extends JApplet{
        public static int i = 0;
        public static int d = 0;
        public static boolean newUserName = false;
        public static boolean isPainted = false;
        public static boolean isAvPainted = false;
        public static int comp1_score;
        public static int player1_score;
        public static int card_count;
        static Logger log = Logger.getLogger(GameWindow.class.getName());
        public Image loadImage(String name){
          Image result = null;
          MediaTracker tracker = new MediaTracker(this);
          Toolkit toolkit = Toolkit.getDefaultToolkit();
          result = toolkit.getImage(name);
          tracker.addImage(result, 0);
              try
            tracker.waitForID(0);
          } catch (InterruptedException e)
            return null;
          return result;
        public void paint(Graphics g){
            log.info("Loading background image into memory");
            Image background = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\new_bg.jpg");
            log.info("Displaying main image");
            g.drawImage(background, 0, 0, null);
            if (isAvPainted == true) {
                log.info("Load and display avatars");
                Image bot_av_bg = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\bot_bg_test_none2.gif");
                g.drawImage(bot_av_bg, 192, 4, null);
                Image bot_av_norm = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\bot_norm.jpg");
                g.drawImage(bot_av_norm, 193, 5, null);
                Image player_av_bg = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\player_av_bg.gif");
                g.drawImage(player_av_bg, 180, 313, null);
                Image player_av_happy = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\player_happy2.jpg");
                g.drawImage(player_av_happy, 183, 316, null);
                g.drawString("Mr. Meld", 270, 18);
                //scores
                log.info("Display scores");
                String comp1_score_string = Integer.toString(comp1_score);
                g.drawString(comp1_score_string, 384, 123);
                String player1_score_string = Integer.toString(player1_score);
                g.drawString(player1_score_string, 156, 121);
                //card count
                log.info("Display card count");
                String card_count_string = Integer.toString(card_count);
                g.drawString("(" + card_count_string + ")", 147, 230);
                Image card0 = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\card0.gif");
                Image card1 = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\card1.gif");
                Image card2 = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\card2.gif");
                Image card3 = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\card3.gif");
                Image card4 = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\card4.gif");
                Image card5 = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\card5.gif");
                g.drawImage(card0, 180, 175, null);
                g.drawImage(card1, 185, 175, null);
                g.drawImage(card2, 190, 175, null);
                g.drawImage(card3, 195, 175, null);
                g.drawImage(card4, 200, 175, null);
                g.drawImage(card5, 205, 175, null);
            g.drawString(StartWindow.getUserName(), 250, 357);
            log.info("Image background is now displayed");
            log.debug("VALUE OF i BEFORE for loop is " + i + "!!!");
            for (; i < 1; i++) {
                log.debug("VALUE OF i IN FOR loop is " + i + "!!!");
                log.info("Loading title image into memory");
                Image title = loadImage("C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\title.gif");
                g.drawImage(title, 111, 120, null);
                log.info("Image title is now displayed");
                log.info("Start the opening sound sequence");
                //try { Thread.sleep(1000); } catch (InterruptedException e) {} // add initial delay for JBuilder workaround
                new SoundApplet("sounds/C_Start2.au");
                try {
                    Thread.sleep(3400);
                } catch (InterruptedException e) {}
                repaint();
            log.debug("VALUE OF i AFTER IF loop is " + i + "!!!");
            if (newUserName == true && isPainted == false) {
                newUserName = false;
                isPainted = true;
                repaint();
            if (isPainted == true && isAvPainted == false) {
                isAvPainted = true;
                Main.StartGame();
                repaint();
        public static void run() throws IOException {
            String path = "C:\\Documents and Settings\\Paulo\\jbproject\\Canasta_Game\\src\\images\\";
            BufferedImage[] images = new BufferedImage[10];
            for(int j = 0, k = 0; j < images.length; j++, k++)
                images[j] = ImageIO.read(new File(path + "card" + k + ".gif"));
            CardMover test = new CardMover(images);
            Main.frame.add(test.getCardTable());
            Main.frame.add(test.getControls(), "Last");
    class CardMover implements ActionListener {
        CardTable cardTable;
        CardDealer cardDealer;
        public CardMover(BufferedImage[] images) {
            GameWindow.log.debug("Create new instances of cardTable and cardDealer");
            cardTable = new CardTable(images);
            cardDealer = new CardDealer(cardTable);
        public void actionPerformed(ActionEvent e) {
            String ac = e.getActionCommand();
                cardDealer.dealCards();
        public JPanel getCardTable() {
            return cardTable;
        public Box getControls() {
            Box box = Box.createHorizontalBox();
            JButton button = new JButton("Deal");
            button.addActionListener(this);
            box.add(button);
            return box;
    class CardTable extends JPanel {
        List<BufferedImage> cardImages;
        Rectangle left;
        Rectangle right;
        int x;
        int y;
        int lastCard;
        int currentCard;
        int nextCard;
        public CardTable(BufferedImage[] images) {
            cardImages = new ArrayList<BufferedImage>(Arrays.asList(images));
            resetCards();
        public void moveCard(double x, double y) {
            this.x = (int)x;
            this.y = (int)y;
            repaint();
        public void next() {
            lastCard = currentCard;
            currentCard = nextCard;
            nextCard++;
            if(nextCard == 10)
                resetCards();
            x = left.x;
            y = left.y;
        public void resetCards() {
            lastCard = -2;
            currentCard = -1;
            nextCard = 0;
            repaint();
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            if(left == null)
                initRects();
            g2.drawImage(cardImages.get(nextCard), left.x, left.y, this);
            if(lastCard > -1)
                g2.drawImage(cardImages.get(lastCard), right.x, right.y, this);
            if(currentCard > -1)
                g2.drawImage(cardImages.get(currentCard), x, y, this);
        private void initRects() {
            int iw = cardImages.get(0).getWidth();
            int ih = cardImages.get(0).getHeight();
            left = new Rectangle(100,100,iw,ih);
            right = new Rectangle(190,100,iw,ih);
            this.x = left.x;
            this.y = left.y;
    class CardDealer implements Runnable {
        CardTable cardTable;
        Thread thread;
        boolean dealing = false;
        int count = 0;
        final double SPEED = 20.0; // speed of cards
        final long DELAY = 15; // delay between cards
        final int MAX_CARDS = 10; //cards to deal in the sequence
        public CardDealer(CardTable ct) {
            cardTable = ct;
        public void dealCard() {
            start();
        public void dealCards() {
            if(!dealing) {
                Thread thread = new Thread(runner);
                thread.setPriority(Thread.NORM_PRIORITY);
                thread.start();
                new SoundApplet("sounds/C_Shuffle.au");
        public void run() {
            while(dealing) {
                try {
                    Thread.sleep(DELAY);
                } catch(InterruptedException e) {
                    GameWindow.log.error("Dealing thread interrupted");
                    stop();
                boolean finished = advanceCard();
                if(finished) {
                    stop();
        public void start() {
            if(!dealing) {
                cardTable.next();
                count = 0;
                dealing = true;
                thread = new Thread(this);
                thread.setPriority(Thread.NORM_PRIORITY);
                thread.start();
        private void stop() {
            dealing = false;
            if(thread != null)
                thread.interrupt();
            thread = null;
        private boolean advanceCard() {
            Point p1 = cardTable.left.getLocation();
            Point p2 = cardTable.right.getLocation();
            double distance = p1.distance(p2);
            double d = ++count*SPEED;
            double x = p1.x + d;
            if(d > distance)
                x -= d - distance;
            cardTable.moveCard(x, p1.y);
            return d > distance;
        Runnable runner = new Runnable() {
            public void run() {
                int count = 0;
                final int WAIT_FOR_END_OF_DEAL = 50;
                while(count++ < MAX_CARDS) {
                    dealCard();
                    while(dealing) {
                        try {
                            Thread.sleep(WAIT_FOR_END_OF_DEAL);
                        } catch(InterruptedException e) {
                            GameWindow.log.error("runner thread interrupted");
                            stop();
    }

  • Combine Two Queries

    Basically what the query is doing, is counting the number of times the speed is over 106. The second query is adding up the distance traveled while going over a speed of 106. Is it possible to add these queries together??
    select
        count("speed") as "speedOver106",
        "trek_id" as "speed_Trek_Id"
    from "QAMASTER"."cust_positions"
    where "speed" > 106
    and "date_time" between to_date('09/01/2006', 'MM/DD/YYYY') and  to_date('09/25/2006', 'MM/DD/YYYY')
    and "operator_id" in (2)
    group by "trek_id"
    SELECT
      p."trek_id", SUM(next_odometer-p."odometer") distance
      from
        SELECT
          t."trek_id", t."odometer",
          LEAD(t."odometer") OVER (PARTITION BY t."trek_id" ORDER BY t."odometer") next_odometer
        FROM QAMASTER."cust_positions" t
        where t."date_time" between to_date('09/01/2006', 'MM/DD/YYYY') and  to_date('09/25/2006', 'MM/DD/YYYY')
        and "speed" > 106
        and "operator_id" in (2)
      ) p
    GROUP BY p."trek_id"

    A count(*) in second query will do:
    SELECT
    p."trek_id", SUM(next_odometer-p."odometer") distance,
    count(*) as "speedOver106"
    from
    SELECT
    t."trek_id", t."odometer",
    LEAD(t."odometer") OVER (PARTITION BY t."trek_id" ORDER BY t."odometer") next_odometer
    FROM QAMASTER."cust_positions" t
    where t."date_time" between to_date('09/01/2006', 'MM/DD/YYYY') and to_date('09/25/2006', 'MM/DD/YYYY')
    and "speed" > 106
    and "operator_id" in (2)
    ) p
    GROUP BY p."trek_id"

  • How do you convert the encoder counts to RMP of the motor using a myRIO in LabVIEW?

    My intent is to gain hardware interfacing and general Labview experience. I am using a myRIO to control a Pittman 8222 34V Brushed DC motor (Motor Specs).
    I recently created a code to control the angle of this motor using PID, which was visually implemented using the black disc with a white tick mark on it (see attached picture: "IMG_2523"). 
    I now want to control the speed of this motor againg using PID, but I am not sure how to properly convert the encoder counts to RPM of this motor. I have attached 2 screen shots of my block diagram and my front panel for reference ("Capture" and "Capture2"). In the front panel picture, you can see my "actual" speed of the motor is a very choppy signal when it should theoretically be a flat line. To get the RPM, I currently use a shift register to store the current count value (which I converted to deg, then to radians), and then subtract the previous run's value, then divide by the while loop sampling time (10 ms). This would give me rad/s, which I then wrote a subVI to convert it to rpm. 
    Any help would be greatly appreciated, thanks. 

    Hi,
    One thing you could try doing is verifying that the conversion from rad/s to rpm is working correctly. 
    This tutorial might also be helpful. It's not using the same hardware that you are, but goes through the general steps using PID control. 
    CompactRIO Motor Control Basics Tutorial: http://www.ni.com/pdf/labview/us/compactrio_motor_control_basics.pdf
     

  • How to measure the rotational speed by using rotary encoder and 1 counter?

    I want to measure the rotational speed of a shaft, and I have below hardware:
    1, a rotary encoder, with A,B,Z signals output;
    2, PCI-E6363 card.
    I do konw how to use such a  encoder to measure the rotational angle by using the function "DAQmxCreateCIAngEncoderChan", but this time I need to measure the speed(rpm), as well as the dirction of the speed, which means a negative speed represent a CCW rotate direction.
    More detail informations:
    for the encoder, the A,B signal is 600ppr, and Z signal is 1ppr
    the rotatinal speed is in range: -300 ~ 5000 rpm.
    some one suggested me that I can use the "DAQmxCreateCIAngEncoderChan" task to measure the angle firstly and then do the differential analysis with the angle. but I have to enable the Z index function, and it's hard to calculate when the shaft speed is fast then 2500rpm.
    Anyone can help me on this issue?
    Thanks in advance!

    RobertoBozzolo:
    Thansk for your reply. You are right that measure frequency to get the speed is the best way, but it's hard to get the dirction at the same time. You suggest me that "perform two angle measurements to get the sense of rotation", but I'm not sure I catched what you mean about this. I try to understand your opinion like this: distribute the signals to 2 counters, and start 2 tasks, one for frequency, the other for angle which used for deciding the dirction?
    And by the way, in my application, the counter is limited:
    I'm using PCI-E6363, which have 4 counters totally, and I have to measure 4 different speed sensors at the same time, so that means only 1 counter for me to measure the speed and the dirction.
    RobertoBozzolo 已写:
    To measure the speed from the encoder you can simply follow some of the frequency measurement examples that ship with DAQmx, considering that speed (rpm) is given by frequency (Hz) on one encoder output / 600 (ppr) * 60 (s->min)  = frequency / 10.
    Difficult is to add a sign to this measurement: frequency measurement gives you no information about sense of rotation, so I suppose you could perform two angle measurements to get the sense of rotation and then get the speed as above.

  • Counting TTL pulses at high speed

    Hi all,
    I am using PCI-6221 board with DAQmx to count the number of TTL pulses (which varies in its frequency between 0Hz to 10MHz) at a high speed (200,000 samples/sec.) and I am having a problem when the TTL pulse frequency drops below a certain level.
    I am using CTR0 to generate continuous pulse train at 200kHz frequency to feed to CTR1 Gate input. I verified that the pulse train is being generated fine.
    I am using CRT1 with buffered counting to collect the count for 200,000 samples at a time (duration of 1 sec.). I got the example code (Cnt-Buf-Cont-ExtClk) and pretty much used it as is.
    CTR1 Gate is coming from CTR0 Out, which is 200kHz pulse train with 50% duty cycle, and CTR1 Source is the TTL signal that I am trying to count. At first, I thought that everything was working fine with the Source signal being at around 5MHz. Then, when I had the Source signal down below about 300kHz, I noticed that the program is taking longer than 1 sec. to collect the same 200k samples. Then, when I got the Source signal down to 0Hz, the program timed out.
    I am guessing that somehow the counter is not reading for the next sample when there has been no change to the count, but I cannot figure out why and how.
    Any information on this and a way to get around would be greatly appreciated.
    Kwang

    One thing you can try is to set the counter input CI.DupCounterPrevention property, this setting will filter the input, it is possible that when the ctr 0 is slow then many of the values you are counting become zero as well and are filtered out, since they are nolonger points, the counter will not collect enough points before the time-out occurs and the counter input read times out.  I am not sure if this is your issue but I found out the hard way that this occurs when I switched to daqMX where this feature was added.  Let me know if it worked,
    Paul
    Paul Falkenstein
    Coleman Technologies Inc.
    CLA, CPI, AIA-Vision
    Labview 4.0- 2013, RT, Vision, FPGA

  • Measuring speed with incrementa​l single counter

    Hi,
    I need to measure the rotational speed and acceleration of a wheel that has 3 hall sensors on it. I will use only 1 of them en it gives 24 pulses 0-5V for a 360° rotation. How can I measure the speed with only a pulse train. I dont have the Quadric encoder...
    Now I'd like to measure the rotational speed using a counter of some sort, but the software I tried writing for it isnt working.
    Thank you for your help

    Hey Nitch,
    Concerning the measurements errors:
    As you get error when speeding up, it looks like the pulses coming from the hall sensors are to short to get measured by the counter.
    Following the USB-6008 specifications, the pulse needs to have a minimum lenght of 100ns (both in high and low state).
    As a counter is using edges to count the pulses (for USB-6008 only the falling edge) the edges need to comply with the TTL specifications which means that the rise and fall time of the pulse needs to be within the 50ns range. 
    So please have a look at the pulse lenght at higher speeds (are they at least 100ns?) and make sure the pulse comply with the TTL specifications.
     If not you will have to add some additional electronics to reshape the pulses.
    Looking at your program.
    It's not nescesarry to have two loops.  It's very well possible to have two DAQ tasks within the same look.
    Have a look at the Examples which come with LabVIEW --> Exampled Finder --> Hardware Input/Output --> DAQmx --> Synchronization --> Multi-Function.
    There are some examples which so the combination of analog and digital input.
    Anyhow you will have to remove the right while loop as the DAQ Express VI which apparently gives you the "spanning, stroom, gashendel" values will only start once you have done the counter measurements.  I assume that you would like to have the "spanning", "stroom", "gashendel" and"speed" synchronized measured.
    Then you have the choice to log to file during acquisition or after the acquisition.
    If you would like to log on the fly don't use the express VI's, but use the lower lever "File I/O" functions. These are faster (less processor time usage).
    As you VI is written now, the left while loop will only output the lastest counter value measured to the next loop when you click the stop button for example.
    You have to "Enable Indexing" of the m/s output tunnel.  Right click on the tunnel and you will be able to select "Enable Indexing".
    This way the application will automatically create an array and each loop iteration the measured value will be added.  One the measurements have been done you can do analysis and save the data using the full array instead of point by point.
    Again, also bring your "spanning, stroom and gashendel" inputs to the left loop.
    In your right loop you also have a loop counter.
    You can simply use the loop iteraction counter (the square box in the left bottom corner with the i).  This is also counting from 0 and incrementing by 1 each loop iteration.
    Again, you can do this in the left loop and forget the second loop completely.
    Hopes this will bring you a step further.
    Don't hesitate to post the VI itself.  This is always easier to look at than an image.
    This way we can also make some modications and post it back.
    Best regards,
    Joeri
    National Instruments
    Applications Engineering
    http://www.ni.com/ask
    Make our forums great:
    If you like the answer, don't forget to "Kudos!".
    "Accept the Solution" if your question is answered!

  • Speeding up select count(*)

    Hi,
    I'm using a query : - SELECT COUNT(*) FROM tebevt01 a WHERE a.DAIRY_EVENT_ID IN (SELECT dairy_event_id FROM tebevt03) AND a.CREATE_TS BETWEEN '22-JAN-04' AND '12-DEC-04'
    Is there any particular optimizer hint that I can use to speed up the retrieval of data?
    Thanks,
    Bharath

    Hi Kuljeet,
    when the auto trace is on, and when i used 'WHERE EXISTS' i got : -
    Operation     Object Name     Rows     Bytes     Cost     Object Node     In/Out     PStart     PStop
    SELECT STATEMENT Optimizer Mode=CHOOSE          1           1                     
    SORT AGGREGATE          1      22                          
    FILTER                                        
    TABLE ACCESS FULL     DRIVER1.TEBEVT01     1      22      1                     
    INDEX RANGE SCAN     DRIVER1.IEVT0301     1      13                          
    when 'ORDERED' hint was used the explain plan gave : -
    Operation     Object Name     Rows     Bytes     Cost     Object Node     In/Out     PStart     PStop
    SELECT STATEMENT Optimizer Mode=CHOOSE          1           7                     
    SORT AGGREGATE          1      35                          
    NESTED LOOPS          1      35      7                     
    VIEW     SYS.VW_NSO_1     1      13      7                     
    SORT UNIQUE          1      13      7                     
    INDEX FULL SCAN     DRIVER1.IEVT0301     1      13                          
    TABLE ACCESS BY INDEX ROWID     DRIVER1.TEBEVT01     1      22                          
    INDEX UNIQUE SCAN     DRIVER1.IEVT0101     1                               
    what do u suggest? should there not be a full table scan which I think. or should the total 'cost' be low?
    what should be the 'cost'? high or low or is this irrelevant??
    thanks buddy,
    Bharath

  • I need to count intermitte​nt high speed pulses from an outside source with cFP-CTR-50​2 and labview.

    I need to count intermittent high speed pulses from an outside source with cFP-CTR-502 and Labview 8.2 . I've found example code for generating pulses and creating intricate count setups but no straightforward examples of a simple counter. Any suggestions?

    Hello tinfish,
    I could not find a simple example that implements simple counting either, but it should be straightforward enough for us to try. Do you have the CTR module configured properly in MAX? If so, can you monitor the channels on your CTR 502 for input? Try connecting a square wave or some other digital pulse to the terminal to test the functionality of the counter module first (before programming). If you monitor the input channels with somethign connected you should see the count increment each time it sees a rising edge (assuming default configuration).
    Once you've verified that everything works in MAX, you can set up your CTR module in a LV 8.2 project. If you need help with this, refer to the help document (look in the "Configuring FieldPoint in LabVIEW" section):
    C:\Program Files\National Instruments\FieldPoint\documentation\Online Help\fplv.chm
    You should be able to just read a channel tag from your CTR 502 using an FP Read VI. (Simply drag the channel from your project onto the block diagram). Since counting is the default behavior of the 502, there is no special programming involved to make it work.
    I hope this helps -- if it's too high-level we can talk details about specific questions you have.  Have a good one!
    Charlie S.
    Visit ni.com/gettingstarted for step-by-step help in setting up your system

  • Speed up daq counter

    Hi,
    I'm trying to determine the pulse width of a signal by using the counter of a NI USB 6216. This works reasonably well, except the acquisition is too slow for my needs.
    Below you can see a stripped down version of my acquisition vi. In the version depicted stage 2 of the loop takes 3ms to execute. This is the time expected to count the appropriate number of low times (20) in the signal I'm measuring. The whole loop takes 30ms however (measured beginning to end of loop - not beginning to beginning of next iteration).
    If I remove start task and stop task vis the loop time doesn't change, the whole time apparently taken up by the read vi.
    I'd like the loop to run with less overhead (ideally none :-). Can anyone with more experience shed some light on how to speed up this vi?
    Regards Florian
    Solved!
    Go to Solution.

    Partially puzzled by two things that seem in conflict:
    1. you're doing a finite triggered task that intentionally misses some pulses while it stops and restarts
    2. you're expressing some concern about those missing pulses
    One idea to make the stop and restart faster is to use DAQmx Control Task to "commit" the task before starting.
    When you do that, cycles of stop and restart can occur much faster than they would otherwise.  An example and
    some benchmark results can be found here.
    Another idea is to perform continuous acquisition of the pulse measurements so you won't miss any.  Depending
    on your app, that may leave you with the job of timestamping the trigger signals with another counter, and
    working a scheme to correlate particular pulse measurement subsets with particular trigger events.  Not a trivial
    job, but a do-able one.
    -Kevin P
    P.S.  Just re-checked and noticed you're using a USB board.  I suspect that's a significant part of the problem.
    There's more latency & overhead with USB acquisition, and the effect is stronger when you request small packets
    at a high rate than if you requested large packets at a lower rate.
    P.P.S.  Looks like you alread got an answer before I hit send -- I was just typing a minute here, a minute there
    while do some other testing. 

  • How to use PCI-6534 High speed DIO to count the no.of pulses aquired

    HI All
    I have PCI-6534 high speed DIO card. My requirement is to count the no.of pulses coming. Here i have an energy meter which generates pulses with frequency of around 8MHz. i need to cunt the no. of pulses coming in, here i am attaching the VI i am using. I could not really count all pulses coming in. right now i am using single line, but the requirement is to develop for 7 lines. I do not know where i am going wrong. Can any of you help me in this regards.
    Thanks
    Anil Punnam
    Attachments:
    Read Dig Chan-Change Detection_stop.vi ‏120 KB

    Sorry, not near a LV PC so can't look at your vi now.  Are you limited to using only the 6534?  If all you need to know is the count of pulses from each of the 7 ~8MHz sources, it seems like the amount of data storage required with a 6534 is terribly inefficient.  Since the 7 sources are unlikely to be synchronized in any way and they are each at ~8MHz, you're looking at about 100+ million transitions per second with change detection.  I don't think the hw can keep up with that.  Even using a constant sampling rate of 20 MHz (which just barely satisfies the Nyquist minimum of 2x 8MHz), it's questionable whether you can keep up with that rate for several minutes.  Even supposing the hw and your PCI bus and software can keep up, there's still a TON of processing to do.  20 MB/sec for 20 minutes = 24 GB! 
    On the other hand, consider the 6602 counter timer board.  Here you would simply set up 7 edge counting tasks, probably without any buffering at all.  At any leisurely pace you want, you can software query the counts of the # of pulses on each of the 7 channels and have an instant answer.  The only issue to deal with is that the counts will rollover when you reach 2**32.  At 8 MHz, this will happen about every 9 minutes.  However, DAQmx provides a nice way to handle this.  There's a property you can query that will tell you if a rollover has occurred.  It automatically resets itself to False after you read it so it's ready to detect the next rollover 9 minutes later.  See my first post in this thread for example.  (Last I knew, only DAQmx does the automatic reset, not traditional NI-DAQ).
    If you can possibly buy a 6602, I'd highly recommend it.
    -Kevin P.

  • MyRIO counting short pulses

    Hello All,
    I am using a NI myRIO and want to count square wave pulses with rather short duty cycles (less than 20%).  I have set up a VI that does a digital read on the proper pins, but it is missing many of the pulses.  Does anyone have a suggestion for how to catch all of these quick pulses without actually inserting hardware to make the duty cycle longer.
    Thank you so much.
    Attachments:
    Main.vi ‏186 KB
    Simple Edge Detection.vi ‏9 KB

    200us equates to roughly 5kHz minimum. Of course, you could still miss the pulse by sampling at even 10k (nyquist minimum) as the edges could possibly be missed. It would be good to sample 4 times faster than the 200us edge to get a valid reading. To do this, you will need to write some LabVIEW FPGA code. Currently, you are using the DI Express VI which runs onthe Real-Time (RT) OS. Even though the hardware (the FPGA) can sample very fast, the RT loop rate is the limiting factor. 
    There is examples in the example finder for counting edges in LabVIEW FPGA. If you navigate to Example Finder » Hardware Input and Output » CompactRIO » FPGA Fundamentals » Counters » Event Counters, you can find several good examples. Here is a screenshot of one:
    Tannerite
    National Instruments

  • High speed event counting

    I am looking to count events where an event is defined by 1 ttl pulse of 30ns (A newer device allows for 3V 9ns)  I prevoiusly used the6602 but am looking to make a standalone singleboard rio application.  When talking to some engineers this I was told that this was possible, but looking at the spect there needs to be a 100ns min pulse width.  Are there any work arounds?  Is it possible to add sme chip as a prescalar to the input (divide by 10 highspeed counter?)  I am stuck and am ready to meke some hardware decisions.
    Paul Falkenstein
    Coleman Technologies Inc.
    CLA, CPI, AIA-Vision
    Labview 4.0- 2013, RT, Vision, FPGA

    falkpl,
    As I am not certain if a moderator can move a post, the best way would probably be to re-post the question on your desired board. Be sure to post a link here to the new discussion. You generally want to avoid double-posting, but as long as it is clear that this discussion was moved to another place, most people will forgive you. 
    Now, assuming you have not posted elsewhere, I will comment on your issue. The sbRIO's have IO pins that allow you to connect right into the FPGA. As you have found, the manual guarantees a 10 MHz rate and states you can get a bit faster if you are acquiring a single 3.3 V signal.
    To get even faster, you may have a few options.
    Use a deserializer to break up one high speed signal into multiple slower signals.
    A similar idea which will not require external hardware, but maybe a bit more programming is to read the same channel on several inputs with slightly staggered start times. This post discusses the idea a bit more.
    Good luck, let us know your thoughts and how it turns out.
    Peter Flores
    Applications Engineer

Maybe you are looking for

  • MacBook late 2008 - stuck in clamshell mode

    This laptop was recently attached to an external display and all was fine - running in either mirror or non-mirror mode. When I last saw it it was set to mirror mode and the lid closed to effect "clamshell" mode. Recently however it has got into a st

  • Seems to be a common recent iTunes problem

    In searching the forum, I've found a few people experiencing this problem, but no solutions...perhaps someone has come across a solution? Yesterday, iTunes informed me that my Library file was damaged, saved it under a different name and opened a new

  • A problem to display a jsp Using MVC approach

    Hello everybody I have got a problem with RequestDispatcher and I would like to get your help. I excpect the servlet to display the index.jsp page but the server displays a blank page. web.xml's <servlet> and <servlet-mapping> are set correctly at th

  • FLVPlayer appearing in Safari and not Firefox

    I've created a custom FLV skin and embedded it in a .swf file so that captions are rotating over top of the video. The FLV skin contains a play/pause button, a mute button and a frame that is overtop of the video. The ideal final product is below: Th

  • How to create HRP type infotype ?

    Hi All , I have an requirement that i have to create (ECC 5.0) a HRP infotype (9330)... and am trying this from PPCJ (Tcode) but am not able to create ... When am going to create the infotype in PPCJ its giving the message.... <b>' Infotype 9330 cann