RS232 : pilot a relay command

I should pilot a relay with RS232 port. If i use the RTS or DTR signals, can i command my relay without damage for my pc

Hi,
I am not sure that I understand your question. Are you going to try to power a relay with a serail port? I wouldn't do this at all. The serial port can't supply enough current to keep the gate closed. You run the risk of blowing up your serial port. I would create a circuit to buffer the output (or better yet, go with a digital card of some sort). You might be able to use some sort of optical isolation circuit to accept the 5 volt input and output the correct voltage/current to power a relay.
Best Regards,
Aaron K.
Application Engineer
National Instruments

Similar Messages

  • Mac Mini - USB/RS232 Cable - help to command display

    Could anyone help out with advice in a project where we would like to put a monitor in different modes from a Mac Mini.
    The interface for the commands to the display is a RS232 serial port. As Mac Mini has no RS232 port but there are USB to RS232 cables on the market our question is if one could use apple script or shell script to make the job?
    Would really appreciate any advice!

    this has absolutely nothing to do with scripting. you need a USB to serial adapter.

  • Relaying commands and objects

    I've been wondering about something for a while, and I'm hoping one of you gurus can help me out.
    Ok. I have a Frame that functions as my application's main window, and this has all sorts of sub-components like fields, check-boxes, etc. There's a List (JList extension) that displays a list of files that are automatically checked for consistency and parseablility whenever the user changes the program's working directory.
    When the user double-clicks on the JList, the program parses the file (in this case, it's an XML feed file.), and executes this method:
        private void dispatchSelectionEvent()
            ((MainApplicationForm) SwingUtilities.
                    getAncestorOfClass(MainApplicationForm.class,  this)).buildFeed(getSelectedFile());
        }Then, the MainApplicationForm will grab the XML feed via the buildFeed() method and populate all of its subcomponents with values from the feed.
    Hideous? I think so. Immediately it precludes the possibility of using the component in a window that does not have a MainApplicationForm in its hierarchy. I've thought about using generics and searching the hierarchy for the appropriate class, etc.
    Now, I've been able to use the Command pattern to implement an Action class that pretty much does the same thing, but allows the List to be used more generically, but I'd love to know how the pros would normally handle something like this.
    Joe

    Hi Ram,
    the documentation how the MATLAB data acquisition toolbox is calling the NI Drivers should be in the MATLAB Toolbox.
    A Dokumentation of the National Instruments DAQmx Drivers are in the Drivers as a Help when you install them.
    How MATLAB handles the NI Driver within its own toolbox you should ask MATLAB because this is nothing National Instruments can influence.
    But maybe the MathWorks Product Page and the Support on it may help you. They have a Documentation linked there.
    http://de.mathworks.com/products/daq/
    Best wishes
    Tenshinhan

  • DHCP Relay Cisco SG500X

    Hi, 
    I've create 2 vlan in a cisco SG500X-24 and a DHCP server on vlan 2. I just want to dhcp server assign ip to devices on vlan 3. I've configured the vlan and dhcp server relay commands.
    ip dhcp relay address 192.168.1.11
    ip dhcp relay enable
    ip dhcp information option
    interface vlan 2                                      
     ip address 192.168.1.250 255.255.255.0
    interface vlan 3
     ip address 192.168.51.254 255.255.255.0
     ip dhcp relay enable
    The dhcp server gets the request from pc, and sends a new address, but the offer packet not comes to device. With Wireshark a see like offer dhcp packet can't jump to vlan 3.
    It's the first time a work with SMB series, and this never happens with catalyst. I'm turning crazy.
    Anyone can help me? Thank you in advances.
    Victor.

    Hi,
    Yes, also I configured ip dhcp relay on intefaces.
    Yesterday I found the trouble. I was using the tftpd32 dhcp server, and I tested with a Windows DHCP server and everything works like a champ. I didn't know what have do, and i turned crazy, so I began to change every element on solution, finally the DHCP server that it was the key.
    Thank you so much for your answer.
    KR!

  • Need to control waterbath temp using labview via RS232

    HI,
    I am new to labview. I have labview 6.1. I need to control a thermo RTE7 water bath temp.  controler using labview.
    The water bath has to be connected to computer via RS232 port and the commands have to be given via binary values.
    The users manual for the bath has "hex" bytes that are to be converted
    to binary values to be passed to bath. If anyone has done this before
    or anyone can help me on this please let me know. Thanks,

    Use simply the recommandations given in the RTE manual. You don't have to convert to binary : that's something done by the hardware.
    For instance, to send the temperature setpoint to the controler, you have to send a byte string such as
    CA 00 01 F0 02 01 2C DD, where CA 00 01 is a header specific to the type of serial link you are using,
    F0 is the set temperature command,
    02 is the number of bytes expressing the temperature that you are about to send
    01 0C is the temperature in tenths of degree (here : 30°C = 300 tenth = 010C$
    DD is a check sum byte.
    The corresponding labVIEW program is as follow :
    Of course, do not forget to initialize the serial port before writing the string !
    Message Edité par chilly charly le 10-21-2005 06:21 AM
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    Water bath.png ‏4 KB
    Water bath.vi ‏28 KB

  • Wago 750-841- labview pour piloter le process

    Bonjour,
    je suis étudiant en stage, je veux mettre sur place une application capable de piloter un système automatisé ( des vannes tout ou rien, pilotée et commandée)  via le controleur ethernet Wago 750-841 en utilisant le langage graphique Labview. Je dispose du logiciel CodeSys et mon automate est relié directement au PC, donc je ne suis pas en réseau.
    Mon soucis est que je ne sais pas si on peut utiliser Labview dans CodeSys sans etre relié à un serveur pour communiquer avec l' automate wago  afin de commander mes vannes et effectuer une supervison des pressions sur le process.
    Je sollicite vivement votre aide.
    Merci d'avance:smileyhappy :
    Transistor.

    Merci Yoann, pour ton éclaircissement.
    J'ai utilisé CodeSys pour configurer le controleur Wago. Juste une question est ce que par programmation graphique (Labview ou Ladder) j'arriverai à commander mon process, sans passer par internet car je travail en local.

  • I'd like to Pilot Parallel Port an its seperate bits

    Hi...
    I'd like to pilot 8 relays with the normal parallel-port of a PC using LabView. In this case I have to pilot 9 bits of the parallel port. How can I realise to pilot the parallel port and the seperate bits and which VI should be used?
    Message Edited by Sushi on 05-16-2006 11:05 AM
    Message Edited by Sushi on 05-16-2006 11:05 AM

    Hi Sushi,
    The first thing to investigate is whether the PC's parallel port can actually drive that many relays due to loading conditions.  Check out the specs of your PC's bus versus the loading requirements (typically mA) for a given relay. 
    As for controlling the relay using the parallel port, you can have a look at the example provided by Labview by searching within the Help menu, under "Find Examples", then search "parallel port".  Although reading & writing to the parallel port is relatively easy, the nice thing with the examples is that it provides information on each line of the port (data vs control, etc).  I also posted an attachment a few years ago on how to set up the port.  This was used to open / close relays..  I will look for the thread.
    Regards,
    JLV

  • Losing communication with DAQ devices - help greatly appreciated

    All,
    I have been working on a VI whose function is the following:
    - Acquire data from three sources
         - A block of eight displacement sensors connected via RS232 (using a USB adapter)
         - An NI-USB 6210 card measuring voltages across eight batteries
         - Another NI-USB 6210 card measuring voltage across four load cells (these correspond to batteries one through four).
         - Data acquired at 1 Hz, written at 0.2 Hz (no buffer - simply writes one fifth of data recorded)
    - Open/close a relay board based on certain inputs
    - Provide basic UI functionality to control data manipulation, display data, and write data to text files
    - Write data to text files
    We have run four tests with this VI.  Each test runs for anywhere from 24 to 48 hours.  During three of these four tests, we have lost connection with one or both of our NI DAQ cards.  I have attached one of the output files - notice that in the 'Current (mA)/Voltage (V)' and 'Load (N)' columns, at a certain point on of the cards starts reading 'NaN', followed soon after by the other card.  Note that this has happened on two different computers, one laptop and one desktop, both of which had hibernate/sleep disabled.
    For your reference, I have attached the VI.  This VI will not run as there are some subVIs that I have not included; these subVIs do not do anything critical to the execution of the program.  The program generally runs as follows:
    - Initially, a subVI runs that aids the user in selecting the appropriate COM port and USB devices.
    - The VISA device and DAQ cards are initialized, all relays are opened, variables are initialized
    - In parallel, there are two producer timed loops, one consumer for loop and an event loop
         - One producer loop continuously acquires voltage data from both DAQ cards.  When the loop is over, basic DC voltage values are taken from all samples in each buffer, and the values are enqueued
         - One producer loop acquires one reading per loop from the displacement sensor (via a VISA Write -> VISA read), and the response string is enqueued.  
         - The consumer loop runs at a similar timing as the producer loops (blocked using queues).  It manipulates, displays, and records acquired data. It also opens relay channels if the corresponding displacement values are greater than a set threshold.
         - The event loop opens text files for writing when a button is depressed, as well as performing basic tasks such as clearing graphs, etc. 
    What is the cause of this issue?  What am I doing wrong?  This error is preventing us from running tests at our company.  Any help is greatly appreciated.
    Thank you,
    Bryan
    Attachments:
    DAQ issue VI.vi ‏124 KB
    sample output.txt ‏1230 KB

    Wayne,
    Thanks for your reply.  Unfortunately, my knowledge is limited in this area.  We are using an ADU208 USB relay from Ontrak (information here: http://www.ontrak.net/ADU208.htm).  We are using the bundled subVIs to open/close each channel of the relay depending on the acquired data.  How could this relay board affect the DAQ communication?  
    It may also be important to note - I have tried to make this VI so that all devices need not be used all of the time.  That is, sometimes we choose to not use the relay, sometimes we choose to not measure load, and sometimes we choose not to measure current.  This means that we do not always have the same hardware connected, but the software runs the same and deals with the resulting errors appropriately (hopefully).  The previously attached output file is from a test where the relay was not connected, however the relay commands were still run (and presumably threw errors).
    Thanks again for your help
    Bryan

  • Permissions Error Dispite using a Signed Jar

    I have developed a PC program that has a built in web server for talking with and relaying command to a device attached to the COM port. Now Right now I'm using JavaScript to talk with the programs web interface. Now this brought browser compatibility issues though, because commands could be relayed to the programs web interface from a cross domain. Dispite adding in the needed header output records to allow it. Only one browser had the ability to do this. So I created a extremely basic java applet that just opens the web pages on the programs web server and returns the output from the web server to a Javascript function on the parent document to be handled as needed.
    Now while this worked great going from localhost to localhost. I then moaved the applet to another computer on the network and tired localhost again and got:
    java.security.AccessControlException: access denied (java.net.SocketPermission localhost:988 connect,resolve).Well at first I thought "Oh I forgot to sign the jar." So i signed the jar file and it still kicked back the same error.
    Now the only way i could get rid of the error was adding a policy entry, but that is not acceptable because of a number of reasons. So it could very well be something in my code. Though I'm not sure. As you can see below it is very simplistic.
    public void CallTimeServ(String Target)
             URL                url;
             URLConnection      urlConn;
             DataInputStream    dis;
               try {
                   url = new URL(Target);
                   urlConn = url.openConnection();
                  urlConn.setDoInput(true);
                  urlConn.setUseCaches(false);
                  dis = new DataInputStream(urlConn.getInputStream());
                  String JSon;
                  while ((JSon = dis.readLine()) != null)
                       ContentsRetrived(JSon);
                  dis.close();
              } catch (MalformedURLException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         public void ContentsRetrived(String msg)
              try
                   msg = msg.replace("'", "\'");
                   getAppletContext().showDocument(new URL("javascript:ContentsRetrived('" + msg +"')"));
              catch (MalformedURLException me) { }
         public void init()
        }So any one have any ideal on how to to do this. With out requiring a policy file entry?

    Phil - did you check out http://otn.oracle.com/products/forms/pdf/SigningJint13.pdf
    regards
    Grant Ronald
    Forms Product Management

  • How to add sql lite winrt

    I am Beginner winrt and sql lite ,  I am creating app that Customer table
    I want how to add data to the Table, edit the data, delete selected data, and delete all
    Please help me Any One
    Here code maybe wrong please right code provide me
    using SQLite;
    namespace MVVM.Models
        public class Customer
            [PrimaryKey, AutoIncrement]
            public int Id { get; set; }
            public string Name { get; set; }
            public string City { get; set; }
            public string Contact { get; set; }
    /////  Relay Command
    /// <summary>
        /// A command whose sole purpose is to relay its functionality
        /// to other objects by invoking delegates.
        /// The default return value for the CanExecute method is 'true'.
        /// <see cref="RaiseCanExecuteChanged"/> needs to be called whenever
        /// <see cref="CanExecute"/> is expected to return a different value.
        /// </summary>
        public class RelayCommand : ICommand
            private readonly Action _execute;
            private readonly Func<bool> _canExecute;
            /// <summary>
            /// Raised when RaiseCanExecuteChanged is called.
            /// </summary>
            public event EventHandler CanExecuteChanged;
            /// <summary>
            /// Creates a new command that can always execute.
            /// </summary>
            /// <param name="execute">The execution logic.</param>
            public RelayCommand(Action execute)
                : this(execute, null)
            /// <summary>
            /// Creates a new command.
            /// </summary>
            /// <param name="execute">The execution logic.</param>
            /// <param name="canExecute">The execution status logic.</param>
            public RelayCommand(Action execute, Func<bool> canExecute)
                if (execute == null)
                    throw new ArgumentNullException("execute");
                _execute = execute;
                _canExecute = canExecute;
            /// <summary>
            /// Determines whether this <see cref="RelayCommand"/> can execute in its current state.
            /// </summary>
            /// <param name="parameter">
            /// Data used by the command. If the command does not require data to be passed, this object can be set to null.
            /// </param>
            /// <returns>true if this command can be executed; otherwise, false.</returns>
            public bool CanExecute(object parameter)
                return _canExecute == null ? true : _canExecute();
            /// <summary>
            /// Executes the <see cref="RelayCommand"/> on the current command target.
            /// </summary>
            /// <param name="parameter">
            /// Data used by the command. If the command does not require data to be passed, this object can be set to null.
            /// </param>
            public void Execute(object parameter)
                _execute();
            /// <summary>
            /// Method used to raise the <see cref="CanExecuteChanged"/> event
            /// to indicate that the return value of the <see cref="CanExecute"/>
            /// method has changed.
            /// </summary>
            public void RaiseCanExecuteChanged()
                var handler = CanExecuteChanged;
                if (handler != null)
                    handler(this, EventArgs.Empty);
    /// ViewModel Base
    class ViewModelBase
            public event PropertyChangedEventHandler PropertyChanged;
            protected virtual void RaisePropertyChanged(string propertyName)
                var handler = this.PropertyChanged;
                if (handler != null)
                    handler(this, new PropertyChangedEventArgs(propertyName));
    ///MainPageViewModel
    class MainPageViewModel : ViewModelBase
            #region Properties
            private int id = 0;
            public int Id
                get
                { return id; }
                set
                    if (id == value)
                    { return; }
                    id = value;
                    RaisePropertyChanged("Id");
            private string name = string.Empty;
            public string Name
                get
                { return name; }
                set
                    if (name == value)
                    { return; }
                    name = value;
                    isDirty = true;
                    RaisePropertyChanged("Name");
            private string city = string.Empty;
            public string City
                get
                { return city; }
                set
                    if (city == value)
                    { return; }
                    city = value;
                    isDirty = true;
                    RaisePropertyChanged("City");
            private string contact = string.Empty;
            public string Contact
                get
                { return contact; }
                set
                    if (contact == value)
                    { return; }
                    contact = value;
                    isDirty = true;
                    RaisePropertyChanged("Contact");
            private bool isDirty = false;
            public bool IsDirty
                get
                    return isDirty;
                set
                    isDirty = value;
                    RaisePropertyChanged("IsDirty");
            #endregion "Properties"
            public ObservableCollection<Customer> _customerlist { get; set; }
     public Person CustomerToAdd { get; set; }
            /// <summary>
            /// Add Customer data to the table
            /// </summary>
            public RelayCommand AddCusomerCommand { get; set; }
            private void addCustomer()
            /// <summary>
            /// Delete Selected Customer data from the table
            /// </summary>
            public RelayCommand DeleteSelectedCustomerCommand { get; set; }
            private void deleteSelectedCustomer()
            /// <summary>
            /// edit Selected Customer data from the table
            /// </summary>
            public RelayCommand EditSelectedCustomerCommand { get; set; }
            private void editSelectedCustomer()
            /// <summary>
            /// Delete All Customer data from the table
            /// </summary>
            public RelayCommand DeleteAllCustomerCommand { get; set; }
            private void deleteAll()
            public MainPageViewModel()
                AddCusomerCommand = new RelayCommand(addCustomer);
                DeleteAllCustomerCommand = new RelayCommand(deleteAll);
                EditSelectedCustomerCommand = new RelayCommand(editSelectedCustomer);
                DeleteSelectedCustomerCommand = new RelayCommand(deleteSelectedCustomer);
    /////////// App.Xaml.Cs
    sealed partial class App : Application
            /// <summary>
            /// Initializes the singleton application object.  This is the first line of authored code
            /// executed, and as such is the logical equivalent of main() or WinMain().
            /// </summary>
            public App()
                this.InitializeComponent();
                this.Suspending += OnSuspending;
            /// <summary>
            /// Invoked when the application is launched normally by the end user.  Other entry points
            /// will be used such as when the application is launched to open a specific file.
            /// </summary>
            /// <param name="e">Details about the launch request and process.</param>
            protected override void OnLaunched(LaunchActivatedEventArgs e)
    #if DEBUG
                if (System.Diagnostics.Debugger.IsAttached)
                    this.DebugSettings.EnableFrameRateCounter = true;
    #endif
                Frame rootFrame = Window.Current.Content as Frame;
                // Do not repeat app initialization when the Window already has content,
                // just ensure that the window is active
                if (rootFrame == null)
                    // Create a Frame to act as the navigation context and navigate to the first page
                    rootFrame = new Frame();
                    // Set the default language
                    rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];
                    rootFrame.NavigationFailed += OnNavigationFailed;
                    if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                        //TODO: Load state from previously suspended application
                    // Place the frame in the current Window
                    Window.Current.Content = rootFrame;
                var dbpath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path,"data.db3");
                using (var db = new SQLite.SQLiteConnection(dbpath))
                    // Create the tables if they don't exist
                    db.CreateTable<Customer>();
                    db.Commit();
                    db.Dispose();
                    db.Close();
                if (rootFrame.Content == null)
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(MVVM.Views.Page1), e.Arguments);
                // Ensure the current window is active
                Window.Current.Activate();
            /// <summary>
            /// Invoked when Navigation to a certain page fails
            /// </summary>
            /// <param name="sender">The Frame which failed navigation</param>
            /// <param name="e">Details about the navigation failure</param>
            void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
                throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
            /// <summary>
            /// Invoked when application execution is being suspended.  Application state is saved
            /// without knowing whether the application will be terminated or resumed with the contents
            /// of memory still intact.
            /// </summary>
            /// <param name="sender">The source of the suspend request.</param>
            /// <param name="e">Details about the suspend request.</param>
            private void OnSuspending(object sender, SuspendingEventArgs e)
                var deferral = e.SuspendingOperation.GetDeferral();
                //TODO: Save application state and stop any background activity
                deferral.Complete();
    /// xaml Code
    <Page.DataContext>
            <ViewModels:MainPageViewModel>
            </ViewModels:MainPageViewModel>
        </Page.DataContext>
        <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <ListView ItemsSource="{Binding _customerlist}"
                      HorizontalAlignment="Left" Margin="44,65,0,327" Width="456">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Width="400" Background="Chocolate">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Name}" FontSize="30" />
                                <TextBlock Text="," FontSize="30" />
                                <TextBlock Text="{Binding City }" FontSize="30" />
                            </StackPanel>
                            <TextBlock Text="{Binding Contact}" FontSize="30" />
                        </StackPanel>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
            <Button Command="{Binding  AddCustomerCommand}"
              Content="Add person"
              FontSize="40" Margin="588,465,0,230"/>
            <Button Command="{Binding EditSelectedCustomerCommand}"
              Content="Edit"
              FontSize="40" Margin="865,465,0,230"/>
            <Button Command="{Binding DeleteSelectedCustomerCommand}"
                    Content="Delete"
                    FontSize="40" Margin="1037,465,0,230" />
            <Button Command="{Binding DeleteAllCustomerCommand }"
                    Content="Delete All"
                    FontSize="40" Margin="979,619,0,76" />
            <TextBlock Text="Name" FontSize="30" Margin="633,65,598,640" Height="63"/>
            <TextBox DataContext="{Binding PersonToAdd}" Text="{Binding Name, Mode=TwoWay}"
                     FontSize="30" Margin="868,62,80,640"/>
            <TextBlock Text="City " FontSize="30" Margin="633,181,551,524"/>
            <TextBox DataContext="{Binding PersonToAdd}" Text="{Binding City, Mode=TwoWay}"
                     FontSize="30" Margin="868,181,80,525"/>
            <TextBlock Text="Age" FontSize="30" Margin="633,296,536,400"/>
            <TextBox DataContext="{Binding PersonToAdd}" Text="{Binding Contact, Mode=TwoWay}"
                     FontSize="30" Margin="868,296,80,403"/>
        </Grid>

    http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=wpf
    The above fourm use MVVM and they can help you there.

  • REINSTALL DMS_JOBS

    Hi friend...
    I have Database server with a litte problem...
    I gave to an user "PILOT" the grant to execute the package DBMS_JOB.
    The problem is that try use logged with the user PILOT, execute the command DBMS_JOB.SUBMIT
    But the command it isn't executed, returning the message that DBMS_JOB, it isn´t valid procedure.
    If try using SYS.DBMS_JOB.SUBMIT, logged with the user PILOT, the command it is executed sussefull.
    The problem the I can´t use the command SYS.DBMS_JOB.SUBMIT because that will need change many program lines from my aplication and many servers.
    But this problem there is only one Database server ther others are OK!
    If i need reinstall DBMS_JOB package how do I do it?
    Thanks!
    Edited by: user10431761 on 15/10/2008 06:43

    Pavan, considering the fact that grants to public are often removed immediately after installation I do not see issuing the grant execute on dbms_jobs to pilot as a problem even if the public grant exists.
    Since user Pilot can execute the package as sys.dbms_jobs.submit then i would suspect that either the public synonym is missing or the execute is inside of stored code and a direct grant to user pilot is required.
    The OP has not provided us with how the grant was done or the status of the public synonym. I think we need this to be able to figure out what the probme is.
    IMHO -- Mark D Powell --

  • MVVM Light Bind value to list on button click

    I am trying to build an simple universal app and I have followed the MVVM light setup. So far everything has fallen in place. Now I have a button and a listview on the same page. What I am trying to achieve is when I click on the button I want the list
    view to show values. I have the list view bound to an observable collection and the button bound to RelayCommand. When I click the button the relay command is executing and returning values which I add to the observable collection, but myview is not getting
    updated. when i directly create object in my design mode and in runtime the view is updating properly. Please provide any suggestion.
    Code Section
    View
    <Page
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:CorrectMetroCardFare"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:ViewModel="using:CorrectMetroCardFare.ViewModel"
        x:Class="CorrectMetroCardFare.MainPage"
        mc:Ignorable="d"
        Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
        DataContext="{Binding Main, Mode=OneWay, Source={StaticResource Locator}}">
        <Grid Height="640" Margin="0,0.333,0,-0.333" VerticalAlignment="Top">
            <TextBlock x:Name="title" Text="Metro Card Fare"  Margin="0,10,0,603"/>
            <TextBox x:Name="txtCurrentValue" InputScope="Number" PlaceholderText="Enter your Current Balance" Margin="0,53,0,0" Text="{Binding CurrentBalance, Mode=TwoWay}"/>
            <Button Content="Show Fares" HorizontalAlignment="Left" Margin="96,113,0,0" VerticalAlignment="Top" Command="{Binding ShowFaresCommand, Mode=OneWay}" CommandParameter="{Binding
    CurrentBalance}" />
            <ListView x:Name="nbc" SelectionMode="Single" Margin="10,182,10,150" ItemsSource="{Binding Charges}">
                <ListView.Resources>
                    <DataTemplate x:Key="FareTemplate">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="{Binding AmountToRecharge}" TextAlignment="Right" Grid.ColumnSpan="4"
    Margin="0,0,-28,0" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource TextStyleLargeFontSize}"></TextBlock>
                            <TextBlock Text="{Binding BonusAmount}" TextAlignment="Right" Margin="118.333,0,-128.333,0"
    Grid.Column="3" FontSize="{StaticResource TextStyleLargeFontSize}"/>
                            <TextBlock Text="{Binding NewBalance}" TextAlignment="Right" Margin="118,0,-229.333,0"
    Grid.Column="3" FontSize="{StaticResource TextStyleLargeFontSize}"/>
                            <TextBlock Text="{Binding NumberofRides}" TextAlignment="Right" Margin="298,0,-308.333,0"
    Grid.Column="3" FontSize="{StaticResource TextStyleLargeFontSize}"/>
                        </Grid>
                    </DataTemplate>
                    <ItemsPanelTemplate x:Key="FaresPanelTemplate">
                        <VirtualizingStackPanel Orientation="Vertical"></VirtualizingStackPanel>
                    </ItemsPanelTemplate>
                    <DataTemplate x:Key="headerTemplate">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="90" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="Amount to Recharge" Grid.Column="0" TextWrapping="WrapWholeWords" FontFamily="{StaticResource
    PivotHeaderItemFontFamily}" FontSize="{StaticResource ContentControlFontSize}"/>
                            <TextBlock Text="Bonus Amount" Grid.Column="1" TextWrapping="WrapWholeWords" FontFamily="{StaticResource
    PivotHeaderItemFontFamily}" FontSize="{StaticResource ContentControlFontSize}"/>
                            <TextBlock Text="New Balance" Grid.Column="2" TextWrapping="WrapWholeWords" FontFamily="{StaticResource
    PivotHeaderItemFontFamily}" FontSize="{StaticResource ContentControlFontSize}"/>
                            <TextBlock Text="Number of Rides" Grid.Column="3" TextWrapping="WrapWholeWords" FontFamily="{StaticResource
    PivotHeaderItemFontFamily}" FontSize="{StaticResource ContentControlFontSize}"/>
                        </Grid>
                    </DataTemplate>
                </ListView.Resources>
                <ListView.HeaderTemplate>
                    <StaticResource ResourceKey="headerTemplate"/>
                </ListView.HeaderTemplate>
                <ListView.ItemsPanel>
                    <StaticResource ResourceKey="FaresPanelTemplate"/>
                </ListView.ItemsPanel>
                <ListView.ItemTemplate>
                    <StaticResource ResourceKey="FareTemplate"/>
                </ListView.ItemTemplate>
                <ListView.DataContext>
                    <ViewModel:MainViewModel/>
                </ListView.DataContext>
            </ListView>
        </Grid>
    </Page>
    View Model
         /// <summary>
                    /// Sets and gets the DayList property.
                    /// Changes to that property's value raise the PropertyChanged event.
                    /// </summary>
                    public ObservableCollection<BonusChargesValue> Charges
                        get
                            return _charges;
                        set
                            if (_charges == value)
                                return;
                           // RaisePropertyChanging(ChargesListPropertyName);
                            _charges = value;
                            RaisePropertyChanged(ChargesListPropertyName);
                    public RelayCommand ShowFaresCommand
                        get;
                        set;
              /// <summary>
                    /// Initializes a new instance of the MainViewModel class.
                    /// </summary>
                    public MainViewModel()
                        if (IsInDesignMode)
                            // Code runs in Blend --> create design time data.
                           // BonusChargesValue bnc = new BonusChargesValue();
                            _charges = new ObservableCollection<BonusChargesValue>();
                            _charges.Add(new BonusChargesValue { AmountToRecharge = 10.0, BonusAmount = 5, NewBalance = 15, NumberofRides = 5 });
                            _charges.Add(new BonusChargesValue { AmountToRecharge = 12.0, BonusAmount = 6, NewBalance = 17, NumberofRides = 6 });
                            _charges.Add(new BonusChargesValue { AmountToRecharge = 14.0, BonusAmount = 7, NewBalance = 19, NumberofRides = 7 });
                            _charges.Add(new BonusChargesValue { AmountToRecharge = 16.0, BonusAmount = 8, NewBalance = 21, NumberofRides = 8 });
                            _charges.Add(new BonusChargesValue { AmountToRecharge = 18.0, BonusAmount = 9, NewBalance = 23, NumberofRides = 9 });
                            _charges.Add(new BonusChargesValue { AmountToRecharge = 10.0, BonusAmount = 5, NewBalance = 15, NumberofRides = 5 });
                            _charges.Add(new BonusChargesValue { AmountToRecharge = 12.0, BonusAmount = 6, NewBalance = 17, NumberofRides = 6 });
                            _charges.Add(new BonusChargesValue { AmountToRecharge = 14.0, BonusAmount = 7, NewBalance = 19, NumberofRides = 7 });
                            _charges.Add(new BonusChargesValue { AmountToRecharge = 16.0, BonusAmount = 8, NewBalance = 21, NumberofRides = 8 });
                            _charges.Add(new BonusChargesValue { AmountToRecharge = 18.0, BonusAmount = 9, NewBalance = 23, NumberofRides = 9 });
                        else
                            // Code runs "for real"
                            Charges = new ObservableCollection<BonusChargesValue>();
                            ShowFaresCommand = new RelayCommand(GetValues, () => { return true; });
                          //  ShowFares = new RelayCommand(() =>
                               // Words = new string(Words.ToCharArray().Reverse().ToArray());
                            //_charges = new ObservableCollection<BonusChargesValue>();
                            //_charges.Add(new BonusChargesValue { AmountToRecharge = 10.0, BonusAmount = 5, NewBalance = 15, NumberofRides = 5 });
                            //_charges.Add(new BonusChargesValue { AmountToRecharge = 12.0, BonusAmount = 6, NewBalance = 17, NumberofRides = 6 });
                            //_charges.Add(new BonusChargesValue { AmountToRecharge = 14.0, BonusAmount = 7, NewBalance = 19, NumberofRides = 7 });
                            //_charges.Add(new BonusChargesValue { AmountToRecharge = 16.0, BonusAmount = 8, NewBalance = 21, NumberofRides = 8 });
                            //_charges.Add(new BonusChargesValue { AmountToRecharge = 18.0, BonusAmount = 9, NewBalance = 23, NumberofRides = 9 });
                            //_charges.Add(new BonusChargesValue { AmountToRecharge = 10.0, BonusAmount = 5, NewBalance = 15, NumberofRides = 5 });
                            //_charges.Add(new BonusChargesValue { AmountToRecharge = 12.0, BonusAmount = 6, NewBalance = 17, NumberofRides = 6 });
                            //_charges.Add(new BonusChargesValue { AmountToRecharge = 14.0, BonusAmount = 7, NewBalance = 19, NumberofRides = 7 });
                            //_charges.Add(new BonusChargesValue { AmountToRecharge = 16.0, BonusAmount = 8, NewBalance = 21, NumberofRides = 8 });
                            //_charges.Add(new BonusChargesValue { AmountToRecharge = 18.0, BonusAmount = 9, NewBalance = 23, NumberofRides = 9 });
                    private void GetValues()
                        CalculateMetroFare cmcf = new CalculateMetroFare();
                        if (!string.IsNullOrWhiteSpace(CurrentBalance))
                            var chr = cmcf.Add2ExistingCard(Convert.ToInt32(CurrentBalance));
                            foreach (BonusChargesValue bncv in chr)
                                Charges.Add(bncv);
                        }`enter code here`
                       // return _charges;
    VAravind ---------------------------------------------------------------------------------------------------------------------------------- Please click "Propose As Answer" if a post solves your problem or "Vote As Helpful" if a post
    has been useful to you. Blog
    VAravind ---------------------------------------------------------------------------------------------------------------------------------- Please click "Propose As Answer" if a post solves your problem or "Vote As Helpful" if a post
    has been useful to you. Blog

    I am not getting error but the Listview is not getting updated after the relay command
    VAravind ---------------------------------------------------------------------------------------------------------------------------------- Please click "Propose As Answer" if a post solves your problem or "Vote As Helpful" if a post
    has been useful to you. Blog

  • Variable local buffer ecriture

    Bonjour,
    Mon probleme ce situe au niveau de l'utilisation des variables locales !
    je vous poste un Vi simplifié de mon projet afin de mieux comprendre le probleme!
    en effet je crée des variables locales (des buffers d'ecritures des instruments que je veut commander afin d'envoyé des commandes plus loin dans le diagramme, en voulant qu'à chaque fois q'une commande est mis dans la variable locales "Ecrire IHM" par ex, le Vi ecrive sur le buffer et lise la reponse !
    pour cela j'ai testé avec une boucle while (sans conviction et sans résultat)
    Merci ! Cordialement !
    Ps : j'utilise Labview 2009 mais enregister pour Labview 8.6
    Pièces jointes :
    pour forum pb variable local buffer ecriture.zip ‏32 KB

    Bonjour, ramses64
      Comme tu a pu le remarquer je suis débutant et voici mon problème, je suis en stage de fin d'étude et je dois faire une application sous Labview 2009 où j'inter agie avec un appareil en Bluetooth (clé BT sur pc portable) et avec un appareil de mesure en RS232 via (usb/comm DB9)
      Donc voila mon problème je dois tantôt envoyer des commandes particulières à l'appareil BT et recevoir un acquittement tantôt envoyer des commandes particulières via RS 232 et recevoir un acquittement. Mes commandes fonctionnent bien en direct Q/R.
      je ne sait pas comment m'y prendre pour séquencer les commandes sur les 2 ports com . (une centaines de commandes pour chaque appareil ! couper en plusieur fonction Init ; Check ; Test ; Etc) . Mon post précedent etait juste une idée !
    En effet mon probleme et un probleme de compréhension de Labview :-/ ( 1 er prog et seul ) , j'ai pensé que les variables locales me renvoyées les données à mon buffer d'ecriture de base (afin de refaire la sequence 1 (comme un sous programme) ! Or ce n'est apparement pas le cas . Je reposte MON VI plus complet afin de bien comprendre mon probleme !
      N'hésiter pas je suis ouvert à toute remarques sur ce que j’ai fait de maladroit ou de faux et aux idées de développements etc..
      Merci
      par ex : BT comm 5 et RS232 comm 6
      ex Commandes a envoyé :
       =>BAT+CG=6 (comm 5)
    <=Timeout 20Sec pour réponse CT+CG=2 (comm 5)
    =>CL :LU (comm 6)
    => BAT+CP= ? (comm 5)
    <= Timeout 20Sec pour réponse (comm 5)
    =>CL :MSN :RL ? comm 6<=-28 ;23 ;98 comm 6
    Pièces jointes :
    forum_buffer variable locale.vi ‏1069 KB

  • Problem reading PXI-2503 channels above 23 in 1-Wire 48x1 Mux mode in Linux

    I'm having trouble getting relay positions above 23 in the 1-wire 48x1 mode
    % nilsdev | grep 2503
    NI PXI-2503: "Dev1"
    The topology is set to "2503/1-Wire 48x1 Mux" via the following API, using device "Dev1"
      DAQmxSwitchSetTopologyAndReset(device,topology)
    In theory that means there are 48 inidividual relays than can be read, however, the following fails:
     switchname = "/Dev1/ch47"
     DAQmxSwitchGetSingleRelayPos(switchName, &pos)
    The error returned is:
    DAQmx Error: Relay name is invalid.
    Relay Name: ch47
    Status Code: -200202
    which is
        #define DAQmxErrorInvalidRelayName   (-200202)
    I am unable to get the relay position for anything above relay 23  ( /Dev1/ch23 )
    Is that the expected behaviour, or is there a driver or hardware issue ?
    Solved!
    Go to Solution.

    When using this switch in "1-wire" mode, we are essentially breaking each (+)/(-) pair into their own channels.  Since this topology utilizes double pole, single throw switches whose individual terminals cannot be switched independently, another switch is introduced to decide which side of the switch is being accessed as what point in time, (+) or (-).
    Instead of having 48 single pole single throw, we can have 24 double pole single throw and one single pole double throw to decide which polarity we're referencing.  You can still utilize this topology in a 48x1 1-wire mode.  
    To manually switch using DAQmx relay commands, you will have to specify the channel switch and the polarity switch as Maggie mentioned.  When you call "DAQmxSwitchConnect /Dev1/ch47 /Dev1/com0", the driver knows to close the ch 24 relay in addition to "HLSELECT" AND "1WIRE" to route only the positive terminal (effectively ch.47).
    The NI Switches Help document contains a more detailed explanation of the topology if you navigate to Devices >> NI PXI-2501/2503 >> 
    1-Wire 48×1 Multiplexer Topology.
    National Instruments

  • Hex display in LabVIEW TestStand equivalent

    Hi, I am trying to communicate to a device using RS232 communications.
    The command i need to send in hex is 5054 4958 2001 200A 0D
    This cannot be represented by ASCII characters, i.e. it appears as PTIX .
    I can achieve this no problem in LabVIEW by setting the string control to 'Hex Display' but when I try to load the hex string via TestStand it becomes 3530 3534 3439 3538 3230 3031 3230 3041 3044  which is the hex display of 5054 4958 2001 200A 0D.
    Is there anyway that I can export the hex command into the LABVIEW VI?  I tried important the decimal number equivalent and then using convert number to hexadcimal string but this doesn't work as the hexadeciaml string is
    505449582001200A0D 
    but the actual string should be PTIX
    I have attached my code and any suggestion would be welcome.
    Rgds,
    Sean
    Attachments:
    Sean RS232 Commv2.vi ‏33 KB

    Not sure why you would try Number to Hex String. What I've done in the past is use a numeric array and the Byte Array to String or a numeric and the Typecast function. Both of these functions have been discussed endlessly in posts about sending hex with a VISA Write.

Maybe you are looking for