Error using bitand - Double inputs must have integer values in the integer range when mixed with integer inputs.
이전 댓글 표시
I'm having an issue regarding the bitand() function. I'm getting an error when I'm running the code. below is just a section of the code I'm running.
properties
SLEEP = hex2dec('10');
function
mode1 = r.i2c.readRegister(r.MODE1); %this is being read as a value of 1
mode1 = bitand(mode1, bitcmp(r.SLEEP, 'int8')); %here is where the error is occurring.
this is what pops up.
Error using bitand
Double inputs must have integer values in the integer range when mixed with integer inputs.
Error in PWM (line 50)
mode1 = bitand(mode1, bitcmp(r.SLEEP, 'int8'));
Error in MotorHat (line 22)
motor_obj.pwm = PWM(motor_obj.rpi, addr);
now if I run just bitcmp(r.SLEEP, 'int8') on its own the value is -17. I have to run it with the assumed type 'int8', because it comes back as a double value 1.8447e+19 if I don't.
anyone have any ideas as to what the issue is and how I can go about fixing it?
If i do the following
bitand(1, -17, 'int8')
i get the answer of 1. Which would be the answer I'm looking for. but for obvious reasons, I can't just insert values, I need to be able to use the variables.
댓글 수: 4
Walter Roberson
2017년 4월 13일
After you read from the register, what shows up if you calculate
model - 1.0
I predict that the answer will not be exactly 0
Michael
2017년 4월 14일
Michael
2017년 4월 14일
Walter Roberson
2017년 4월 14일
Is it possible that some of the values are >= 128 ? That would cause confusion between uint8 and int8 .
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Frequency Transformations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!