AzeoTech

Administrators
  • Content Count

    5,672
  • Joined

  • Last visited

Everything posted by AzeoTech

  1. Actually, its not even cutting it close, but rather is impossible with the U12 using software polling. The pulses are at 27 hz, but in order to count them you have to sample at at least twice the frequency so that you see both the high and the low of the pulse (think nyquist). This means you have to sample at 54 hz which is too fast for the U12. The streaming mode mentioned would work, but processing it would be more difficult. As mentioned, your best bet is to get a U3, or another U12. You can use the counter on the U12 for this, but there is only one per, while the U3 has several. Now assuming you do use a counter I recommend NOT resetting the counter, except perhaps when you application loads. The reason is that during the reset period, which is rather short, there is a possibility that you will miss a count. With a slower pulse rate like you have, this is rare, but probably would happen 1 out of ever 1000 resets. At higher rates, this goes way up. So instead, you should record the difference between consequtive counts. To do this in DAQFactory is pretty easy: 1) Create two channels, one called RawCount and one called ActualCount. The RawCount channel should specify the counter to be read with the appropriate timing information. The ActualCount channel should be a non-existant counter number (say 10), and have a timing of 0. 2) In the event of RawCount put: ActualCount.AddValue(RawCount[0] - RawCount[1]) That's it. From then on, use ActualCount for display and logging. The event code gets called with every reading of RawCount. The code simply takes the difference between the most recent point ([0]) and the next most recent point ([1]) and puts it into ActualCount. As to how to log it, I recommend going through the guided tour as that will walk you through basic logging. If Excel is putting time and force in the same column then you are probably importing the file incorrectly. Make sure you specify in Excel the delimiter as comma instead of the default of tab.
  2. AzeoTech

    resolution and voltage range

    Depends on how you have it wired. It should read 0 when pulled to ground, and 1 when at 3.3 or 5V. Note that with an open switch, the input technically is floating and could read either 0 or 1 (or any valid value for analogs). You'll need to put a pull up or pull down resistor, or use a double pole switch to avoid the float. The digital ins may already have the pull up. I'll let the LabJack guys address that.
  3. AzeoTech

    resolution and voltage range

    I would need to see what you are doing. Can you attach it?
  4. AzeoTech

    resolution and voltage range

    The problem is that your variables are initialized to invalid values for the call. The functions follow the functions described in the LabJack UD manual almost exactly, except that strings are provided instead of the declared constants (i.e. "LJ_ioPUT_AIN_RANGE" instead of just LJ_ioPUT_AIN_RANGE in other languages). Device.LabJack.AddRequest(0,"LJ_ioPUT_AIN_RANGE",Var.Channel_Number,Var.Voltage_Range,0,0) In general, the first parameter (0) is the device number, or 0 for first found. The second parameter is a particular command, in this case setting the Analog range. The third parameter varies depending on the command. In this case it is the channel number to set the range of. The forth parameter also varies, in this case it is the range value to set to. You have to look up the range in the UD header file. The other parameters are mostly not used except for certain rather special commands. With the latest DAQFactory driver, you should be able to specify range and resolution using the device configuration among many other parameters, and avoid programming altogether. If you are using DF-Express, go to www.daqexpress.com to update to the latest. Simply install that over top of your existing installation. You must have Express already installed for the updater to work. If you are using a regular version of DAQFactory, go to www.azeotech.com/dfbeta.php and get the latest beta of 5.30 which includes the latest DAQFactory LabJack driver.
  5. AzeoTech

    Win 98

    No it will not work under Windows 98. Windows 98 is a completely different operating system then 2000 and XP with a different core and a different way of multitasking. It is also notoriously unreliable, and with a data acquisition application where reliability is usually very important, windows 98 (and Me) are completely inadequate. I strongly recommend you upgrade to Win2000 or XP even if you plan on using a different DAQ application or coding your own. You can buy Win2000 for around $100. I'm not sure what the upgrade cost is.
  6. AzeoTech

    logging time

    You can't modify it while DAQFactory is using it. So you either need to quit DAQFactory, or set the logging set file to a different file so DAQFactory releases the file. DAQFactory can't let you open it while it is editing for optimization reasons.
  7. AzeoTech

    logging time

    I'm not sure what you are doing wrong. Do the three columns end up in different columns (different cells) in Excel? If not, then you are importing it wrong (perhaps selecting tab delimited instead of comma). I attached a sample showing it working. I simply typed in the first two rows of numbers you posted and then clicked on the column header for A (which highlighted the whole column) and selected Format-Cells, then picked Date from category and one of the date types.
  8. AzeoTech

    logging time

    In Excel: Just select the column (by clicking on the column header), then go to Cells-Format and select your desired date/time format.
  9. AzeoTech

    0 - 5Volt Fader

    Is there any data in the graph? If there isn't, or only a scaler value, then the graph will scale weird because it doesn't have anything to scale. Are you sure it is thawed? There should be green lines at the top and bottom when you left-click on the graph. Are you able to autoscale the y axis and have the scale change? What is your Y expression?
  10. AzeoTech

    0 - 5Volt Fader

    No, none of the LabJack units can act as standalone systems. The 2D graph is probably frozen. When you click on it, it probably has a purple box around it indicating it is frozen. Just right click, select Freeze/Thaw and then Thaw all axes. Angular gauges aren't included in DF-Express, which I assume you are using. You'd have to upgrade to at least DF-Lite for $199 to get gauges. I'm not sure what you want to display on the gauge, but a gauge can display any scaler value, so whatever you want should work.
  11. AzeoTech

    0 - 5Volt Fader

    Is the code you just sent in the channel event? If so, you really shouldn't put a delay() inside a channel event because it will cause the polling loop to slow down. Instead you should have this: if ((start[0] == 1) && (stop[1] == 0)) beginseq(rise) endif Note how I put parenthesis around each separate section of the if. It amounts to the same things, but I strongly recommend always doing this for two reasons: 1) its easier to read 2) unless you have memorized the priorities of operators, its better to use parenthesis to force the compiler to evaluate things the way you want. Now in the rise sequence put: output = input[0] delay(2) while(1) ... endwhile In that first line we set the output to the pot setting recorded on the input. Then we delay 2 seconds, then we go into the loop. Another point: notice that I put [0] after input. [0] means take the most recent value. If you don't put [0], the entire history of input is returned. In this case it doesn't really matter because the "output =" part will automatically take the most recent value, but this time there are three reasons why you should do [0]: 1) once again, its clearer to someone reading the code what you mean. This becomes more important as your code gets more complex. 2) doing [0] allows DAQFactory to optimize memory as it just retreives the most recent value. Without it, it has to retreive the entire history, and then only when it does the = does it get trimmed down to the most recent value. This is a big problem if your histories are large. 3) once again, unless you have memorized all the spots where DAQFactory automatically takes the most recent value (and I haven't even memorized that!) you may not get what you expect.
  12. Yes, that will work, though it is a bit round-about and doesn't have much flexibility. There are many others. Really, though, the TestBit() function is the best and fastest way to determine the state of any bit in an integer if for no other reason then all that code is in C++ rather than in DAQFactory script. C++ code is much faster than DAQFactory script, so any time there is a DAQFactory function to do something you should use that rather than multiple DAQFactory operations. Another example of this is using array math. For example, if you wanted to find the maximum value of a channel you could do: private.max = -999 for (private.x = 0, private.x < NumRows(MyChan), private.x++) if (MyChan[Private.x] > private.max) private.max = MyChan[Private.x] endif endfor but that would be really, really, slow compared to this: private.max = Max(MyChan) Here's another example. Lets say you want to see if array1 and array2 contain the same values. You could create a loop like the max one I showed above, or you could do: private.match = Min(array1 == array2) This is a little more advanced, but is a good example of where a little creativity can yield a dramatic speed benefit over loops. In this case, the part "array1 == array2" will generate a third array containing 0's and 1's. A 0 whenever the matching element of array1 does not equal array2, and 1 when it does. If all the elements of array1 are identical to array2, then array1 == array2 will give an array of all 1's. If some don't match, there will be 1's and 0's, and if none match, all 0's. So, we then take the Min of this array. If there are any 0's, meaning at least one of the elements don't match, the Min is 0. But if all the elements match, the array only contains 1's so the Min is 1.
  13. AzeoTech

    Importing picture

    The best way to ensure the graphic displays right in DAQFactory is to open it up in Microsoft Paint and then cut and paste it out of that program. DAQFactory currently cannot resize bitmap images.
  14. AzeoTech

    0 - 5Volt Fader

    I think we're confusing the term initial voltage. There are two initial voltages really: 1) When the program starts, it initializes the output to a starting voltage. This is the one to use the registry with. 2) When the ramping loop starts, it has an initial voltage to ramp from. This is stored in Var.InitialVoltage and is set by one of the screen components I made in that sample, so is already user settable. My previous post with the registry assumed you were trying to solve #1 since #2 is already implemented. A registry variable is a variable that instead of being stored in memory is stored in the windows registry. Because of this, it persists even if you reboot your computer. Its limited to integers and strings so actually I should have added a multiplier in to allow for non-integer starting voltages. I only suggested using the registry variable in the startup sequences to set the initial voltage on the analog output.
  15. AzeoTech

    HEX display

    Well, I've had cases before where customers didn't quite get that binary, decimal, and hex are all the same thing when talking about numbers. They are just different ways of displaying them. Usually are only two cases where you need to actually do a conversion: 1) With ASCII serial communications when the device sends a string containing a hex value and you need to convert that to base 10 (decimal). 2) When you have a number and for some reason you want to see it displayed on screen (or logged) as a hex string. The key is that the hex values are strings not numbers. A number is a number is a number, it doesn't matter if its hex, decimal, octal or base 23. The computer is going to represent it internally the way it wants and you'll never know. Its only when you want to display it, which requires you to convert it to a string representation, or you want to go the other way and take a string representation and make a number that it makes a difference. That all said, to convert a string hex value to a number you use the expression: Evaluate("0x"+var.strMyString) or if a binary string, use "0b" instead. Under DAQFactory 5.15 there is no way to display a number as a hex string, but in DAQFactory 5.30 you can use the Format() function: Format("%x",var.myvalue)
  16. AzeoTech

    More questions about sequences

    Sorry I didn't see this post earlier, but perhaps the response to your next post answered the questions. Since others may read this, here is the answer to this question: The problem here is that the detect sequences pretty much get started immediately on load before those inputs have had a chance to read. To avoid this error, you can just put a delay(1) or similar to delay the start of those sequences until after the channels have had a chance to read a value. You have the AddValue() functions which should avoid this. Did you still get the error with those lines in place? If so then you have something else going on (like a history of 0 or something) and I'd have to see your document. As I mention in the other post, you need a loop with a delay() in it on these detect sequences to get them to continually monitor. A few more pointers: 1) When monitoring channel values as you are, its actually better to use the Event on the channel instead. The event gets called every time a new value comes in on that channel. By using an event you avoid the C1040 error, avoid having lots of loops, and get quicker (actually the quickest) response. The code in your event would actually be the same as what you have in your detect sequences, except the if's would be with the appropriate channel. Note that you would never want to put a delay() in a channel event as that would stall the next reading. 2) If you want an easy way to avoid startup alerts like this, assuming you had a loop in those detect sequences, you can always add: ignore("all") or just: ignore("C1040") to get the sequence to ignore all errors or errors starting with C1040.
  17. AzeoTech

    0 - 5Volt Fader

    The start voltage is user set. Its called "Var.Initialvoltage" Or did you mean the voltage when the application is started? If so, use a registry variable. So, right now, you have in the startup sequence: Output = 0 Put this instead: Output = Registry.StartVoltage Then create another variable value component that changes the Registry.StartVoltage variable. Then, when you change this variable and restart, the output will be set to that value. Note that Registry variables default to 0.
  18. AzeoTech

    0 - 5Volt Fader

    Did you remember to create the output channel? I've attached a sample showing it working. I didn't know whether you had a U12, UE9, or U3, so I made the Output just a test channel. Hopefully you can build from my sample. As for it being hard, well data acquisition is not super easy, and anyone or anything that is making it really easy is probably hiding things from you that you should understand otherwise you may be trusting results and actions that aren't correct. My favorite example of this is with the discovery of the ozone hole. When the ozone hole was discovered, there was already people measuring ozone for years who never saw the hole. When the announcement was made, they went back and discovered that the programmer, who had made it "easy" for the scientists had made it so values below 50 were marked invalid, thus throwing away all the real data that showed there was a hole. As for other programs that might be easier, well only if you happen to find a program that does exactly what you want. LabView will be much harder, any programming language (VB, C, etc) will be as well. The problem is that everyone needs to do things differently. The first versions of DAQFactory had very limited scripting and tried to avoid programming, but we quickly discovered that then DAQFactory only worked for a very small subset of people who happen to need the features we offered. We thought about simply adding more features, but then the program just gets combursome with menu options. The only way to allow the flexibility to do all the different things people want to do, you have to use some scripting. Unlike LabView, and low level programming languages, DAQFactory takes care of a lot for you. Plus you can use a lot of the non-programming features and just supplement it with some scripting for your unique application. And then of course, you can always post here when you have problems and get a quick answer risesample.ctl
  19. AzeoTech

    0 - 5Volt Fader

    The private means the variable is only visible from within the sequence. This is done to avoid cluttering the global namespace. Basically that just means it is done to keep from having too many different names accessible globally. With DAQFactory 5.30 this becomes even more of an issue for reasons I'll skip for now. Anyhow, in general if you just need a variable in a single sequence you should use a private, and if you want to change it elsewhere you should use a global (var.) variable. Var. variables can be used any place you would use an output channel, so, for example, you could create a Variable Value component and then open its properties, click on "Analog Out" button in the bottom right and enter "Var.TotalTime". What this button does is set the Action of the component (on the Action tab of the properties) to "Set To" and the set to channel to the Var.TotalTime variable. The SetTo action prompts the user for a new value and then sets the variable to that value. If you have not done so already, you may want to go through the Guided Tour in the help / manual. And for more info on variables, and the scripting code, review the chapter on sequences.
  20. AzeoTech

    0 - 5Volt Fader

    OK, well here's a sequence that slopes a D to A output over a fixed amount of time and at a certain update rate: Var.TotalTime = 300 // total change time in seconds Var.UpdateTime = 1 // how often to change output Var.InitialVoltage = 1 // starting voltage Var.EndVoltage = 5 // ending voltage // note that the above could be set elsewhere, for example with a screen component private.starttime = SysTime() while (SysTime() < Private.starttime + Var.TotalTime) Output = Var.InitialVoltage + (SysTime() - private.starttime) / Var.TotalTime * (Var.EndVoltage - Var.InitialVoltage) delay(Var.UpdateTime) endwhile Output = Var.EndVoltage // make sure we are at end since last step could be missed So, in the meat of the loop, we first record the time we start the transition. Then, while the totaltime has not elapsed we loop. On each iteration we set the output channel. The formula is made up of several parts. The (SysTime()-private.starttime) / Var.TotalTime returns a number between 0 and 1 where 0 is the start and 1 means the total time has elapsed. We then multiply this by the total voltage change and add that to the initial voltage. After setting, we delay for the update interval and then loop. When the loop quits, we set the output to the target voltage to ensure we got the last step. This is because depending on the timing of the loop the final output setting might not occur within the loop.
  21. AzeoTech

    0 - 5Volt Fader

    I'm not really sure exactly what you are trying to do. But first, and I only mention it because if I don't say it, you may never know, but 0-5volt is voltage not current. Current is typical in units of Amps and a power supply that allows you to vary the current is a completely different beast. OK, that said, you have just a regular variable power supply with a pot to adjust the voltage on the PS. You want to be able to set the power supply to 5 volts from within DAQFactory no matter what the pot says? If so, this is actually a bit trickier then you'd think. You have to look at the Pot and see what it is doing. If its just a simple voltage divider on the output, then you could use a relay to bypass it. If its controlling some internal circuitry, you have to figure out how it works. It could be grounding the circuitry to set it to 5V or doing the opposite. That's why its tricky, and if done wrong you could blow the power supply. What you may want to do is keep the power supply set at 5V all the time, and then put your own bypassable pot downstream of the powersupply. Truthfully, I'm the software guy, so perhaps others can contribute here about how best to implement the hardware side. So, moving on to my area: what do you want the software to do? Do you want it to control the voltage all round (if so you can use an I/O module)? What determines what voltage to output? As for your code: 1) Pretty much any time you want to monitor an input you should use an event as I showed you in your previous enquiry. 2) There is no "then" statement in DAQFactory 3) "(Digout + 1)" is not a valid statement either since it doesn't say where to put the value digout+1. "Digout = Digout + 1" is valid, or "Digout = 1" 4) There are only very rare reasons to use wait(). You should use delay() instead in general. 5) The indenting should look more like this: while (1) read(inputvalue) if (Inputvalue <= 5) Digout = 1 endif delay(1) endwhile
  22. AzeoTech

    timer function

    I'm a little confused want you want, but I believe you want to monitor a digital input and if it goes high (i.e. switch closed) you want to light an LED for 15 seconds by setting a digout high and then low again after 15 seconds. To do this, you'll of course need a digital input and digital output channel. Lets say they are called DigIn and DigOut. 1) In the event for DigIn (click on the "DigIn" in the workspace under CHANNELS: then select the Event tab), put: if ((DigIn[0] == 1) && (DigIn[1] == 0)) beginseq(PulseLED) endif This looks for when the digital signal goes high after being low. 2) Next create a sequence called PulseLED and put: DigOut = 1 // turn on LED delay(15) // wait 15 seconds DigOut = 0 // turn off LED The event will cause this to run when the switch is pressed. If the switch is pressed while the LED is already on nothing additional will happen.
  23. AzeoTech

    question about sequence execution

    Oh, and since this seems to be the question of the day and relates: The only way to control the order in which multiple sequences auto-start is to do what you did and create a single auto-start sequence and have that start your other sequences.
  24. AzeoTech

    question about sequence execution

    No, sequences run until they don't have any more statements to exectute. A sequence will only run forever if you have a loop in it. So this sequence: var.a = 3 var.b = 4 beginseq(myotherseq) will set a and b and start myotherseq and then stop since it ran out of things to do. However, this sequence: while (1) var.a = 3 var.b = 4 beginseq(myotherseq) endwhile would repeated set a and b and try to start myotherseq. "while(1)" means loop forever because 1 is the same as true. Since myotherseq is probably already running the second time around, it will not restart it, but instead the second and subsequent execution of beginseq(myotherseq) would probably do nothing. Once myotherseq stopped though some other means, this sequence would restart it. Please note: you would NEVER want to do the second sequence as it is essentially an infinite loop. If the sequence priority was anything other than 0, you would most likely hang DAQFactory. If it is 0, your graph and image drawing might be sluggish. Instead, you should pretty much always have a delay() inside the loop. The delay typically should be at least 0.01: while (1) var.a = 3 var.b = 4 beginseq(myotherseq) delay(1) endwhile
  25. AzeoTech

    HEX display

    Well it depends. Where is this binary value stored? In a string I presume?