1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
using System;
using System.Text;
using System.Linq;
using System.Drawing;
using System.Diagnostics;
using System.Windows.Forms;
using System.Threading;
using System.Threading.Tasks;
using System.Collections.Generic;
using Tango.PMR.Stubs;
using Tango.Stubs;
/*** LTFU SSI Encoders ***/
const Int32 F1_LDANCER1_ROTENC_MSB = 0x01c2;
const Int32 F1_LDANCER1_ROTENC_LSB = 0x01c0;
const Int32 F1_LDANCER1_ROTENC_TX = 0x01ce;
const Int32 F1_LDANCER2_ROTENC_MSB = 0x01b2;
const Int32 F1_LDANCER2_ROTENC_LSB = 0x01b0;
const Int32 F1_LDANCER2_ROTENC_TX = 0x01be;
const Int32 F1_LSPARE_ROTENC_MSB = 0x0192;
const Int32 F1_LSPARE_ROTENC_LSB = 0x0190;
const Int32 F1_LSPARE_ROTENC_TX = 0x019e;
/*** RTFU SSI Encoders ***/
const Int32 F1_RDANCER_ROTENC_MSB = 0x01a2;
const Int32 F1_RDANCER_ROTENC_LSB = 0x01a0;
const Int32 F1_RDANCER_ROTENC_TX = 0x01ae;
const Int32 F1_RSPARE_ROTENC_MSB = 0x0182;
const Int32 F1_RSPARE_ROTENC_LSB = 0x0180;
const Int32 F1_RSPARE_ROTENC_TX = 0x018e;
/*** RTFU, LTFU and DISPENSER SSI Prescalers ***/
const Int32 F1_Prescaler1_reg1 = 0x03e0;
const Int32 F1_Prescaler1_reg2 = 0x03e2;
const Int32 F1_SPI_Busy1_Direct = 0x0090;
const Int32 F2_Prescaler1_reg1 = 0x03e0;
const Int32 F2_Prescaler1_reg2 = 0x03e2;
const Int32 F3_Prescaler1_reg1 = 0x03e0;
const Int32 F3_Prescaler1_reg2 = 0x03e2;
/*** DISPENSER SSI Encoders ***/
const Int32 F2_DISPENSER_ROTENC_1_MSB = 0x0182;
const Int32 F2_DISPENSER_ROTENC_1_LSB = 0x0180;
const Int32 F2_DISPENSER_ROTENC_1_TX = 0x018e;
const Int32 F2_DISPENSER_ROTENC_2_MSB = 0x0192;
const Int32 F2_DISPENSER_ROTENC_2_LSB = 0x0190;
const Int32 F2_DISPENSER_ROTENC_2_TX = 0x019e;
const Int32 F2_DISPENSER_ROTENC_3_MSB = 0x01a2;
const Int32 F2_DISPENSER_ROTENC_3_LSB = 0x01a0;
const Int32 F2_DISPENSER_ROTENC_3_TX = 0x01ae;
const Int32 F2_DISPENSER_ROTENC_4_MSB = 0x01b2;
const Int32 F2_DISPENSER_ROTENC_4_LSB = 0x01b0;
const Int32 F2_DISPENSER_ROTENC_4_TX = 0x01be;
const Int32 F2_DISPENSER_ROTENC_5_MSB = 0x01c2;
const Int32 F2_DISPENSER_ROTENC_5_LSB = 0x01c0;
const Int32 F2_DISPENSER_ROTENC_5_TX = 0x01ce;
const Int32 F2_DISPENSER_ROTENC_6_MSB = 0x01d2;
const Int32 F2_DISPENSER_ROTENC_6_LSB = 0x01d0;
const Int32 F2_DISPENSER_ROTENC_6_TX = 0x01de;
const Int32 F2_DISPENSER_ROTENC_7_MSB = 0x01e2;
const Int32 F2_DISPENSER_ROTENC_7_LSB = 0x01e0;
const Int32 F2_DISPENSER_ROTENC_7_TX = 0x01ee;
const Int32 F2_DISPENSER_ROTENC_8_MSB = 0x01f2;
const Int32 F2_DISPENSER_ROTENC_8_LSB = 0x01f0;
const Int32 F2_DISPENSER_ROTENC_8_TX = 0x01fe;
const Int32 F3_SPARE1_ROTENC_MSB = 0x02c0;
const Int32 F3_SPARE1_ROTENC_LSB = 0x02c2;
const Int32 F3_SPARE1_ROTENC_TX = 0x02ce;
const Int32 F3_SPARE2_ROTENC_MSB = 0x02d0;
const Int32 F3_SPARE2_ROTENC_LSB = 0x02d2;
const Int32 F3_SPARE2_ROTENC_TX = 0x02de;
int ssi_loop(Int32 Addr)
{
var RetValue = Fpga_Read_Reg(FPGA1, F1_SPI_Busy1_Direct,10);
if ( (RetValue.Value&0x1f) == 0)
{
//stubManager.Write("\nWriting to F1 DANCER TX");
//Trigger SSI Tx
Fpga_Write_Reg(FPGA1, Addr, 0xffff, 0);
//Wait for SSI sequence to finish
Thread.Sleep(800);
}
RetValue.Value = 1;
return 1;
}
int SSI_Read_Write(Int32 Fpga, Int32 HighAdr, Int32 LowAdr, Int32 TxAdr)
{
var rv1 = Fpga_Read_Reg(Fpga, HighAdr, 0);
var rv2 = Fpga_Read_Reg(Fpga, LowAdr, 0);
stubManager.Write(" Adr = ");
stubManager.WriteHex(TxAdr,4);
stubManager.Write(" (");
stubManager.WriteHex(rv1.Value,4); stubManager.Write(", ");
stubManager.WriteHex(rv2.Value,4); stubManager.Write(")");
//if ( (rv2.Value&0x200) == 0x200) stubManager.Write(" Error");
Fpga_Write_Reg(Fpga, TxAdr, 0xffff, 0);
Thread.Sleep(100);
return 1;
}
|