ADwin-Gold II
, Manual February 2013
199
Storage media (TiCoBasic)
Media_Write
ADwin
Example
Part 1: ADbasic
Rem ------------------------------
Rem Part 1: ADbasic program
Rem initialize media card
#Include
ADwinGoldII.inc
#Define
blocks
PAR_52
'number of medium data blocks
#Define
media_info
DATA_197
'array with media information
Dim
media_info
[
100
]
As
Long
LowInit
:
blocks
=
Media_Init
(
media_info
)
If
(
blocks
<
0
)
Then
Exit
PAR_53
=
Media_Erase
(
media_info
)
If
(
PAR_53
>
0
)
Then
Exit
Rem Set flag on TiCo processor: card is initialized
Set_Par
(
1
,
12
,
blocks
)
Part 2: TiCoBasic
Rem ------------------------------
Rem Part 2: TiCoBasic program
Rem store measurement values
#Include
GoldIITiCo.inc
#Define
val_per_blk
128
'values per medium data block
#Define
blk_group
40
'number of blocks to write
#Define
blk_total
PAR_12
'number of medium data blocks
Dim
values
[
5120
]
As
Long
'5120=blk_group*val_per_blk
Dim
idx
,
blk_no
As
Long
Init:
Do
'wait for flag: media card initialized
Until
(
blk_total
>
0
)
idx
=
0
'index of measurement values
blk_no
=
1
'first block to write
Event:
Inc
idx
'get next value
values
[
idx
]
=
ADC
(
1
)
If
(
idx
=
val_per_blk
*
blk_group
)
Then
Rem write 40 x 128 values
PAR_1
=
Media_Write
(
blk_no
,
blk_group
,
values
,
1
)
If
(
PAR_1
>
0
)
Then
End
Rem adjust counters
idx
=
0
blk_no
=
blk_no
+
blk_group
If
(
blk_no
+
blk_group
>
blk_total
)
Then
End
EndIf