Device-Velleman-K8055
view release on metacpan or search on metacpan
lib/Device/Velleman/K8055.pm view on Meta::CPAN
this are welcome.
use Device::Velleman::K8055 qw(:all);
# Trying to open device 0
die "Can't open K8055 device" unless OpenDevice(0) == 0;
# let us flicker the Analog output leds three times each
for (my $i = 0; $i < 3; $i++)
{
for (my $j = 1; $j < 3; $j++)
{
SetAnalogChannel($j);
ClearAnalogChannel($j == 1 ? 2 : ($j -1));
sleep(1);
}
}
# clear the analog output
ClearAllAnalog();
# and close the device
CloseDevice();
=head1 USAGE
This module consists of the functions that the K8055D.dll provides:
=head2 OpenDevice($devicenumber);
This opens the device, indicated by $devicenumber, which can be any
value ranging from 0 to 3. The devicenumber is determined by the
jumpers you set on the board. The default setting is 0.
It returns -1 if it's unsuccessful, the devicenumber that has been opened in case of success.
This function can also be used to select the active K8055 card to read and write the data. All the
communication routines after this function call are addressed to this card until the other card is
selected by this function call.
=head2 CloseDevice();
This closes the device. You don't need to call CloseDevice between
switching of the different devicenumbers. Just call it at the end
of your application.
=head2 $value = ReadAnalogChannel($channel);
This reads the value from the analog channel indicated by $channel (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.
=head2 ReadAllAnalog($data1, $data2);
This reads the values from the two analog ports into $data1 and $data2.
=head2 OutputAnalogChannel($channel, $data);
This outputs $data to the analog channel indicated by $channel.
The indicated 8-bit Digital to Analogue Converter channel is altered according to the new data.
This means that the data 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 $data lying in between these extremes can be translated by the following formula :
$data / 255 * 5V.
=head2 OutputAllAnalog($data1, $data2);
This outputs $data1 to the first analog channel, and $data2 to the
second analog channel. See OutputAnalogChannel for more information.
=head2 ClearAnalogChannel($channel);
This clears the analog channel indicated by $channel. The selected DA-channel is set to
minimum output voltage (0 Volt).
=head2 ClearAllAnalog();
The two DA-channels are set to the minimum output voltage (0 volt).
=head2 SetAnalogChannel($channel);
The selected 8-bit Digital to Analogue Converter channel is set to maximum output voltage.
=head2 SetAllAnalog();
The two DA-channels are set to the maximum output voltage.
=head2 WriteAllDigital($data);
The channels of the digital output port are updated with the status of the corresponding
bits in the $data parameter. A high (1) level means that the microcontroller IC1 output
is set, and a low (0) level means that the output is cleared.
$data is a value between 0 and 255 that is sent to the output port (8 channels).
=head2 ClearDigitalChannel($channel);
This clears the digital channel $channel, which can have a value between 1 and 8
that corresponds to the output channel that is to be cleared.
=head2 ClearAllDigital();
This clears (sets to 0) all digital output channels.
=head2 SetDigitalChannel($channel);
This sets digital channel $channel to 1.
=head2 SetAllDigital();
This sets all digital output channels to 1.
=head2 $value = ReadDigitalChannel($channel);
The status of the selected input $channel is read.
$channel can have a value between 1 and 5 which corresponds to the input channel whose
status is to be read.
The return value will be true if the channel has been set, false otherwise
=head2 $value = ReadAllDigital();
This reads all 5 digital ports at once. The 5 least significant bits correspond to the
status of the input channels. A high (1) means that the
channel is set, a low (0) means that the channel is cleared.
( run in 1.142 second using v1.01-cache-2.11-cpan-9581c071862 )