Using Type Float in
Integer Situations
There are certain situations where integers would normally be used, but, with the
VT1419A, type float is all that is available. This usually has to do with writing
values to digital SCP channels. With the VT1533A Digital I/O SCP, each channel
(two per SCP) reads or writes 8 bits. With the VT1534A and VT1536A SCPs, each
channel (eight per SCP) reads or writes 1 bit. Note the following behavior when
sending values to digital channels:
·
A floating point number sent to a digital channel is truncated to integer by
dropping any fractional portion. So, the value 234.8 sent to an 8 bit channel
will have the same effect as the integer value 234. The value 0.8 sent to a 1
bit channel will be evaluated as 0. The value 1.9 becomes 1.
·
The VT1419A treats values sent to a digital channel as signed. That is,
negative and positive values are valid. For instance, -1 sent to a VT1533A
Digital I/O channel sets all bits to one.
·
A value sent to a digital channel that is greater than the channel’s bit
capacity is treated in a modulo(bit width) fashion. For an 8 bit channel the
formula is
<channel value>
MODULO 256. For example, 255 sent to an 8
bit channel sets all of its bits. But, 256 clears all eight bits because 256 is a 9
bit value. The value 257 would then set bit 0 (the 8 bit value 1).
One bit channels behave in the same way. The formula becomes
<channel
value>
MODULO 1. So the value 1 sent to a 1 bit channel sets the bit, but
the value 2 clears the bit. For 1 bit channels all odd values set the bit while
all even values clear the bit.
Bitfield Access
The VT1419A implements bitfield syntax that allows individual bit values to be
manipulated within a variable. This syntax is similar to what would be done in ‘C,’
but doesn’t require a structure declaration. Bitfield syntax is supported only for the
lower 16 bits (bits 0-15) of simple (scalar) variables and channel identifiers. Values
read from or written to bitfields behave as integer values as described in “Using
Type Float in Integer Situations” above.
Use
if(word_var.B0 || word_var.B3) /* if either bit 0 or bit 3 true ... */
word_var.B15 = 1;
/* set bit 15
*/
NOTES
1.
It is not necessary to declare a bitfield structure in order to use it. In the
Algorithm Language, the bitfield structure is assumed to be applicable to
any simple variable including channel identifiers.
2.
Unlike ‘C’, the Algorithm Language allows both bit access and “whole”
access to the same variable. Example:
static float my_word_var;
my_word_var = 255
/* set bits 0 through 7 */
my_word_var.B3 = 0
/* clear bit 3 */
Declaration
Initialization
Only simple variables (not array members) can be initialized in the declaration
statement:
static float my_var = 2;
The Algorithm Language and Environment
Algorithm Language Reference
Chapter 4
127
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com
Содержание VT1419A Multifunction Plus
Страница 5: ...4 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 15: ...14 Contents Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 25: ...24 Chapter 1 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 173: ...Notes 172 Chapter 5 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 332: ...332 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 333: ...Appendix A 333 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 334: ...334 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 335: ...Appendix A 335 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 336: ...336 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 337: ...Appendix A 337 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 338: ...338 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 339: ...Appendix A 339 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 340: ...340 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 341: ...Appendix A 341 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 342: ...342 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 343: ...Appendix A 343 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 344: ...344 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 345: ...Appendix A 345 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 346: ...346 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 347: ...Appendix A 347 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 348: ...348 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 349: ...Appendix A 349 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 350: ...350 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 351: ...Appendix A 351 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 352: ...352 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 353: ...Appendix A 353 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 354: ...354 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 355: ...Appendix A 355 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 356: ...356 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 357: ...Appendix A 357 Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 358: ...358 Appendix A Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...
Страница 370: ...Notes 370 Appendix C Artisan Technology Group Quality Instrumentation Guaranteed 888 88 SOURCE www artisantg com...