Jimmy1125 Posted November 30, 2021 Share Posted November 30, 2021 Hello, I’m having issues with a velocity sensor. I would like to use a displacement sensor ,called stroke ,I record to determine velocity. I know I have to (stroke[0]-stroke[1])/(stroke.time[0]-stroke.time[1]). I want to do the whole array so would I do a for or while loop? And where would it go? I don’t believe it would go in an event as I’ve read it comes in blocks and won’t process correctly. I was thinking of a v channel but not sure how to do it correctly. I want to use data in a graph after. Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted November 30, 2021 Share Posted November 30, 2021 So you are streaming the input? Do you want to log the velocity, or just trend it? If you just want to trend it, you can just trend the calculation: (stroke[0,10000] - stroke[1,10000]) / (stroke.time[0,10000] - stroke.time[1,10000]) That would go right in the Y Expression for the graph. Quote Link to comment Share on other sites More sharing options...
Jimmy1125 Posted November 30, 2021 Author Share Posted November 30, 2021 Great. What if I want to log it? Could I put the same in v channel? Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted November 30, 2021 Share Posted November 30, 2021 No. How you would log it depends on how you are logging everything else. Quote Link to comment Share on other sites More sharing options...
Jimmy1125 Posted December 28, 2021 Author Share Posted December 28, 2021 hello, I am having a strange problem. I'm setting up a basic counter. I tried it in Labjack test panel and it works okay. after numerous tries in DAQ, I decided to try the basic counter sample and was successful. The problem lies in my .ctl somehow. I can't get the RawCounts channel to read anything. After reconfiguring my startup sequence, I copied and pasted the sample startup and just changed the pin offset to match my Labjack( I did it in basic counter to get it to work). I'm still not getting anything. Basic counter sample works fine but my .ctl doesn't. Maybe you can see something I missed? Also, I've double and triple checked to channel settings compared to sample. SHOCKDYNO.ctl Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted December 28, 2021 Share Posted December 28, 2021 Two things: 1) I recommend doing PIN_CONFIGURATION_RESET to ensure the LabJack isn't in a weird mode 2) and most likely the issue: I am pretty sure you can only apply an even Counter pin offset. You'd have to ask LabJack to confirm. Quote Link to comment Share on other sites More sharing options...
Jimmy1125 Posted December 28, 2021 Author Share Posted December 28, 2021 Then why does it work in the basic counter sample, which is configured as 7? Also, as I said, everything is exactly the same in both but mine doesn’t work. I have the pin reset in my startup and that didn’t work either. That’s why I copied the sample startup sequence to no avail. Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted December 28, 2021 Share Posted December 28, 2021 Sorry, my version of BasicCounter has it configured at 4. Are you getting any sort of errors in the Command/Alert? What does the counter do? How do you know it doesn't work? Quote Link to comment Share on other sites More sharing options...
Jimmy1125 Posted December 29, 2021 Author Share Posted December 29, 2021 It says 4 but I changed it to 7 and it works. No alerts. As I said, when I load basic sample and change pin to 7, the RawCounts increments by turning gear tooth wheel. When I load my document it doesn’t. I’ve quadruple checked the settings and nothing increments. Baffling. Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted December 29, 2021 Share Posted December 29, 2021 So it sits at 0, but updates? Can you run it without running any other script so it just runs the same Startup2 script and reads the counter, but not any of the A to D (or anything else)? Quote Link to comment Share on other sites More sharing options...
LabJackSupport Posted December 29, 2021 Share Posted December 29, 2021 You can use an odd pin offset configuration. The valid pin offsets depends on the device. For the U3, 4-8 is valid. For the U6, 0-8 is valid. Your STARTUP1 script contains everything you should need to get going with a counter and your RawCounts channel looks set up correctly to read it. One thing I noticed is that you almost certainly have the wrong header file path, the include would not resolve correctly if you are using 64-bit Windows. You can better handle OS bitness related path issues by using a try catch block around the include. The following is what we use in our examples and should work correctly for 32-bit or 64-bit Windows: try include("c:\program files (x86)\labjack\drivers\labjackud.h") catch() include("c:\program files\labjack\drivers\labjackud.h") endcatch If you are still having issues with the counter not incrementing, I would recommend removing your actual signal and using a test signal. Connecting a wire to FIO7 and touching the free end to the inside back of a GND terminal should cause edges and therefore increment the counter some arbitrary amount. We would also recommend you try running the counter setup sequence manually after startup. Quote Link to comment Share on other sites More sharing options...
Jimmy1125 Posted December 30, 2021 Author Share Posted December 30, 2021 Crazy! I went this afternoon to try and it was working fine. Don’t know if it was an issue with the way I tried resetting it but all is good. Next question I want to use my rawcounts in my post-process data processing. Can I stream the rawcounts channel? I want to be able to filter my other channels based on the rawcounts. Since it’s set at 1 second timing, Compared to my stream of 1000, I don’t see how my data would line up properly. Also, can I have the same channel with different names? I want to stream them but also setup a variable value component I can watch live. Quote Link to comment Share on other sites More sharing options...
Jimmy1125 Posted December 30, 2021 Author Share Posted December 30, 2021 Hello. Apparently I must have done something wrong resetting because when I went back it was working. Is it possible to stream the rawcounts channel? I want to use it in post run data processing. I need it to line up with my streaming channels. I don’t think it will line up reading at 1second intervals when I’m streaming at 1000/ sec. Also, can you use the same channel with a different name? I’d like to use some variable value components to display real time readings. Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted December 30, 2021 Share Posted December 30, 2021 You should be able to, but I'll let LabJack respond. But, the data should line up if you use a logging set and set the alignment threshold small (0.001 probably). I'm not sure what you mean by the channel name. You can change the channel name all you want. Quote Link to comment Share on other sites More sharing options...
LabJackSupport Posted December 31, 2021 Share Posted December 31, 2021 You can stream the counters, but that will look a little different in terms of the channel configuration. To read Counter0 while streaming you must read channel 210 as an A to D I/O Type and channel 224 (TC_Capture) as an A to D I/O Type. The following page has additional information about the timer/counter stream channel changes: https://labjack.com/support/datasheets/u3/operation/stream-mode/digital-inputs-timers-counters We also have a few DAQFactory examples that stream timers/counters at the bottom of the following page: https://labjack.com/support/software/examples/ud/daqfactory Quote Link to comment Share on other sites More sharing options...
Jimmy1125 Posted December 31, 2021 Author Share Posted December 31, 2021 Thanks, I’ll read up on that. As far as channel names, I’d like to have 2different names for the same channel. One I can stream and the other I can set timing to something like 0.01 to put in a variable value box for real time readings. So I would have a channel named force on channel 0 with timing of 0 and one named force1 on channel 0 with timing of 0.01. Then I can stream force and put force1 in a variable value box. Thanks Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted January 4, 2022 Share Posted January 4, 2022 Why wouldn't you just display the result of the stream? Just do [0] on it. It will update with every stream block which is several times a second. Quote Link to comment Share on other sites More sharing options...
Jimmy1125 Posted January 4, 2022 Author Share Posted January 4, 2022 That’s fine. Didn’t know that. Still learning. Thanks for all the great advice. Quote Link to comment Share on other sites More sharing options...
Jimmy1125 Posted January 12, 2022 Author Share Posted January 12, 2022 hello Is it possible to use the event of a channel to control my LJTic_DAC? I have a 60 tooth wheel and want to rotate it 140 teeth. if I use an if statement in event with appropriate LJ command, will that work? Im using rawcounts channel to count. Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted January 12, 2022 Share Posted January 12, 2022 Yes, you can do that but you have to be careful. Just remember that the script in the channel Event runs in the same thread as the Timing loop so any delay in executing the script could affect your timing. For example, if you have your input channel timing set to 0.02, and you do the LJTic_DAC command and that takes 0.03 seconds, then your input channel will only read at every 0.03 seconds since it was tied up adjusting the LJTic_DAC. That is why it is sometimes better to have a secondary loop in a sequence watching the input and tweaking an output separately. That all said, in your case, you are probably fine... Quote Link to comment Share on other sites More sharing options...
Jimmy1125 Posted January 13, 2022 Author Share Posted January 13, 2022 I tried using a separate sequence to do that but for some reason it wouldn’t work correctly. Seemed like the sequence would get kicked out at some point and not execute the rest of the lines. By that I mean, I would watch the sequence in the workspace and the black line showing the sequence running would disappear before it was finished. Tried a few different things and couldn’t figure out why. Thought a channel event might work better. Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted January 13, 2022 Share Posted January 13, 2022 If the sequence doesn't run all the way through then there is likely an error and a corresponding error message in the command / alert window. Moving the script to an event won't likely eliminate the error, so you should probably chase that down. Quote Link to comment Share on other sites More sharing options...
Jimmy1125 Posted January 18, 2022 Author Share Posted January 18, 2022 Hello, As a follow up, does an if statement only evaluate one time? I believe that is my problem. The sequence runs through and checks once and the value isn't met and it just ends the sequence. I assume I need to put a while(1) before the if to keep it in a loop until the value is met? On another note , all of a sudden i'm getting a communication failure message. previously it was intermittent and I paid no attention to it but now it won't communicate at all. I tried it in LJ control panel and things work fine, but not in DAQFactory..any ideas? Quote Link to comment Share on other sites More sharing options...
Jimmy1125 Posted January 24, 2022 Author Share Posted January 24, 2022 Sent a post but it says hidden. Is there a problem? Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted January 24, 2022 Share Posted January 24, 2022 No problem. We just didn't get the notification of the new post for some reason. Sorry about that and I'm glad you followed up. Unless an if() statement is in a loop, it only executes once. But aren't you calling the sequence from your event? Or do you want it to just run, continuously checking the value. If the second, then yes, you need to put a while(1) along with some sort of delay() to get it to check every so often. Something like: while(1) if (...) endif delay(1) endwhile The delay should probably match the Timing of your input channel. There is no reason to check it faster than the values are updating. As for comm errors, that's going to be on the LabJack side, but here are few items to note: 1) you cannot run DAQFactory at the same time LJControlPanel or Kipling is running. For that matter, you can't run it at the same time as any other program that is accessing the LabJack. This is a limitation of the LabJackUD and M drivers, not DAQFactory. 2) watch out for using First Found (D# 0) and an actual ID at the same time in an application. You should only use First Found if you only have one LabJack, and in my opinion, never, since inevitably, once you see how flexible the LabJack's are, you end up buying a second one! If you have two, then it is possible that First Found will find the same LabJack that you specified the ID for, and it won't be able to open two connections to the device. This becomes more complicated because First Found is not predictable on what it considers "first", so might give you a different LabJack when you restart DAQFactory. So it might work for a while and then, after a restart, stop working. 3) make sure you are running the latest drivers and firmware from LabJack. Being fully updated fixes a surprising number of issues. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.