Sunday, 08 December 2019
     
 
Main Menu
Home Home
Shop Shop
News News
BASCOM-AVR BASCOM-AVR
BASCOM-8051 BASCOM-8051
Products Products
Application Notes Application Notes
Publications Publications
Links Links
Support Center Support Center
Downloads Downloads
Forum Forum
Resellers Resellers
Contact Us Contact Us
Updates Updates
MCS Wiki MCS Wiki
Online Help
BASCOM-AVR Help BASCOM-AVR Help
BASCOM-8051 Help BASCOM-8051 Help
Contents in Cart
Show Cart
Your Cart is currently empty.
Search the Shop

Products Search

User Login
Username

Password

If you have problem after log in with disappeared login data, please press F5 in your browser

RSS News
 
     
 

 
   
     
 
AN #184 - Bascom Oscilloscope Print
Digital Oscilloscope based on AVR and BASCOM-AVR.
by AVR64

This is a Digital Oscilloscope based on AVR. this Oscilloscope has professional settings such as horizontal, vertical, Domain, Sweep, Refresh, Scan Speed, etc.





Source code:


'---------------------------------------------------------------
'Digital Oscilloscope <Oscope2.bas>
'Programmer: Behnam Zakizadeh
'Compiler : BASCOM 2.0.4.0
'Creation Date: 04.Dec.2010
'Last Change:   23.Apr.2011
'Copyright:  2011 By www.avr64.com
'License: This Is A Free Firmware, Ver: 2.01
'Suitable for Bascom Demo: Yes (less than 4KB)
'---------------------------------------------------------------

$regfile = "m16def.dat"
$crystal = 4000000
$hwstack = 64
$swstack = 64
$framesize = 64

'GLCD
$lib "glcdKS108.lbx"
Config Graphlcd = 128 * 64sed , Dataport = Portc , Controlport = Porta , Ce = _
 6 , Ce2 = 7 , Cd = 2 , Rd = 3 , Reset = 5 , Enable = 4
Setfont My6_8

'A2D
Config Adc = Single , Prescaler = Auto , Reference = Internal
Enable Adc
Start Adc

'I/O
Config Pind.= Input 'K1
Config Pind.= Input 'K2
Config Pind.= Input 'K3
Config Pinb.= Input 'K4

Set Portd.4                                                 'Set Pullup Res
Set Portd.5                                                 '//
Set Portd.6                                                 '//
Set Portb.0                                                 '//

'Variables
Dim A As Word
Dim X As Byte , Speed As Word , Temp1 As Word
Speed = 1
Dim Refresh As Word
Refresh = 40

Cls
Lcdat 1 , 1 , "Digital Oscilloscope"
Wait 1

Cls
Showpic 0 , 0 , Pic1

Do
 'Horizontal Set
 If Pind.= 0 Then
 If Speed < 1000 Then
 Incr Speed
 End If
 End If
 If Pinb.= 0 Then
 If Speed > 0 Then
 Decr Speed
 End If
 End If

 'Refresh Speed Set
 If Pind.= 0 Then
 If Refresh < 4000 Then
          Refresh = Refresh * 2
 End If
 End If
 If Pind.= 0 Then
 If Refresh > 2 Then
          Refresh = Refresh / 2
 End If
 End If

 For X = 0 To 127
      A = Getadc(1)
      A = A / 16
      A = 64 - A

 'Draw Line ---___---___---___
 Pset X , A , 255

 'Horizontal
 For Temp1 = 1 To Speed
 Waitus 1
 Next Temp1

 Next
 Waitms Refresh
 Cls
 Showpic 0 , 0 , Pic1
 Lcdat 1 , 1 , "Sweep: " ; Speed
 Lcdat 2 , 1 , "Refresh: " ; Refresh
Loop
End

Pic1:
$bgf "Oscope.bgf"
$include "my6_8.font"