Hello,
I found this servo tester on internet and I'm wondering what kind of compiler was used to make this program.
Any ideas ?
Code Basic4GL - [expand ] 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Device = 12F675
Config WDT_OFF, CPD_OFF, CP_OFF, MCLRE_OFF, BODEN_ON, INTRC_OSC_NOCLKOUT
'Setup system registers
ADCON0 = $ 81
ANSEL = $ 11
TRISIO = $ 1F
CMCON = $ 7
WPU = $ 16
OPTION_REG.7 = 0
GPIO = 0
'Global Variables
Dim adc_return As ADRESL.Word
Dim pos_value As Float
Dim servo_pos As Word
'Analog mode GP3 = 1
If GPIO.3 = 1 Then
While 1 = 1
ADCON0.1 = 1
While ADCON0.1 = 1 : Wend
pos_value = adc_return/ 1024 ;
servo_pos = ( pos_value * 2000 ) + 500 ;
Servo GPIO.5, servo_pos
DelayMS 5
Wend
Else
'Digital mode GP3 = 0
servo_pos = 1500
While 1 = 1
'Down key control logic
If GPIO.1 = 0 Then
If servo_pos <= 510 Then
servo_pos = 500
Else
servo_pos = servo_pos - $ A
EndIf
End If
'Up key control logic
If GPIO.2 = 0 Then
If servo_pos >= 2490 Then
servo_pos = 2500
Else
servo_pos = servo_pos + $ A
EndIf
End If
'Reset key control logic
If GPIO.4 = 0 Then servo_pos = 1500
Servo GPIO.5, servo_pos
DelayMS 5
Wend
EndIf
regards
Nils
Last edited by a moderator: Aug 17, 2014