Atmega16 Software enquiry

Status
Not open for further replies.

jokester4u

Junior Member level 2
Joined
Nov 26, 2013
Messages
20
Helped
1
Reputation
2
Reaction score
0
Trophy points
1
Activity points
124
Does anyone know which software could be used to run the following code?
Code:
$regfile "M16DEF.DAT"
$crystal = 8000000
$baud = 9600
$hwstack = 32
$swstack = 8
$framesize = 40
Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Up , Prescale = 8
Config Lcdpin = Pin , E = Portc.4 , Rs = Portc.5 , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portc.1 , Db7 = Portc.0
Config Lcd = 16 * 2
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Config Timer0 = Counter , Edge = Rising
On Ovf0 Tim0_isr
Enable Interrupts
Enable Timer0
Tcnt0 = 0
Config Portc = Output
Dim A As Integer
Dim B As Integer
Dim C As Integer
Dim D As Single
Dim E As Single
Dim F As Single
Dim G As Single
Dim H As Single
Dim I As Single
Dim J As Single
Dim K As Single
Dim L As Single
Dim M As Single
Dim X As Single
Dim Y As Single
Dim Errr As Integer
Dim Ad As Integer
Dim Onn As Integer
Dim P_gain As Single
Dim I_gain As Single
Dim D_gain As Single
Dim Dt As Single
Dim Set_rpm As Integer
Dim Previous_error As Single
Dim D_error As Single
Dim I_error As Single
Dim Error As Single
Dim Feedback_rpm As Integer
Dim Otpt As Integer
Set_rpm = 0
Previous_error = 0
D_error = 0
I_error = 0
P_gain = 0.65
I_gain = 0.005
D_gain = 0.005
Dt = 0.5
A = 0
B = 0
C = 0
D = 0
E = 0
F = 0
H = 0
G = 0
I = 0
J = 0
K = 0
L = 0
M = 0
X = 0
Y = 0
Otpt = 0
 Previous_error = Set_rpm - Feedback_rpm
Start Adc
Do
Set_rpm = Getadc(0)
Locate 2 , 1
Lcd Set_rpm
 Tcnt0 = 0
 Start Timer0
 Waitms 500
 Stop Timer0
 A = Tcnt0
 B = F * 255
 C = A + B
 D = C / 1
 E = D * 5
   E = E + 0
   G = E
  Feedback_rpm = G
  X = Set_rpm - 2
  Y = Set_rpm + 2
 If G > X And G < Y Then
    G = Set_rpm
 End If
 Cls
 Locate 1 , 1
 Lcd G
 F = 0
             Error = Set_rpm - Feedback_rpm
             H = Error * Dt
             I_error = I_error + H
             I = Error - Previous_error
             D_error = I / Dt
             J = P_gain * Error
             K = I_gain * I_error
             L = D_gain * D_error
             M = J + K
             Otpt = M + L
             Previous_error = Error
           ' Errr = Set_rpm - Otpt
           Onn = Onn + Otpt
           If Onn > 254 Then
           Onn = 254
           End If
           Compare1a = Onn
Loop
Tim0_isr:
F = F + 1
Return
End
Explanation of main course of program:
Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Up , Prescale = 8
Config Lcdpin = Pin , E = Portc.4 , Rs = Portc.5 , Db4 = Portc.3 , Db5 = Portc.2 , Db6 = Portc.1 , Db7 = Portc.0
Config Lcd = 16 * 2
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Config Timer0 = Counter , Edge = Rising
On Ovf0 Tim0_isr
Timer 0 is configured as counter which counts the input pulse from the sensor.
Timer 1 is configured as PWM to give the output signal to the L298n.
Lcd and adc is also configured.
Start Timer0
 Waitms 500
 Stop Timer0
 A = Tcnt0
Timer is started to count the pulse for every 500 ms.
Value is stored into variable A.
A = Tcnt0
 B = F * 255
 C = A + B
 D = C / 1
 E = D * 5
   E = E + 0
   G = E
Conversion of pulses into rpm
  Feedback_rpm = G
  X = Set_rpm - 2
  Y = Set_rpm + 2
 If G > X And G < Y Then
    G = Set_rpm
 End If
 Cls
 Locate 1 , 1
 Lcd G
 F = 0
 Error = Set_rpm - Feedback_rpm
 H = Error * Dt
             I_error = I_error + H
             I = Error - Previous_error
             D_error = I / Dt
             J = P_gain * Error
             K = I_gain * I_error
             L = D_gain * D_error
             M = J + K
             Otpt = M + L
             Previous_error = Error
           ' Errr = Set_rpm - Otpt
           Onn = Onn + Otpt
 

The first line refers to a file "M16DEF.DAT".
Searching on this filename brings up several versions of BASIC.

Furthermore many of the keywords resemble BASIC:

Do
Locate
If...End if
Dim A As Integer
Enable Interrupts
Start Timer0
If G > X And G < Y Then
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…