<?xml version="1.0" encoding="UTF-8"?>

<!--
 *
 * This help file was generated from cmd_analog_out.sci using help_from_sci().
 *
 -->

<refentry version="5.0-subset Scilab" xml:id="cmd_analog_out" xml:lang="en"
          xmlns="http://docbook.org/ns/docbook"
          xmlns:xlink="http://www.w3.org/1999/xlink"
          xmlns:svg="http://www.w3.org/2000/svg"
          xmlns:ns3="http://www.w3.org/1999/xhtml"
          xmlns:mml="http://www.w3.org/1998/Math/MathML"
          xmlns:scilab="http://www.scilab.org"
          xmlns:db="http://docbook.org/ns/docbook">

  <refnamediv>
    <refname>cmd_analog_out</refname>
    <refpurpose>Command to sent out analog signal to a connected Arduino board</refpurpose>
  </refnamediv>


<refsynopsisdiv>
   <title>Calling Sequence</title>
   <synopsis>
   cmd_analog_out(h,pin_no,val)
   
   </synopsis>
</refsynopsisdiv>

<refsection>
   <title>Parameters</title>
   <variablelist>
   <varlistentry><term>h :</term>
      <listitem><para> Board number, reserved for future use. For this version, any number would do</para></listitem></varlistentry>
   <varlistentry><term>pin_no :</term>
      <listitem><para> Digital pin with ~ to sent the signal</para></listitem></varlistentry>
   <varlistentry><term>val :</term>
      <listitem><para> The value of 0-255 to be sent to the digital pins with ~ sign. It will be then scaled to 0-5V</para></listitem></varlistentry>
   </variablelist>
</refsection>

<refsection>
   <title>Description</title>
   <para>
The analog outputs of the Arduino Uno is available at the pins 3,5,6,9,10 and 11, while on the Mega board, the outputs are on pins 1-13 and 44-46.
It is a bit misleading to use the term "analog output", because in order to generate this output while minimizing energy losses,
the Arduino uses PWM (Pulse Width Modulation) available on these ports. By varying the duty cycle of the PWM is altered the average
voltage across the component connected to this port, which has the effect of having a analog output voltage.
   </para>
   <para>
The input port accepts the value from 0 to 255 which is correspoding to the duty cycle of 0 to 100%. In other words, sending 0 to the block will generate 0 V output at the port, 127 generates 2.5V and 255 generates 5V. (the port is 8 bits, so the resolutions of output would be 2^8 =256).
   </para>
   <para>
</para>
</refsection>

<refsection>
   <title>Examples</title>
   <programlisting role="example"><![CDATA[
ok = open_serial(1,9,115200)
cmd_analog_out(1,9,100)
close_serial(1)

   ]]></programlisting>
</refsection>

<refsection>
   <title>See also</title>
   <simplelist type="inline">
   <member><link linkend="cmd_analog_out_volt">cmd_analog_out_volt</link></member>
   <member><link linkend="cmd_arduino_a_control">cmd_arduino_a_control</link></member>
   </simplelist>
</refsection>

<refsection>
   <title>Authors</title>
   <simplelist type="vert">
   <member>Bruno JOFRET, Tan C.L.</member>
   </simplelist>
</refsection>
</refentry>
