Rodney Posted February 2, 2018 Share Posted February 2, 2018 Hi please see attached excuse my ignorance on this topic as a non programmer newbie this is an area I know little about I need to access the the bytes (I think) of the registers to use the data I can return the data readinputU16 but don't know what to do with it..... I have read the manual section 4.12.10 on byte conversions but I'm a little lost for hex register 3201 (Decimal 12801) if I wanted to access the value in D9 (load over current) (I am assuming it will be either 1 or 0) what is the expression to do this? similarly D3-D2(charging status) how do I access the value (2 bytes?) - what is the expression for this? Regards Rodney Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted February 2, 2018 Share Posted February 2, 2018 For a bit, you can use TestBit(). For a group of bits (say D7-D4 of A15), you would have to mask and shift: (value >> 4) & 0x07. This is basic bitwise boolean math that is covered in basic old-school computer science texts if you want to read more. Quote Link to comment Share on other sites More sharing options...
Rodney Posted June 10, 2018 Author Share Posted June 10, 2018 Hi Sorry for the late reply but other issues on my project have taken priority..... Can you confirm if I have understood you reply if I named A15 above Batt_Status and I want to return D8 then the syntax is TestBit(Batt_Status[0],8) D7-D4 (Batt_Status[0]>>4) & 0x07 and D3-D0 (Batt_Status[0]>>4) & 0x03 if I named A16 CES and I wanted the charging status (D3-D2) (CES[0]>>2) & 0x03 Thank you Rodney Quote Link to comment Share on other sites More sharing options...
Rodney Posted June 10, 2018 Author Share Posted June 10, 2018 sorry one final syntax to check if I wanted A16 D15-D14 would it be (CES[0]>>2) & 0x0F thanks Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted June 14, 2018 Share Posted June 14, 2018 Most no. You have the wrong hex values. You have to think in binary, and might want to use binary notation instead:: D7-D4 (Batt_Status[0]>>4) & 0b1111 and D3-D0 Batt_Status[0] & 0b1111 if I named A16 CES and I wanted the charging status (D3-D2) (CES[0]>>2) & 0b0011 if I wanted A16 D15-D14 would it be (CES[0]>>14) & 0b11 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.