« Close

Datasheets and User Guides

Software & Driver

 

5.2.22 - ReadDefaults (ReadCurrent) [U3 Datasheet]

Reads the power-up defaults from flash (Read the current configuration).

Table 5.2.22-1. ReadDefaults Command Response and Defaults map

Command:       Defaults Map    
Byte     Block Number Byte Offset Description Nominal Values
0 Checksum8   0 0-3 Not Used 0x00
1 0xF8   0 4 FIO Directions 0x00
2 0x01   0 5 FIO States 0xFF
3 0x0E   0 6 FIO Analog 0x00
4 Checksum16 (LSB)   0 7 Not Used 0x00
5 Checksum16 (MSB)   0 8 EIO Directions 0x00
6 0x00   0 9 EIO States 0xFF
7 bits[0:6] BlockNum 0-7   0 10 EIO Analog 0x00
  bit 7: 1 = ReadCurrent   0 11 Not Used 0x00
      0 12 CIO Directions 0x00
Response:     0 13 CIO States 0xFF
Byte     0 14-15 Not Used 0x00
0 Checksum8   0 16 Config Write Mask 0x00 (NM)
1 0xF8   0 17 NumOfTimersEnabled 0x00
2 0x01   0 18 Counter Mask 0x00
3 0x0E   0 19 Pin Offset 0x04
4 Checksum16 (LSB)   0 20 Options 0x00
5 Checksum16 (MSB)   0 21-31 Not Used 0x00
6 Errorcode   1 0 (32) Clock_Source 0x02
7 0x00   1 1 (33) Divisor 0x00
8-39 Data   1 2-15 (33-47) Not Used 0x00
      1 16 (48) TMR0 Mode 0x0A
      1 17 (49) TMR0 Value L 0x00
      1 18 (50) TMR0 Value H 0x00
      1 19 (51) Not Used 0x00
      1 20 (52) TMR1 Mode 0x0A
      1 21 (53) TMR1 Value L 0x00
      1 22 (54) TMR1 Value H 0x00
      1 23-31 (55-63) Not Used 0x00
             
      2 0-15 (64-79) Not Used 0x00
      2 16-17 (80-81) DAC0 (2 Bytes) 0x0000
      2 18-19 (82-83) Not Used 0x00
      2 20-21 (84-85) DAC1 (2 Bytes) 0x0000
      2 22-31 (86-95) Not Used 0x00
             
      3 0-15 (96-111) AIN Neg Channel 0x1F
      3 16-31 (112-127) Not Used 0x00

6 comments

georgsoerensen@gmail.com's picture

I've not used the '5.1 General Protocol' before (just regular high level) and I am a bit confused about it. I'm trying to read in the Defaults using LJUD.eGet(LJ_handle, LJUD.IO.RAW_OUT, 0, dblByteCount, bytArray)  with the parameters in 5.2.22 

 

5.1 has extended command being bytes 0-5 with byte 2 being the number of data words.

Now 5.2.22 has 0-7 bytes associated with the command but byte 2 is only 1. Is this correct? Would it not need to be 2 to include the blocknum value?

I tried 1, and 2 but my returned values are always all zeros (no error). Am I missing or confused about something?

Georg

LabJack Support's picture

Byte 2 is the number of data words, where 1 word is 2 bytes. So it being 1 is correct as it means 2 bytes (bytes 6 and 7 of the command). Byte 6 is 0 and byte 7 is the BlockNum and ReadCurrent setting. After setting those in your array, make sure to calculate the checksum for the command before sending it. You will be sending 8-bytes for the command.

The response is 40 bytes, so make sure that with RAW_IN that is how many bytes you read. Check bytes 1 to 3 to make sure those match the documented bytes, and check byte 6 for an error code.

If you are sending a bad checksum in your command, the response will be this two byte response:

https://labjack.com/support/datasheets/u3/low-level-function-reference/b...

If that doesn't help, please provide the command bytes you are sending, including the calculated checksum.

georgsoerensen@gmail.com's picture

the command I am using is

LJerror = LJUD.eGet(ljhandle, LJUD.IO.RAW_IN, 0, dblByteCount, bytArray)

dblByteCount = 40 and bytArray is a 40 element array

my sending bytArray are: (248+1+14+128=391 = 1*256 + 135 which should have Check sum 1+135= 136)

136, 248, 1, 14, 0, 0, 0, 128, 0 (all remaining bytes are 0) (for block 0)   {88, F8, 1, E, 0, 0, 0, 80, 0}

137, 248, 1, 14, 0, 0, 0, 129, 0  (for block 1) {89, F8, 1, E, 0, 0, 0, 81, 0}

138, 248, 1, 14, 0, 0, 0, 130, 0 (for block 2) {8A, F8, 1, E, 0, 0, 0, 82, 0}

139, 248, 1, 14, 0, 0, 0, 131, 0 (for block 3) {8B, F8, 1, E, 0, 0, 0, 83, 0}

in all cases the bytArray after the call is unchanged and LJerror is [no error]

(even when I purposely mix up the values I still get LJerror of 0). I must be doing something fundamentaly wrong.

I can run a simple LJUD.eAIN( ...) command and retrieve a correct voltage

My U3 is hardware version 1.30 and I am running .NET 3.50 LJUD version

 

LabJack Support's picture

Please update to firmware 1.53 for ReadCurrent functionality: https://labjack.com/support/firmware/u3/beta

As for your command, pass only 8 bytes for the command. You are showing arrays of 9 bytes.

Also, you are not setting Checksum16, which will lead to a Bad Checksum response (0xB8, 0xB8). Your first command for block 0 should be:

136, 248, 1, 14, 128, 0, 0, 128

Checksum16 is bytes 6 and above, and Checksum8 is bytes 1 to 5 (includes Checksum16).

georgsoerensen@gmail.com's picture

Working now, I thought checksum8 was bytes 1 to 8 (Table 5.1.2 says checksum8 includes bytes 1 to 15 but I missed the ?correction? somewhat below it where it says bytes 1 to 5 are what are used). I was also mistaken about checksum16, I started at 16 (which are zeros) because I thought checksum8 ended at 15 whereas checksum16 which actually starts with byte 6 .

For anyone else looking at this for block 0 of the defaults, my bytArray(40) is in size

bytArray={136,248,1,14,128,0,0,128} is the array sent, with dCount=8 in

LJerror = LJUD.ePut(LJhandle, LJUD.IO.RAW_OUT, 0, dCount, bytArray)

setting dCount=40, defaults for block 0 are received with

LJerror=LJUD.eGet(LJhandle, LJUD.IO.RAW_IN, 0, dCount, bytArray)

Thanks for the help LabJack.

Georg

LabJack Support's picture

Thanks for letting us know about the error in Table 5.1.2 about the Checksum8. Its been correct to "Includes bytes 1-5".