diff options
| author | Avi Levkovich <avi@twine-s.com> | 2019-05-16 12:02:17 +0300 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2019-05-16 12:02:17 +0300 |
| commit | d2fe3001624ea3bb5e9d5eea9d69d6ec790ef0c0 (patch) | |
| tree | 5042bdaa17de19228b78702025023026d3fbbc24 /Software/Embedded_SW/Embedded | |
| parent | 4fdb3d2406b16a95e15fe24d6f562e666b3258af (diff) | |
| download | Tango-d2fe3001624ea3bb5e9d5eea9d69d6ec790ef0c0.tar.gz Tango-d2fe3001624ea3bb5e9d5eea9d69d6ec790ef0c0.zip | |
update the Screw ENC logic (acording to the FPGA change request)
Diffstat (limited to 'Software/Embedded_SW/Embedded')
| -rw-r--r-- | Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c | 30 | ||||
| -rw-r--r-- | Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.h | 5 |
2 files changed, 22 insertions, 13 deletions
diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c index 3e839b53c..e3eaf4547 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c @@ -432,8 +432,7 @@ typedef union { struct { - uint16_t M:10;//0..9 - uint16_t Direction:1;//10 + uint16_t M:10;//0..10 uint8_t Spare:5;//11-15 }Bits; uint32_t Word; @@ -443,8 +442,8 @@ typedef union { struct { - uint16_t L; - uint16_t M; + uint16_t L; + uint16_t M; }Word; uint32_t Position; }SCREW_POS; @@ -454,18 +453,29 @@ typedef union SCREW_ENC Screw_RotEnc; -void Read_Screw_Encoder() +uint32_t Read_Screw_Encoder()//the value of Screw_RotEnc.Position is legal only when the status is OK { + uint32_t status = OK; + + uint16_t Save_M = 0; + SCREW_ENC_M Screw_Enc_M; SCREW_POS Screw_Pos; - Screw_Pos.Word.L = F1_SCREW_ROTENC_L; // Must First Read the register of Lsw. + Screw_Enc_M.Word = F1_SCREW_ROTENC_M;; + Screw_Pos.Word.M = Screw_Enc_M.Bits.M; + Screw_Pos.Word.L = F1_SCREW_ROTENC_L; Screw_Enc_M.Word = F1_SCREW_ROTENC_M; + Save_M = Screw_Enc_M.Bits.M; - Screw_Pos.Word.M = Screw_Enc_M.Bits.M; + if(Save_M != Screw_Pos.Word.M) + status = ERROR; + else + Screw_RotEnc.Position = Screw_Pos.Position; + Screw_RotEnc.Index_Counter = F1_SCREW_ROTENC_I; - Screw_RotEnc.Position = Screw_Pos.Position; - Screw_RotEnc.Direction = Screw_Enc_M.Bits.Direction; - Screw_RotEnc.Index = F1_SCREW_ROTENC_I; + return status; } + + diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.h b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.h index 8564c2266..f225227f0 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.h +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.h @@ -19,13 +19,12 @@ uint32_t Read_Dryer_Fan_Tacho(); void Set_Speed_Sensor_TypeII_Registers(uint32_t Counter, uint32_t Prescaler); uint32_t Read_Speed_Sensor_TypeII(); -void Read_Screw_Encoder(); +uint32_t Read_Screw_Encoder();//the value of Screw_RotEnc.Position is legal only when the status is OK typedef struct { uint32_t Position; - bool Direction; - uint16_t Index; // This counter counts the amount of index pulses that have occurred since the last time the register was read. + uint16_t Index_Counter; // This counter counts the amount of index pulses that have occurred since the last time the register was read. }SCREW_ENC; |
