#include <rb8514_delay.h>
Inherits RulbusDevice.
Generate a programmable time delay.
Module RB8515 is a programmable delay time generator.
The module has a clock input, a trigger input, two delay outputs, a gate and a gate-not output, and a Rulbus interrupt output.
The delay is made with a 24-bit down counter that counts a programmable number of clock-pulses, when started by a trigger-pulse on the trigger input. See setClockFrequency(), setIntrinsicDelayTime(), setDelayTime(), setDelayCount(), isBusy().
The trigger input can be made positive or negative edge sensitive. Besides triggering the delay with the trigger-input, it is also possible to trigger the delay with the software command. See setTriggerEdge(), trigger().
Each of the two delay outputs (1 and 2) can be programmed to generate a short pulse (15 ns) at the start of the delay, at the end of it, both or to generate no pulse at all. See for example enableStart1().
The level of the start- and end-pulses of output 1 and 2 can be made positive or negative. The restriction is that both outputs have the same polarity for the same pulse. See for example setStart12Direction().
An additional restriction with negative pulses is, that only the start- or the end-pulse may be enabled on an output.
The gate and gate-not outputs generate a pulse from the start of the delay time upto the end of it. The gate-output is active high, the gate-not output is active low.
The Rulbus interrupt output can be enabled or disabled to generate an interrupt at the end of the delay time. It can be checked if an interrupt is pending, and a pending interrupt can be cleared. See enableInterrupt(), isPendingInterrupt().
Methods setSignalDirection() and enableSignal() and their accessor counterparts let you specify the signal through a parameter. They are added for the Rubus Device Library (RDL).
Here is a small example how you may use a delay module.
Rulbus::RB8514_delay delay( "delay" ); delay.setClockFrequency( 10e6 ); delay.setDelayTime ( 132e-3 );
Module RB8514 contains a three-byte register to load the delay-count from and it contains a control-status register to select the output pulses and to see if a counting operation is going on. Further it contains the logic to read the trigger signal, to create the output pulses and to interface to the Rulbus.
Input Description --------------------------------------------------------------------------- clock clock input for 24-bit down counter trigger input to start delay
Output Description --------------------------------------------------------------------------- out1 output with start- and endpulse out2 output with start- and endpulse gate this output is high during the delay /gate inverse of gate output interrupt Rulbus interrupt
Register Offset Rd/Wr Description --------------------------------------------------------------------------- CountByte2 0 write delay count most significant byte CountByte1 1 write ... CountByte0 2 write delay count least significant byte Control 3 write 76543210 7 : level end 1,2 : 0:neg, 1:pos 6 : level start 1,2: 0:neg, 1:pos 5 : edge trigger : 0:pos, 1:neg soft trigger : 1 -> 0 4 : enable and /clear interrupt 3 : enable end 2 2 : enable start 2 1 : enable end 1 0 : enable start 1 Status 3 read 76543210 765432 : not used 1 : delay busy 0 : interrupt pending
Public Types | |
typedef Int32 | Count |
the delay-count type | |
Public Member Functions | |
Construction | |
RB8514_delay (NameCref aName, Addr aAddr=DEF_ADDR, Rack aRack=DEF_RACK) | |
constructor; may throw RulbusOpenError | |
~RB8514_delay () | |
destructor. | |
Accessors | |
Freq | clockFrequency () const |
the current clock frequency. | |
Time | intrinsicDelayTime () const |
the current intrinsic delay time (it is subtracted from requested delay time). | |
Time | delayTime () const |
the current delay time. | |
Count | delayCount () const |
the current delay count. | |
char | signalDirection (CharCptr signal) const |
the current signal direction: signal in [t s1 s2 e1 e2], result: [p n]. | |
bool | isEnabledSignal (CharCptr signal) const |
true if signal enabled: signal in [i s1 s2 e1 e2]. | |
char | triggerEdge () const |
return active trigger edge: positive or negative active [pn]. | |
char | start12Direction () const |
return current start12 signal direction [pn]. | |
char | end12Direction () const |
return current end12 signal direction [pn]. | |
bool | isEnabledStart1 () const |
true if start1 signal is enabled. | |
bool | isEnabledEnd1 () const |
true if end1 signal is enabled. | |
bool | isEnabledStart2 () const |
true if start2 signal is enabled. | |
bool | isEnabledEnd2 () const |
true if end2 signal is enabled. | |
bool | isBusy () const |
true if delaying. | |
bool | isPendingInterrupt () |
true if an interrupt is pending; also clears interrupt. | |
bool | isEnabledInterrupt () const |
true if interrupt is enabled. | |
Mutators | |
void | setClockFrequency (Freq freq) |
set clock frequency. | |
void | setIntrinsicDelayTime (Time time) |
set intrinsic delay time (will be subtracted from requested delay time). | |
void | setDelayTime (Time time) |
set new delay time. | |
void | setDelayCount (Count count) |
set new delay count. | |
void | trigger () |
trigger or start delay. | |
void | setSignalDirection (CharCptr signal, char dir) |
set new signal direction: signal in [t s1 s2 e1 e2], dir in [p n i] for positive, negative and invert. | |
void | enableSignal (CharCptr signal, bool enable) |
enable signal: signal in [i s1 s2 e1 e2], i for interrupt. | |
void | setTriggerEdge (char edge) |
set new active trigger edge: positive or negative [pn]. | |
void | setStart12Direction (char dir) |
set start12 signal direction [pni]. | |
void | setEnd12Direction (char dir) |
set end12 signal direction [pn]. | |
bool | enableStart1 (bool enable=true) |
enable start1 signal. | |
bool | enableEnd1 (bool enable=true) |
enable end1 signal. | |
bool | enableStart2 (bool enable=true) |
enable start2 signal. | |
bool | enableEnd2 (bool enable=true) |
enable end2 signal. | |
void | clearInterrupt () |
clear (pending) interrupt. | |
bool | enableInterrupt (bool enable=true) |
enable interrupt. | |
Static Public Attributes | |
Defaults | |
const Addr | DEF_ADDR = 0xC4 |
default address | |
const Freq | DEF_FRQ = 1.0 |
clock frequency (1 Hz) | |
const Time | DEF_IDT = 0.0 |
intrinsic delay time (0 s) | |
const Time | DEF_DLY = 1.0 |
delay time (1 s) | |
const Count | DEF_CNT = (DEF_DLY - DEF_IDT) * DEF_FRQ |
intrinsic delay count | |
const bool | DEF_EINT = false |
enable interrupt | |
const char | DEF_ETRG = 'p' |
edge trigger | |
const char | DEF_LS12 = 'p' |
dir start 1,2 | |
const char | DEF_LE12 = 'p' |
dir end 1,2 | |
const bool | DEF_ES1 = true |
enable start 1 | |
const bool | DEF_EE1 = true |
enable end 1 | |
const bool | DEF_ES2 = true |
enable start 2 | |
const bool | DEF_EE2 = true |
enable end 2 | |
Limits | |
const Count | LIM_CNTMIN = 0 |
minimum count limit | |
const Count | LIM_CNTMAX = 16777215 |
maximum count limit | |
const Freq | LIM_FRQMIN = 1.0 |
minimum frequency limit | |
const Freq | LIM_FRQMAX = 100e6 |
maximum frequency limit | |
const Time | LIM_IDTMIN = 0.0 |
minimum intrinsic delay time limit | |
const Time | LIM_IDTMAX = 100e-9 |
maximum intrinsic delay time limit | |
Protected Member Functions | |
Construction and Assignment | |
RB8514_delay () | |
prevent default construction | |
RB8514_delay (RB8514_delayCref rhs) | |
prevent copying | |
RB8514_delayRef | operator= (RB8514_delayCref rhs) |
prevent copying | |
Validation | |
bool | isValidSignalName (CharCptr aSignal, CharCptr aExtra) const |
true if specified signal name is in [aExtra s1 s2 e1 e2]. | |
bool | isValidSignalDirection (Char aDirection) const |
true if specified signal direction is in [p n i]. | |
bool | isValidDelayCount (Count aCount) const |
true if specified count is a valid delay register value. | |
bool | isValidClockFrequency (Freq aFreq) const |
true if specified frequency is a valid clock frequency. | |
bool | isValidIntrinsicTime (Time aTime) const |
true if specified time is a valid delay time. | |
Private Member Functions | |
int | countByte2 () const |
return 3rd byte of delay register. | |
int | countByte1 () const |
return 2nd byte of delay register. | |
int | countByte0 () const |
return 1st byte of delay register. | |
char | getDirection (int mask) const |
return direction for signal specified by mask. | |
void | setDirection (char dir, int mask, CharCptr description) |
set direction for signal specified by mask to dir. | |
bool | getEnable (int mask) const |
true if signal specified by mask is enabled. | |
void | setEnable (bool enable, int mask) |
set enable state of signal specified by mask to enable. | |
Private Attributes | |
Data | |
Byte | theControlRegister |
control register contents | |
Count | theDelayRegister |
delay register contents | |
Freq | theClockFrequency |
clock frequency | |
Time | theIntrinsicDelayTime |
intrinsic delay time | |
Static Private Attributes | |
Register offsets | |
const int | OFF_BT2 = 0 |
delay count BT2-register | |
const int | OFF_BT1 = 1 |
delay count BT1-register | |
const int | OFF_BT0 = 2 |
delay count BT0-register | |
const int | OFF_CTL = 3 |
control-register | |
const int | OFF_STS = 3 |
status-register | |
const int | ADR_WIDTH = OFF_STS + 1 |
address with | |
Status-register masks | |
const int | MSK_STSINT = 0x01 |
interrupt pending | |
const int | MSK_STSBSY = 0x02 |
busy status | |
Control-register masks | |
const int | MSK_CTLES1 = 0x01 |
enable start 1 | |
const int | MSK_CTLEE1 = 0x02 |
enable end 1 | |
const int | MSK_CTLES2 = 0x04 |
enable start 2 | |
const int | MSK_CTLEE2 = 0x08 |
enable end 2 | |
const int | MSK_CTLINT = 0x10 |
enable interrupt | |
const int | MSK_CTLTRG = 0x20 |
trigger edge | |
const int | MSK_CTLLS12 = 0x40 |
dir start 1,2 | |
const int | MSK_CTLLE12 = 0x80 |
dir end 1,2 | |
Delay count mask and shifts | |
const int | MSK_BYTE = 0xFF |
a byte | |
const int | SHR_BT2 = 16 |
msb | |
const int | SHR_BT1 = 8 |
... | |
const int | SHR_BT0 = 0 |
lsb |