![AWC GP3 Скачать руководство пользователя страница 21](http://html.mh-extra.com/html/awc/gp3/gp3_manual_3035292021.webp)
least significant bit of the duty cycle. Send the duty cycle as the second byte. The duration/frequency is in ARG.
led –
This property allows you to turn the onboard LED on or off.
Raw command: 0 0 0 0 1 1 0 X where X=0 to
turn LED off and X=1 to turn LED on.
count
- The count command allows the GP3 to count the number of low to high pulses that occur on an input
pin over a particular period of time. This is not the hardware counter, but instead requires the GP3 to watch the
input pin (the pin is forced to be an input). The duration (the argument when using raw commands) is specified
in milliseconds. The GP3 samples the pin every 4uS for that period and returns the count as a 16-bit integer
(most significant byte first).
Raw command: 0 1 0 0 P P P 0 where P P P is the pin number.
rctime –
This command allows the GP3 to measure the time a pin (forced to be an input) stays in a particular
state. This is useful for measuring the charge or discharge time of an RC network (which can be used to
measure a potentiometer or a thermistor, for example). The time returned (a 16-bit integer with most significant
byte first) indicates the time in 2uS units.
Raw command: 0 0 0 0 1 1 1 0, 1 0 1 0 P P P S where P P P is the pin
number and S is the desired state.
pulsein –
Use this function to read a single pulse on one of the 8 digital I/O pins (the pin is made an input). The
return value (16-bits, most significant byte first) is in 2uS units (e.g., a return value of 100 indicates 200uS).
The state argument indicates if you want to measure a low pulse (0) or a high pulse (1). If there is no pulse
within 131.07mS, the command times out and returns 0.
Raw command: 0 1 1 1 P P P S where P P P is the pin
number and S is the pulse state.
pulseout –
Generate an output pulse on one of the 8 digital I/O pins (the pin is made an output). The duration
(in 2uS units) uses ARG in raw command mode. The pulse is formed by inverting the current state of the output
pin for the time specified.
Raw command: 0 1 0 0 P P P 1 where P P P is the pin number.
freq –
This command generates a simulated sine wave (using PWM) on one of the 8 digital I/O pins. The
duration is specified in milliseconds and the frequency in Hertz. For raw commands, ARG indicates the duration
in milliseconds. The frequency in Hertz (up to 32767) is sent as two bytes. The first byte is the most significant
byte with bit 7 set (the GP3 ignores this bit). The second byte is the least significant byte shifted right one place
and also with bit 7 set. The L bit is the least significant bit of the least significant byte.
Raw command: 0 0 0 0
1 1 1 0, 1 0 0 0 P P P L where P P P is the pin number and L is the least significant bit of the frequency's least
significant byte.
setcounter
– The GP3 has a hardware counter. This command sets the mode for the counter. In particular, you
can select a prescale factor of 1, 2, 4, or 8. You can also select the internal 5MHz clock as a counter source (set
the mode=0 for internal clock). The counter is 16-bits, so at 5MHz and a prescale of 8, for example, it rolls over
at roughly 105mS. When counting external pulses, the hardware counter counts high-going pulses. When using
the library, simply specify the prescale number (e.g., 8). Setting the counter resets the count to zero.
Raw
command: 0 0 0 0 1 1 1 0, 1 0 0 1 0 V V X where V V is the prescale factor (0 0 = 1:1, 0 1 = 1:2, 1 0 = 1:4, 1 1
= 1:8).
counter –
This command reads the current counter value and resets the counter to zero. The 16-bit result is sent
most significant byte first.
Raw command: 0 1 0 1 1 0 1 0.
resetall –
Use this command to return the GP3 to its initial state (all digital I/O as inputs, counter off and reset,
PWM off).
Raw command: 0 1 0 1 1 1 0 0.
repeat –
You may wish to repeat certain input operations as rapidly as possible. If this is the case, set ARG to
-18-