MikroElektronika white logo
  • Products
    • Click Boards
      • Wireless Connectivity
        • GPS/GNSS
        • GSM/LTE
        • LTE IoT
        • BT/BLE
        • WiFi
        • RFID/NFC
        • GSM+GPS
        • 6LoWPAN
        • ZigBee
        • UWB
        • SigFox
        • Sub-1 GHz Transceievers
        • 2.4 GHz Trancevers
        • LoRa
      • Sensors
        • Biometrics
        • Gas
        • Magnetic
        • Motion
        • Optical
        • Pressure
        • Proximity
        • Temperature & humidity
        • Current sensor
        • Miscellaneous
        • Environmental
        • Force
        • Inductance
        • RF meter
        • Click Shields
        • Click Bundles
      • Interface
        • Adapter
        • CAN
        • Port expander
        • RS485
        • USB
        • 1-Wire
        • RS232
        • Ethernet
        • LIN
        • PWM
        • Current
        • DALI
        • I2C
        • Fiber optics
        • SPI
        • DMX
        • CXPI
        • Click Shields
        • Click Bundles
      • Display & LED
        • LED Drivers
        • LED Matrix
        • LED Segment
        • OLED
        • LCD
        • Click Shields
        • Click Bundles
      • Miscellaneous
        • Relay
        • Optocoupler
        • ID
        • Proto
        • Encryption
        • Click Shields
        • Click Bundles
      • Mixed Signal
        • ADC
        • Measurements
        • DAC
        • Digital potentiometer
        • ADC-DAC
        • Click Shields
        • Click Bundles
      • Storage
        • EEPROM
        • FLASH
        • FRAM
        • microSD
        • MRAM
        • SRAM
        • EERAM
        • ReRAM
        • DRAM
        • Click Shields
        • Click Bundles
      • Motor Control
        • Brushed
        • Brushless
        • Servo
        • Stepper
        • Click Shields
        • Click Bundles
      • Audio & Voice
        • Amplifier
        • Microphone
        • Speakers
        • Signal Processing
        • Speech recognition
        • FM
        • MP3
        • Click Shields
        • Click Bundles
      • HMI
        • Capacitive
        • Pushbutton/Switches
        • Potentiometers
        • Rotary encoder
        • Haptic
        • Fingerprint
        • Click Shields
        • Click Bundles
      • Clock & Timing
        • RTC
        • Clock generator
        • Click Shields
        • Click Bundles
      • Power Management
        • Battery charger
        • Boost
        • Buck
        • Linear
        • Buck-Boost
        • Wireless Charging
        • Power Switch
        • USB-C PD
        • Click Shields
        • Click Bundles
      • Click Bundles
      • Click Shields
    • NECTO
      • NECTO Studio
    • Compilers
      • PIC
        • C
          • NECTO Studio
          • mikroC PRO for PIC
        • Basic
          • mikroBasic PRO for PIC
        • Pascal
          • mikroPascal PRO for PIC
        • Additional Software
          • CODEGRIP WiFi license
          • CODEGRIP SSL license
          • Visual TFT
          • Visual TFT AI
          • Visual GLCD
          • Package Manager
          • mikroBootloader
          • CAN calculator
          • GLCD Font Creator
          • Timer Calculator
          • MikroPlot
      • dsPIC/PIC24
        • C
          • NECTO Studio
          • mikroC PRO for dsPIC
        • Basic
          • mikroBasic PRO for dsPIC
        • Pascal
          • mikroPascal PRO for dsPIC
        • Additional Software
          • CODEGRIP WiFi license
          • CODEGRIP SSL license
          • Visual TFT
          • Visual GLCD
          • Package Manager
          • mikroBootloader
          • CAN calculator
          • GLCD Font Creator
          • Timer Calculator
          • MikroPlot
      • PIC32
        • C
          • NECTO Studio
          • mikroC PRO for PIC32
        • Basic
          • mikroBasic PRO for PIC32
        • Pascal
          • mikroPascal PRO for PIC32
        • Additional Software
          • CODEGRIP WiFi license
          • CODEGRIP SSL license
          • Visual TFT
          • Visual GLCD
          • Package Manager
          • mikroBootloader
          • CAN calculator
          • GLCD Font Creator
          • Timer Calculator
          • MikroPlot
      • ARM
        • C
          • NECTO Studio
          • mikroC PRO for ARM
        • Basic
          • mikroBasic PRO for ARM
        • Pascal
          • mikroPascal PRO for ARM
        • Additional Software
          • CODEGRIP WiFi license
          • CODEGRIP SSL license
          • Visual TFT
          • Visual TFT AI
          • Visual GLCD
          • Package Manager
          • mikroBootloader
          • CAN calculator
          • GLCD Font Creator
          • Timer Calculator
          • MikroPlot
      • AVR
        • C
          • NECTO Studio
          • mikroC PRO for AVR
        • Basic
          • mikroBasic PRO for AVR
        • Pascal
          • mikroPascal PRO for AVR
        • Additional Software
          • CODEGRIP WiFi license
          • CODEGRIP SSL license
          • Visual TFT
          • Visual GLCD
          • Package Manager
          • mikroBootloader
          • CAN calculator
          • GLCD Font Creator
          • Timer Calculator
          • MikroPlot
      • FT90x
        • C
          • mikroC PRO for FT90x
        • Basic
          • mikroBasic PRO for FT90x
        • Pascal
          • mikroPascal PRO for FT90x
        • Additional Software
          • CODEGRIP WiFi license
          • CODEGRIP SSL license
          • Visual TFT
          • Visual GLCD
          • Package Manager
          • mikroBootloader
          • CAN calculator
          • GLCD Font Creator
          • Timer Calculator
          • MikroPlot
      • 8051
        • C
          • mikroC PRO for 8051
        • Basic
          • mikroBasic PRO for 8051
        • Pascal
          • mikroPascal PRO for 8051
        • Additional Software
          • CODEGRIP WiFi license
          • CODEGRIP SSL license
          • Visual TFT
          • Visual GLCD
          • Package Manager
          • mikroBootloader
          • CAN calculator
          • GLCD Font Creator
          • Timer Calculator
          • MikroPlot
    • Dev Boards
      • PIC (8-bit)
        • 8th Generation
          • Fusion for PIC v8
          • EasyPIC PRO v8
          • EasyPIC PRO v8 over USB-C
          • EasyPIC v8
          • EasyPIC v8 over USB-C
          • UNI-DS v8
          • UNI-DS v8 over USB-C
        • 7th Generation
          • EasyPIC PRO v7a
          • PICPLC16 v7a
          • EasyPIC v7a
          • EasyPIC PRO v7
          • EasyPIC v7
        • 6th Generation
          • PICPLC16 v6
      • dsPIC/PIC24 (16-bit)
        • 8th Generation
          • EasyPIC v8 PIC24/dsPIC33
          • EasyPIC v8 for dsPIC30
          • EasyPIC v8 for dsPIC30 over USB-C
          • Fusion for PIC v8
          • UNI-DS v8
          • UNI-DS v8 over USB-C
        • 7th Generation
          • EasyPIC Fusion v7
          • EasyPIC v7 for dsPIC30
        • 6th Generation
          • Easy24-33 v6
      • PIC32 (32-bit)
        • 8th Generation
          • Fusion for PIC32
          • Fusion for PIC32 over USB-C
          • Fusion for PIC v8
          • UNI-DS v8
          • UNI-DS v8 over USB-C
        • 7th Generation
          • EasyPIC Fusion v7
      • ARM (32-bit)
        • 8th Generation
          • Fusion for ARM v8
          • Fusion for ARM v8 over USB-C
          • Fusion for STM32 v8
          • Fusion for STM32 over USB-C
          • Fusion for KINETIS v8
          • Fusion for Kinetis v8 over USB-C
          • Fusion for TIVA v8
          • Fusion for TIVA v8 over USB-C
          • UNI-DS v8
          • UNI-DS v8 over USB-C
        • 7th Generation
          • EasyMx PRO v7a STM32
          • EasyMx PRO v7 STM32
          • EasyMx PRO v7 Tiva
      • AVR (8-bit)
        • 8th Generation
          • EasyAVR PRO v8
          • EasyAVR PRO v8 over USB-C
          • UNI-DS v8
          • UNI-DS v8 over USB-C
        • 7th Generation
          • EasyAVR v7
        • 6th Generation
          • AVRPLC16 v6
      • 8051 (8-bit)
        • 7th generation
          • BIG8051
        • 6th Generation
          • Easy8051 v6
      • PSoC (8-bit)
        • 6th Generation
          • UNI-DS6 Development System
      • RISC-V (32bit)
        • 8th Generation
          • UNI-DS v8
          • UNI-DS v8 over USB-C
      • Universal Boards
        • 8th Generation
          • UNI-DS v8
          • UNI-DS v8 over USB-C
          • Fusion for PIC v8
          • Fusion for ARM v8
        • 7th Generation
          • EasyPIC Fusion v7
        • 6th Generation
          • UNI-DS6
          • mikroBoard for PIC 80-pin
          • mikroBoard for AVR
          • mikroBoard for dsPIC
          • mikroBoard for PSoC
          • mikroBoard for 8051
          • mikroBoard for PIC 40-pin
          • mikroBoard for ARM
          • mikroBoard for ARM 144-pin
      • IoT - Wearable
        • Hexiwear
          • Hexiwear
          • Hexiwear Power User Pack
          • Hexiwear Docking Station
          • Hexiwear Battery Pack
          • Hexiwear Color Pack
          • Hexiwear Workstation
      • Analog Boards
        • 7th Generation
          • Analog System Lab Kit PRO
    • Starter Boards
      • PIC (8-bit)
        • Clicker
          • PIC clicker
        • Clicker 2
          • Clicker 2 for PIC18FJ
          • Clicker 2 for PIC18FK
        • Clicker 4
          • UNI Clicker
        • Ready
          • Ready for PIC Board
          • Ready for PIC (DIP28)
          • PIC-Ready2 Board
          • MMC Ready Board
        • StartUSB
          • StartUSB for PIC
      • dsPIC/PIC24 (16-bit)
        • Clicker 2
          • Clicker 2 for PIC24
          • Clicker 2 for dsPIC33
        • Clicker 4
          • UNI Clicker
        • Ready
          • dsPIC-Ready1 Board
          • dsPIC-Ready2 Board
          • DsPIC-Ready3 Board
          • dsPIC-Ready4 Board
      • PIC32 (32-bit)
        • Clicker
          • PIC32MX clicker
          • 6LoWPAN Clicker
          • PIC32MZ clicker
        • Clicker 2
          • Clicker 2 for PIC32MX
          • Clicker 2 for PIC32MZ
        • Clicker 4
          • UNI Clicker
        • MINI
          • MINI-32 Board
          • MINI-32 for PIC32MZ
        • Flip&Click
          • Flip&Click PIC32MZ
      • ARM (32-bit)
        • Clicker
          • RA4M1 Clicker
          • Kinetis Clicker
          • MSP432 Clicker
          • CEC1702 clicker
          • CEC1302 Clicker
          • STM32 M4 clicker
        • Clicker 2
          • Clicker 2 for STM32
          • Clicker 2 for Kinetis
          • Clicker 2 for CEC1702
          • Clicker 2 for MSP432
          • Clicker 2 for CEC1302
          • Clicker 2 for PSoC 6
        • Clicker 4
          • Clicker 4 for TMPM4K
          • Clicker 4 for STM32
          • UNI Clicker
        • MINI
          • MINI-M4 for STM32
          • MINI-M4 For Kinetis
          • MINI-M4 for Tiva
          • MINI-M4 for Stellaris
          • MINI-M4 for MSP432
          • MINI-M0 for STM32
        • Flip&Click
          • Flip&Click SAM3X
      • AVR (8-bit)
        • Clicker 4
          • UNI Clicker
        • MINI
          • MINI-AT Board - 3.3V
          • MINI-AT Board - 5V
        • Ready
          • Ready for AVR Board
          • Ready For XMEGA
          • mikroXMEGA Board
          • AVR-Ready2 Board
        • StartUSB
          • StartUSB for AVR
      • 8051 (8-bit)
        • Clicker 4
          • UNI Clicker
        • Ready
          • 8051-Ready Board
      • FT90x (32-bit)
        • Clicker 2
          • Clicker 2 for FT90x
      • Miscellaneous
        • USB
          • USB Wizard
          • Quail
          • FlowPaw Kit
      • Universal Boards
        • Clicker 4
          • UNI Clicker
    • Prog-Debug
      • PIC (8-bit)
        • CODEGRIP
          • UNI CODEGRIP
          • UNI CODEGRIP - USB-C
          • CODEGRIP for PIC
          • CODEGRIP for PIC USB-C
        • mikroProg
          • mikroProg for PIC
      • dsPIC/PIC24 (16-bit)
        • CODEGRIP
          • UNI CODEGRIP
          • UNI CODEGRIP - USB-C
          • CODEGRIP for PIC
        • mikroProg
          • mikroProg for dsPIC
      • PIC32 (32-bit)
        • CODEGRIP
          • UNI CODEGRIP
          • UNI CODEGRIP - USB-C
          • CODEGRIP for PIC
          • CODEGRIP for PIC USB-C
        • mikroProg
          • mikroProg for PIC32
      • ARM (32-bit)
        • CODEGRIP
          • UNI CODEGRIP
          • UNI CODEGRIP USB-C
          • CODEGRIP for ARM
          • CODEGRIP for ARM USB-C
          • CODEGRIP for STM32
          • CODEGRIP for KINETIS
          • CODEGRIP for Tiva
          • CODEGRIP for Tiva USB-C
        • mikroProg
          • mikroProg for STM32
          • mikroProg for Tiva
          • mikroProg for Kinetis
          • mikroProg for CEC
          • mikroProg for MSP432
          • mikroProg for PSoC 5LP
      • AVR (8-bit)
        • CODEGRIP
          • CODEGRIP for AVR
          • CODEGRIP for AVR - USB-C
          • UNI CODEGRIP
          • UNI CODEGRIP - USB-C
        • mikroProg
          • mikroProg for AVR
      • 8051 (8-bit)
        • mikroProg
          • mikroProg for 8051
      • FT90x (32-bit)
        • mikroProg
          • mikroProg for FT90x
    • Smart Displays
      • 2.8"
        • ARM (32-bit)
        • AVR (8-bit)
        • dsPIC/PIC24 (16-bit)
        • PIC (8-bit)
        • PIC32 (32-bit)
      • 3.5"
        • ARM (32-bit)
        • FT90x (32-bit)
        • PIC (8-bit)
        • PIC32 (32-bit)
      • 4.3"
        • ARM (32-bit)
        • FT90x (32-bit)
        • PIC (8-bit)
        • PIC32 (32-bit)
      • 5"
        • ARM (32-bit)
        • FT90x (32-bit)
        • PIC32 (32-bit)
      • 7"
        • ARM (32-bit)
        • FT90x (32-bit)
    • MCU Cards
      • PIC (8-bit)
        • 8th Generation
        • 7th Generation
        • 6th Generation
      • dsPIC/PIC24 (16-bit)
        • 8th Generation
        • 7th Generation
        • 6th Generation
      • PIC32 (32-bit)
        • 8th Generation
        • 7th Generation
      • ARM (32-bit)
        • 8th Generation
        • 7th Generation
      • AVR (8-bit)
        • 8th Generation
      • RISC-V (32bit)
        • 8th Generation
    • Accessories
      • TFT Displays
      • LCD Displays
      • LED Displays
      • E-Paper Displays
      • Sensors
      • Headers and Connectors
      • Wire Jumpers and Cables
      • Antennas
      • Batteries
      • RFID/NFC
      • Proto
      • Motors
      • Storage
      • Power
      • Adapters
      • Interface
      • Input/Output
      • Miscellaneous
      • FANware
      • MCUs
      • Books
    • Kits
      • PIC
        • mikroLab
          • PIC M
          • PIC L
          • PIC 18FK
          • PIC XL
          • PIC 18FJ
        • EasyStart
          • PIC EasyStart
        • TFT Designer
          • PIC 18FJ
        • TFT Developer
          • PIC 18FJ
        • GLCD Designer
          • GLCD Designer
        • GLCD Developer
          • GLCD Developer
      • ARM
        • mikroLab Kits
          • mikroLAB for STM32
          • mikroLAB for Tiva
        • EasyStart Kits
          • EasyStart Kit - STM32
          • Easy Start Kit - Tiva
        • TFT Designer Kits
          • TFT 3" - TIVA
          • TFT 4" - STM32F4
          • TFT 5" - TIVA
          • TFT 7" - STM32F4
          • TFT 3" - STM32 M3
          • TFT 3" - STM32 M4
        • TFT Developer Kits
          • TFT 3" - TIVA
          • TFT 3" - STM32F3
          • TFT 3" - STM32F4
        • TFT Professional Kits
          • TFT 5 Pro Kit - TIVA
          • TFT 7 Pro Kit - STM32F4
          • TFT Plus Pro Kit - STM32F4
      • PIC32
        • mikroLab Kits
          • mikroLAB for PIC32
        • EasyStart Kits
          • EasyStart Kit - PIC32MX4
          • EasyStart Kit - PIC32MX7
        • TFT Designer Kits
          • TFT 3" - PIC32MX4
          • TFT 4" - PIC32MX7
        • TFT Developer Kits
          • TFT 3" - PIC32MX4
        • Home Automation
          • AWS Home
      • dsPIC/PIC24
        • mikroLab Kits
          • mikroLAB for dsPIC
          • mikroLAB for dsPIC L
          • mikroLAB for dsPIC XL
        • EasyStart Kits
          • EasyStart Kit - dsPIC33FJ
          • EasyStart Kit - dsPIC33EP
          • EasyStart Kit - PIC24EP
          • Easy Start Kit - dsPIC30
        • TFT Designer Kits
          • TFT 3" - dsPIC33FJ
          • TFT 3" - dsPIC33EP
          • TFT 3" - PIC24EP
          • TFT 3" - PIC24FJ
        • TFT Developer Kits
          • TFT 3" - dsPIC33FJ
          • TFT 3" - PIC24FJ
          • TFT 3" - PIC24EP
          • TFT 3" - dsPIC33EP
      • AVR
        • mikroLab Kits
          • mikroLAB for AVR
          • mikroLAB for AVR L
          • mikroLAB for AVR XL
        • EasyStart Kits
          • Easy Start Kit - AVR
        • TFT Designer Kits
          • TFT Designer kit - XMEGA
        • TFT Developer Kits
          • TFT Developer kit - XMEGA
      • 8051
        • mikroLab Kits
          • mikroLAB for 8051 L
          • mikroLAB for 8051
        • EasyStart Kits
          • Easy Start Kit - 8051
  • Shop
  • Applications
  • Support
    • Helpdesk
    • Contact us
    • Forum
    • LibStock
    • Learn
    • Let's make
    • Books
  • Services
    • Planet Debug
    • Design Service
    • Product Customization
    • Contract Manufacturing
    • Premium Technical Support
  • News
  • My profile
  • Privacy settings
  • Activity
  • Sign out

Your shoppingcart is empty.
Continue shopping.

MikroElektronika white logo
  • Products
    • click boards icon Click Boards
      • Wireless Connectivity
        • GPS/GNSS
        • GSM/LTE
        • LTE IoT
        • BT/BLE
        • WiFi
        • RFID/NFC
        • GSM+GPS
        • 6LoWPAN
        • ZigBee
        • UWB
        • SigFox
        • Sub-1 GHz Transceievers
        • 2.4 GHz Trancevers
        • LoRa
      • Sensors
        • Biometrics
        • Gas
        • Magnetic
        • Motion
        • Optical
        • Pressure
        • Proximity
        • Temperature & humidity
        • Current sensor
        • Miscellaneous
        • Environmental
        • Force
        • Inductance
        • RF meter
        • Click Shields
        • Click Bundles
      • Interface
        • Adapter
        • CAN
        • Port expander
        • RS485
        • USB
        • 1-Wire
        • RS232
        • Ethernet
        • LIN
        • PWM
        • Current
        • DALI
        • I2C
        • Fiber optics
        • SPI
        • DMX
        • CXPI
        • Click Shields
        • Click Bundles
      • Display & LED
        • LED Drivers
        • LED Matrix
        • LED Segment
        • OLED
        • LCD
        • Click Shields
        • Click Bundles
      • Miscellaneous
        • Relay
        • Optocoupler
        • ID
        • Proto
        • Encryption
        • Click Shields
        • Click Bundles
      • Mixed Signal
        • ADC
        • Measurements
        • DAC
        • Digital potentiometer
        • ADC-DAC
        • Click Shields
        • Click Bundles
      • Storage
        • EEPROM
        • FLASH
        • FRAM
        • microSD
        • MRAM
        • SRAM
        • EERAM
        • ReRAM
        • DRAM
        • Click Shields
        • Click Bundles
      • Motor Control
        • Brushed
        • Brushless
        • Servo
        • Stepper
        • Click Shields
        • Click Bundles
      • Audio & Voice
        • Amplifier
        • Microphone
        • Speakers
        • Signal Processing
        • Speech recognition
        • FM
        • MP3
        • Click Shields
        • Click Bundles
      • HMI
        • Capacitive
        • Pushbutton/Switches
        • Potentiometers
        • Rotary encoder
        • Haptic
        • Fingerprint
        • Click Shields
        • Click Bundles
      • Clock & Timing
        • RTC
        • Clock generator
        • Click Shields
        • Click Bundles
      • Power Management
        • Battery charger
        • Boost
        • Buck
        • Linear
        • Buck-Boost
        • Wireless Charging
        • Power Switch
        • USB-C PD
        • Click Shields
        • Click Bundles
      • Click Bundles
      • Click Shields
    • necto icon NECTO
      • NECTO Studio
    • compilers icon Compilers
      • PIC
        • C
          • NECTO Studio
          • mikroC PRO for PIC
        • Basic
          • mikroBasic PRO for PIC
        • Pascal
          • mikroPascal PRO for PIC
        • Additional Software
          • CODEGRIP WiFi license
          • CODEGRIP SSL license
          • Visual TFT
          • Visual TFT AI
          • Visual GLCD
          • Package Manager
          • mikroBootloader
          • CAN calculator
          • GLCD Font Creator
          • Timer Calculator
          • MikroPlot
      • dsPIC/PIC24
        • C
          • NECTO Studio
          • mikroC PRO for dsPIC
        • Basic
          • mikroBasic PRO for dsPIC
        • Pascal
          • mikroPascal PRO for dsPIC
        • Additional Software
          • CODEGRIP WiFi license
          • CODEGRIP SSL license
          • Visual TFT
          • Visual GLCD
          • Package Manager
          • mikroBootloader
          • CAN calculator
          • GLCD Font Creator
          • Timer Calculator
          • MikroPlot
      • PIC32
        • C
          • NECTO Studio
          • mikroC PRO for PIC32
        • Basic
          • mikroBasic PRO for PIC32
        • Pascal
          • mikroPascal PRO for PIC32
        • Additional Software
          • CODEGRIP WiFi license
          • CODEGRIP SSL license
          • Visual TFT
          • Visual GLCD
          • Package Manager
          • mikroBootloader
          • CAN calculator
          • GLCD Font Creator
          • Timer Calculator
          • MikroPlot
      • ARM
        • C
          • NECTO Studio
          • mikroC PRO for ARM
        • Basic
          • mikroBasic PRO for ARM
        • Pascal
          • mikroPascal PRO for ARM
        • Additional Software
          • CODEGRIP WiFi license
          • CODEGRIP SSL license
          • Visual TFT
          • Visual TFT AI
          • Visual GLCD
          • Package Manager
          • mikroBootloader
          • CAN calculator
          • GLCD Font Creator
          • Timer Calculator
          • MikroPlot
      • AVR
        • C
          • NECTO Studio
          • mikroC PRO for AVR
        • Basic
          • mikroBasic PRO for AVR
        • Pascal
          • mikroPascal PRO for AVR
        • Additional Software
          • CODEGRIP WiFi license
          • CODEGRIP SSL license
          • Visual TFT
          • Visual GLCD
          • Package Manager
          • mikroBootloader
          • CAN calculator
          • GLCD Font Creator
          • Timer Calculator
          • MikroPlot
      • FT90x
        • C
          • mikroC PRO for FT90x
        • Basic
          • mikroBasic PRO for FT90x
        • Pascal
          • mikroPascal PRO for FT90x
        • Additional Software
          • CODEGRIP WiFi license
          • CODEGRIP SSL license
          • Visual TFT
          • Visual GLCD
          • Package Manager
          • mikroBootloader
          • CAN calculator
          • GLCD Font Creator
          • Timer Calculator
          • MikroPlot
      • 8051
        • C
          • mikroC PRO for 8051
        • Basic
          • mikroBasic PRO for 8051
        • Pascal
          • mikroPascal PRO for 8051
        • Additional Software
          • CODEGRIP WiFi license
          • CODEGRIP SSL license
          • Visual TFT
          • Visual GLCD
          • Package Manager
          • mikroBootloader
          • CAN calculator
          • GLCD Font Creator
          • Timer Calculator
          • MikroPlot
    • dev boards icon Dev Boards
      • PIC (8-bit)
        • 8th Generation
          • Fusion for PIC v8
          • EasyPIC PRO v8
          • EasyPIC PRO v8 over USB-C
          • EasyPIC v8
          • EasyPIC v8 over USB-C
          • UNI-DS v8
          • UNI-DS v8 over USB-C
        • 7th Generation
          • EasyPIC PRO v7a
          • PICPLC16 v7a
          • EasyPIC v7a
          • EasyPIC PRO v7
          • EasyPIC v7
        • 6th Generation
          • PICPLC16 v6
      • dsPIC/PIC24 (16-bit)
        • 8th Generation
          • EasyPIC v8 PIC24/dsPIC33
          • EasyPIC v8 for dsPIC30
          • EasyPIC v8 for dsPIC30 over USB-C
          • Fusion for PIC v8
          • UNI-DS v8
          • UNI-DS v8 over USB-C
        • 7th Generation
          • EasyPIC Fusion v7
          • EasyPIC v7 for dsPIC30
        • 6th Generation
          • Easy24-33 v6
      • PIC32 (32-bit)
        • 8th Generation
          • Fusion for PIC32
          • Fusion for PIC32 over USB-C
          • Fusion for PIC v8
          • UNI-DS v8
          • UNI-DS v8 over USB-C
        • 7th Generation
          • EasyPIC Fusion v7
      • ARM (32-bit)
        • 8th Generation
          • Fusion for ARM v8
          • Fusion for ARM v8 over USB-C
          • Fusion for STM32 v8
          • Fusion for STM32 over USB-C
          • Fusion for KINETIS v8
          • Fusion for Kinetis v8 over USB-C
          • Fusion for TIVA v8
          • Fusion for TIVA v8 over USB-C
          • UNI-DS v8
          • UNI-DS v8 over USB-C
        • 7th Generation
          • EasyMx PRO v7a STM32
          • EasyMx PRO v7 STM32
          • EasyMx PRO v7 Tiva
      • AVR (8-bit)
        • 8th Generation
          • EasyAVR PRO v8
          • EasyAVR PRO v8 over USB-C
          • UNI-DS v8
          • UNI-DS v8 over USB-C
        • 7th Generation
          • EasyAVR v7
        • 6th Generation
          • AVRPLC16 v6
      • 8051 (8-bit)
        • 7th generation
          • BIG8051
        • 6th Generation
          • Easy8051 v6
      • PSoC (8-bit)
        • 6th Generation
          • UNI-DS6 Development System
      • RISC-V (32bit)
        • 8th Generation
          • UNI-DS v8
          • UNI-DS v8 over USB-C
      • Universal Boards
        • 8th Generation
          • UNI-DS v8
          • UNI-DS v8 over USB-C
          • Fusion for PIC v8
          • Fusion for ARM v8
        • 7th Generation
          • EasyPIC Fusion v7
        • 6th Generation
          • UNI-DS6
          • mikroBoard for PIC 80-pin
          • mikroBoard for AVR
          • mikroBoard for dsPIC
          • mikroBoard for PSoC
          • mikroBoard for 8051
          • mikroBoard for PIC 40-pin
          • mikroBoard for ARM
          • mikroBoard for ARM 144-pin
      • IoT - Wearable
        • Hexiwear
          • Hexiwear
          • Hexiwear Power User Pack
          • Hexiwear Docking Station
          • Hexiwear Battery Pack
          • Hexiwear Color Pack
          • Hexiwear Workstation
      • Analog Boards
        • 7th Generation
          • Analog System Lab Kit PRO
    • starter boards icon Starter Boards
      • PIC (8-bit)
        • Clicker
          • PIC clicker
        • Clicker 2
          • Clicker 2 for PIC18FJ
          • Clicker 2 for PIC18FK
        • Clicker 4
          • UNI Clicker
        • Ready
          • Ready for PIC Board
          • Ready for PIC (DIP28)
          • PIC-Ready2 Board
          • MMC Ready Board
        • StartUSB
          • StartUSB for PIC
      • dsPIC/PIC24 (16-bit)
        • Clicker 2
          • Clicker 2 for PIC24
          • Clicker 2 for dsPIC33
        • Clicker 4
          • UNI Clicker
        • Ready
          • dsPIC-Ready1 Board
          • dsPIC-Ready2 Board
          • DsPIC-Ready3 Board
          • dsPIC-Ready4 Board
      • PIC32 (32-bit)
        • Clicker
          • PIC32MX clicker
          • 6LoWPAN Clicker
          • PIC32MZ clicker
        • Clicker 2
          • Clicker 2 for PIC32MX
          • Clicker 2 for PIC32MZ
        • Clicker 4
          • UNI Clicker
        • MINI
          • MINI-32 Board
          • MINI-32 for PIC32MZ
        • Flip&Click
          • Flip&Click PIC32MZ
      • ARM (32-bit)
        • Clicker
          • RA4M1 Clicker
          • Kinetis Clicker
          • MSP432 Clicker
          • CEC1702 clicker
          • CEC1302 Clicker
          • STM32 M4 clicker
        • Clicker 2
          • Clicker 2 for STM32
          • Clicker 2 for Kinetis
          • Clicker 2 for CEC1702
          • Clicker 2 for MSP432
          • Clicker 2 for CEC1302
          • Clicker 2 for PSoC 6
        • Clicker 4
          • Clicker 4 for TMPM4K
          • Clicker 4 for STM32
          • UNI Clicker
        • MINI
          • MINI-M4 for STM32
          • MINI-M4 For Kinetis
          • MINI-M4 for Tiva
          • MINI-M4 for Stellaris
          • MINI-M4 for MSP432
          • MINI-M0 for STM32
        • Flip&Click
          • Flip&Click SAM3X
      • AVR (8-bit)
        • Clicker 4
          • UNI Clicker
        • MINI
          • MINI-AT Board - 3.3V
          • MINI-AT Board - 5V
        • Ready
          • Ready for AVR Board
          • Ready For XMEGA
          • mikroXMEGA Board
          • AVR-Ready2 Board
        • StartUSB
          • StartUSB for AVR
      • 8051 (8-bit)
        • Clicker 4
          • UNI Clicker
        • Ready
          • 8051-Ready Board
      • FT90x (32-bit)
        • Clicker 2
          • Clicker 2 for FT90x
      • Miscellaneous
        • USB
          • USB Wizard
          • Quail
          • FlowPaw Kit
      • Universal Boards
        • Clicker 4
          • UNI Clicker
    • prog-debug icon Prog-Debug
      • PIC (8-bit)
        • CODEGRIP
          • UNI CODEGRIP
          • UNI CODEGRIP - USB-C
          • CODEGRIP for PIC
          • CODEGRIP for PIC USB-C
        • mikroProg
          • mikroProg for PIC
      • dsPIC/PIC24 (16-bit)
        • CODEGRIP
          • UNI CODEGRIP
          • UNI CODEGRIP - USB-C
          • CODEGRIP for PIC
        • mikroProg
          • mikroProg for dsPIC
      • PIC32 (32-bit)
        • CODEGRIP
          • UNI CODEGRIP
          • UNI CODEGRIP - USB-C
          • CODEGRIP for PIC
          • CODEGRIP for PIC USB-C
        • mikroProg
          • mikroProg for PIC32
      • ARM (32-bit)
        • CODEGRIP
          • UNI CODEGRIP
          • UNI CODEGRIP USB-C
          • CODEGRIP for ARM
          • CODEGRIP for ARM USB-C
          • CODEGRIP for STM32
          • CODEGRIP for KINETIS
          • CODEGRIP for Tiva
          • CODEGRIP for Tiva USB-C
        • mikroProg
          • mikroProg for STM32
          • mikroProg for Tiva
          • mikroProg for Kinetis
          • mikroProg for CEC
          • mikroProg for MSP432
          • mikroProg for PSoC 5LP
      • AVR (8-bit)
        • CODEGRIP
          • CODEGRIP for AVR
          • CODEGRIP for AVR - USB-C
          • UNI CODEGRIP
          • UNI CODEGRIP - USB-C
        • mikroProg
          • mikroProg for AVR
      • 8051 (8-bit)
        • mikroProg
          • mikroProg for 8051
      • FT90x (32-bit)
        • mikroProg
          • mikroProg for FT90x
    • smart displays icon Smart Displays
      • 2.8"
        • ARM (32-bit)
        • AVR (8-bit)
        • dsPIC/PIC24 (16-bit)
        • PIC (8-bit)
        • PIC32 (32-bit)
      • 3.5"
        • ARM (32-bit)
        • FT90x (32-bit)
        • PIC (8-bit)
        • PIC32 (32-bit)
      • 4.3"
        • ARM (32-bit)
        • FT90x (32-bit)
        • PIC (8-bit)
        • PIC32 (32-bit)
      • 5"
        • ARM (32-bit)
        • FT90x (32-bit)
        • PIC32 (32-bit)
      • 7"
        • ARM (32-bit)
        • FT90x (32-bit)
    • mcu cards icon MCU Cards
      • PIC (8-bit)
        • 8th Generation
        • 7th Generation
        • 6th Generation
      • dsPIC/PIC24 (16-bit)
        • 8th Generation
        • 7th Generation
        • 6th Generation
      • PIC32 (32-bit)
        • 8th Generation
        • 7th Generation
      • ARM (32-bit)
        • 8th Generation
        • 7th Generation
      • AVR (8-bit)
        • 8th Generation
      • RISC-V (32bit)
        • 8th Generation
    • accessories icon Accessories
      • TFT Displays
      • LCD Displays
      • LED Displays
      • E-Paper Displays
      • Sensors
      • Headers and Connectors
      • Wire Jumpers and Cables
      • Antennas
      • Batteries
      • RFID/NFC
      • Proto
      • Motors
      • Storage
      • Power
      • Adapters
      • Interface
      • Input/Output
      • Miscellaneous
      • FANware
      • MCUs
      • Books
    • kits icon Kits
      • PIC
        • mikroLab
          • PIC M
          • PIC L
          • PIC 18FK
          • PIC XL
          • PIC 18FJ
        • EasyStart
          • PIC EasyStart
        • TFT Designer
          • PIC 18FJ
        • TFT Developer
          • PIC 18FJ
        • GLCD Designer
          • GLCD Designer
        • GLCD Developer
          • GLCD Developer
      • ARM
        • mikroLab Kits
          • mikroLAB for STM32
          • mikroLAB for Tiva
        • EasyStart Kits
          • EasyStart Kit - STM32
          • Easy Start Kit - Tiva
        • TFT Designer Kits
          • TFT 3" - TIVA
          • TFT 4" - STM32F4
          • TFT 5" - TIVA
          • TFT 7" - STM32F4
          • TFT 3" - STM32 M3
          • TFT 3" - STM32 M4
        • TFT Developer Kits
          • TFT 3" - TIVA
          • TFT 3" - STM32F3
          • TFT 3" - STM32F4
        • TFT Professional Kits
          • TFT 5 Pro Kit - TIVA
          • TFT 7 Pro Kit - STM32F4
          • TFT Plus Pro Kit - STM32F4
      • PIC32
        • mikroLab Kits
          • mikroLAB for PIC32
        • EasyStart Kits
          • EasyStart Kit - PIC32MX4
          • EasyStart Kit - PIC32MX7
        • TFT Designer Kits
          • TFT 3" - PIC32MX4
          • TFT 4" - PIC32MX7
        • TFT Developer Kits
          • TFT 3" - PIC32MX4
        • Home Automation
          • AWS Home
      • dsPIC/PIC24
        • mikroLab Kits
          • mikroLAB for dsPIC
          • mikroLAB for dsPIC L
          • mikroLAB for dsPIC XL
        • EasyStart Kits
          • EasyStart Kit - dsPIC33FJ
          • EasyStart Kit - dsPIC33EP
          • EasyStart Kit - PIC24EP
          • Easy Start Kit - dsPIC30
        • TFT Designer Kits
          • TFT 3" - dsPIC33FJ
          • TFT 3" - dsPIC33EP
          • TFT 3" - PIC24EP
          • TFT 3" - PIC24FJ
        • TFT Developer Kits
          • TFT 3" - dsPIC33FJ
          • TFT 3" - PIC24FJ
          • TFT 3" - PIC24EP
          • TFT 3" - dsPIC33EP
      • AVR
        • mikroLab Kits
          • mikroLAB for AVR
          • mikroLAB for AVR L
          • mikroLAB for AVR XL
        • EasyStart Kits
          • Easy Start Kit - AVR
        • TFT Designer Kits
          • TFT Designer kit - XMEGA
        • TFT Developer Kits
          • TFT Developer kit - XMEGA
      • 8051
        • mikroLab Kits
          • mikroLAB for 8051 L
          • mikroLAB for 8051
        • EasyStart Kits
          • Easy Start Kit - 8051
  • Shop
  • Applications
  • Support
    • Helpdesk
    • Contact us
    • Forum
    • LibStock
    • Learn
    • Let's make
    • Books
  • Services
    • Planet Debug
    • Design Service
    • Product Customization
    • Contract Manufacturing
    • Premium Technical Support
  • News
  • Price :

    More info
Reset filter
  • 0
Authentication
Account

Create account

Forgot your password?

Your cart is empty !
View cart ( )
  1. Home
  2. ebooks
  3. Programming dsPIC Microcontrollers in PASCAL
  4. example-1-menu
MikroElektronika books

14.2.1 Example 1 – Menu

The example shows a method of formation of a menu with options on an LCD in 4-bit mode. Setting of bit 1 on port F means go to the next option, whereas setting of bit 0 on port F means go to the previous option. The rate of transition to the next/previous option is limited so the maximum of 4 transitions per second is allowed.

{ This project is designed to work with PIC P30F6014A. It has been tested
  on dsPICPRO3 development system with 10.0 MHz crystal and 8xPLL.
  It should work with any other crystal.
  Note: the maximum operating frequency for dsPIC is 120MHz.
  With minor adjustments, this example should work with any other dsPIC MCU }

program MenuTest1;

var
  menu_index : byte;
  menu : array[1..5] of String[6]; absolute $1880;
                                   // Directive absolute specifies
                                   //   the starting address in RAM for a variable.

begin
  ADPCFG := $FFFF;                 // Configure PORTB as digital
  TRISF  := $FFFF;                 // Configure PORTF as input (menu control)

  menu_index := 1;                 // Init menu_item[1]
  menu[1] := 'First' ;             // Menu items
  menu[2] := 'Second';
  menu[3] := 'Third' ;
  menu[4] := 'Fourth';
  menu[5] := 'Fifth' ;

  Lcd_Init_DsPicPro3();            // Init LCD in 4-bit mode for dsPICPRO3 board
  // Note: GLCD/LCD Setup routines are in the setup library files located in the Uses folder
  // These routines will be moved into AutoComplete in the future.
  Lcd_Cmd(LCD_CURSOR_OFF);
  Lcd_Cmd(LCD_FIRST_ROW);
  Lcd_Out(1,1,'Menu :');

  Lcd_Out(1,8,menu[menu_index]);   // Show menu element on LCD

  while true do                           // endless loop
    begin

      if PORTF.1 = 1 then                 // Detect logical one on RF1 pin => MENU UP
        begin
          menu_index := menu_index+1;     // Next index in menu
          if menu_index>5 then
            menu_index := 1;              // Circular menu
          Lcd_Out(1,8, '      ');         // Clear text
          Lcd_Out(1,8,menu[menu_index]);  // Show menu element on LCD
          Delay_ms(250);                  // No more than 4 changes per sec
        end;
        
      if PORTF.0 = 1 then                 // Detect logical one on RF0 pin => MENU DOWN
        begin
          menu_index := menu_index-1;     // Previous index in menu
          if menu_index<1 then
            menu_index := 5;              // Circular menu
          Lcd_Out(1,8, '      ');         // Clear text
          Lcd_Out(1,8,menu[menu_index]);  // Show menu element on LCD
          Delay_ms(250);                  // No more than 4 changes per sec
        end;
        
    end;
end.

14.2.2 Example 2 – DTMFout

The example shows a method of generation of DTMF signal. The following assumptions have been adopted:
  • the level of the signal of the higher frequency is 0 to 3dB higher compared to the signal of the lower frequency,
  • transmission of one character lasts 90ms, the pause between two characters is 200ms,
  • the sampling frequency is 20kHz,
  • input data are sent to the microcontroller via the UART module at the rate of 9600 bps,
The algorithm of generating the signal is the following. On the basis of the calculated frequencies the square signal is sent first. Then, this signal is filtered by a low pass IIR filter of the third order (4 coefficients). The output signal specifications are:
  • frequency deviation is less than 1.5%,
  • the level of all harmonics is 20dB below the useful signal.
The algorithm is shown in Fig. 14-1. pic-microcontrollers-programming-dspic-in-pascal-chapter-14-image-1
Fig. 14-1 Algorithm for generation of DTMF signal
Digital filter is lowpass Chebyshev type 1 filter. Wp is 1700 Hz, Ap is 3dB, sampling frequency is 20kHz. Third order fiter can meet the requirements: a) level of all harmonics is 20dB below the useful signal: Harmonic nearest to the useful signal is 3xf1. f1 is lowest frequency of useful signal, f1=697 Hz. Fourier series of square wave signal implies that amplitude of 3xf1=2091 Hz harmonic is 1/3 of f1signal amplitude. So we already have -9.5dB. In IIR frequency window we can see that 3xf1 frequency is 12dB weaker than useful signal. The most critical harmonic 3xf1 is -9.5dB -12dB = -21.5dB weaker than useful signal – so this requirement is fullfilled. b) the level of the signal of the higher frequency is 0 to 3dB higher compared to the signal of the lower frequency: IIR frequency window also shows that low frequencies 697-941Hz filter attenuation is in -3dB to -2.8dB range and low frequencies 1209-1633Hz filter attenuation is in –1.8dB to 0dB range. So any higher frequency signal is 1 to 3dB stronger than any lower frequency signal. pic-microcontrollers-programming-dspic-in-pascal-chapter-14-image-8
Filter Designer Tool Window 1.
pic-microcontrollers-programming-dspic-in-pascal-chapter-14-image-9
Filter Designer Tool Window 2.
Fig. 14-2 shows the generated signal. The signals of the lower and higher frequencies are added, with the higher frequency signal 3dB above the lower frequency signal. pic-microcontrollers-programming-dspic-in-pascal-chapter-14-image-2
Fig. 14-2 Generated signal.
pic-microcontrollers-programming-dspic-in-pascal-chapter-14-image-3
Fig. 14-3 Spectrum of the signal of Fig. 14-2
pic-microcontrollers-programming-dspic-in-pascal-chapter-14-image-4
Fig. 14-4 Filtered signal
pic-microcontrollers-programming-dspic-in-pascal-chapter-14-image-5
Fig. 14-5 Spectrum of the signal after filtering (output signal)
For generation of the filter coefficients use the Filter Designer Tool which is a constituent part of mikroPascal for dsPIC. The program for generation of the described signal is as follows:
{ This project is designed to work with PIC P30F6014A. It has been tested
  on dsPICPRO3 board with 10.0 MHz crystal and 8xPLL. It should work with any
  other crystal. Note: the maximum operating frequency for dsPIC is 120MHz.
  With minor adjustments, this example should work with any other dsPIC MCU

 On-board DAC module
 Enable SPI connection to DAC on SW4 and DAC's Load(LD) and Chip Select(CS) pins on SW3.
 }

program DTMFout;

// *** Filter Designer Tool outputs *** //
const
  BUFFER_SIZE  = 8;
  FILTER_ORDER = 3;
  COEFF_B : array[FILTER_ORDER+1] of Integer=(0x21F3, 0x65DA, 0x65DA, 0x21F3);
  COEFF_A : array[FILTER_ORDER+1] of Integer=(0x2000, 0xB06D, 0x47EC, 0xE8B6);
  SCALE_B =  6;
  SCALE_A = -2;

// *** DAC pinout *** //
const  LOAD_PIN = 2;                         // DAC load pin
const  CS_PIN   = 1;                         // DAC CS pin

var
  THalf_Low, THalf_High : word;              // half-periods of low and high-frequency 
                                             // square signals
  char2send : byte;                          // char recived from UART
  sample, sending_ch_cnt : word;             // digital signal sample, sending char counter
  us_cntL, us_cntH : word;                   // low and high-frequency square 
                                             // signal microseconds counters
  input  : array[BUFFER_SIZE] of integer;    // filter input signal (two square signals)
  output : array[BUFFER_SIZE] of integer;    // filtered signal
  sample_index       : word;                 // index of current sample
  voltageL, voltageH : integer;              // square signals amplitudes

procedure InitMain();
begin
  LATC.CS_PIN    := 1;                       // set DAC CS to inactive
  LATC.LOAD_PIN  := 0;                       // set DAC LOAD to inactive
  TRISC.LOAD_PIN := 0;                       // configure DAC LOAD pin as output
  TRISC.CS_PIN   := 0;                       // configure DAC CS pin as output

  // Initialize SPI2 module
  Spi2_Init_Advanced(_SPI_MASTER, _SPI_16_BIT, _SPI_PRESCALE_SEC_1, _SPI_PRESCALE_PRI_1,
                     _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH,
                     _SPI_ACTIVE_2_IDLE);

  Uart1_Init(9600);                          // Initialize UART1 module
end;

procedure DAC_Output(valueDAC : word) ;
begin
  LATC.CS_PIN := 0;                          // CS enable for DAC
  // filter output range is 16-bit number; DAC input range is 12-bit number
  valueDAC := valueDAC shr 4;
  // now both numbers are 12-bit but filter output is signed and DAC input is unsigned.
  //  Half of DAC range 4096/2=2048 is added to correct this
  valueDAC := valueDAC + 2048;
  SPI2BUF := 0x3000 or valueDAC;             // write valueDAC to DAC (0x3 is required by DAC)
  while (SPI2STAT.1 = 1) do                  // wait for SPI module to finish sending
    nop;
  LATC.CS_PIN := 1;                          // CS disable for DAC
end;

procedure SetPeriods(ch:Word);
begin
{ DTMF frequencies:

            1209 Hz     1336 Hz     1477 Hz     1633 Hz
 697 Hz       1           2           3           A
 770 Hz       4           5           6           B
 852 Hz       7           8           9           C
 941 Hz       *           0           #           D
}

  // Calculate half-periods in microseconds
  //   example: 1/697Hz = 0.001435 seconds = 1435 microseconds
  //            1435/2  = 717
  case ch of
    49: begin THalf_Low:=717; THalf_High:=414; end;  //'1'
    50: begin THalf_Low:=717; THalf_High:=374; end;  //'2'
    51: begin THalf_Low:=717; THalf_High:=339; end;  //'3'
    65: begin THalf_Low:=717; THalf_High:=306; end;  //'A'
    
    52: begin THalf_Low:=649; THalf_High:=414; end;  //'4'
    53: begin THalf_Low:=649; THalf_High:=374; end;  //'5'
    54: begin THalf_Low:=649; THalf_High:=339; end;  //'6'
    66: begin THalf_Low:=649; THalf_High:=306; end;  //'B'
    
    55: begin THalf_Low:=587; THalf_High:=414; end;  //'7'
    56: begin THalf_Low:=587; THalf_High:=374; end;  //'8'
    57: begin THalf_Low:=587; THalf_High:=339; end;  //'9'
    67: begin THalf_Low:=587; THalf_High:=306; end;  //'C'
    
    42: begin THalf_Low:=531; THalf_High:=414; end;  //'*'
    48: begin THalf_Low:=531; THalf_High:=374; end;  //'0'
    35: begin THalf_Low:=531; THalf_High:=339; end;  //'#'
    68: begin THalf_Low:=531; THalf_High:=306; end;  //'D'
  end;
end;

procedure ClearBufs();
begin
  //Clear buffers
  Vector_Set(input,  BUFFER_SIZE, 0);
  Vector_Set(output, BUFFER_SIZE, 0);
end;

procedure Timer1Int; org $1A;         // interrupt frequency is 20kHz
begin

  // calculate sample
  sample := voltageL + voltageH;      // add voltages
  input[sample_index] := sample;      // write sample to input buffer
  
  // update low-frequency square signal microseconds counter
  us_cntL := us_cntL + 50;            // since us_cntL and THalf_Low are in microseconds
                                      // and Timer1 interrupt occures every 50us
                                      // increment us_cntL by 50
  if us_cntL > THalf_Low then         // half-period exceeded, change sign
    begin
      voltageL := -voltageL;
      us_cntL  := us_cntL - THalf_Low;// subtract half-period
    end;
    
  // update high-frequency square signal microseconds counter
  us_cntH := us_cntH + 50;
  if us_cntH > THalf_High then
    begin
      voltageH := -voltageH;
      us_cntH  := us_cntH - THalf_High;
    end;
    
  //IIR(amp), filtering new sample
  sample := IIR_Radix(SCALE_B, SCALE_A, @COEFF_B, @COEFF_A, FILTER_ORDER+1, 
                      @input, BUFFER_SIZE, @output, sample_index);
  
  DAC_Output(sample);                 // send sample to digital-to-analog converter

  output[sample_index] := sample;     // write filtered sample in output buffer
  
  Inc(sample_index);                  // increment sample index, prepare for next sample
  if sample_index = BUFFER_SIZE then
    sample_index := 0;

  Dec(sending_ch_cnt);                // decrement char sending counter
                                      //   (character transmition lasts 90ms = 1800 samples)
  if sending_ch_cnt = 0 then          // if character transmition is over
    begin
      T1CON:=0;                       // turn off Timer1
      DAC_Output(0);
      Delay_ms(200);                  // pause between two characters is 200ms
    end;
    
  IFS0.3 := 0;                        // clear Timer1 interrupt flag
end;


// --- main --- //
begin

  InitMain();                         // perform initializations
  DAC_Output(0);
  sending_ch_cnt := 0;                // reset counter
  sample_index   := 0;                // initialize sample index

  // Clear interrupt flags
  IFS0 := 0;
  IFS1 := 0;
  IFS2 := 0;
  
  INTCON1 := $8000;                   // disable nested interrupts
  IEC0    := $0008;                   // enable Timer1 interrupt
  
  // Timer1 input clock is Fosc/4. Sampling frequency is 20kHz. Timer should
  // raise interrupt every 50 microseconds. PR1 = (Fosc[Hz]/4) / 20000Hz = Fosc[kHz]/(4*20)
  PR1 := Clock_kHz() div 80;
  // Note: interrupt routine execution takes ~10us

  while true do
    begin
      if (sending_ch_cnt = 0) and         // check if sending of previous character is over
         (Uart1_Data_Ready() = 1) then    // check if character arrived via UART1
        begin
          char2send := Uart1_Read_Char(); // read data from UART and store it
          SetPeriods(char2send);          // set periods for low and high-frequency 
                                          // square signals
          ClearBufs();                    // clear input and output buffers
          // digital filter computing error is smaller for signals of higher amplitudes
          // so signal amplitude should as high as possible. The highest value for
          // signed integer type is 0x7FFF but since we are adding 2 signals we must
          // divide it by 2.
          voltageH := $7FFF div 2;        // high-frequency square signal amplitude
          voltageL := $7FFF div 2;        // low-frequency square signal amplitude
          us_cntL := 0;                   // low-frequency square signal microseconds counter
          us_cntH := 0;                   // high-frequency square signal microseconds counter
          
          // start Timer T1
          sending_ch_cnt :=  1800;        // character tansmition lasts 
                                          // 90ms = 1800 samples * 50us
          T1CON          := $8000;        // enable Timer1 (TimerOn, prescaler 1:1)
        end;
    end;
    
end.

14.2.3 Example 3 – DTMFin

The example shows a method of detecting DTMF signal. The following detection algorithm has been applied. The level of input signal denoting the presence of DTMF signal is awaited. Frequency estimation over 1024 samples is performed. The sampling frequency is 20kHz. In other words, the process of estimation lasts approximately 50ms. The minimum length of one character is 65ms. The minimum pause after one character is 80ms. For this reason each estimation is followed by an 80ms pause, and then the next character is awaited. The estimate of the signal frequency can be performed by counting zero crossings, as shown in Fig. 14-6. pic-microcontrollers-programming-dspic-in-pascal-chapter-14-image-6
Fig. 14-6 DTMF signal before filtering
Before zero crossing estimation algorithm can be performed signal must be filtred to separate low frequency from high frequency. The signal is then put through a lowpass IIR filter of the 4th order having stopband corner frequency 1200Hz whereby all frequencies except the lower frequency are suppressed. By counting zero crossings of the filtered signal the estimation of the frequency of the lower frequency signal is performed. The signal is also put through a highpass IIR filter of the 4th order having stopband corner frequency 950Hz whereby all frequencies except the higher frequency are suppressed. The signal after filtering is shown in Fig. 14-7. pic-microcontrollers-programming-dspic-in-pascal-chapter-14-image-7
Fig. 14-7 DTMF signal after filtering
By counting zero crossings of the filtered signal the estimation of the frequency of the higher frequency signal is performed. After the frequencies have been obtaind, the sent character is obtained simply by comparison. For generation of the filter coefficients one can use the Filter Designer Tool which is a constituent part of mikroPascal for dsPIC. Settings of Filter Designer Tool for LowPass and HighPass filter are given below: pic-microcontrollers-programming-dspic-in-pascal-chapter-14-image-10
IIR lowpass filter settings
pic-microcontrollers-programming-dspic-in-pascal-chapter-14-image-11
IIR lowpass frequency window
pic-microcontrollers-programming-dspic-in-pascal-chapter-14-image-12
IIR highpass filter settings
pic-microcontrollers-programming-dspic-in-pascal-chapter-14-image-13
IIR highpass frequency window
Implementation of the described algorithm:
{ This project is designed to work with PIC P30F6014A. It has been tested
  on dsPICPRO3 board with 10.0 MHz crystal and 8xPLL. It should work with any
  other crystal. Note: the maximum operating frequency for dsPIC is 120MHz.
  With minor adjustments, this example should work with any other dsPIC MCU
 }

program DTMFin;

// *** DAC pinout *** //
const  LOAD_PIN = 2;                         // DAC load pin
const  CS_PIN   = 1;                         // DAC CS pin


const
// filter setup:
//     filter kind: IIR
//     filter type: lowpass filter
//     filter order: 4
//     design method: Chebyshev type II
  BUFFER_SIZE  = 8;
  FILTER_ORDER  = 4;
  BPF1_COEFF_B : array[FILTER_ORDER+1] of Integer=(0x1BD7, 0xAB5D, 0x753A, 0xAB5D, 0x1BD7);
  BPF1_COEFF_A : array[FILTER_ORDER+1] of Integer=(0x2000, 0xA1C7, 0x6C59, 0xC6EA, 0x0BDE);
  BPF1_SCALE_B       =  0;
  BPF1_SCALE_A       = -2;
// filter setup:
//     filter kind: IIR
//     filter type: Highpass filter
//     filter order: 4
//     design method: Chebyshev type II

  BPF2_COEFF_B : array[FILTER_ORDER+1] of Integer=(0x0BF7, 0xD133, 0x45AF, 0xD133, 0x0BF7);
  BPF2_COEFF_A : array[FILTER_ORDER+1] of Integer=(0x1000, 0xCA8B, 0x44B5, 0xD7E5, 0x08F3);
  BPF2_SCALE_B       = -3;
  BPF2_SCALE_A       = -3;
  
  MinLevel : integer = 18;          // min voltage offset level on ADC 
                                    // that can be detected as DTMF

var
  SignalActive : Boolean;           // indicator (if input signal exists)
  sample : Integer;                 // temp variable used for reading from ADC
  Key : Char;                       // detected character
  f:longint;                        // detected frequency
  SampleCounter : word;             // indicates the number of samples in circular buffer
  sample_index : word;              // index of next sample
  input : array[8] of Integer;      // circular buffer - raw samples (directly after ADC)
  output_f1  : array[8] of Integer; // circular buffer - samples after IIR BP filter
  output_f2  : array[8] of Integer; // circular buffer - samples after IIR BP filter

  TransitLow, TransitHigh:Word;     // counts of transitions (low, high freq)
  sgnLow, sgnHigh:Integer;          // current signs of low and high freq signal
  KeyCnt : integer;                 // number of recived DTFM and displayed on LCD


procedure Estimate;
var
  fd:Word;
begin
{ DTMF frequencies:
                1209 Hz     1336 Hz     1477 Hz     1633 Hz
      697 Hz      1           2           3           A
      770 Hz      4           5           6           B
      852 Hz      7           8           9           C
      941 Hz      *           0           #           D
}
  //calculating index of lower freq

  f := TransitLow*20000;  // f := No_Of_Transitions*Sampling_Freq [Hz]
  f := f shr 11;          // f := f div 2048 := f/2/1024 (2 transitions in each period)

  if f < 733 then
    fd:=1   //index of Low_freq = 1
  else if f < 811 then
    fd:=2   //index of Low_freq = 2
  else if f < 896 then
    fd:=3   //index of Low_freq = 3
  else
    fd:=4;  //index of Low_freq = 4

  //calculating index of higher freq
  f:=TransitHigh*20000;  // f := No_Of_Transitions*Sampling_Freq
  f:=f shr 11;           // f := f/2048 := f/2/1024 (2 transitions in each period)

  if f<1272 then
    fd:=fd+10  // encode Index of higher freq as 10
  else if f<1406 then
    fd:=fd+20  // encode Index of higher freq as 20
  else if f<1555 then
    fd:=fd+30  // encode Index of higher freq as 30
  else
    fd:=fd+40; // encode Index of higher freq as 40

  case fd of   // Reading of input char from DTMF matrix
    11: Key:='1';
    12: Key:='4';
    13: Key:='7';
    14: Key:='*';
    21: Key:='2';
    22: Key:='5';
    23: Key:='8';
    24: Key:='0';
    31: Key:='3';
    32: Key:='6';
    33: Key:='9';
    34: Key:='#';
    41: Key:='A';
    42: Key:='B';
    43: Key:='C';
    44: Key:='D';
  end;
  
  // diplay recived char on second row of LCD
  if(KeyCnt >= 16) then
    begin // if second row is full erase it and postion cursor at first column
      Lcd_Cmd(LCD_SECOND_ROW);
      Lcd_Out_CP('                ');
      Lcd_Cmd(LCD_SECOND_ROW);
      KeyCnt := 0; // reset recived DTFM signals counter
    end;
  Lcd_Chr_CP(Key); // output recived on LCD
  inc(KeyCnt);     // increment counter

end;

procedure DAC_Output(valueDAC : word) ;
begin
  LATC.CS_PIN := 0;  // CS enable for DAC
  // filter output range is 16-bit number; DAC input range is 12-bit number
  valueDAC := valueDAC shr 4;
  // now both numbers are 12-bit but filter output is signed and DAC input is unsigned.
  // Half of DAC range 4096/2=2048 is added to correct this
  valueDAC := valueDAC + 2048;
  SPI2BUF := 0x3000 or valueDAC;             // write valueDAC to DAC (0x3 is required by DAC)
  while (SPI2STAT.1 = 1) do                  // wait for SPI module to finish sending
    nop;
  LATC.CS_PIN := 1;                          // CS disable for DAC
end;

procedure InitDec();
begin                                // Estimate on 1024 samples for fast DIV
  SampleCounter := 1024;             // Init low-freq transitions counter
  TransitLow := 0;                   // Init high-freq transitions counter
  TransitHigh := 0;                  // Init input circular buffer (zero-filled)
  Vector_Set(input, 8, 0);           // Init filtered circular buffer (zero-filled)
  Vector_Set(output_f1, 8, 0);       // Init filtered circular buffer (zero-filled)
  Vector_Set(output_f2, 8, 0);       // Points on first element of circular buffer
  sample_index := 0;                 // Current sign is positive
  sgnLow:=0;                         // Current sign is positive
  sgnHigh:=0;
  DAC_Output(0);
end;

procedure ADC1Int; org $2A;
begin
  sample := ADCBUF0;                                // read input ADC signal

  if (sample > 2048+MinLevel) and not(SignalActive) then // detecting signal
    begin
      SignalActive := true;                         // activate estimation algorithm
      InitDec();                                    // initialize variables
    end;

  // since ADC is configured to get samples as intgers
  // mean value of input signal is expected to be located at
  // middle of ADC voltage range
  sample := sample shl 4;
  sample := sample-(2048 shl 4);  //expanding signal to full scale
  // now sample is ready to be filtred

  
  if SignalActive then
    begin
      input[sample_index] := sample;                // Write sample in circular buffer

      //Filter input signal (for low-freq estimation)
      sample := IIR_Radix(BPF1_SCALE_B, BPF1_SCALE_A, @BPF1_COEFF_B, @BPF1_COEFF_A,
                          FILTER_ORDER+1, @input, BUFFER_SIZE, @output_f1, sample_index);
      DAC_Output(sample);  // output filtred signal to DAC for Visual check
      output_f1[sample_index]:=sample;

      //transition_Low?
      if sample.15<>sgnLow then               // If transition trough 0
        begin
          sgnLow:=sample.15;                  // save current sign
          Inc(TransitLow);                    // Increment transition counter
        end;

      //Filter input signal (for high-freq estimation)
      sample := IIR_Radix(BPF2_SCALE_B, BPF2_SCALE_A, @BPF2_COEFF_B, @BPF2_COEFF_A,
                          FILTER_ORDER+1, @input, BUFFER_SIZE, @output_f2, sample_index);

      output_f2[sample_index]:=sample;               // Write filtered signal in buffer
      //transition_High?
      if sample.15<>sgnHigh then             // If transition
        begin
          sgnHigh:=sample.15;
          Inc(TransitHigh);                  // Increment transition counter
        end;
        
      sample_index:=(sample_index+1) and 7;  // Move pointer on next element
      dec(SampleCounter);                    // Decrement sample counter
      if SampleCounter = 0 then              // If all of 1024 samples are readed
        begin
          SignalActive:=false;               // Deactivate estimation algorithm
          Estimate();                        // Read estimated character
          DAC_Output(0);                     // set DAC output to 0
          Delay_ms(80);                      // Wait for next char
        end;
    end;
  IFS0.11 := 0;                              // clear ADC complete IF
end;

procedure Timer1Int; org $1A;
begin
  ADCON1.1  := 1; // ASAM=0 and SAMP=1 begin sampling
  ADCON1.15 := 1; // start ADC
  IFS0.3    := 0; // clear Timer1 IF
end;

begin
  KeyCnt := 0;                              // set to 0
  SignalActive := false;                    // no signal is present
  ADPCFG := $FFFF;                          // configure pins as digital
  Lcd_Init_DsPicPro3();                     // initialize LCD
  Lcd_Out(1,1,'tone is:');                  // print message at first row
  Lcd_Cmd(LCD_SECOND_ROW);                  // position cursor at second row
  LATC.CS_PIN    := 1;                      // set DAC CS to inactive
  LATC.LOAD_PIN  := 0;                      // set DAC LOAD to inactive
  TRISC.LOAD_PIN := 0;                      // configure DAC LOAD pin as output
  TRISC.CS_PIN   := 0;                      // configure DAC CS pin as output
  // Initialize SPI2 module
  Spi2_Init_Advanced(_SPI_MASTER, _SPI_16_BIT, _SPI_PRESCALE_SEC_1, _SPI_PRESCALE_PRI_1,
                     _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH,
                     _SPI_ACTIVE_2_IDLE);

  TRISB.10  := 1;          // configure RB10 pin as input
  ADPCFG    := $FBFF;      // configure RB10 pin as analog
  ADCON1    := $00E0;      // auto-convert, auto-conversion
  ADCON2    := $0000;
  ADCON3    := $021A;      // sampling time=2*Tad, minimum Tad selected
  ADCHS     := $000A;      // sample input on RB10
  ADCSSL    := 0;          // no input scan

  // clear interrupt flags
  IFS0    := 0;
  IFS1    := 0;
  IFS2    := 0;
  
  INTCON1 := $8000;      // disable nested interrupts
  INTCON2 := 0;
  IEC0    := $0808;      // enable Timer1 and ADC interrupts
  IPC0.12 := 1;          // Timer1 interrupt priority level = 1
  IPC2.13 := 1;          // ADC interrupt priority level = 2

  // Timer1 input clock is Fosc/4. Sampling frequency is 20kHz. Timer should
  // raise interrupt every 50 microseconds. PR1 = (Fosc[Hz]/4) / 20000Hz = Fosc[kHz]/(4*20)
  PR1 := Clock_kHz() div 80;
  T1CON   := $8000;    // Enable Timer1

  while true do        // Infinite loop
    nop;
end.

14.2.4 Example 4 – Acceleration sensor

This example shows a possibility of using dsPIC30F4013 or dsPIC6014A in order to realize control of the pointer of a GLCD on the basis of the signal from an acceleration sensor. In this example the use is made of an accelerometer card containing the sensor ADXL330 by Analog Devices. Besides the sensor, the card contains an operational amplifier used as a unit amplifier increasing the output current capacity of the sensor. The sensor measures the acceleration along two axes, X and Y. The offset voltage of the sensor has to be measured during the calibration procedure. From the accelerometer card, two analogue signals, for the X and Y axes, are fed to the inputs of AN8 and AN9 AD converters (pins PORTB.8 and PORTB.9). After the sampling and conversion, the measured value is presented as the shift of the pointer from the central position on the GLCD. This example is widely applicable for the realization of e.g. joysticks, simple gyroscopes, robot controls or movement detectors.
{ An example of the use of the microcontroller dsPIC30F6014A and Accel Extra Board.
  The example shows how the signal from the sensor is sampled and how the information on the
  accelerations along the X and Y axes are used for controlling the cursor on a GLCD.
  The example also covers the calibration of the sensor (determination of zeroG
  and 1G values for X and Y axes). Pin RC1 is used as user input. Pull-down PORTC and
  put button jumper in Vcc position. }

program AccelerationPointer;

// --- GLCD Messages ---
const msg1 = 'Put board to pos  ';
const msg2 = 'and press RC1';

var // Global variables
zeroG_x, zeroG_y : integer;  // zero gravity values
oneG_x,  oneG_y  : integer;  // 1G values
meas_x,  meas_y  : integer;  // measured values
box_x,   box_y   : integer;  // variables for drawing box on GLCD
positionNo : byte;           // variable used in text messages
text : String[20];           // variable used for text messages

procedure Init();
begin
  ADPCFG  := $FCFF;          // configure AN8(RB8) and AN9(RB9) as analog pins
  TRISB.8 := 1;              // configure RB8 and RB9 as input pins
  TRISB.9 := 1;
  Glcd_Init_DsPicPro3();     // init GLCD for dsPICPRO3 board
  // Note: GLCD/LCD Setup routines are in the setup library files located in the Uses folder
  //       These routines will be moved into AutoComplete in the future.
  Glcd_Fill(0);              // clear GLCD
  TRISC := $02;              // pin PORTC.1 is input for calibration
  positionNo := 1;           // variable used in text messages
end;

procedure DoMeasureXY();
begin
  meas_x := Adc_Read(8);     // measure X axis acceleration
  meas_y := Adc_Read(9);     // measure Y axis acceleration
end;

procedure DrawPointerBox();
var x_real, y_real : real;
begin
  x_real := (meas_x-zeroG_x)/(oneG_x-zeroG_x);  // scale [-1G..1G] to [-1..1]
  x_real := x_real * 64;                        // scale [-1..1]   to [-64..64]
  x_real := x_real + 64;                        // scale [-64..64] to [0..128]
  
  y_real := (meas_y-zeroG_y)/(oneG_y-zeroG_y);  // scale [-1G..1G] to [-1..1]
  y_real := y_real * 32;                        // scale [-1..1]   to [-32..32]
  y_real := y_real + 32;                        // scale [-32..32] to [0..64]
  
  // convert reals to integers
  box_x := x_real;
  box_y := y_real;
  
  // force x and y to range [0..124] and [0..60] because of Glcd_Box parameters range
  if (box_x>124) then box_x:=124;
  if (box_x<0)   then box_x:=0;
  if (box_y>60)  then box_y:=60;
  if (box_y<0)   then box_y:=0;
  
  Glcd_Box(box_x, box_y, box_x+3, box_y+3, 2);  // draw box pointer, color=2(invert ecah dot)
end;

procedure ErasePointerBox();
begin
  Glcd_Box(box_x, box_y, box_x+3, box_y+3, 2);  // draw inverted box at the same position
                                                //   (erase box)
end;

// --- Calibration procedure determines zeroG and 1G values for X and Y axes ---//
procedure DoCalibrate();
begin
//  1) Put the Accel board in the position 1 : PARALLEL TO EARTH'S SURFACE
//     to measure Zero Gravity values for X and Y
  text := msg1;
  text[17] := positionNo + 48;
  Glcd_Write_Text(text,5,1,1);
  Inc(positionNo);
  text := msg2;
  Glcd_Write_Text(text,5,20,1);
  while (PORTC.1 = 0) do            // wait for user to press RC1 button
    nop;
  DoMeasureXY();
  zeroG_x := meas_x;                // save Zero Gravity values
  zeroG_y := meas_y;
  Delay_ms(1000);

//  2) Put the Accel board in the position 2 : X AXIS IS VERTICAL, WITH X LABEL UP
//     to measure the 1G X value
  text := msg1;
  text[17] := positionNo + 48;
  Glcd_Write_Text(text,5,1,1);
  Inc(positionNo);
  text := msg2;
  Glcd_Write_Text(text,5,20,1);
  while (PORTC.1 = 0) do            // wait for user to press RC1 button
    nop;
  DoMeasureXY();
  oneG_x := meas_x;                 // save X axis 1G value
  Delay_ms(1000);
  
//  3) Put the Accel board in the position 3 : Y AXIS IS VERTICAL, WITH Y LABEL UP
//     to measure the 1G Y value
  text := msg1;
  text[17] := positionNo + 48;
  Glcd_Write_Text(text,5,1,1);
  Inc(positionNo);
  text := msg2;
  Glcd_Write_Text(text,5,20,1);
  while (PORTC.1 = 0) do            // wait for user to press RC1 button
    nop;
  DoMeasureXY();
  oneG_y := meas_y;                 // save Y axis 1G value
  Delay_ms(1000);
end;


begin
  Init();                           // initialization
  
  DoCalibrate();                    // calibration
  
  Glcd_Fill(0);                     // clear GLCD
  Glcd_H_Line(0, 127, 32, 1);       // draw X and Y axes
  Glcd_V_Line(0, 63,  64, 1);
  Glcd_Write_Char('X', 122, 3, 1);
  Glcd_Write_Char('Y', 66,  0, 1);
  
  while TRUE do                     // endless loop
    begin
      DoMeasureXY();                // measure X and Y values
      DrawPointerBox();             // draw box on GLCD
      Delay_ms(250);                // pause
      ErasePointerBox();            // erase box
    end;
end.

MIKROE

MIKROE is a development tools company dedicated to standardization and time-saving in the embedded industry.

  • About us
  • Success story
  • Contact
  • PressKit
  • Timeline
  • Partners
  • Legal
  • Distributors
  • Legacy Products

SOLUTIONS

  • Click boards™
  • Development boards
  • Mikromedia
  • CODEGRIP
  • NECTO Studio
  • Planet Debug

SUPPORT

  • Helpdesk
  • Forum
  • Libstock
  • Learn
  • Let's Make
  • eBooks
  • Premium TS
  • Design service
  • Product Customization
  • Contract Manufacturing

STANDARD

  • mikroBUS™
  • mikroSDK
  • SiBRAIN
  • DISCON

Prodavnica za inostrano tržište

Nalazite se na prodavnici za inostrano tržište. Da li želite da Vas odvedemo na prodavnicu koja je namenjena za Srbiju?

Prodavnica za inostrano tržište

Nalazite se na prodavnici za inostrano tržište. Da li želite da Vas odvedemo na prodavnicu koja je namenjena za Srbiju?

Daily products releases, special offers, and more

  • FOLLOW US:

  • instagram
  • linkedin
  • facebook
  • github
  • newsletter
  • youtube
  • twitter

Join us

Pridruži nam se

Careers
Internship
Posao
Napravi Click
Praksa
Copyright© 2023 MikroElektronika d.o.o.

Privacy