Hi,
today i want to publish an anglekeeper for RC submarines, a design i finished last year. I use the prototype in my submarine type XXII, an experimental study from WWII that was never built. The anglekeeper works pretty good for me.
The code might be simple to others, but costs me a lot of sleepless hours and4 some help from my friend Marco. I am not a programmer, sorry for mistakes. I am sure, the code could be improved. Feel free to do so and share!
The circuit consists mainly of a cheap accelerometer from china and a 18M2 PICAXE. Also on the board there are three potentiometer to adjust gain and Servo min/max to prevent that the servo runs into mechanical limits. A jumper is used to teach in the proper horizontal position that is later indicated by a LED. Thats it.
This circuit cant and will never be a substitute or competitor to the anglekeepers of established distributors. Also the circuit ist published "as is", a privat project of me without any guarantee that it will work with any RC control. Please keep that in mind.
Here ist the code (unfortunately in german):
BTW, i just can upload only two pictures in one posting. Is that correct?
today i want to publish an anglekeeper for RC submarines, a design i finished last year. I use the prototype in my submarine type XXII, an experimental study from WWII that was never built. The anglekeeper works pretty good for me.
The code might be simple to others, but costs me a lot of sleepless hours and4 some help from my friend Marco. I am not a programmer, sorry for mistakes. I am sure, the code could be improved. Feel free to do so and share!
The circuit consists mainly of a cheap accelerometer from china and a 18M2 PICAXE. Also on the board there are three potentiometer to adjust gain and Servo min/max to prevent that the servo runs into mechanical limits. A jumper is used to teach in the proper horizontal position that is later indicated by a LED. Thats it.
This circuit cant and will never be a substitute or competitor to the anglekeepers of established distributors. Also the circuit ist published "as is", a privat project of me without any guarantee that it will work with any RC control. Please keep that in mind.
Here ist the code (unfortunately in german):
Code:
;picaxe 18m2
;10k poti an c.0 (gain)
;10k poti an b.5 (maximal)
;10k poti an b.6 (minimal)
;empfänger an c.2
;led an b.3
;inklinometer an c.1
;servo an b.7
;nulltaster an b.2
;definitionen
symbol counter =b0
symbol servomax =b1
symbol servomin =b2
symbol gain =b3
symbol filter =b4
symbol totpunkt =b5
symbol sensornull =w4
symbol ad_wert =w5
symbol adwert_sum =w6
symbol subtract =w7
symbol pulse =w8
symbol value =w9
symbol cas1 =w10
symbol cas2 =w11
symbol verst =c.0
symbol inkl =c.1
symbol empf =c.2
symbol nullp =b.2
symbol lednull =b.3
symbol smax =b.5
symbol smin =b.6
symbol tiefenr =b.7
;variablen
filter = 7 'Anzahl der Schleifendurchgänge. Guter Wert ist 5-7
totpunkt = 2 'Totpunkt
setfreq m16 'Gib Gummi!
;programm
start:
read 0,WORD sensornull 'Sensornull aus eeprom auslesen
if pinb.2 =0 then goto main 'wenn Nullpunkttaster gedrückt
readadc10 inkl,ad_wert 'Sensor lesen
sensornull=ad_wert 'dann Sensornull mit aktuellem Wert laden
write 0,WORD sensornull 'Sensornull wert in eeprom speichern
main:
cas1 = sensornull -totpunkt 'Grenzen für Nullpunktled definieren
cas2 = sensornull +totpunkt
;
pulsin empf,1,pulse 'Empfänger lesen
pulse=pulse*25 'Impuls anpassen
pulse=pulse/100
;
for counter = 1 to filter 'Filterstufe zur Rauschverringerung
readadc10 inkl,ad_wert 'Inklinometer lesen
subtract = adwert_sum/filter 'Filter anwenden
adwert_sum = adwert_sum - subtract
adwert_sum = adwert_sum + ad_wert
next
;
ad_wert = adwert_sum/filter
readadc smin,servomin 'Servoendanschläge min lesen
readadc smax,servomax 'Servoendanschläge max lesen
readadc verst,gain 'Verstärkungspoti lesen
gain = gain min 10 max 240 'Wert eingrenzen
select case ad_wert
case cas1 to cas2 'Totpunkt für Ledmitte
high b.3 'wenn ja, dann Led an
else 'sonst
low b.3 'aus
endselect
;
if ad_wert < sensornull then
value = sensornull-ad_wert
else
value = ad_wert-sensornull
end if
;
value = value * gain 'Verstärkung mit einrechnen
value = value / 100 max 50 'Wert anpassen
if ad_wert < sensornull then 'Verknüpfung Sensor mit Empfängersignal
value = pulse-value
else
value = pulse+value
end if
value=value max servomax min servomin 'Wert begrenzen
servo tiefenr,value 'Wert auf Servo ausgeben
goto main
Attachments
-
34.7 KB Views: 91
-
57.5 KB Views: 62
Last edited: