# AzeoTech

5,729

## Everything posted by AzeoTech

Upload where? Do you mean load it into DAQFactory memory for display? Or upload it to a webserver? Or something else?
2. ## Hall Effect Current sensor / transducer

Assuming you are seeing the proper voltage swing, to convert from Volts to Amps you would use a Conversion. Click on CONVERSIONS: in the Workspace, then Add a new conversion. Give it a name, like "HallEffectCurrent" or something. The Expression in your case would be: Value / 5 * 60 - 30 Of course you can reduce that if you want, but showing it unreduced makes it more obvious what was done. So Value/5 takes 0-5 and converts it to 0-1. * 60 converts it to 0-60 (amps), then the -30 converts it to -30 to +30 amps. Finally, go to your input channel and select the new Conversion and Apply.
3. ## Report Creation

Unfortunately you will almost certainly have to use the Acrobat Distiller and printPage. If you are having problems with printing the page, you might need the latest build. Please email us directly and we can provide you with a beta. It does printing a lot better than older releases.
4. ## Newbie.. Counting Pulses every 10 seconds

This really only applies if you are running continuously without powering off the LabJack (which resets the counter): I believe that the LabJack M counter is a 32 bit counter. So, once you reach 4.2 billion counts or so, its going to reset to 0. So every so often (like once a month) RawCounts[0] is actually going to be less than RawCounts[1]. So, you have to adjust: if (RawCounts[1] < RawCounts[0]) counts = RawCounts[0] - RawCounts[1] else counts = RawCounts[0] + 2^32 - RawCounts[1] endif Just FYI: you can do this two other ways in a single line of script, which is more efficient for the computer, but harder to understand by humans: counts = iif(RawCounts[1] < RawCounts[0], RawCounts[0] - RawCounts[1], RawCounts[0] + 2^32 - RawCounts[1]) or even better: counts = RawCounts[0] - RawCounts[1] + (2^32) * (RawCounts[0] < RawCounts[1]) The last one is probably 100 times faster than the original if/else, and maybe 20 or 30% faster than the iif(), but I''m guessing at that.
5. ## Newbie.. Counting Pulses every 10 seconds

You are right. I got that backwards. I was thinking about a regular delta. The folks at LabJack will need to address the DIO# issue. But the problem with using this method is that you can lose counts while the counter is being reset. This probably isn't an issue at low count rates, but at high ones, it can be significant. That said, at high rates, you also have to change the expression I gave you to account for counter roll over.
6. ## Newbie.. Counting Pulses every 10 seconds

Create a second channel, Device Type "Test", I/O type D to A. Call this one, say "Counts", and call your actual LabJack counter channel "RawCounts". Expand CHANNELS in the workspace, and select RawCounts. Then select the Event tab. In the event type the following: Counts = RawCounts[1] - RawCounts[0] The Counts channel will now hold the difference in counts between two consecutive readings. To get 10 second counts, set the Timing for the RawCounts channel to 10.
7. ## AscA not working as expected in execute()

Actually the problem isn't with asca(). The problem is that string concatenation doesn't support arrays. So even: ? "array: " + {1,2,3} + " end array" will print: array: 1 end array The problem is that DAQFactory doesn't really know how you want to present the array. Do you want a comma delimited list? With brackets or without? Space after the comma? Etc. Plus, beginners often really only want [0], especially when using channels, but forget to do so. So: "My Value: " + myChannel will do the same as: "My Value: " + myChannel[0] So, in your case, what you really need to do is keep the asca() in the quotes: execute(ChannelName + ".AddValue(asca(" + strArg + "))") that way the concatenation doesn't involve the array. But then, why are you pulling out strArg anyway? Remember, execute() runs in the scope of the call script, so you should be able to reference strArg from within the string: execute(ChannelName = ".AddValue(asca(strArg))")
8. ## Passing a variable to a sequence with beginseq()

Not directly. But you'd simply have to create a global variable, set that variable, start the sequence, then use the variable inside the sequence. I suggest naming your globals something with the sequence name, for example: mySequence_variableName. There are ways to run functions in their own thread, though this is usually best done inside an object to avoid losing track of the thread.
9. ## Reading a streamed channel

Starting and stopping the stream like that is impossible because DAQFactory only sees the data in blocks. You can log that data, however, using an export set. Just clear the history of the channel before starting the stream (myChannel.clearHistory()), then start the stream. Once you stop the stream you can log the first 125 values using the expression: myChannel[numrows(myChannel)-126, numrows(myChannel)-1] in the export set.
10. ## Byte conversions

Most no. You have the wrong hex values. You have to think in binary, and might want to use binary notation instead:: D7-D4 (Batt_Status[0]>>4) & 0b1111 and D3-D0 Batt_Status[0] & 0b1111 if I named A16 CES and I wanted the charging status (D3-D2) (CES[0]>>2) & 0b0011 if I wanted A16 D15-D14 would it be (CES[0]>>14) & 0b11

Good. Actually I pretty much never use the user serial protocols unless I need to create a protocol that I will use across multiple documents. It is much easier to develop protocol code in a sequence. In fact, even if I expect to create a user serial protocol, I'll still develop it first in a sequence to test it, then migrate it over.
12. ## windows 10 saving

This actually has more to do with default security settings for folders in Windows 10, along with changes in how DAQFactory installs. By default, the DAQFactory installation folder (and most of its subfolders) are marked read-only to non-admins. Simply running as Admin doesn't get you past this. So, you have to go the folder you are trying to log to in Windows Explorer, and change the security on that folder to allow Everyone to write to the folder.
13. ## Calculate rms value of an an array

I don't think so. You were on the right track at the bottom, but the field labelled RMS is: max(captureddata) / 2^0.5 when it should be: mean(captureData^2) ^ 0.5
14. ## Logging on a specific treshold

#1) do you only want to log after the time the channel becomes greater than X? I.e. when it crosses the threshold? First of all, there are time latencies that can't be avoided if you do this in software. This comes from both the delays in communications with hardware, and with how often you query the input. For example, if your Timing is set to 0.1, then even ignoring comm delays, DAQFactory may not know if the channel crossed the threshold for 99.99 ms. There are a couple ways around this, as you can't query the input faster than maybe every 10 or 20 ms. Even if you stream, you can't do the logic in-situ because in stream mode, the data comes in in blocks. The first way is to stream, but stream both channels, then analyze the data in blocks as they come in. This is a bit more complicated to achieve, and is usually best done in a separate sequence. The problem with this is that you still are subject to the latencies of streaming, but you can stream really fast and get that well below a millisecond. If, however, you really need it super tight, you will have to use hardware triggering. Use a schmidt trigger to set a digital signal for when the threshold is crossed, and feed that trigger into a trigger input on your DAQ device. The LabJack supports this sort of thing, but I don't know what hardware you are using. #2) this is much easier. Create a global variable called, say, "startTime", declared in an auto-start sequence. Then at the top of the sequence you want to top, do: startTime = systime() Then, wherever you want to display the elapsed time, use something like: iif(mySequence.running, systime() - startTime, 0)
15. ## Calculate rms value of an an array

Yup, but I'm not sure how well it will work with quantized data. The accuracy is going to depend on the sampling interval, and some sort of curve fit might be helpful. But ignoring that and assuming you have a channel / array "X" with your data, the RMS calculation in DAQFactory would simply be: mean(x^2) ^ 0.5 Remember, doing x^2 returns an array the same size as x, where each value of x is squared. Mean() takes the mean of whatever array is provided to it. And ^ 0.5 raises whatever is to the left to the 1/2 power, which is the same as square root.
16. ## I/O Type - Set Register type 10?

That's a Modbus specific error returned by your device. You'd have to check your device docs as the meaning of that really depends on the device.
17. ## Setting up FIO for a Labjack U6

First get it so you can manually control the Tick DACs. I'm pretty sure there is sample code on the LabJack website. After you have that working, then you can put the desired code in the Event for the appropriate channel. Event's are code in channels that get executed every time the channel gets a new value. You get to them by expanding CHANNlELS: in the workspace, clicking on a specific channel, then selecting the Events tab.
18. ## Calculate rms value of an an array

There is no built in function for calculating RMS, but if you can point me to a page with the formula you'd like to use, I can probably show you how to write it in DAQFactory.
19. ## Reading a streamed channel

What do you mean by counting? Do you want to read 125 times then stop? I'm unsure what you want to do.
20. ## CRC &LT

OK, somewhere along the line, the system or your browser encoded the code for browser compatibility. &gt; means a greater than sign. &lt; is less than, &amp; is the amperstand. Once you replace those it should make sense. Note however that this is the CRC for Modbus. Not all systems use the same CRC and you should probably look at your device's documentation to see how they do it. private crc = 0xffff private raw = asca(buffer) for (private x = 0, x < GetLength(buffer), x++) crc = crc # raw[x] for (private j = 0, j < 8, j++) if (crc & 0x0001) crc = crc >> 1 crc = crc # 0xA001 else crc = crc >> 1 endif endfor endfor return(crc)
21. ## Simple Script for copying channel groups

It would not be difficult to create one as I believe every variable, even the event (strEvent) code is available from script. Use channel.listAll("groupName") to retrieve a list of channels, then loop through that list and using execute() copy all the parameters from one to the other, remembering to change the group name, as well as the channel name for the new channels.
22. ## I/O Type - Set Register type 10?

My guess is that they are specifying the function codes in hex, as 10 hex is 16 decimal. Especially since there is no function 10 in standard Modbus. So you should be able to use code 16. If it isn't working it may be an alignment issue. What error are you getting?
23. ## Reading a streamed channel

I don't know what you have. Can you post your script?
24. ## Pop up message

It means the document is open by another program exclusively and DAQFactory can't access it. It is not a message I've ever seen with a DAQFactory document, especially since DAQFactory doesn't access the .ctl document except when it is loading and saving. Are you perhaps triggering a save from script?