سلام دوستان کد پایین رو در محیط بسکام نوشتم. این برنامه چهار نوع داده اعم از سه داده مربوط به شتاب سنج و یک داده ضربان قلب رو در حافظه mmc در فایل تکست ذخیره می کنه اما فقط یک سطر از داده ها رو نشون میده. من میخوام که حداقل 200 تا داده بگیرم اما نمیشه ممنون میشم راهنماییم کنید.
دریافت داده به این صورت: 56 200 322 178
سه ستون اول سمت چپ سه داده شتاب و ستون چهارم داده ضربان قلب است.
دریافت داده به این صورت: 56 200 322 178
سه ستون اول سمت چپ سه داده شتاب و ستون چهارم داده ضربان قلب است.
کد:
'-------------------------------
'mmc----------------------------
$regfile = "m32def.dat"
$crystal = 8000000
$baud = 38400
$swstack = 32
$hwstack = 64
$framesize = 64
Enable Interrupts
$include "CONFIG_AVR-DOS.Bas"
$include "config_mmc.bas"
'-------------------------------
Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.1 , Db6 = Portc.0 , _
Db7 = Portd.7 , E = Portc.3 , Rs = Portc.5
Config Lcd = 16 * 2
Cls : Cursor Off
Config Adc = Single , Prescaler = Auto
'-------------------------------------------
Deflcdchar 0 , 24 , 24 , 32 , 32 , 32 , 32 , 32 , 32
'-------------------------------------------
'mmc
Dim Conter As Byte
Conter = 0
'--------------------------------
'adxl
Dim X(5) As Integer
Dim Y(5) As Integer
Dim Z(5) As Integer
Dim A1 As Byte
Dim Integert As Integer
Dim Singlee As Single
Dim Stringg As String * 10
Dim X_manfi As Integer
Dim Y_manfi As Integer
Dim Z_manfi As Integer
'============================================
'zaraban
Dim A As Byte
Dim B As Word
Dim C As Byte
Config Pind.1 = Input : Start_sw Alias Pind.1
Config Pind.0 = Input : Sensor Alias Pind.0
'------------------------------
'adxl
Config Pinb.0 = Input : Key_x Alias Pinb.0
Config Pinb.1 = Input : Key_y Alias Pinb.1
Config Pinb.2 = Input : Key_z Alias Pinb.2
Config Pinb.3 = Input : Key_reset Alias Pinb.3
'==============================================
'============================================
'adxl
Enable Interrupts
X_manfi = 0
Y_manfi = 0
Z_manfi = 0
'============================================
'start---------------------------
Again:
If Conter > 5 Then
Cls
Lcd " error !!! "
Waitms 500
End
End If
Incr Conter
'--------------------------------- CHECK MMC
Cls
Lcd " RESET MMC"
Waitms 500
If Drivecheck() <> 0 Then
Cls
Locate 1 , 1
Lcd "not ready to use … "
Waitms 500
Gosub Again
End If
'---------------------------------- INIT DRIVE
If Driveinit() <> 0 Then
Cls
Locate 1 , 1
Lcd "not inserted "
Waitms 500
Gosub Again
End If
Cls
Locate 1 , 1
Lcd "mmc init... OK"
Wait 1
'---------------------------------- CHECK FILE SYSTEM
If Initfilesystem(1) <> 0 Then
Cls
Locate 1 , 1
Lcd " not supported "
Wait 1
Gosub Again
End If
'-----------------------------------
'-----------------------------------
'Zaraban
Cls
Do
Locate 1 , 5
Lcd "Welcome"
Locate 2 , 3
Lcd "Press Start"
Loop Until Pind.1 = 0
'------------
Enable Interrupts
Config Clock = Soft
Time$ = "00:00:00"
'zaraban****************************"
Program_start:
Do
Locate 1 , 4
Lcd Time$
If Time$ = "00:00:10" Then
C = 10
End If
Locate 2 , 3
Lcd "Please Wait"
Debounce Pind.0 , 1 , Ok_button
Loop Until C = 10
Do
Locate 1 , 3
Lcd "Heartbeat:" ; B
'-------------------------
If B <= 60 Then
Locate 2 , 3
Lcd "Mood:Low" ; " "
End If
If B => 100 Then
Locate 2 , 3
Lcd "Mood:High" ; " "
End If
If 60 < B And B < 100 Then
Locate 2 , 3
Lcd "Mood:Normal" ; " "
End If
Portd.0 = 1
' adxl****************************"
If Key_reset = 0 Then
Cls
Lcd "RESET X,Y,Z"
X_manfi = 0
Y_manfi = 0
Z_manfi = 0
Do : Loop Until Key_reset = 1
End If
'=====================================
Integert = 0
'------------------------------
For A1 = 1 To 100
X(1) = Getadc(0)
Waitus 100
Integert = Integert + X(1)
Next
X(1) = Integert / 100
'-----------------------------
Integert = 0
For A1 = 1 To 100
X(2) = Getadc(0)
Waitus 100
Integert = Integert + X(2)
Next
X(2) = Integert / 100
'-----------------------------
Integert = 0
For A1 = 1 To 100
X(3) = Getadc(0)
Waitus 100
Integert = Integert + X(3)
Next
X(3) = Integert / 100
'-------------------------------
Integert = 0
For A1 = 1 To 100
X(4) = Getadc(0)
Waitus 100
Integert = Integert + X(4)
Next
X(4) = Integert / 100
'------------------------------
X(5) = 0
X(5) = X(1)
X(5) = X(5) + X(2)
X(5) = X(5) + X(3)
X(5) = X(5) + X(4)
X(5) = X(5) / 4
X(5) = X(5) - X_manfi
X(5) = X(5) - 10
'-------------------------------
If Key_x = 0 Then
X_manfi = X(5)
Locate 1 , 1 : Lcd "X= --- "
Do : Loop Until Key_x = 1
End If
Show_x:
Locate 1 , 1
X(5) = X(5) - 324
Lcd "X=" ; X(5) ; " " 'Stringg ; " "
'===============================================================================
Integert = 0
For A1 = 1 To 100
Y(1) = Getadc(1)
Waitus 100
Integert = Integert + Y(1)
Next
Y(1) = Integert / 100
'----------------------------
Integert = 0
For A1 = 1 To 100
Y(2) = Getadc(1)
Waitus 100
Integert = Integert + Y(2)
Next
Y(2) = Integert / 100
'----------------------------
Integert = 0
For A1 = 1 To 100
Y(3) = Getadc(1)
Waitus 100
Integert = Integert + Y(3)
Next
Y(3) = Integert / 100
'----------------------------
Integert = 0
For A1 = 1 To 100
Y(4) = Getadc(1)
Waitus 100
Integert = Integert + Y(4)
Next
Y(4) = Integert / 100
'----------------------------
Y(5) = 0
Y(5) = Y(1)
Y(5) = Y(5) + Y(2)
Y(5) = Y(5) + Y(3)
Y(5) = Y(5) + Y(4)
Y(5) = Y(5) / 4
Y(5) = Y(5) - Y_manfi
'-------------------------------
If Key_y = 0 Then
Y_manfi = Y(5)
Locate 2 , 1 : Lcd "Y= ---"
Do : Loop Until Key_y = 1
End If
Locate 2 , 1
Y(5) = Y(5) - 337
Lcd "Y=" ; Y(5) ; " " ' Stringg ; " "
'===========================================
Integert = 0
For A1 = 1 To 100
Z(1) = Getadc(2)
Waitus 100
Integert = Integert + Z(1)
Next
Z(1) = Integert / 100
'-----------------------------
Integert = 0
For A1 = 1 To 100
Z(2) = Getadc(2)
Waitus 100
Integert = Integert + Z(2)
Next
Z(2) = Integert / 100
'-----------------------------
Integert = 0
For A1 = 1 To 100
Z(3) = Getadc(2)
Waitus 100
Integert = Integert + Z(3)
Next
Z(3) = Integert / 100
'-----------------------------
Integert = 0
For A1 = 1 To 100
Z(4) = Getadc(2)
Waitus 100
Integert = Integert + Z(4)
Next
Z(4) = Integert / 100
'-----------------------------
Z(5) = 0
Z(5) = Z(1)
Z(5) = Z(5) + Z(2)
Z(5) = Z(5) + Z(3)
Z(5) = Z(5) + Z(4)
Z(5) = Z(5) / 4
Z(5) = Z(5) - Z_manfi
'-------------------------------
If Key_z = 0 Then
Z_manfi = Z(5)
Locate 1 , 10 : Lcd "Z= ---"
Do : Loop Until Key_z = 1
End If
Locate 1 , 10
Z(5) = Z(5) - 416
Lcd "Z=" ; Z(5) ; " "
' mmc****************************"
Cls
Locate 1 , 1 : Lcd "ok"
Locate 2 , 1
Lcd "mmcsize : " ; Disksize() ; " bytes"
Wait 5
'-----------------------------------
Dim S As String * 30
Dim S1 As String * 30
Dim S2 As String * 30
Dim S3 As String * 30
Dim S4 As String * 30
Dim Filename As String * 20
Filename = "temp.txt"
Open Filename For Output As #1
Waitms 1
Dim Num As Word
Dim Temp As String * 15
'S = " ****************************"
'Printeger #1 , S
' PrInteger #1 , " file 1 :"
' PrInteger #1 , " lm35=temperature_sensor"
'PrInteger #1 , " new but best 1394***"
' PrInteger #1 , " ****************"
' PrInteger #1 , " end of write in file "
Num = Getadc(4)
Num = Num / 2
S = Str(num)
S1 = Str(b)
S2 = Str(x(5))
S3 = Str(y(5))
S4 = Str(z(5))
Cls
Locate 1 , 1 : Lcd "tem=" ; S ; Chr(0) ; "c"
Locate 1 , 10 : Lcd "pulse=" ; S1
Locate 2 , 1 : Lcd "x=" ; S2
Locate 2 , 6 : Lcd "y=" ; S3
Locate 2 , 11 : Lcd "z=" ; S4
Waitms 500
' Print #1 , "temp : " ; S ; " c "
'Print #1 , "pulse : " ; S1
' Print #1 , "z : " ; S2
' Print #1 , "y : " ; S3
'Print #1 , "x : " ; S4
Print #1 , S1 ; " " ; S2 ; " " ; S3 ; " " ; S4
'Print #1 , S1 ; " " ; S2 ; " " ; S3 ; " " ; S4
Close #1
Waitms 100
Print "-----------------------------------"
Open "TEST.TXT" For Input As #2
Do
Line Input #2 , S
Print S
Cls
Locate 1 , 1
Lcd "temperature=" ; S ; Chr(0) ; "c"
Waitms 500
Loop Until Eof(#2 ) <> 0
Close #2
Print "-----------------------------------"
Loop
End
'-----------------------------------
Ok_button:
Incr A
B = A * 4
Goto Program_start
'-------------------------
'-----------------------------------




دیدگاه