Labjack T7, PWM and Daqfactory | LabJack
 

Labjack T7, PWM and Daqfactory

32 posts / 0 new
Last post
johanholstein
johanholstein's picture
Labjack T7, PWM and Daqfactory
My small test project is 1 temperature sensor type K and a Labjack T7. Some issues to get a PID contoller working with Daqfactory. First of all I loaded some registers in the Register Matrix,
DIO_EF_CLOCK0_ROLL_VALUE DIO_EF_CLOCK0_ENABLE DIO0_EF_INDEX DIO0_EF_CONFIG_A DIO0_EF_ENABLE

Then I created in Daqfactory some channels and for the Duty cycle I use in Quick Note : DIO0_EF_CONFIG_A 
All works perfect.... my question is can I load the register such as ( DIO_EF_CLOCK0_ROLL_VALUE DIO_EF_CLOCK0_ENABLE DIO0_EF_INDEX DIO0_EF_CONFIG_A DIO0_EF_ENABLE   directly from Daqfactory in Sequence startup instead of using Kipling ?

thanks in advance 

Johan Holstein

 
LabJack Support
labjack support's picture
Yes, start with the "Device

Yes, start with the "Device Configuration" section here:

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

Note that if your configuration is always the same, you can just do it once in Kipling and save that configuration as the power-up default.

johanholstein
johanholstein's picture
Dear support, I look to the

Dear support, I look to the Daqfactory examples but not know how to do that .... can I use LJM_eWriteName(identifier, "DIO0_EF_CONFIG_A",16000)

Best,

regards,

Johan

LabJack Support
labjack support's picture
I updated the "Device

I updated the "Device Configuration" section a little bit:

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

Sounds like you are wanting to use method #2A as described in that section.  Yes, you can use eWriteName to write values to the 5 configuration registers you listed.  See the example LJM_Basic.ctl, as it does just that, writing to 4 different configuration registers to set analog input ranges.

That is the configuration.  Your next question will likely be how to change the duty-cycle (CONFIG_A) in DAQFactory as your program runs.  For that, I would start with something similar to what you see for DAC0 or FIO1 Output in the basic example.  So first define a channel in the DF Channels list using the "Special", and then make a Variable Value Display on a Page that writes a new value to your Channel when clicked.  Then you might be interested in setting the output based on an input read:

https://labjack.com/support/ud/df-lj-app-guide/7.1

johanholstein
johanholstein's picture
Thank you support that was a

Thank you support that was a great help!

johanholstein
johanholstein's picture
Dear support one question can

Dear support one question can the T7 power directly a Solid state relay 3 volt. I mean here the PWM output from The T7. Thanks Johan

LabJack Support
labjack support's picture
A digital output can directly

A digital output can directly control most SSRs, but in the case of PWM output it cannot directly control most LEDs.

Understand that digital I/O have 3 states:  input, output-high, and output-low.  To do direct control of an SSR, you connect it for sinking control (VS & DIO) where you change the DIO between input (off) and output-low (on) to control the SSR.  PWM drives a digital output between output-high and output-low, not input and output-low.

https://labjack.com/support/app-notes/controlling-relays

johanholstein
johanholstein's picture
Test project under test

Test project under test Daqfactory and T7 a nice combination!

johanholstein
johanholstein's picture
Hi again, I have conected 1

Hi again, I have conected 1 thermocouple to AIN0 and use for PWM FIO0 that's works fine with DIO_EF_CLOCK0_ROLL_VALUE=80000, DIO_EF_CLOCK0_ENABLE=1, DIO0_EF_INDEX=0, DIO0_EF_CONFIG_A=32000, DIO0_EF_ENABLE =1  For thermocouple 2 and 3 I am stuck .... how must I address this registers to get 3 thermocouples and 3 pwm out  ?

The first work fine ... and now the next ...

Thanks for helping

Johan Holstein

johanholstein
johanholstein's picture
Hello Support, do you have

Hello Support, do you have any suggestion ... witch register I must use for the setup for pwm 2 out and pwm 3 out see above.

Thank you.

Best,

Johan

johanholstein
johanholstein's picture
Problem solved with PWM,

Problem solved with PWM,

//Allow supported calls to the LabJack LJM library.

Using("device.labjackm")

//Configure PWM Functionality on T7

Global string identifier = "any"

LJM_eWriteName(identifier, "DIO_EF_CLOCK0_ROLL_VALUE",80000)

//PWM on output FIO0

LJM_eWriteName(identifier, "DIO0_EF_ENABLE",1)

LJM_eWriteName(identifier, "DIO0_EF_INDEX",0)

//PWM on output FIO2

LJM_eWriteName(identifier, "DIO2_EF_ENABLE",1)

LJM_eWriteName(identifier, "DIO2_EF_INDEX",0)

//PWM on output FIO3

LJM_eWriteName(identifier, "DIO3_EF_ENABLE",1)

LJM_eWriteName(identifier, "DIO3_EF_INDEX",0)

//Watchdog

LJM_eWriteName(identifier, "WATCHDOG_ENABLE_DEFAULT",0)

LJM_eWriteName(identifier, "WATCHDOG_TIMEOUT_S_DEFAULT",15)

LJM_eWriteName(identifier, "WATCHDOG_RESET_ENABLE_DEFAULT",1)

LJM_eWriteName(identifier, "WATCHDOG_ENABLE_DEFAULT",1)

LabJack Support
labjack support's picture
As a recap for others, you

As a recap for others, you are handling device configuration by using method 2A from the "Device Configuration" section here:

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

I see that you are setting the Clock0 roll value, but you do not enable the clock.  Do you enable it somewhere else?

For each of your 3 PWM outputs, you enable the feature and then set the index.  It would be more correct to set the index (and also set an initial value for config-a), and then enable.

Are you wanting to also add thermocouple configuration?  For each analog input, you would write to AIN#_EF_INDEX and perhaps some of the
AIN#_EF_CONFIG_ registers if needed.

Your watchdog configuration looks good.  You have configured the watchdog to reset the T7 whenever it does not receive any communication from the host for 15 seconds.  Note that if you close DAQFactory, without disabling the watchdog, the device will then reset every 15 seconds as long as no software is talking to it.  There is nothing wrong with this, but if you want to avoid it you might post on AzeoTech's forum to ask about how to run a script when DF closes so you can disable the watchdog:

http://www.azeotech.com/board/

Note that the watchdog registers have _DEFAULT at the end, which means they are immediately saved to non-volatile memory:

https://labjack.com/support/datasheets/t7/io-config-default

The DIO-EF and AIN-EF configuration in your script is not immediately saved.  That means that if the T7 reboots while your program is running, these will go back to default condition.  You could have some sort of error handling that detects this and re-runs the configuration script at that time, or an easy solution would be to just save your configuration by adding a write of IO_CONFIG_SET_DEFAULT_TO_CURRENT = 1 at the end of your script.

johanholstein
johanholstein's picture
Dear support, I enabled the

Dear support, I enabled the clock in Kipling.... but yes I also added now the next line to Daqfactory  LJM_eWriteName(identifier, "DIO_EF_CLOCK0_ENABLE",1) and added also //Set default values LJM_eWriteName(identifier, "IO_CONFIG_SET_DEFAULT_TO_CURRENT",1)  What means config -a ?????  

I also not understand exactly what you mean with : "For each analog input, you would write to AIN#_EF_INDEX and perhaps some of the AIN#_EF_CONFIG_ registers if needed."  Can you please give example ?????   Best regards, Johan Holstein

johanholstein
johanholstein's picture
Dear support, I did this for

Dear support, I did this for the startup in Daqfactory,

LJM_eWriteName(identifier, "AIN0_EF_INDEX",22)

LJM_eWriteName(identifier, "AIN1_EF_INDEX",22)

LJM_eWriteName(identifier, "AIN2_EF_INDEX",22)

LJM_eWriteName(identifier, "AIN0_EF_CONFIG_A",1)

LJM_eWriteName(identifier, "AIN1_EF_CONFIG_A",1)

LJM_eWriteName(identifier, "AIN2_EF_CONFIG_A",1)

Is this the right way ?

Best,

Johan

johanholstein
johanholstein's picture
Also this works perfect!

Also this works perfect!

LabJack Support
labjack support's picture
> Dear support, I enabled the

> Dear support, I enabled the clock in Kipling.... but yes I also added now the next line
> to Daqfactory  LJM_eWriteName(identifier, "DIO_EF_CLOCK0_ENABLE",1)

Doing some of the configuration in Kipling (Device Configuration method #1) and some in script in DAQFactory (Device Configuration method #2A) seems strange.  As long as you are doing some configuration in DAQFactory, I would do all configuration there.

> What means config-a ?????  

That was my shorthand for "DIO#_EF_CONFIG_A".  That is the parameter that sets the duty-cycle of the PWM output:

https://labjack.com/support/datasheets/t7/digital-io/extended-features/p...

> LJM_eWriteName(identifier, "AIN0_EF_INDEX",22)
> LJM_eWriteName(identifier, "AIN0_EF_CONFIG_A",1)

The first line is enabling the thermocouple feature for type K.  The second line is setting the output units to degrees F, rather than the default of degrees C.  You have not written anything for config-b (AIN0_EF_CONFIG_B), so are using the default which is device temperature.

https://labjack.com/support/datasheets/t7/ain/extended-features/thermoco...

https://labjack.com/support/datasheets/t7/internal-temp-sensor

https://labjack.com/support/app-notes/thermocouples

https://labjack.com/support/app-notes/thermocouples/t7

johanholstein
johanholstein's picture
Dear support, I use

Dear support, I use Daqfactory as the interface between the LabjackT7 very nice. But sometimes Daqfactory crashes (I never see crashes in other projects with Daqfactory) sometimes when start Daqfactory and sometimes after a while..... very starnge because many projects running with Daqfactory. Also I see sometimes LJME_RECONNECT_FAILED how come ? Please help I am stuck. Best regards, Johan

LabJack Support
labjack support's picture
USB or Ethernet?

USB or Ethernet?

For both, if you power-cycle the T7 while your program is running does it recover properly?

For Ethernet, if you disconnect/connect the Ethernet cable while your program is running does it recover properly?

Please update to LJM 1.11 using the 12-4 installer so you are using the latest library.

johanholstein
johanholstein's picture
When I disconnect the

When I disconnect the Ethernet cable I get a message in Daqfactory LJME_RECONNECT_FAILED .... and Daqfactory cannot connect again. But when I remove the power cable  of the Labjack then Daqfactory starts again. I downloaded and installed LJM1.11 but that make no difference. So the problem is still there!

LabJack Support
labjack support's picture
I posted 2 examples and am

I posted 2 examples and am tagging these for a couple other people to look at.  Both examples simply read 1 analog input.  1 use D#=0 and the other uses D#=IP.  Neither comes back when I disconnect then reconnect the Ethernet cable.

I'm testing with:

T7 Firmware 1.0192
LJM 1.11
DAQFactory Express 5.91 Build: 2233

johanholstein
johanholstein's picture
Dear support, I contacted

Dear support, I contacted also Matt W. from Azeotech he told me that probably Norton can mess up somethings.... and really I removed Norton and now everything works fine without any problem. Sorry for the inconvenience and your time. Best regards Johan

johanholstein
johanholstein's picture
Still one issue to clear ...

Still one issue to clear ... when disconnect the Ethernet cable from the Labjack the connection between labjack and Daqfactory stays lost

johanholstein
johanholstein's picture
I am testing with LabjackT7,

I am testing with LabjackT7, Daqfactory developer 5.91 release 2203. Firmware 1.0188, Labjack-2015-10-15 

johanholstein
johanholstein's picture
Dear Labjack support, is

Dear Labjack support, is there any news about ETH connection lost with Daqfactory ? best Johan

LabJack Support
labjack support's picture
No.  Sorry but the LJM guy

No.  Sorry but the LJM guy who needs to tackle this is on vacation this week, so can't look at it until next week.

I did a test in LabVIEW and was able to cause the same problem there.  I ran "LJM_eReadName Example.vi" using Ethernet, but put a breakpoint before the Close call so I could stop the VI before it closed the Handle.  I then just ran-continuously the "LJ_eReadName.vi" sub-vi with that Handle number, disconnected the Ethernet cable until I got the 1239 error, then reconnected the Ethernet cable, but kept getting the 1239 error forever.  I feel that LJM should automatically heal this connection but is not.

In other languages (including LabVIEW) besides DAQFactory, we could close the handle and do a re-open, but DF needs the auto-reconnect to work here.

johanholstein
johanholstein's picture
Hello Support, due problems

Hello Support, due problems with the LabkjackM driver we decide to use Modbus over Ethernet  with Daqfactory ....for temperatures / analog signals this works fine but for the DIO0_EF_CONFIG_A  register 44300 I get an error. I like to write to this register ... must I set also an other register to write to the modbus address 44300 ? Please help, best regards, Johan

johanholstein
johanholstein's picture
Dear support is there any

Dear support is there any news about post 25 and 26 ....... best regards Johan

LabJack Support
labjack support's picture
#25:  No new news.  This

#25:  No new news.  This problem is pretty complex in LJM, and lots of vacations going on right now, so unfortunately we have not resolved this as quick as usual.  I would add that normally Ethernet runs forever without any communication disruptions, so you usually don't need the reconnect functionality.  This might suggest a further problem in your case.

#26:  I just tried a direct Modbus write to 44300 using some LabVIEW-Modbus VIs and it worked fine for me.  Here are the packets sent and received:

Sent:  0, 0, 0, 0, 0, B, 1, 10, AD, C, 0, 2, 4, 0, 1

Received: 0, 0, 0, 0, 0, 6, 1, 10, AD, C, 0, 2

johanholstein
johanholstein's picture
I send in Daqfactory U32(16)

I send in Daqfactory U32(16)  modbus register 44300 still not accepted and get illegal data address ..... is there something wrong somewhere else ?

johanholstein
johanholstein's picture
Dear support, now I get this

Dear support, now I get this working with help from Matt  from Azeotech, for sending to register use 443100 and Set Register U32 R Words(16) for receiving  443100 use Read Holding U32 R Words (3).   Do also a call to an register above 50000. 

AzeoTech
AzeoTech's picture
LabJack uses a significant #

LabJack uses a significant # of Modbus registers to allow you access to all the features of the T7.  For this reason, all registers are numbered from 0, and because there were so many, they had to use registers in the 30,000 and 40,000 range.  These registers can confuse some software, including DAQFactory, into thinking that you are actually using the 40,001 notation that many manufacturers use.  So, when you specify 44300 it strips the 4 and subtracts 1.  This may even make some of your other readings suddenly not work as DAQFactory does the same thing to all registers.  To get DAQFactory to stick with 0 indexed notation, simply create a channel with a tag > 50,000 and read it once.  It doesn't have to be a real tag.

LabJack Support
labjack support's picture
Hi Johan,

Hi Johan,

If you're still using LJM and still have Ethernet reconnection issues, please try running the latest beta installer, which has LJM 1.1100. Ethernet reconnection works well for my tests.