Modified PWM Vi example and LabJack Error #43: Timer sharing error occurred at LJUD_eTCValuesB.vi | LabJack
 

Modified PWM Vi example and LabJack Error #43: Timer sharing error occurred at LJUD_eTCValuesB.vi

11 posts / 0 new
Last post
MarsianaM
MarsianaM's picture
Modified PWM Vi example and LabJack Error #43: Timer sharing error occurred at LJUD_eTCValuesB.vi

So i combined 2 VIs which is Stream VI and  PWM VI. My intention is to control motor servo using PWM based on the movement of accelerator. but I got this message, and the VI keep stopping. Motor servo move a bit based on the frequency from acceleration signal. Can someone help me solve the problem? i really appreciate it 
hereby, i attached the file of my VI. it is a bit messy, but please focus on X acceleration and on. I am planning to finish the other channel after resolving this problem. Thankyou

File Attachment: 
LabJack Support
labjack support's picture
We use LabVIEW 7.1, so can't

We use LabVIEW 7.1, so can't open your VI.

I would look at "U3 Stream AIN with Timers & Counters.vi".  In the stream read loop this example makes a call to eTCValues.  That function can update the duty cycle of PWM output, but not change the frequency, so to change frequency you need to change the VI to call the eTCConfig function whenever you want to change frequency.

MarsianaM
MarsianaM's picture
Hi, i am truly sorry i can't

Hi, i am truly sorry i can't save the vi into 7.1 version, best i could do is saving the vi into 8.0 . I modifying "U3 Stream Ain with Timer and Counter" abit. I change time clockdivisor with the one similar to PWM.VI example, also change TimerValuesWrite with the one in PWM.VI. It do solved the timesharing problem, but i still not get it why I cannot control the output PWM?
I connecting the servo motor to FIO4 output which connect to PWM output, but nothing change and the servo motor keep rotating.  Is something wrong with my program? please kindly check it. i also attach the screenshot of my VI..

Also i want to ask you what is the use of u3 backlog[%] and UD backlog[%] in program? and can i stream 2 channel with "U3 Stream Ain with Timer and Counter.Vi" ?

Thankyou

File Attachment: 
LabJack Support
labjack support's picture
Look closely at the

Look closely at the documentation for the aUpdateResetTimers parameter of the TCValues function:

https://labjack.com/support/datasheets/u3/high-level-driver/function-ref...

You are passing false for the first element of that array, meaning that you will not update the value of Timer0.

Read more about the backlog values here:

https://labjack.com/support/datasheets/u3/high-level-driver/example-pseu...

It is normal that they bounce around a little, but should not be growing over time.  If they are growing you are not reading data as fast as it is being collected.

Yes, you can stream 2 analog inputs.  Just change the channel list.  The default is 1-201-224-211-224-193, but to add AIN2 and AIN3 you could do 1-201-224-211-224-193-2-3.

JimWilson
James.Wilson's picture
Hi,

Hi,

I have a U3-HV and am new to programming LabJacks, so I am learning DAQFacrory and have LabVIEW 7.1 through 15. I started with basic counter and basic stream (DF). They worked individually, but combining them raised issues. Suspend streaming and the counter works, start streaming and the counter while still counting does not get logged by software.

The second issue;

ePut(lD, LJ_ioPUT_ANALOG_ENABLE_PORT, 0, 255, 16) to test the channels all offer reasonable voltage values. In the combines file;

ePut (lD, LJ_ioPUT_ANALOG_ENABLE_BIT, 3, 1, 0);     //Configure FIO3 as an analogue input. In this scenario suspended streaming gave a binary value around 32830 then when streamed the value became reasonable. {Should this not work either way?}

I am sure I should be able to read timers, counters and Ain or Dio channels and streaming at the same time, I just don’t know how, streaming seems to take over. Went looking at the U3 Forums and found “Modified PWM Vi example and LabJack Error #43: Timer sharing error occurred at LJUD_eTCValuesB.vi” among others. I loaded MarsianaM VI, found the LabVIEW_LJUD_2016_02_09.zip and LJUD64bitv328 for a dll file. It loads everything, but fails in all SubVIs because of “Call Library Function Node: Library not found or failed to load.” Now it is beyond me to know what I should be looking for. I know they are emulating the same “C” style code used in DAQFactory but having found all the files I can only assume a wrong DLL.

Will have to get back on LV7.1 to see what I can find. Any Ideas would be greatly appreciated.

Cheers Jim

PS I don’t normally use forums, so I didn’t know if I should comment here or start a new thread.

File Attachment: 
JimWilson
James.Wilson's picture
My comment disappeared, did

My comment disappeared, did it upload?

Cheers Jim

LabJack Support
labjack support's picture
Error 43 is thrown when

Error 43 is thrown when attempting to use a Counter0 and a PCA clock mode that has a divisor. Described in more detail in the second to last paragraph here: https://labjack.com/support/datasheets/u3/hardware-description/timers-co...

The easy solution is to disable Counter0 and enable Counter1 instead.

LabJack Support
labjack support's picture
To add:

To add:

You'll want to make sure your stream code is not disabling your counter. Note that a LJ_ioPIN_CONFIGURATION_RESET call will disable all timers and counters, which BasicStream.ctl does in the StartStream sequence. To stream a counter, use channels 210/211 and 224 in your scan list. These channels are documented here:

https://labjack.com/support/datasheets/u3/operation/stream-mode/digital-...

In this scenario suspended streaming gave a binary value around 32830 then when streamed the value became reasonable. {Should this not work either way?}

Are you streaming AIN3/FIO3 and getting this binary value? I'm unsure on the channel you are streaming when you mention this.

Yes, you can stream timers, counters, digital I/O and analog inputs in the same stream. I'm not sure on the MarsianaM VI dependencies, but in our VIs the dependencies are in the examples download:

https://labjack.com/support/software/examples/ud/labview

As with helpful examples on streaming timers/counter, in our LabVIEW examples there is a "U3 Stream AIN with Timers & Counters.vi" example in the U3\Stream folder. In the DAQFactory examples page there is a U3_StreamTimerCounter.ctl example:

https://labjack.com/support/software/examples/ud/daqfactory

Regarding LJUD64bitv328 and its dll, that is the old 64-bit UD driver 3.28 before the installer had it. Current installers have the 64-bit driver and is version 3.50. Please use the driver from the installers instead (it's installed to \Windows\System32).

Last, forum topics are moderated and not visible until approved. When a post is edited, it needs to go through the approval process again.

JimWilson
James.Wilson's picture
Thank you for the response.

Thank you for the response.

In my counter&stream combined file the LJ_ioPIN_CONFIGURATION_RESET call is only in the Setup Sequence. I carried the start & stop buttons from BasicStreaming in case I needed the control. The “Start” has no general reset and the “Stop” stops stream only.

"In this scenario suspended streaming gave a binary value around 32830 then when streamed the value became reasonable. {Should this not work either way?}

Are you streaming AIN3/FIO3 and getting this binary value? I'm unsure on the channel you are streaming when you mention this."

In the suspended scenario that is stopped streaming, I expected a 1 second update of the Ain3 Voltage not the binary value seen. There is some mention of how to convert this (I think) in the raw section. When I start streaming this value resolves to the correct voltage. I am quite happy with the 1 second poll of data it generates enough numbers for analysis. I only want the stream to capture and display an AC signal with enough resolution. I would rather analyse the wave and update a 1 second test channel. Logging all the streamed data is way too much info to sort through.

The way you resolved my issue was to put everything in streaming. Is it not possible to log mixed mode information (stream array and single poll)? I would be happy with counter[0] every second from the data stream and ignore the rest. So this is to be my lot, put all channels in steaming and resolve the outcomes into test channels every second and log the test channels (DF). Would it be possible to log the streaming arrays if necessary?

Cheers Jim

LabJack Support
labjack support's picture
I afraid I'm a little

I afraid I'm a little confused about where we are talking about LabVIEW or DAQFactory.  If you still have problems try to narrow it down a bit and we can help you tackle it.  One general comment is that you can use command-response calls, while a stream is active, to read/write almost everything except analog inputs.  Analog inputs are taken over by the stream system:

https://labjack.com/support/datasheets/u3/operation

JimWilson
James.Wilson's picture
This thread started in

This thread started in LabVIEW which I have access to. Finding a glitch that I will look to avoid by replicating the LV program in 7.1. All my other questions have been from DAQFactory (DF) access to the U3. It appears that DF set channels cannot poll while a stream is running. Hopefully I can resolve it all from here. Thanks again for your help. Cheers Jim