SD Block Functions

SD Data Blocks are data storage files in the SdBLocks folder on a SD card.

SD Data Blocks may reach a total of 4G, or a single Block may be up to 4G. A Data Block comprises Sub-Blocks of 512 Bytes. The SD Block functions enable you to read/write blocks of raw data between operands and these files.

SD Data Block Functions

Create SD Block

Use this function to:

You can also specify the number of Sub-Blocks the block will contain. This may be used to enlarge the Block by appending Sub-Blocks.

 

 

Parameter

Purpose

SD Block number

Select the Block number, 0-3, or use an operand to assign a number at run time.

Sub-Blocks

Use this to specify the number of Sub-blocks in the Data Block.

Overwrite/Append

If this function finds an existing SD Block of this number, you can overwrite it or append these Sub-Blocks. Selecting Append enlarges the SD Block by adding Sub-blocks.

Status Operand

This MI is a bitmap; a bit turns ON to indicate status.

The MI is initialized when the function starts.

  • All bits OFF – No errors, and the SD card is idle

  • Bit 1 – The SD card is busy.

  • Bit 2 – No SD card found, or the card is locked (Write-enable OFF)

  • Bit 6 - Internal error

 

Success Bit

Turns ON when the Block is created. It remains ON until it is reset by the application, or until the application calls the function.

 

Read from Vector to SD Block

 

 

Parameter

Purpose

SD Block number

Select the Block number, 0-3, or use an operand to assign a number at run time.

Target Sub-Block (location in Block): Vec->SD.udb

The data will be written to this sub block. The number is the sequential number of the sub-block in the .udb file.

Source: Start of Vector (512 bytes): Vec->SD

Select the operand that is the start of the 512-byte long vector that provides the data that is written to the .udb file.

Status Messages

This MI is a bitmap; a bit turns ON to indicate status.

The MI is initialized when the function starts.

  • All bits OFF – No errors, and the SD card is idle

  • Bit 1 – The SD card is busy.

  • Bit 2 – No SD card found, or the card is locked (Write-enable OFF)

  • Bit 3 .-.There are less than 512 bytes in this vector (can happen if the start of the vector is too close to the end of the operand address range)

  • Bit 4 – The SD Data Block number is invalid (valid numbers are 0-3. This error may result when using indirect addressing)

  • Bit 5 - SD card function was called while the SD is busy

  • Bit 6 - Internal error

  • Bit 7 - Data Block size exceeds 4G

  • Bit 8 - SD card is full

  •  

Bits 10-13 can occur because the SD card does not have an SD_Blocks folder, or because a file of that name has not been created in the SD_Blocks folder.

  • Bit 10 - Can't open file/path not found

  • Bit 11 - Error while writing to a file/path not found

  • Bit 13 - Failed to close a file/path not found

  • Bit 14 - Create SD Block: Do not overwrite is selected, but the number of Sub-blocks is less than the number of sub-blocks already in the Data Block

Success Bit

Turns ON when the data is successfully written to the Block. It remains ON until it is reset by the application, or until the application calls the function.

 

Write from SD Block to Vector

 

 

Parameter

Purpose

SD Block number

Select the Block number, 0-3, or use an operand to assign a number at run time.

Source Sub-Block (location in Block): SD.udb-> Vec

This is the sequential number of the sub-block in the .udb file.

Target: Start of Vector: SD.udb-> Vec

The function will write 512 bytes of data to the PLC, starting with this operand.

Status Messages

This MI is a bitmap; a bit turns ON to indicate status.

The MI is initialized when the function starts.

 

  • All bits OFF – No errors, and the SD card is idle

  • Bit 1 – The SD card is busy.

  • Bit 2 – No SD card found, or the card is locked (Write-enable OFF)

  • Bit 3 .-.There are less than 512 bytes in this vector (can happen if the start of the vector is too close to the end of the operand address range)

  • Bit 4 – The SD Data Block number is invalid (valid numbers are 0-3. This error may result when using indirect addressing)

  • Bit 5 - SD card function was called while the SD is busy

  • Bit 6 - Internal error

  • Bit 8 - SD card is full

  • Bit 9 - Read: End Of File indication

Bits 10-13 can occur because the SD card does not have an SD_Blocks folder, or because a file of that name has not been created in the SD_Blocks folder.

  • Bit 10 - Can't open file/path not found

  • Bit 12 - Error while reading from a file/path not found

  • Bit 13 - Failed to close a file/path not found

Success Bit

Turns ON when the data is successfully written to the Block. It remains ON until it is reset by the application, or until the application calls the function.

 

System Operands