06-11-2019 06:03 AM
Hi, I am facing a problem in defining register. I have 8 bit register in which first 4 bits are for ODR selection and 2nd 2 bits for range selection and last 2 bits for performance selection. I want to make cases for all but it is very difficult to make combination. is there any way to make 4 bit buffer for ODR, 2 bit buffer for range and same 1 1 bit for performance, and then from all these buffer make a register. i tried it but i didn't succeeded. Help please.
Solved! Go to Solution.
06-11-2019 06:14 AM
06-11-2019 09:57 PM
Thank you for kind reply. I tried this method but i am not succeeded. can you please share the VI you made for example?
06-11-2019 11:10 PM
Hi, Thank you for your response. I tried the method but i didn't succeeded. I have attached the problem which i want to get solution.
06-11-2019 11:20 PM
Attach what you tried but did not succeed with. It should be easy to recreate the VI shown in the picture. If it didn't work, then you must have done something wrong and attaching your VI we can point out the error.
06-12-2019 12:08 AM
Thank yo. I have attached two vi's. One is for fixed ODR which i am using and result ok. The other is for variable ODR and Range which has problem.
06-12-2019 02:34 AM
Neither 208 fits in 4 bits nor 250 in 2 bits. So how we could set these values?
208 (base 10) = 1101 0000 (base 2)
250 (base 10) = 1111 1010 (base 2)
Your specifications are wrong or at least incomplete.
06-12-2019 03:04 AM
Hi, thank you for your reply.
1- I have attached the snap in detail. Infact, it is 8 bit register in which for ODR first 4 Bits are reserved, 2nd 2 for range and last two for full scale range and operation. but the last two bits has to be kept zero.
2- For these ( 208 (base 10) = 1101 0000 (base 2), 250 (base 10) = 1111 1010 (base 2) ) you can see the table i have attached in snapshot. may that will help to clear it.
hope that it will make way to solution.
06-12-2019 04:40 AM - edited 06-12-2019 04:42 AM
So GerdW's code is working, but before calculation you need to "translate" your settings to the actual values contained in the tables.
For example, 208 Hz must be translated to 5, 250 dps to 0; 833 Hz would translate to 7, etc.
I suggest you to create two enum typedefs with U8 representation, one with possible frequencies, the other with possible dps.
See my attached example for the full scale.