Unlike digital current loops, which often involves simple optical isolators, when talking about the Analog industrial control method, the theoretical solution would be to convert the current to a voltage in a range suitable for an ADC chip using a resistor, and adding an external (I2C or SPI (which could be optically isolated) ADC, see picture below) to the PI.
<div>
<!-- Add Russian to English -->
<a target="_blank" onclick="window.open('http://www.google.com/translate?u='+encodeURIComponent(location.href)+'&langpair=ru%7Cen&hl=en&ie=UTF8'); return false;" title="Google-Translate-Russian to English"><img border="0" width="25" alt="Google-Translate-Russian to English" src="http://www.google.com/images/flags/uk_flag.gif" height="16" title="Google-Translate-Russian to English"/>English</a>
<!-- END Russian to English -->
<br/>
<!-- Add Russian to German -->
<a target="_blank" onclick="window.open('http://www.google.com/translate?u='+encodeURIComponent(location.href)+'&langpair=ru%7Cde&hl=de&ie=UTF8'); return false;" title="Google-Translate-Russian to German"><img border="0" width="25" alt="Google-Translate-Russian to German" src="http://www.google.com/images/flags/de_flag.gif" height="16" title="Google-Translate-Russian to German"/> German</a>
<!-- END Russian to German -->
<br/>
<!-- Add Russian to French -->
<a target="_blank" onclick="window.open('http://www.google.com/translate?u='+encodeURIComponent(location.href)+'&langpair=ru%7Cfr&hl=fr&ie=UTF8'); return false;" title="Google-Translate-Russian to French "><img border="0" width="25" alt="Google-Translate-Russian to French " src="http://www.google.com/images/flags/fr_flag.gif" height="16" title="Google-Translate-Russian to French "/>French </a>
<!-- END Russian to French -->
<br/>
<!-- Add Russian to Italian -->
<a target="_blank" onclick="window.open('http://www.google.com/translate?u='+encodeURIComponent(location.href)+'&langpair=ru%7Cit&hl=it&ie=UTF8'); return false;" title="Google-Translate-Russian to Italian"><img border="0" width="25" alt="Google-Translate-Russian to Italian" src="http://www.google.com/images/flags/it_flag.gif" height="16" title="Google-Translate-Russian to Italian"/> Italian</a>
<!-- END Russian to Italian -->
<br/>
</div>
Математически функция map() может быть записана так:
long map(long x, long in_min, long in_max, long out_min, long out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
//а если заменить long на float или double, то она будет работать с плавающей точкой
//и соответственно изменить имя функции, что бы оно не пересекалось с родной библиотекой ардуины