Wednesday, March 30, 2011

windmills newsletter , bit of code in here .

-------------------------Monitor------------------------The Newsletter for PC-Based Data Acquisition and ControlIssue 152 www.windmill.co.uk March 2011--------------------ISSN 1472-0221----------------------Welcome to the March edition of Monitor. Here in England the sun is shining and spring has at last arrived. As I mentioned last month, the Windmill Software company is 20 years old this year. As part of our celebrations we are pleased to offer you our lowest ever price on measurement hardware. See below for more details or visit http://www.windmillsoft.com/daqshop/analogue-input.htmlDon't forget, Windmill data acquisition software is still on offer at £50, 60 Euros or US $80. With this package you can log data from, and control, up to 10 instruments which can send data via RS-232, RS-422, RS-485 or Modbus. You can find out more at http://www.windmillsoft.com/daqshop/rs232-modbus.htmlWe hope you find the newsletter useful, but should you wish to remove yourself from our mailing list please go to http://www.windmillsoft.com/daqshop/Monitor_Newsletter.htmlCONTENTS========* Windmill News: Half Price Measurement and Control via USB* Multiplexing Analogue Inputs* Excel Corner: Setting the interval between data readings* Data Acquisition and Control News Roundup________________________________________________________________________________________________________________Windmill News: Half Price Measurement and Control via USB________________________________________________________We are delighted to bring you our lowest ever price on data acquisition and control hardware. For just £147, US $239 or 169 Euros you get - the 750 unit which plugs into the computers USB port,- the Windmill logging, charting and control software suite, for USB devices,- technical support for life by e-mail or telephone.With the 750 system you can...- Measure voltage through 16 analogue inputs- Switch up to 16 digital outputs (relays etc)- Monitor up to 16 digital inputs- Count events with up to 8 counters- Log and chart data, count, control outputs and send data to Excel or other Windows software: no programming is needed- Connect up to eight 750s to a PC, providing 128 voltage inputsWe offer a money-back guarantee: if the 750 system doesn't do what you want simply return it for a full refund. For computers running Windows 7, Vista, XP and 98.The offer is running from now until 30th April. To try the 750 at the low price go to http://www.windmillsoft.com/daqshop/analogue-input.html, e-mail sales@windmill.co.uk or telephone +44 (0)161 833 2190.________________________________________________________________________________________________________________Multiplexing Analogue Inputs: ________________________________________________________When data acquisition equipment receives an analogue signal, it digitises it, converting it into a format that the computer can understand. This is done by an analogue-to-digital (A/D) converter.An A/D converter can only digitise one signal at a time. Some data acquisition systems provide an A/D converter for each analogue input. However, it is more common to switch (multiplex) the signals in turn to one converter. This method is used in lower cost systems like the 750.Settling Time and Cross-Talk============================As the multiplexer switch one input after another to the A/D converter, you must allow time for each reading to settle to its new value. This settling time defines the minimum interval between reading each input. If you try to go faster than this there will be increasing cross-talk between channels, leading to inaccurate results. Cross-talk is when one channel's signal causes an undesired effect on anotherLogging Data from only Some of the Connected Inputs===================================================For test applications you may want to read from some inputs in one test run and from a completely different set of inputs in another. You obviously don't want to slow down the system by reading all channels every time. Software like Windmill avoids this by letting you select as sub-set to scan for each test. This avoids the need to rewire your connections each time you want to record some data.You can find out more on multiplexing at http://www.windmill.co.uk/multiplexing.html________________________________________________________________________________________________________________Excel Corner: Setting the interval between data readings________________________________________________________You can use Windmill Logger to regularly collect data and store it in files; periodically starting a new file for long-term logging. Once Logger has closed a file you can open it in Excel.There are some situations though, when you will want to use Excel to regularly capture data from instruments and devices. To do this you need to use a macro. A typical data collection macro is given at http://www.windmill.co.uk/excel.html#ExcelWhen taking readings at regular intervals which are controlled by Excel, the macro must pause for a while before taking the next reading. There are several ways to do this, the most often used being Wait or Sleep. These are detailed below, but both have the disadvantage of tying up Excel whilst the macro pauses. There is a way round this: by logging only when new data arrives. See below for details.Using The Wait Method=====================The Wait method pauses a running macro until a specified time. For exampleApplication.Wait(Now + TimeValue("0:00:10")) would wait for 10 seconds.Using Wait has a couple of disadvantages.1. The minimum Wait time is 1 second, so sampling rates of less than one sample per second would not be possible.2. The Wait method suspends all Microsoft Excel activity and may prevent you from performing other operations on your computer while Wait is in effect. However, background processes such as printing and recalculation continue.Using the Sleep Function========================Before your macro you need this declaration statement:Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) This is because Sleep is a Windows API - application program interface - which is available from the Windows operating system.In your macro, to sleep for 10 seconds, useSleep 10000(Sleep is measured in milliseconds.)Disadvantages of using Sleep1. Again, Excel activity will be suspended for the duration of the Sleep.Logging only when New Data Arrives==================================This method lets the Windmill DDE Panel control the timing, rather than Excel. It only runs the data collection macro when new data is available from your instrument.1. In Windmill DDE Panel select the Copy to Clipboard button and copy data from All Channels. 2. From Excel's Edit menu choose Paste Special and "Paste as Links" into the first row of a worksheet called "Sheet1". 3. Create the code given below and run MonitorDDE. The MonitorData routine monitors cells which are showing live data via DDE. When values change, it calls the LogData procedure which progressively writes the readings into new rows in the worksheet. You will need to change the channel name from "My_Channel" to match your data channel, as the DDE Panel displays it.Dim NoOfRows As IntegerSub MonitorData()NoOfRows = 2' Monitors the DDE links for updates' When data is updated runs the subroutine LogDataActiveWorkbook.SetLinkOnData "WindmillData!My_Channel", "LogData"End SubSub LogData()NoOfRows = NoOfRows + 1Column = 1'Initiates conversation with Windmill DDE Panelddechan = DDEInitiate("Windmill", "Data")'Requests data from "My_Channel" and stores it in'memory under mydata.mydata = DDERequest(ddechan, "My_Channel")'Inserts data into the first column of Sheet1Sheets("Sheet1").Cells(NoOfRows, Column).Value = mydata'Ends DDE conversationDDETerminate (ddechan)End SubFurther Reading: Using Excel for Data Acquisitionhttp://www.windmill.co.uk/excel.html_______________________________________________________________________________

No comments:

Post a Comment

please,close your eyes and hit random keys ,the message, if there is one, will be analysed ,and you might get a prize .