Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: Tark on November 13, 2015, 12:30:57 PM

Title: Store String
Post by: Tark on November 13, 2015, 12:30:57 PM
What's the best way to store a string to memory?  I'm looking to store a constant into a memory location, like "Pump1".
Title: Re: Store String
Post by: HB_GUY on November 13, 2015, 01:22:37 PM
you can use one of the built in memory locations SSx (String Short) or SLx (String Long),
or create your own memory location for strings. The built in memory locations are retentive by default.

I needed to store extra long strings in my application so I created an SELx memory block (String Extra Long) to store my strings.

Title: Re: Store String
Post by: Tark on November 13, 2015, 01:43:50 PM
I'm looking for the proper instruction to use to store a string like "Pump1" in my User Block, like in DL where you would LOAD "Pump1" and OUT V2000.  What's the best instruction to use to do something like that?
Title: Re: Store String
Post by: HB_GUY on November 13, 2015, 01:53:35 PM
You can use the STRINSERT command to insert simple strings,
or use STRPRINT to create complex strings
Title: Re: Store String
Post by: BobO on November 13, 2015, 02:21:39 PM
I'm looking for the proper instruction to use to store a string like "Pump1" in my User Block, like in DL where you would LOAD "Pump1" and OUT V2000.  What's the best instruction to use to do something like that?

What is the user block data type?
Title: Re: Store String
Post by: Tark on November 13, 2015, 02:32:29 PM
I'll be writing the String to a Signed Word User Block.  I'm creating a user block for each device, so that user block will hold multiple types of data in it.  For instance the first word of the signed word user block will hold the status bits of the device, then next word in the data block might hold a setpoint for the device, etc.  I'm thinking about putting a string in the user block, such as a device ID, in order to view this in my SCADA.
Title: Re: Store String
Post by: BobO on November 13, 2015, 02:34:47 PM
The preferred way to access bytes in a string is STRGETB and STRPUTB. If the byte order is wrong, use SWAPB after.
Title: Re: Store String
Post by: plcnut on November 14, 2015, 12:33:59 PM
My prefered method would be to create a user data block for each type of data.
Example:

First block: DevName String
Second block: DevRun Bit
Third block DevSpeed Unsigned word
Fourth block DevState Unsigned byte
Etc.

Now I would use a pointer to access each one.

Move 0 to V0 for device 1 (n-1 index).
Then read DevName [V0] for the device name.
SET DevRun [V0] to run the device.
Move 2047 to DevSpeed [V0] to set the speed at 50%.
Read DevState [V0] to get the device status.
Etc.

Move 3 into V0 and repeat for your fourth device etc.

As far as getting string data into a string, just use STRPRINT.