AzeoTech

Administrators
  • Content Count

    5,729
  • Joined

  • Last visited

Everything posted by AzeoTech

  1. Well, it depends on whether you want to log the averaged data or not. If you just want to make your graph look better, use the boxcar() function as the expression for your graph. Boxcar is only designed for use with an array of data that you want reduced to a smaller array. If you want everything, including logging, to be averaged, you really want the mean() function because you want to take an array of data and get a single averaged point. To use it, you'd have to accumulate some values: private m1 = 0 private m2 = 0 private count = 0 while (1) count++ DigitalOut = 0 read(Eingang0) m1 += eingang0[0] if (count == 5) Motor01.AddValue(m1/count) m1 = 0 endif delay (30) DigitalOut = 1 read(Eingang0) m2 += eingang0[0] if (count == 5) Motor02.AddValue(m2/count) m2 = 0 endif delay (30) endwhile This assumes you still want to alternate readings. If instead you want to read eingang rapidly and then have it put the average in motor01 do something like: while (1) DigitalOut = 0 for (private.c = 0, c < 5, c++) read(Eingang0) endfor Motor01.AddValue(mean(eingang0[0,4])) delay (30) DigitalOut = 1 for (private.c = 0, c < 5, c++) read(Eingang0) endfor Motor02.AddValue(mean(eingang0[0,4])) delay (30) endwhile
  2. AzeoTech

    unable to load file!!!

    99.9% of the time this happens when you try to load a document created with a newer version of DAQFactory with an older release. Make sure your new computer has the latest release by downloading an update from www.daqexpress.com If that doesn't fix it then the file got corrupted at some point, probably due to disk error, which is why backups are so important.
  3. AzeoTech

    graph control with edit box or button

    I'm a little unsure what the problem is. If you don't have an else, just don't put one: if (System.MessageBox("Do you really want to stop?","YesNo") == "Yes") Mychannel.ClearHistory() endif
  4. Yes. First you have to name your graph: select the graph and right click and select "Component Name...". Lets say you call it MyGraph. Next, you need to put a trace on the graph for your initial channel. You'll need to name the trace. This is about half way down on the trace page. Now you can change the Y expression programmatically: Component.MyGraph.MyTrace.strYExpression = "V.Motor5" There are a variety of components: combo, radio, button, etc. that can be used to actually set this value.
  5. AzeoTech

    graph control with edit box or button

    Just use an if to see what the current expression is: if (Component.MyGraph.MyTrace.strYExpression == "V.Motor5") Component.MyGraph.MyTrace.strYExpression = "" else Component.MyGraph.MyTrace.strYExpression = "V.Motor5" endif This will toggle the graph display between V.Motor5 and nothing.
  6. AzeoTech

    graph control with edit box or button

    Sure, lets say your sequence is MySequence and you named your button MyButton. In the quick sequence action for the button put: if (Sequence.MySequence.Running) if (System.MessageBox("Do you really want to stop?","YesNo") == "Yes") endseq(MySequence) Component.MyButton.BackColor = RGB(0,0,0) endif else beginseq(MySequence) Component.MyButton.BackColor = RGB(0,255,0) endif
  7. AzeoTech

    button to start logging

    Actually, I was wrong. You can name the logging set log even though it is a reserve word. You would not want to create a variable or channel named "log" however. So, the docs are actually correct.
  8. AzeoTech

    button to start logging

    Do you have that if in a loop? Otherwise it will execute only once and unless you have the button pressed at that time, nothing will happen. Actually, when you want to do something based on channel value, you probably should use a channel event. Click on the FIO0 channel in the workspace under CHANNELS: and then select the event tab on the right. You can put code here that executes whenever FIO0 is read (except stream, in which case it is in blocks). There you should be able to put your exact code. Also, I just noticed: you can't call your logging set "log" because log is a reserved word for the function log() which performs the logarithm of a value. You should pick a different name.
  9. AzeoTech

    simple if

    You need to use two equal signs to do comparison: if (switch[0] == 1) a single = is assignment
  10. AzeoTech

    parallel traces in a graph

    How are you clearing the one trace? Using ClearHistory() I assume. Well if your _cal traces are just variables, they should still remain when you clear the history of the regular channels unless you have some sort of autoscaling. Perhaps you can email back and attach your document so we can tell what you have done.
  11. No, not quite. Anytime you create a group of channels with different Timing / Offset parameters, they run in a different thread. These threads are synced in time, but the averaging point (i.e. where in the second it decides to take 10 points) is pretty much determined by when the document is loaded and is not predictable. I'd bet if you quit and restarted it would land on a different time than the 0.7 point in the second. You have a couple choices: 1) Unless you have a reason not to, I would just sample all the channels at 10hz and average them all. With the UE9 you are well within the bandwidth, so the only reason why not would be if you need an instantaneous reading every second instead of the average 2) You can sync up the average with the 1 second reads using an event in one of the 1 second channels and a new averaged channel. To do this: a) create a new channel, lets say you call it datafinal. Make it just like your raw 10 hz channel, but give it a channel number in the thousands (one that doesn't really exist) and set the Timing to 0. This is the channel you will want to log instead of the raw 10 hz Turn averaging off on the 10hz channel and set the history to something small like 20. c) in the event for one of 1 second channels put: private average = mean(rawdata[0,9]) average.time[0] = mychannel.time[0] datafinal.AddValue(average) The first line calcs the average of our 10hz data (which I assumed you called rawdata). By doing [0,9] you are taking the mean of the last 10 data points. The next line simply injects the time of this channel into our average so it lines up. I'm assuming your 1 hz channel that holds this event is called mychannel. The final line takes that data and injects it into the datafinal channel. Now this channel will hold the 10 point average of 10 hz data lined up to mychannel. The average is calced every time mychannel gets a new value.
  12. Yes you can certainly stream the UE9 over Ethernet. In fact, it is slightly faster over Ethernet. As to your problem, I would first make sure you can communicate with the device at all by simply polling the device once a second instead of streaming. If you get that and the stream still doesn't work, please email your document and any error messages. Also, one thing that comes to mind: did you remember to change the D# on the channels that receive the data? This must match the D# you assigned your UE9 too. As for your logging problem, if you are looking to simply log once a second snapshots, you might want to use an export set instead and then use a sequence to trigger it. The export set would have [0] in all the expressions to log only the most recent value, then the sequence would simply start the export set once a minute: while (1) beginexport(myexport) delay(1) endwhile The big advantage of this method is that you can start and stop at will, and you can easily switch it to event driven logging, where the logging set is really designed for continuous logging.
  13. AzeoTech

    2 counters on UE9

    OK, first you probably should avoid using D# 0. D# 0 was provided mostly for people used to using the U12, but with the addition of first found in the device configuration, you should avoid it. The reason is that if you get another UE9 or U3 (and so are using 2 labjack devices on the same PC) you'll can't use D# 0 at all and so you'd have to go back through your code and change every instance. If, instead, you had used first found in device configuration with a D# of 1 say, then all you'd have to do is replace this listing with an actual ID number, and all your instances / code would update. Now, as to your question, the problem is simply that you didn't enable both counters in your ResetCounters sequence (which, by the way, is misnamed, as the code inside only enables the counters and doesn't reset them). The code you want is: device.LabJack.AddRequest(0,"LJ_ioPUT_COUNTER_ENABLE",0,1,0,0) device.LabJack.AddRequest(0,"LJ_ioPUT_COUNTER_ENABLE",1,1,0,0) device.Labjack.GoOne(0) Alternatively, if you use the device configuration instead of D#0 you can enable the counters from there without any code.
  14. AzeoTech

    graph control with edit box or button

    I'm not sure I understand your question. If you are using a button, you'd just go to the Action page, select Quick Sequence and type in the code like: Component.MyGraph.MyTrace.strYExpression = "V.Motor5" Create a different button for each possible trace, changing the code appropriately.
  15. AzeoTech

    add page

    If you wish additional pages, you can purchase DAQFactory Lite for $199 from www.azeotech.com. This will give you unlimited pages, 30 or so more screen components (like guages, sliders, knobs, etc) and support for devices other than LabJack. Your Express document will work without change in Lite or any other version of DAQFactory, so the upgrade is very easy.
  16. AzeoTech

    U12 stop logging at a defined time

    No problem. Assuming your logset is called MyLogSet: beginlogging(mylogset) wait(900) endlogging(mylogset) This simply starts the logging when the sequence starts, then the sequences waits 900 seconds (15 minutes), and then it stops the logging set. Then just create a button to start this sequence. Note that stopping this sequence early won't stop the logging set, so if you want to be able to manually stop early, use the Quick Sequence action of the button instead of Start/Stop sequence and put something like this (assuming the above sequence is named MySeq: if (Sequence.MySeq.Running) endseq(MySeq) endlogging(mylogset) else beginseq(MySeq) endif Basically it looks to see if the sequence is running and if it is, it stops both the sequence and the logging set, otherwise it simply starts the sequence.
  17. Sure, just use a variable. Declare it somewhere (say auto-start sequence:) global timecounter Then when you want the time to start do: timecounter = systime() and wherever it is displayed, put: SysTime() - timecounter Use formattime() to display in H:m:s: formattime(systime()- timecounter) or formatdatetime() if you want more control over the display. If you want an accumulating counter, you'll need two variables: global timecounter = 0 global totaltime = 0 to start counting do: timecounter = systime() to display do: formatdatetime("%H:%M:%S", (systime()-timecounter) * (timecounter != 0) + totaltime) This uses a little boolean math to only include the running time (timecounter) part when the counter is counting. to stop counting do: totaltime += systime() - timecounter timecounter = 0 to reset do (when timer is stopped): totaltime = 0
  18. Well, as I said, you have to put V. in front of all your V channels. To clear the history, just do V.MyChannel.ClearHistory(). That all said, I'd use test channels instead. Just create regular channels with device type test, I/O type A/D and a Timing of 0. Then you can do: MyChannel.AddValue(Eingang0[0]) The advantage of this is that you can utilize all the other channel features such as logging, averaging, broadcasting (if using >= DF-Standard), and the persist files.
  19. Well, first I'd have to ask why you are using V channels? They are a bit old school and most of their features have been replaced by better solutions. But as to why your code doesn't work, you have to put V. in front of V channels because technically the channels are on the V connection. Also, note that you won't really easily be able to log these channels. You'd pretty much have to use an export set. Also, be careful about this: V.Virtual1 = Eingang0 By not subsetting Eingang0 you are technically trying to add the entire history of Eingang0 to the v channel. I believe in this mode, with =, it will actually only put the latest value, but its much better to be specific as to what you want: V.Virtual1 = Eingang0[0]
  20. AzeoTech

    Streaming counter

    Yup, sorry about that. I forgot to mention that detail. DAQFactory doesn't know that you are streaming a counter. The driver is designed to be open so that when LabJack releases new hardware and new features, it will work immediately with DAQFactory. So, all the stream data comes in on the A to D I/O type because as far as DF is concerned, its all analog input...
  21. AzeoTech

    Flowmeter - pulse or voltage?

    Whenever you have a choice between a device that outputs pulses and the same device that outputs volts for the same measurement you should choose the pulses. This is of course provided you are using one of the LabJack devices (any type), have an available counter or timer, and the frequency of the pulses is less than the max freq of the counter or timer. The reason is that pulses are digital signals and volts are analog. Like everything else that toutes digital over analog, the reason is that digital signals are less subject to noise. All your device with a voltage output is doing is counting the pulses coming out of the paddle wheel and generating a proportional voltage. Its called a frequency to voltage converter for the simple reason that that's what it does. So, you have a pulse, which is then converted to an analog voltage which you feed into an analog input on a LabJack which converts it to a digital signal. If you use the pulses directly with a counter, you simply have a pulse which the LabJack converts into a digital signal. Notice how "analog" isn't in this method. Exception to this rule: If the distance between your sensor and your LabJack is long and you are in a noisy environment, then there is the possibility of getting a noise spike that looks like a pulse. You can easily check for this by simply stopping the process and making sure the counts remain at 0. If they don't, there are two solutions: 1) move the LabJack closer, either by using a UE9 that supports ethernet, or extending your USB using hubs. Note that you cannot run a USB cable more than 6 feet without a hub. Yes they sell USB cables that are longer than 6 feet, but the spec says 6 feet max and if you want reliability you'll follow the spec. 2) you could use a freq-voltage converter and then a voltage to current converter to get a 4-20mA signal and run that to the Labjack, then put a resistor to convert the current back to voltage and read it with an analog input. Current signals are not subject to noise, thus the reason 4-20mA signals are used in industrial environments. Of course this method requires extra hardware, and will generate noise of its own because of all the conversions so its a bit of a toss up. Which is better really depends on environment. As for how to do it with DAQFactory and U3, go to www.daqexpress.com and you'll find samples that include reading the U3 counter.
  22. AzeoTech

    Streaming counter

    In DAQFactory, instead of multiplying MSW by 2^16 you can just left shift by 16: (MSW << 16) + LSW The parenthesis are required because << is a lower priority operator than +
  23. AzeoTech

    error C1070

    First, go to www.daqexpress.com and download the latest version of DAQExpress. It allows unlimited sequencing. As for your V Channel issue, you have to use V.Chan = newvalue not the AddValue() function.
  24. AzeoTech

    error C1070

    This is because you used a single = sign in your comparison. It must be ==. We may change this in the future as it catches a number of people, but for now you must use == whenever comparing values, and a = when assigning a value. Next a few comments on your sequences: 1) Don't use Time / Goto notation. Its bad form and is only there for backward compatability. Use: while (1) digitalout = 0 delay(30) digitalout = 1 delay(30) endwhile 2) If you really want the setting of the digitals and the readings to sync up, put them in the same sequence: while (1) digitalout = 0 read(Eingang0) Motor1.AddValue(Eingang0[0]) delay(30) digitalout = 1 delay(30) endwhile 3) if you are concerned about propogating time errors (i.e. loop taking slightly longer than 1 minute, use wait() instead of delay(). For those reading this and doing short loops, you have to be careful using wait(), but for your app, where the delays are long, a wait() should be fine.
  25. AzeoTech

    Streaming counter

    Actually you didn't mention that you were using a UE9 originally, thus your original problem. The UE9 / U3 use a different driver then the U12 so anything that applies to the U12, such as Glenn's document and the U12 samples on the CD will not work for the UE9 or U3. For these, you should use the UE9 samples as you did. As for how to stream the counter / digital in's, I leave it to the Labjack guys to tell you the exact commands for this. The DAQFactory UE9/U3 driver pretty much exposes the UD as is, so the functions you would do as documented in the UE9 manual are the ones you would use in DAQFactory, except that you would put quotes around the constant names. You can see this in the stream sample for the UE9, which would make a good starting point. You should only need to specify different channel numbers. The other different between the DAQFactory UE9 / U3 driver and the LabJack UD is that DAQFactory automatically takes care of reading the stream data and putting it in the appropriate channels. Again, the stream sample shows this. You can find the latest samples and the latest release of DAQFactory Express at www.daqexpress.com