Device-Velleman-K8055-Fuse

 view release on metacpan or  search on metacpan

lib/Device/Velleman/K8055/Fuse.pm  view on Meta::CPAN

    return $dev;
}

=head2 ReadAnalogChannel();

 my $val1 = $dev->ReadAnalogChannel(1);
 my $val2 = $dev->ReadAnalogChannel(2);

 my $channel = 1;
 my $val3 = $dev->ReadAnalogChannel($channel);



Reads the value from the analog channel indicated by (1 or 2).
The input voltage of the selected 8-bit Analogue to Digital converter channel is converted to a value
which lies between 0 and 255.

Returns the numeric  value.

=cut

sub ReadAnalogChannel ($$) {
    my $self = shift;
    my $cid  = shift;
    my $res  = $self->get( "analog_in" . $cid );
    return $res;
}

=head2 ReadAllAnalog();

 my ($val1,$val2) = $dev->ReadAllAnalog();

ReadAllAnalog reads the values from the two analog ports into $data1 and $data2.

Inputs: None

Outputs: array of two numeric values

=cut

sub ReadAllAnalog ($) {
    my $self = shift;
    my $cid;
    $cid = 1;
    my $one = $self->get( "analog_in" . $cid );
    $cid = 2;
    my $two = $self->get( "analog_in" . $cid );
    return ( $one, $two );
}

=head2 OutputAnalogChannel();

 my $val = $dev->OutputAnalogChannel(1,0);
 my $val = $dev->OutputAnalogChannel(2,255);

This outputs $value to the analog channel indicated by $channel.

The indicated 8-bit Digital to Analogue Converter channel is altered according to the new value.
This means that the value corresponds to a specific voltage. The value 0 corresponds to a
minimum output voltage (0 Volt) and the value 255 corresponds to a maximum output voltage (+5V).
A value of $value lying in between these extremes can be translated by the following formula :
$value / 255 * 5V.

See also SetAnalogChannel() and SetAllAnalog()

=cut

sub OutputAnalogChannel($$) {
    my $self = shift;
    my $cid  = shift;
    my $val  = shift;
    $self->set( "analog_out" . $cid, $val );
}

=head2 OutputAllAnalog();

 my ($val1,$val2) = $dev->OutputAllAnalog(0,255);

 my $val = $dev->OutputAllAnalog(255);

This outputs $value1 to the first analog channel, and $value2 to the
second analog channel. If only one argument is passed, then both channels are given the same value.

See also: SetAllAnalog()

=cut

sub OutputAllAnalog($@) {
    my $self = shift;
    my $val1 = shift;
    my $val2;

    if   ( scalar @_ ) { $val2 = shift; }
    else               { $val2 = $val1 }

    my $cid;
    my @out;
    $cid = 1;
    push @out, $self->set( "analog_out" . $cid, $val1 );
    $cid = 2;
    push @out, $self->set( "analog_out" . $cid, $val2 );

    if   ( $val1 != $val2 ) { return @out }
    else                    { return $out[0] }
}

=head2 ClearAnalogChannel();

This clears the analog channel indicated by $channel. The selected DA-channel is set to minimum output voltage (0 Volt).

Input: channel number

Output: value between 0 (min) and 255 (max)

 my $dev->ClearAnalogChannel(1);
 my $dev->ClearAnalogChannel(2);

See also OutputAnalogChannel(), ClearAllAnalog()

=cut



( run in 1.666 second using v1.01-cache-2.11-cpan-9581c071862 )