This makes Amplitude Modulated Pulse Train, which can be regarded as the discretized wave of the signal. Pulse Train can be defined by frequency and duty cycle, which can be temporarily changed, referring to PWM.
Dependents: Interference_Simple
AMPulseTrain.cpp@5:77ac0df7c3a1, 2020-01-06 (annotated)
- Committer:
- aktk
- Date:
- Mon Jan 06 21:37:20 2020 +0000
- Branch:
- 35e9675a
- Revision:
- 5:77ac0df7c3a1
- Parent:
- 1:19c3a52c80c3
- Child:
- 8:1f88fb3a4c57
Complicated branch revision :'(
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aktk | 1:19c3a52c80c3 | 1 | #include "AMPulseTrain.h" |
aktk | 0:6400e338266f | 2 | |
aktk | 1:19c3a52c80c3 | 3 | AMPulseTrain::AMPulseTrain( |
aktk | 1:19c3a52c80c3 | 4 | /// Carrier Pulse Train |
aktk | 1:19c3a52c80c3 | 5 | PulseTrain * const arg_carrier, |
aktk | 1:19c3a52c80c3 | 6 | /// Initial AM Signal expression |
aktk | 1:19c3a52c80c3 | 7 | AMSignal * const arg_signal |
aktk | 0:6400e338266f | 8 | ): |
aktk | 1:19c3a52c80c3 | 9 | Carrier(arg_carrier), |
aktk | 1:19c3a52c80c3 | 10 | Signal(arg_signal) |
aktk | 0:6400e338266f | 11 | { |
aktk | 1:19c3a52c80c3 | 12 | setFrequency_Carrier(Carrier->getFrequency()); |
aktk | 0:6400e338266f | 13 | } |
aktk | 0:6400e338266f | 14 | |
aktk | 1:19c3a52c80c3 | 15 | |
aktk | 1:19c3a52c80c3 | 16 | |
aktk | 1:19c3a52c80c3 | 17 | |
aktk | 1:19c3a52c80c3 | 18 | uint16_t |
aktk | 1:19c3a52c80c3 | 19 | AMPulseTrain::getClockperiod_us() |
aktk | 0:6400e338266f | 20 | { |
aktk | 1:19c3a52c80c3 | 21 | return Carrier->getClockperiod_us(); |
aktk | 0:6400e338266f | 22 | } |
aktk | 0:6400e338266f | 23 | |
aktk | 1:19c3a52c80c3 | 24 | void |
aktk | 1:19c3a52c80c3 | 25 | AMPulseTrain::incrementClock() |
aktk | 0:6400e338266f | 26 | { |
aktk | 1:19c3a52c80c3 | 27 | Carrier->incrementClock(); |
aktk | 0:6400e338266f | 28 | } |
aktk | 0:6400e338266f | 29 | |
aktk | 1:19c3a52c80c3 | 30 | |
aktk | 1:19c3a52c80c3 | 31 | |
aktk | 1:19c3a52c80c3 | 32 | |
aktk | 1:19c3a52c80c3 | 33 | void |
aktk | 1:19c3a52c80c3 | 34 | AMPulseTrain::attachCallback_asClock( |
aktk | 1:19c3a52c80c3 | 35 | Callback<void(bool, AMPulseTrain*)> arg_callback |
aktk | 0:6400e338266f | 36 | ) |
aktk | 0:6400e338266f | 37 | { |
aktk | 1:19c3a52c80c3 | 38 | m_callback_asClock = arg_callback; |
aktk | 1:19c3a52c80c3 | 39 | Carrier->attachCallback_asClock(callback(this, &ulseTrain::CallbackWrapper_asClock)); |
aktk | 1:19c3a52c80c3 | 40 | } |
aktk | 1:19c3a52c80c3 | 41 | |
aktk | 1:19c3a52c80c3 | 42 | void |
aktk | 1:19c3a52c80c3 | 43 | AMPulseTrain::CallbackWrapper_asClock(bool arg_pulsestate) |
aktk | 1:19c3a52c80c3 | 44 | { |
aktk | 1:19c3a52c80c3 | 45 | m_callback_asClock(arg_pulsestate, this); |
aktk | 0:6400e338266f | 46 | } |
aktk | 0:6400e338266f | 47 | |
aktk | 1:19c3a52c80c3 | 48 | |
aktk | 1:19c3a52c80c3 | 49 | |
aktk | 1:19c3a52c80c3 | 50 | |
aktk | 1:19c3a52c80c3 | 51 | void |
aktk | 1:19c3a52c80c3 | 52 | AMPulseTrain::attachCallback_asPulseEdge( |
aktk | 1:19c3a52c80c3 | 53 | Callback<void(bool, AMPulseTrain*)> arg_callback |
aktk | 0:6400e338266f | 54 | ) |
aktk | 0:6400e338266f | 55 | { |
aktk | 1:19c3a52c80c3 | 56 | m_callback_asPulseEdge = arg_callback; |
aktk | 1:19c3a52c80c3 | 57 | Carrier->attachCallback_asPulseEdge(callback(this, &ulseTrain::CallbackWrapper_asPulseEdge)); |
aktk | 0:6400e338266f | 58 | } |
aktk | 0:6400e338266f | 59 | |
aktk | 1:19c3a52c80c3 | 60 | void |
aktk | 1:19c3a52c80c3 | 61 | AMPulseTrain::CallbackWrapper_asPulseEdge(bool arg_pulsestate) |
aktk | 0:6400e338266f | 62 | { |
aktk | 1:19c3a52c80c3 | 63 | m_callback_asPulseEdge(arg_pulsestate, this); |
aktk | 0:6400e338266f | 64 | } |
aktk | 0:6400e338266f | 65 | |
aktk | 1:19c3a52c80c3 | 66 | |
aktk | 1:19c3a52c80c3 | 67 | |
aktk | 1:19c3a52c80c3 | 68 | |
aktk | 1:19c3a52c80c3 | 69 | void |
aktk | 1:19c3a52c80c3 | 70 | AMPulseTrain::attachAMSignalExpression( |
aktk | 1:19c3a52c80c3 | 71 | Callback<uint16_t(AMPulseTrain*)> arg_callback |
aktk | 1:19c3a52c80c3 | 72 | ) |
aktk | 0:6400e338266f | 73 | { |
aktk | 1:19c3a52c80c3 | 74 | m_AMSignalExpression = arg_callback; |
aktk | 1:19c3a52c80c3 | 75 | Signal->attachAMSignalExpression( |
aktk | 1:19c3a52c80c3 | 76 | callback(this, &ulseTrain::CallbackWrapper_AMSignalExpression) |
aktk | 1:19c3a52c80c3 | 77 | ); |
aktk | 0:6400e338266f | 78 | } |
aktk | 0:6400e338266f | 79 | |
aktk | 1:19c3a52c80c3 | 80 | uint16_t |
aktk | 1:19c3a52c80c3 | 81 | AMPulseTrain::CallbackWrapper_AMSignalExpression(AMSignal* arg_signal) |
aktk | 0:6400e338266f | 82 | { |
aktk | 1:19c3a52c80c3 | 83 | return m_AMSignalExpression(this); |
aktk | 0:6400e338266f | 84 | } |