udamonic.com
  • Start
    • What is a Scamp?
    • Getting Started
    • Getting Started (Windows)
  • Learn
    • What is Forth?
    • Arithmetic
    • The Stack
    • Creating Words
    • Compilation Tricks
    • Decompilation
    • Comments
    • Characters and Strings
    • Accessing Memory
    • Constants, Variables and Values
    • Flow Control
    • Loops
    • Data Structures
    • Doubles, Triples and Quads
    • FlashForth Dictionary Reference
    • Scamp Dictionary Reference
  • Extras
    • Interrupts
    • Timers
    • Multitasking
    • Delays and Tick Count
    • Processor Words
    • Starting up with turnkey
    • Changing the Prompt
    • Formatting Text on Screen
  • Interfacing
    • Using the LED Array
    • Temperature Sensor
    • Input/Output
    • Analog Input
    • Serial >
      • Serial Communication
      • Scamp2 UART Pins
    • I2C >
      • I2C Overview
      • I2C Commands
    • SPI
    • PWM
    • Peripheral Pin Select
    • Input Capture
    • Digital Signal Modulator
  • Create
    • Creating PCBs >
      • Designing PCBs
      • Fabricating PCBs
      • Soldering
    • Sensing >
      • Measuring Temperature
    • LEDs >
      • Adding LEDs
      • LED arc-welder effect
    • Displays >
      • Adding a 7 Segment Display
      • Adding a Touch LCD
      • Touch LCD GUI
      • Game of Pong
    • Adding Extra GPIO
    • Adding a Low Side Switch
    • FizzBuzz
    • Adding MRAM
    • Model Train Control
    • Adding a Real Time Clock
    • Scamp Projects on Youtube
  • Resources
  • Store
  • About
  • Contact

Digital Signal Modulator (DSM)
​

The Scamp processor has a Digital Signal Modulator that can mix a source digital data stream with a carrier to produce a modulated output. Both the carrier and the modulator signals are supplied to the DSM module, either internally from the output of a peripheral module, or externally through an input pin. The DSM module can produce Frequency Shift Keying (FSK), Phase-Shift Keying (PSK) and On-Off Keying (OOK).
Refer to the Microchip User Guide for the DSM module to fully understand its operation. 

The Scamp3 provides Forth support for the DSM module. The word dsm assigns the DSM module to a pin, source and carrier in that order. For example, to assign the DSM output to pin 2, with the source from UART2 Tx (source value 5) and the carrier from PWM1 (carrier value 4):
2 5 4 dsm

The following codes select the source:
14 = SPI3 module output (SDO3)
13 = Output Compare/PWM Module 6 **
12 = Output Compare/PWM Module 5 **
11 = Output Compare/PWM Module 4 **
10 = Output Compare/PWM Module 3 **
9 = Output Compare/PWM Module 2 **
8 = Output Compare/PWM Module 1 **
7 = UART4 TX output
6 = UART3 TX output
5 = UART2 TX output
4 = UART1 TX output
3 = SPI2 module output (SDO2) 
2 = SPI1 module output (SDO1) 
1 = Input on MDMIN pin
0 = Manual modulation using MDBIT
The following codes select the carrier:
9 = Output Compare/PWM Module 6  **
8 = Output Compare/PWM Module 5 **
7 = Output Compare/PWM Module 4 **
6 = Output Compare/PWM Module 3 **
5 = Output Compare/PWM Module 2 **
4 = Output Compare/PWM Module 1 **
3 = Reference Clock Output (REFO) *
2 = Input on MDCIN2 pin
1 = Input on MDCIN1 pin
0 = GND (no carrier)

* See Processor Words for information on changing the Reference Clock frequency
* * Don't forget to set the period and duty cycle of the PWM module as appropriate

For example, to modulate characters sent by tx1 with a 160 kHz reference clock, output on pin 11:
#100 oscdiv  \ set reference clock to 160 kHz
#11 4 3 dsm  \ set pin 11 as dsm output

             \ source is Tx1 (source = 4)
             \ carrier is reference clock (carrier = 3)
Note that there is no requirement to map TX1 to an external pin or to manually wire TX1 to anything. The routing between peripheral modules and the DSM takes place inside your Scamp3. 

Manual control of the Modulator
​

MDBIT (source = 0) allows for manual control of the modulation.

​The word mdbit is used with a boolean on the stack to turn the modulation on or off as required, when the source is set to manual modulation with MDBIT:
#11 0 4 dsm  \ set pin 11 as dsm output
             \ source is MDBIT (source = 0)
             \ carrier is PWM1 (carrier = 4)
1 mdbit      \ output is modulated with carrier
0 mdbit      \ output is not modulated

Setting an External Digital Source
​

The word mdmin assigns a pin to the MDMIN (input) of the modulator. This allows an external (digital) signal to be used as the source for the modulator. For example, we assign pin 7 to MDMIN, and pin 11 to the modulator output, with the reference clock as the carrier:
#7 mdmin     \ set pin 7 to MDMIN
#11 1 3 dsm  \ set pin 11 as dsm output
             \ source is MDMIN (source = 1)
             \ carrier is reference clock (carrier = 3)

Setting an External Carrier
​

The words mdcin1 and mdcin2 assign a pin to the MDCIN1 and MDCIN2 carrier inputs of the modulator, respectively. This allows an external signal to be used as the carrier for the modulator. For example, we assign pin 4 to MDCIN1, and pin 11 to the modulator output, with the reference clock as the carrier:
#4 mdcin1    \ set pin 4 to MDCIN1
#11 5 1 dsm  \ set pin 11 as dsm output
             \ source is TX2 (source = 5)
             \ carrier is MDCIN1 (carrier = 1)

Learn : Interfacing : DSM
Site powered by Weebly. Managed by Hostwinds
  • Start
    • What is a Scamp?
    • Getting Started
    • Getting Started (Windows)
  • Learn
    • What is Forth?
    • Arithmetic
    • The Stack
    • Creating Words
    • Compilation Tricks
    • Decompilation
    • Comments
    • Characters and Strings
    • Accessing Memory
    • Constants, Variables and Values
    • Flow Control
    • Loops
    • Data Structures
    • Doubles, Triples and Quads
    • FlashForth Dictionary Reference
    • Scamp Dictionary Reference
  • Extras
    • Interrupts
    • Timers
    • Multitasking
    • Delays and Tick Count
    • Processor Words
    • Starting up with turnkey
    • Changing the Prompt
    • Formatting Text on Screen
  • Interfacing
    • Using the LED Array
    • Temperature Sensor
    • Input/Output
    • Analog Input
    • Serial >
      • Serial Communication
      • Scamp2 UART Pins
    • I2C >
      • I2C Overview
      • I2C Commands
    • SPI
    • PWM
    • Peripheral Pin Select
    • Input Capture
    • Digital Signal Modulator
  • Create
    • Creating PCBs >
      • Designing PCBs
      • Fabricating PCBs
      • Soldering
    • Sensing >
      • Measuring Temperature
    • LEDs >
      • Adding LEDs
      • LED arc-welder effect
    • Displays >
      • Adding a 7 Segment Display
      • Adding a Touch LCD
      • Touch LCD GUI
      • Game of Pong
    • Adding Extra GPIO
    • Adding a Low Side Switch
    • FizzBuzz
    • Adding MRAM
    • Model Train Control
    • Adding a Real Time Clock
    • Scamp Projects on Youtube
  • Resources
  • Store
  • About
  • Contact