圣龙扬特-AVR电子

标题: bascom 步进电机仿真 [打印本页]

作者: 赵彬    时间: 2013-2-27 23:07
标题: bascom 步进电机仿真
$regfile = "m16def.dat"
$crystal = 4000000
Config Timer1 = Timer , Prescale = 1024
Dim Bz As Bit
Bz = 0
Dim Dsq As Word
Dsq = 65400
Timer1 = Dsq
Dim Shuju(4) As Byte
Config Portb = Output
Config Pind.0 = Input
Portd.0 = 1
Config Pind.1 = Input
Portd.1 = 1
Config Pind.2 = Input
Portd.2 = 1
Config Pind.7 = Input
Portd.7 = 1
Dim B As Byte
B = 1
Dim Bs As Byte
Dim Dy As Word
Dim A As Byte
Dim Jd As Word
Config Pinc.0 = Output
Set Portc.0
Config Pinc.1 = Output
Set Portc.1
Dy = 3600
'转十圈停止
'Bs = 1
Portb = &B00000001
Restore Daima
For A = 1 To 4
Read Shuju(a)
Next
On Ovf1 Timer1_isr
Enable Timer1
Start Timer1
Enable Interrupts
Do
If Pind.0 = 0 Then
Waitms 50
Dsq = Dsq + 10
If Dsq > 65400 Then
Dsq = 65400
End If
End If
If Pind.1 = 0 Then
Waitms 50
Dsq = Dsq - 10
End If
If Pind.7 = 0 Then
Waitms 30
Toggle Bz
End If
If Pind.2 = 0 Then
Start Timer1
End If
If Jd >= Dy Then
Jd = 0
Stop Timer1
'Portb = &B11111111
End If
Loop
End
Daima:
Data &B00000001 , &B00000010 , &B00000100 , &B00001000


:
Timer1_isr:
Timer1 = Dsq
If Bz = 0 Then
Incr B
Else
Decr B
If B < 1 Then
B = 4
End If
End If
If B > 4 Then
B = 1
End If
Portb = Shuju(b)
Jd = Jd + 90

Return

作者: admin    时间: 2013-2-27 23:17
顶一个,支持一下。
作者: ba1731    时间: 2013-2-28 14:15
表四鄙人纯属随机路过。。。顺带帮顶。。。
作者: oneway    时间: 2013-2-28 18:21
顶起………………
作者: lijn    时间: 2013-3-12 05:33
楼主的程序,用的什么语言编写的?
作者: 箫天    时间: 2013-3-12 07:36
标题: RE: bascom 步进电机仿真
lijn 发表于 2013-3-12 05:33
楼主的程序,用的什么语言编写的?

用BASIC写的
作者: oscfy    时间: 2013-3-27 18:19
好贴,值得收藏,大家都顶




欢迎光临 圣龙扬特-AVR电子 (http://avr.cnta.net/) Powered by Discuz! X2.5