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; //Reg Name Functionlity/Contents D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 const Int32 F1_Moto_Driver_NBUSY1_Direct = 0x050;// Reads the direct values that are currently being sent to the fpga. rsv rsv rsv rsv rsv F1_MOTO_DH_CLEANHEAD_A1_NBUSY F1_MOTO_DH_CLEANMECH_A1_NBUSY F1_MOTO_DH_LID_A1_NBUSY F1_MOTO_DRYER_DRIVING_A1_NBUSY F1_MOTO_DRYER_LID_A1_NBUSY F1_MOTO_DRYER_LOADARM_A1_NBUSY F1_MOTO_LDANCER1_A1_NBUSY F1_MOTO_LDANCER2_A1_NBUSY F1_MOTO_LDRIVING_A1_NBUSY F1_MOTO_LLOADING_A1_NBUSY F1_MOTO_LPIVOT1_A1_NBUSY const Int32 F1_Moto_Driver_NBUSY2_Direct = 0x060;// Reads the direct values that are currently being sent to the fpga. rsv rsv rsv rsv rsv rsv rsv rsv rsv rsv F1_MOTO_RDANCER_A1_NBUSY F1_MOTO_RDRIVING_A1_NBUSY F1_MOTO_RLOADARM_A1_NBUSY F1_MOTO_RLOADING_A1_NBUSY F1_MOTO_SCREW_A1_NBUSY F1_MOTO_WINDER_A1_NBUSY const Int32 F2_Moto_Driver_NBUSY1_Direct = 0x050;// Reads the direct values that are currently being sent to the fpga. rsv rsv rsv rsv rsv rsv rsv rsv F2_MOTO_DISPENSER_A1_1_NBUSY F2_MOTO_DISPENSER_A1_2_NBUSY F2_MOTO_DISPENSER_A1_3_NBUSY F2_MOTO_DISPENSER_A1_4_NBUSY F2_MOTO_DISPENSER_A1_5_NBUSY F2_MOTO_DISPENSER_A1_6_NBUSY F2_MOTO_DISPENSER_A1_7_NBUSY F2_MOTO_DISPENSER_A1_8_NBUSY const Int32 F3_Moto_Driver_NBUSY1_Direct = 0x060;// Reads the direct values that are currently being sent to the fpga. rsv rsv rsv rsv rsv rsv rsv rsv rsv rsv rsv F3_MOTO_SPARE3_1_A1_NBUSY F3_MOTO_SPARE2_2_A1_NBUSY F3_MOTO_SPARE2_1_A1_NBUSY F3_MOTO_SPARE1_2_A1_NBUSY F3_MOTO_SPARE1_1_A1_NBUSY /*** Motor Driver Reset Signals ***/ //Reg Name Functionlity/Contents D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 const Int32 F1_Moto_Driver_NSTBYRST1 = 0x0B2 ; // "F1_MOTO_LPIVOT1_A1_NSTBYRST", "F1_MOTO_LLOADING_A1_NSTBYRST", "F1_MOTO_LDRIVING_A1_NSTBYRST", "F1_MOTO_LDANCER2_A1_NSTBYRST", "F1_MOTO_LDANCER1_A1_NSTBYRST", "F1_MOTO_DRYER_LOADARM_A1_NSTBYRST", "F1_MOTO_DRYER_LID_A1_NSTBYRST", "F1_MOTO_DRYER_DRIVING_A1_NSTBYRST", "F1_MOTO_DH_LID_A1_NSTBYRST", "F1_MOTO_DH_CLEANMECH_A1_NSTBYRST", "F1_MOTO_DH_CLEANHEAD_A1_NSTBYRST", "rsv", "rsv", "rsv", "rsv", "rsv" string[] F1_Moto_Driver_NSTBYRST1_Bits = {"F1_MOTO_LPIVOT1_A1_NSTBYRST", "F1_MOTO_LLOADING_A1_NSTBYRST", "F1_MOTO_LDRIVING_A1_NSTBYRST", "F1_MOTO_LDANCER2_A1_NSTBYRST", "F1_MOTO_LDANCER1_A1_NSTBYRST", "F1_MOTO_DRYER_LOADARM_A1_NSTBYRST", "F1_MOTO_DRYER_LID_A1_NSTBYRST", "F1_MOTO_DRYER_DRIVING_A1_NSTBYRST", "F1_MOTO_DH_LID_A1_NSTBYRST", "F1_MOTO_DH_CLEANMECH_A1_NSTBYRST", "F1_MOTO_DH_CLEANHEAD_A1_NSTBYRST", "rsv", "rsv", "rsv", "rsv", "rsv"}; const Int32 F1_Moto_Driver_NSTBYRST2 = 0x0C2 ; // "F1_MOTO_WINDER_A1_NSTBYRST", "F1_MOTO_SCREW_A1_NSTBYRST", "F1_MOTO_RLOADING_A1_NSTBYRST", "F1_MOTO_RLOADARM_A1_NSTBYRST", "F1_MOTO_RDRIVING_A1_NSTBYRST", "F1_MOTO_RDANCER_A1_NSTBYRST", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv" string[] F1_Moto_Driver_NSTBYRST2_Bits = {"F1_MOTO_WINDER_A1_NSTBYRST", "F1_MOTO_SCREW_A1_NSTBYRST", "F1_MOTO_RLOADING_A1_NSTBYRST", "F1_MOTO_RLOADARM_A1_NSTBYRST", "F1_MOTO_RDRIVING_A1_NSTBYRST", "F1_MOTO_RDANCER_A1_NSTBYRST", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv"}; const Int32 F2_Moto_Driver_NSTBYRST1 = 0x0B2 ; // "F2_MOTO_DISPENSER_A1_8_NSTBYRST", "F2_MOTO_DISPENSER_A1_7_NSTBYRST", "F2_MOTO_DISPENSER_A1_6_NSTBYRST", "F2_MOTO_DISPENSER_A1_5_NSTBYRST", "F2_MOTO_DISPENSER_A1_4_NSTBYRST", "F2_MOTO_DISPENSER_A1_3_NSTBYRST", "F2_MOTO_DISPENSER_A1_2_NSTBYRST", "F2_MOTO_DISPENSER_A1_1_NSTBYRST", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv" string[] F2_Moto_Driver_NSTBYRST1_Bits = {"F2_MOTO_DISPENSER_A1_8_NSTBYRST", "F2_MOTO_DISPENSER_A1_7_NSTBYRST", "F2_MOTO_DISPENSER_A1_6_NSTBYRST", "F2_MOTO_DISPENSER_A1_5_NSTBYRST", "F2_MOTO_DISPENSER_A1_4_NSTBYRST", "F2_MOTO_DISPENSER_A1_3_NSTBYRST", "F2_MOTO_DISPENSER_A1_2_NSTBYRST", "F2_MOTO_DISPENSER_A1_1_NSTBYRST", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv"}; const Int32 F3_Moto_Driver_NSTBYRST1 = 0x0B2 ; // "F3_MOTO_SPARE3_1_A1_NSTBYRST", "F3_MOTO_SPARE2_2_A1_NSTBYRST", "F3_MOTO_SPARE2_1_A1_NSTBYRST", "F3_MOTO_SPARE1_2_A1_NSTBYRST", "F3_MOTO_SPARE1_1_A1_NSTBYRST", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv" string[] F3_Moto_Driver_NSTBYRST1_Bits = {"F3_MOTO_SPARE3_1_A1_NSTBYRST", "F3_MOTO_SPARE2_2_A1_NSTBYRST", "F3_MOTO_SPARE2_1_A1_NSTBYRST", "F3_MOTO_SPARE1_2_A1_NSTBYRST", "F3_MOTO_SPARE1_1_A1_NSTBYRST", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv"}; /*** SW signals ***/ const Int32 F1_Moto_Driver_SW1 = 0x0D2 ; // "F1_MOTO_LPIVOT1_A1_SW ", "F1_MOTO_LLOADING_A1_SW ", "F1_MOTO_LDRIVING_A1_SW ", "F1_MOTO_LDANCER2_A1_SW ", "F1_MOTO_LDANCER1_A1_SW ", "F1_MOTO_DRYER_LOADARM_A1_SW ", "F1_MOTO_DRYER_LID_A1_SW ", "F1_MOTO_DRYER_DRIVING_A1_SW ", "F1_MOTO_DH_LID_A1_SW ", "F1_MOTO_DH_CLEANMECH_A1_SW ", "F1_MOTO_DH_CLEANHEAD_A1_SW", "F1_GPO_TFEED_BREAK_1", "F1_GPO_TFEED_BREAK_2", "rsv", "rsv", "rsv" string[] F1_Moto_Driver_SW1_Bits = {"F1_MOTO_LPIVOT1_A1_SW ", "F1_MOTO_LLOADING_A1_SW ", "F1_MOTO_LDRIVING_A1_SW ", "F1_MOTO_LDANCER2_A1_SW ", "F1_MOTO_LDANCER1_A1_SW ", "F1_MOTO_DRYER_LOADARM_A1_SW ", "F1_MOTO_DRYER_LID_A1_SW ", "F1_MOTO_DRYER_DRIVING_A1_SW ", "F1_MOTO_DH_LID_A1_SW ", "F1_MOTO_DH_CLEANMECH_A1_SW ", "F1_MOTO_DH_CLEANHEAD_A1_SW", "F1_GPO_TFEED_BREAK_1", "F1_GPO_TFEED_BREAK_2", "rsv", "rsv", "rsv"}; const Int32 F1_Moto_Driver_SW2 = 0x0E2 ; // "F1_MOTO_WINDER_A1_SW", "F1_MOTO_SCREW_A1_SW ", "F1_MOTO_RLOADING_A1_SW ", "F1_MOTO_RLOADARM_A1_SW ", "F1_MOTO_RDRIVING_A1_SW ", "F1_MOTO_RDANCER_A1_SW ", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv" const Int32 F2_Moto_Driver_SW1 = 0x0D2 ; // "F1_MOTO_LPIVOT1_A1_SW ", "F1_MOTO_LLOADING_A1_SW ", "F1_MOTO_LDRIVING_A1_SW ", "F1_MOTO_LDANCER2_A1_SW ", "F1_MOTO_LDANCER1_A1_SW ", "F1_MOTO_DRYER_LOADARM_A1_SW ", "F1_MOTO_DRYER_LID_A1_SW ", "F1_MOTO_DRYER_DRIVING_A1_SW ", "F1_MOTO_DH_LID_A1_SW ", "F1_MOTO_DH_CLEANMECH_A1_SW ", "F1_MOTO_DH_CLEANHEAD_A1_SW", "F1_GPO_TFEED_BREAK_1", "F1_GPO_TFEED_BREAK_2", "rsv", "rsv", "rsv" const Int32 F3_Moto_Driver_SW1 = 0x0D2 ; // "F3_MOTO_SPARE1_1_A1_SW", "F3_MOTO_SPARE1_2_A1_SW", "F3_MOTO_SPARE2_1_A1_SW", "F3_MOTO_SPARE2_2_A1_SW", "F3_MOTO_SPARE3_1_A1_SW", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv", "rsv" /*** RTFU Motors ***/ const Int32 F1_MOTO_RLOADING_TX1 = 0x0202; const Int32 F1_MOTO_RLOADING_TX0 = 0x0200; const Int32 F1_MOTO_RLOADING_RX1 = 0x0206; const Int32 F1_MOTO_RLOADING_RX0 = 0x0204; const Int32 F1_MOTO_RDRIVING_TX1 = 0x0212; const Int32 F1_MOTO_RDRIVING_TX0 = 0x0210; const Int32 F1_MOTO_RDRIVING_RX1 = 0x0216; const Int32 F1_MOTO_RDRIVING_RX0 = 0x0214; const Int32 F1_MOTO_RLOADARM_TX1 = 0x02a2; const Int32 F1_MOTO_RLOADARM_TX0 = 0x02a0; const Int32 F1_MOTO_RDANCER_TX1 = 0x02b2; const Int32 F1_MOTO_RDANCER_TX0 = 0x02b0; /*** LTFU Motors ***/ const Int32 F1_MOTO_LDRIVING_TX1 = 0x0222; const Int32 F1_MOTO_LDRIVING_TX0 = 0x0220; const Int32 F1_MOTO_LDRIVING_RX1 = 0x0226; const Int32 F1_MOTO_LDRIVING_RX0 = 0x0224; const Int32 F1_MOTO_LLOADING_TX1 = 0x0232; const Int32 F1_MOTO_LLOADING_TX0 = 0x0230; const Int32 F1_MOTO_LDANCER1_TX1 = 0x02c2; const Int32 F1_MOTO_LDANCER1_TX0 = 0x02c0; const Int32 F1_MOTO_LDANCER2_TX1 = 0x02d2; const Int32 F1_MOTO_LDANCER2_TX0 = 0x02d0; const Int32 F1_MOTO_LDANCER2_A1_AMT_OF_WORDS = 0x02d8; const Int32 F1_MOTO_LPIVOT1_TX1 = 0x0302; const Int32 F1_MOTO_LPIVOT1_TX0 = 0x0300; const Int32 F1_MOTO_LPIVOT1_A1_AMT_OF_WORDS = 0x0308; /*** Dryer Motors ***/ const Int32 F1_MOTO_DRYER_LOADARM_A1_TX_00 = 0x240 ; const Int32 F1_MOTO_DRYER_LOADARM_A1_TX_01 = 0x242 ; const Int32 F1_MOTO_DRYER_LOADARM_A1_RX_00 = 0x244 ; const Int32 F1_MOTO_DRYER_LOADARM_A1_RX_01 = 0x246 ; const Int32 F1_MOTO_DRYER_DRIVING_A1_TX_00 = 0x250 ; const Int32 F1_MOTO_DRYER_DRIVING_A1_TX_01 = 0x252 ; const Int32 F1_MOTO_DRYER_DRIVING_A1_RX_00 = 0x254 ; const Int32 F1_MOTO_DRYER_DRIVING_A1_RX_01 = 0x256 ; const Int32 F1_MOTO_DRYER_LID_A1_TX_00 = 0x2E0 ; const Int32 F1_MOTO_DRYER_LID_A1_TX_01 = 0x2E2 ; const Int32 F1_MOTO_DRYER_LID_A1_RX_00 = 0x2E4 ; const Int32 F1_MOTO_DRYER_LID_A1_RX_01 = 0x2E6 ; /*** Dyeing Head Motors ***/ const Int32 F1_MOTO_DH_CLEANHEAD_A1_TX_00 = 0x260 ; const Int32 F1_MOTO_DH_CLEANHEAD_A1_TX_01 = 0x262 ; const Int32 F1_MOTO_DH_CLEANHEAD_A1_RX_00 = 0x264 ; const Int32 F1_MOTO_DH_CLEANHEAD_A1_RX_01 = 0x266 ; const Int32 F1_MOTO_DH_CLEANMECH_A1_TX_00 = 0x270 ; const Int32 F1_MOTO_DH_CLEANMECH_A1_TX_01 = 0x272 ; const Int32 F1_MOTO_DH_CLEANMECH_A1_RX_00 = 0x274 ; const Int32 F1_MOTO_DH_CLEANMECH_A1_RX_01 = 0x276 ; const Int32 F1_MOTO_DH_LID_A1_TX_00 = 0x2F0 ; const Int32 F1_MOTO_DH_LID_A1_TX_01 = 0x2F2 ; const Int32 F1_MOTO_DH_LID_A1_RX_00 = 0x2F4 ; const Int32 F1_MOTO_DH_LID_A1_RX_01 = 0x2F6 ; /*** Winder Motors ***/ const Int32 F1_MOTO_SCREW_A1_TX_00 = 0x280 ; const Int32 F1_MOTO_SCREW_A1_TX_01 = 0x282 ; const Int32 F1_MOTO_SCREW_A1_RX_00 = 0x284 ; const Int32 F1_MOTO_SCREW_A1_RX_01 = 0x286 ; const Int32 F1_MOTO_WINDER_A1_TX_00 = 0x290 ; const Int32 F1_MOTO_WINDER_A1_TX_01 = 0x292 ; const Int32 F1_MOTO_WINDER_A1_RX_00 = 0x294 ; const Int32 F1_MOTO_WINDER_A1_RX_01 = 0x296 ; /*** Dispenser Motors ***/ const Int32 F2_MOTO_DISPENSER_A1_1_TX_00 = 0x320 ; // The second register to be shifted out of the spi. The msb bit of this register is shifted out first. const Int32 F2_MOTO_DISPENSER_A1_1_TX_01 = 0x322 ; // The first register to be shifted out of the spi. The msb bit of this register is shifted out first. const Int32 F2_MOTO_DISPENSER_A1_1_RX_00 = 0x324 ; // The 8 msb bits of the shifted in bits. The 8 msb bits of this register are zeros. const Int32 F2_MOTO_DISPENSER_A1_1_RX_01 = 0x326 ; // The 16 Lsb bits of the shifted in data. const Int32 F2_MOTO_DISPENSER_A1_1_AMT_OF_WORDS = 0x328 ; // The amount of spi words (usually byte sized) per transmission. const Int32 F2_MOTO_DISPENSER_A1_2_TX_00 = 0x330 ; // The second register to be shifted out of the spi. The msb bit of this register is shifted out first. const Int32 F2_MOTO_DISPENSER_A1_2_TX_01 = 0x332 ; // The first register to be shifted out of the spi. The msb bit of this register is shifted out first. const Int32 F2_MOTO_DISPENSER_A1_2_RX_00 = 0x334 ; // The 8 msb bits of the shifted in bits. The 8 msb bits of this register are zeros. const Int32 F2_MOTO_DISPENSER_A1_2_RX_01 = 0x336 ; // The 16 Lsb bits of the shifted in data. const Int32 F2_MOTO_DISPENSER_A1_2AMT_OF_WORDS = 0x338 ; // The amount of spi words (usually byte sized) per transmission. const Int32 F2_MOTO_DISPENSER_A1_3_TX_00 = 0x340 ; // The second register to be shifted out of the spi. The msb bit of this register is shifted out first. const Int32 F2_MOTO_DISPENSER_A1_3_TX_01 = 0x342 ; // The first register to be shifted out of the spi. The msb bit of this register is shifted out first. const Int32 F2_MOTO_DISPENSER_A1_3_RX_00 = 0x344 ; // The 8 msb bits of the shifted in bits. The 8 msb bits of this register are zeros. const Int32 F2_MOTO_DISPENSER_A1_3_RX_01 = 0x346 ; // The 16 Lsb bits of the shifted in data. const Int32 F2_MOTO_DISPENSER_A1_3_AMT_OF_WORDS = 0x348 ; // The amount of spi words (usually byte sized) per transmission. const Int32 F2_MOTO_DISPENSER_A1_4_TX_00 = 0x350 ; // The second register to be shifted out of the spi. The msb bit of this register is shifted out first. const Int32 F2_MOTO_DISPENSER_A1_4_TX_01 = 0x352 ; // The first register to be shifted out of the spi. The msb bit of this register is shifted out first. const Int32 F2_MOTO_DISPENSER_A1_4_RX_00 = 0x354 ; // The 8 msb bits of the shifted in bits. The 8 msb bits of this register are zeros. const Int32 F2_MOTO_DISPENSER_A1_4_RX_01 = 0x356 ; // The 16 Lsb bits of the shifted in data. const Int32 F2_MOTO_DISPENSER_A1_4_AMT_OF_WORDS = 0x358 ; // The amount of spi words (usually byte sized) per transmission. const Int32 F2_MOTO_DISPENSER_A1_5_TX_00 = 0x360 ; // The second register to be shifted out of the spi. The msb bit of this register is shifted out first. const Int32 F2_MOTO_DISPENSER_A1_5_TX_01 = 0x362 ; // The first register to be shifted out of the spi. The msb bit of this register is shifted out first. const Int32 F2_MOTO_DISPENSER_A1_5_RX_00 = 0x364 ; // The 8 msb bits of the shifted in bits. The 8 msb bits of this register are zeros. const Int32 F2_MOTO_DISPENSER_A1_5_RX_01 = 0x366 ; // The 16 Lsb bits of the shifted in data. const Int32 F2_MOTO_DISPENSER_A1_5_AMT_OF_WORDS = 0x368 ; // The amount of spi words (usually byte sized) per transmission. const Int32 F2_MOTO_DISPENSER_A1_6_TX_00 = 0x370 ; // The second register to be shifted out of the spi. The msb bit of this register is shifted out first. const Int32 F2_MOTO_DISPENSER_A1_6_TX_01 = 0x372 ; // The first register to be shifted out of the spi. The msb bit of this register is shifted out first. const Int32 F2_MOTO_DISPENSER_A1_6_RX_00 = 0x374 ; // The 8 msb bits of the shifted in bits. The 8 msb bits of this register are zeros. const Int32 F2_MOTO_DISPENSER_A1_6_RX_01 = 0x376 ; // The 16 Lsb bits of the shifted in data. const Int32 F2_MOTO_DISPENSER_A1_6_AMT_OF_WORDS = 0x378 ; // The amount of spi words (usually byte sized) per transmission. const Int32 F2_MOTO_DISPENSER_A1_7_TX_00 = 0x380 ; // The second register to be shifted out of the spi. The msb bit of this register is shifted out first. const Int32 F2_MOTO_DISPENSER_A1_7_TX_01 = 0x382 ; // The first register to be shifted out of the spi. The msb bit of this register is shifted out first. const Int32 F2_MOTO_DISPENSER_A1_7_RX_00 = 0x384 ; // The 8 msb bits of the shifted in bits. The 8 msb bits of this register are zeros. const Int32 F2_MOTO_DISPENSER_A1_7_RX_01 = 0x386 ; // The 16 Lsb bits of the shifted in data. const Int32 F2_MOTO_DISPENSER_A1_7_AMT_OF_WORDS = 0x388 ; // The amount of spi words (usually byte sized) per transmission. const Int32 F2_MOTO_DISPENSER_A1_8_TX_00 = 0x390 ; // The second register to be shifted out of the spi. The msb bit of this register is shifted out first. const Int32 F2_MOTO_DISPENSER_A1_8_TX_01 = 0x392 ; // The first register to be shifted out of the spi. The msb bit of this register is shifted out first. const Int32 F2_MOTO_DISPENSER_A1_8_RX_00 = 0x394 ; // The 8 msb bits of the shifted in bits. The 8 msb bits of this register are zeros. const Int32 F2_MOTO_DISPENSER_A1_8_RX_01 = 0x396 ; // The 16 Lsb bits of the shifted in data. const Int32 F2_MOTO_DISPENSER_A1_8_AMT_OF_WORDS = 0x398 ; // The amount of spi words (usually byte sized) per transmission. const Int32 F3_MOTO_SPARE1_1_A1_TX_00 = 0x200 ; const Int32 F3_MOTO_SPARE1_1_A1_TX_01 = 0x202 ; const Int32 F3_MOTO_SPARE1_1_A1_RX_00 = 0x204 ; const Int32 F3_MOTO_SPARE1_1_A1_RX_01 = 0x206 ; const Int32 F3_MOTO_SPARE1_1_A1_AMT_OF_WORDS = 0x208 ; const Int32 F3_MOTO_SPARE1_2_A1_TX_00 = 0x210 ; const Int32 F3_MOTO_SPARE1_2_A1_TX_01 = 0x212 ; const Int32 F3_MOTO_SPARE1_2_A1_RX_00 = 0x214 ; const Int32 F3_MOTO_SPARE1_2_A1_RX_01 = 0x216 ; const Int32 F3_MOTO_SPARE1_2_A1_AMT_OF_WORDS = 0x218 ; const Int32 F3_MOTO_SPARE2_1_A1_TX_00 = 0x220 ; const Int32 F3_MOTO_SPARE2_1_A1_TX_01 = 0x222 ; const Int32 F3_MOTO_SPARE2_1_A1_RX_00 = 0x224 ; const Int32 F3_MOTO_SPARE2_1_A1_RX_01 = 0x226 ; const Int32 F3_MOTO_SPARE2_1_A1_AMT_OF_WORDS = 0x228 ; const Int32 F3_MOTO_SPARE2_2_A1_TX_00 = 0x230 ; const Int32 F3_MOTO_SPARE2_2_A1_TX_01 = 0x232 ; const Int32 F3_MOTO_SPARE2_2_A1_RX_00 = 0x234 ; const Int32 F3_MOTO_SPARE2_2_A1_RX_01 = 0x236 ; const Int32 F3_MOTO_SPARE2_2_A1_AMT_OF_WORDS = 0x238 ; /*** Spare Motor ***/ const Int32 F3_MOTO_SPARE3_1_A1_TX_00 = 0x240; const Int32 F3_MOTO_SPARE3_1_A1_TX_01 = 0x242; const Int32 F3_MOTO_SPARE3_1_A1_RX_00 = 0x244; const Int32 F3_MOTO_SPARE3_1_A1_RX_01 = 0x246; const Int32 F3_MOTO_SPARE3_1_A1_AMT_OF_WORDS = 0x248; /*** Motor Driver Commands ***/ const Int32 MOTORDRIVER_HIGHZ_COMMAND_MSB = 0xa800; const Int32 MOTORDRIVER_HIGHZ_COMMAND_LSB = 0x0000; const Int32 MOTORDRIVER_RUN_COMMAND_MSB = 0x5000; const Int32 MOTORDRIVER_RUN_COMMAND_LSB = 0x0000; const Int32 MOTORDRIVER_MOVE_COMMAND_MSB = 0x4000; const Int32 MOTORDRIVER_MOVE_COMMAND_LSB = 0x0000; const Int32 MOTORDRIVER_RDCFG_COMMAND_MSB = 0x3800; const Int32 MOTORDRIVER_RDCFG_COMMAND_LSB = 0x0000; const Int32 MOTORDRIVER_RDSTATUS_COMMAND_MSB = 0x3900; const Int32 MOTORDRIVER_RDSTATUS_COMMAND_LSB = 0x0000; const Int32 MOTORDRIVER_RDSTEPREG_COMMAND_MSB = 0x3600; const Int32 MOTORDRIVER_RDSTEPREG_COMMAND_LSB = 0x0000; const Int32 MOTORDRIVER_WRSTEPREG_COMMAND_MSB = 0x1600; const Int32 MOTORDRIVER_WRSTEPREG_COMMAND_LSB = 0x0000; const Int32 MOTORDRIVER_GETSTATUS_COMMAND_MSB = 0xd000; const Int32 MOTORDRIVER_GETSTATUS_COMMAND_LSB = 0x0000; int Motor_OutOfReset() { //Pull all L6470 motor drivers out of reset Fpga_Write_Reg(FPGA1, F1_Moto_Driver_NSTBYRST1, 0x07ff,0); Fpga_Write_Reg(FPGA1, F1_Moto_Driver_NSTBYRST2, 0x003f,0); Fpga_Write_Reg(FPGA2, F2_Moto_Driver_NSTBYRST1, 0x00ff,0); Fpga_Write_Reg(FPGA3, F3_Moto_Driver_NSTBYRST1, 0x001f,0); /* Fpga_Read_Reg(FPGA1, F1_Moto_Driver_NSTBYRST1,0); Fpga_Read_Reg(FPGA1, F1_Moto_Driver_NSTBYRST2,0); Fpga_Read_Reg(FPGA2, F2_Moto_Driver_NSTBYRST1,0); Fpga_Read_Reg(FPGA3, F3_Moto_Driver_NSTBYRST1,0); */ return 1; } int Motor_DriverReset() { Fpga_Write_Reg(FPGA1, F1_Moto_Driver_NSTBYRST1, 0x0000,0); Fpga_Write_Reg(FPGA1, F1_Moto_Driver_NSTBYRST2, 0x0000,0); Fpga_Write_Reg(FPGA2, F2_Moto_Driver_NSTBYRST1, 0x0000,0); Fpga_Write_Reg(FPGA3, F3_Moto_Driver_NSTBYRST1, 0x0000,0); return 1; } int Motor_HighZ(Int32 Fpga, Int32 HighAdr, Int32 LowAdr) { Fpga_Write_Reg(Fpga, HighAdr, MOTORDRIVER_HIGHZ_COMMAND_MSB,0); Fpga_Write_Reg(Fpga, LowAdr, MOTORDRIVER_HIGHZ_COMMAND_LSB,0); return 1; } int Motor_Run(Int32 Fpga, Int32 HighAdr, Int32 LowAdr, Int32 Speed, Int32 Direction) { var RunCmdHigh = ( ((MOTORDRIVER_RUN_COMMAND_MSB >> 8) + (Direction & 0x1)) << 8 ) + ( (Speed & 0x0fffff) >> 16); var RunCmdLow = (Speed & 0xffff); Fpga_Write_Reg(Fpga, HighAdr, RunCmdHigh, 0); Fpga_Write_Reg(Fpga, LowAdr, RunCmdLow, 0); return 1; } int Motor_Move(Int32 Fpga, Int32 HighAdr, Int32 LowAdr, Int32 NumOfSteps, Int32 Direction) { var MoveCmdHigh = ( ((MOTORDRIVER_MOVE_COMMAND_MSB >> 8) + (Direction & 0x1)) << 8 ) + ( (NumOfSteps & 0x3fffff) >> 16); var MoveCmdLow = (NumOfSteps & 0xffff); Fpga_Write_Reg(Fpga, HighAdr, MoveCmdHigh, 0); Fpga_Write_Reg(Fpga, LowAdr, MoveCmdLow, 0); return 1; } int Motor_Move_Loop(Int32 Fpga, Int32 HighAdr, Int32 LowAdr, Int32 NumOfSteps, Int32 Direction, Int32 NumOfLoops) { for (int i = 0; i < NumOfLoops; i++) { Motor_Move(Fpga, HighAdr, LowAdr, NumOfSteps, Direction); Thread.Sleep(1000); Motor_Move(Fpga, HighAdr, LowAdr, NumOfSteps, Direction^0x1); Thread.Sleep(1000); } return 1; } int Motor_Move_Loop_Screw(Int32 Fpga, Int32 HighAdr, Int32 LowAdr, Int32 NumOfSteps, Int32 Direction, Int32 NumOfLoops) { Int32 Bit = 0; for (int i = 0; i < NumOfLoops; i++) { Motor_Move(Fpga, HighAdr, LowAdr, NumOfSteps, Direction); Bit = GetBit(FPGA1, F1_Moto_Driver_NBUSY2_Direct, 1); while (Bit == 0x0) { Bit = GetBit(FPGA1, F1_Moto_Driver_NBUSY2_Direct, 1); } Motor_Move(Fpga, HighAdr, LowAdr, NumOfSteps, Direction^0x1); Bit = GetBit(FPGA1, F1_Moto_Driver_NBUSY2_Direct, 1); while (Bit == 0x0) { Bit = GetBit(FPGA1, F1_Moto_Driver_NBUSY2_Direct, 1); } } return 1; } int Motor_ReadCfg(Int32 Fpga, Int32 HighAdr, Int32 LowAdr) { Fpga_Write_Reg(Fpga, HighAdr, MOTORDRIVER_RDCFG_COMMAND_MSB, 0); Fpga_Write_Reg(Fpga, LowAdr, MOTORDRIVER_RDCFG_COMMAND_LSB, 0); Fpga_Read_Reg(Fpga, HighAdr+4, 1); Fpga_Read_Reg(Fpga, LowAdr+4, 1); return 1; } int Motor_ReadStatus(Int32 Fpga, Int32 HighAdr, Int32 LowAdr) { Fpga_Write_Reg(Fpga, HighAdr, MOTORDRIVER_RDSTATUS_COMMAND_MSB, 0); Fpga_Write_Reg(Fpga, LowAdr, MOTORDRIVER_RDSTATUS_COMMAND_LSB, 0); Fpga_Read_Reg(Fpga, HighAdr+4, 1); Fpga_Read_Reg(Fpga, LowAdr+4, 1); return 1; } int Motor_GetStatus(Int32 Fpga, Int32 HighAdr, Int32 LowAdr) { Fpga_Write_Reg(Fpga, HighAdr, MOTORDRIVER_GETSTATUS_COMMAND_MSB, 0); Fpga_Write_Reg(Fpga, LowAdr, MOTORDRIVER_GETSTATUS_COMMAND_LSB, 0); Fpga_Read_Reg(Fpga, HighAdr+4, 1); Fpga_Read_Reg(Fpga, LowAdr+4, 1); return 1; } // ParaData1 shall be left justified i.e. <0x00><0x00> int Motor_SetParam(Int32 Fpga, Int32 HighAdr, Int32 LowAdr, Int32 ParaAddr, uint ParaData1) { Int32 Temp = 0; Temp = (ParaAddr << 8 ) + ( (Int32) ParaData1 >> 24); Fpga_Write_Reg(Fpga, HighAdr, Temp, 0); Temp = ((Int32)ParaData1 >> 8) & 0xffff; Fpga_Write_Reg(Fpga, LowAdr, Temp, 0); Thread.Sleep(50); //Fpga_Read_Reg(Fpga, HighAdr+4, 1); //Fpga_Read_Reg(Fpga, LowAdr+4, 1); return 1; } int Motor_GetParam(Int32 Fpga, Int32 HighAdr, Int32 LowAdr, Int32 ParaAddr) { Int32 Temp = 0; Temp = (ParaAddr + 0x20) << 8 ; Fpga_Write_Reg(Fpga, HighAdr, Temp, 0); Temp = 0x0; Fpga_Write_Reg(Fpga, LowAdr, Temp, 0); Fpga_Read_Reg(Fpga, HighAdr+4, 1); Fpga_Read_Reg(Fpga, LowAdr+4, 1); return 1; } /* int Motor_IsBusy(Int32 Fpga, Int32 HighAdr, Int32 LowAdr, Int32 BusyRegister, Int32 BusyBitNo) { int temp1 = 0; int tmp3 = 0; tmp3 = (int) GetBit(Fpga, F2_SPI_Busy1_Direct, BusyBitNo); while ( tmp3 == 1) { tmp3 = (int) GetBit(Fpga, F2_SPI_Busy1_Direct, BusyBitNo); stubManager.Write("\n\nBUSY"); } var RV_High = Fpga_Read_Reg(Fpga, HighAdr+4, 0); var RV_Low = Fpga_Read_Reg(Fpga, LowAdr+4, 0); temp = ( (int) RV_High.Value << 16) + (int) RV_Low.Value; return temp; } */ /* int Motor_SetStep(Int32 Fpga, Int32 HighAdr, Int32 LowAdr, Int32 StepVal) { var RetVal = Fpga_Read_Reg(Fpga, HighAdr+4, 1); Fpga_Read_Reg(Fpga, LowAdr+4, 1); Fpga_Write_Reg(Fpga, HighAdr, MOTORDRIVER_RDCFG_COMMAND_MSB, 1); Fpga_Write_Reg(Fpga, LowAdr, MOTORDRIVER_RDCFG_COMMAND_LSB, 1); } const Int32 MOTORDRIVER_RDSTEPREG_COMMAND_MSB = 0x3600; const Int32 MOTORDRIVER_RDSTEPREG_COMMAND_LSB = 0x0000; const Int32 MOTORDRIVER_WRSTEPREG_COMMAND_MSB = 0x1600; const Int32 MOTORDRIVER_WRSTEPREG_COMMAND_LSB = 0x0000; */