定義
#define HEATER_DUTY_FOR_SETPOINT(setpoint) ((int)((187L*(long)setpoint)>>8)-27)
シミュレーション
function heater clear; close all; %x=0:65535; x=0:255; y=heater_duty_for_setpoint(x); plot(x,y,'b-'); title('HEATER DUTY FOR SETPOINT'); function result=heater_duty_for_setpoint(setpoint) result = (bitshift((setpoint*187),-8))-27; end end
function heater clear; close all; %x=0:65535; x=0:255; y=heater_duty_for_setpoint(x) a=(y(end)-y(1))/256; z=a*x-27; plot(x,y,'b-'); hold on; plot(x,z,'r-'); title('HEATER DUTY FOR SETPOINT','FontSize',20); s = sprintf('%f * x -27',a); lgd = legend('((int)((187L*(long)setpoint)>>8)-27',s); lgd.FontSize=14; set(gca,'fontsize',14) function result=heater_duty_for_setpoint(setpoint) result = (bitshift((setpoint*187),-8))-27; end end