troubles with cognew and LaserRangeFinder-Functions.
nomad
Posts: 276
Hi,
i have some trouble and problems with cognew and my LRF-Functions
i working on the Software of a Quadcopter with the PropellerProtoBoard
for testing "cognew" and my LRF-Code i make a little testprogram for this
-> as attachment : mylrftest2.spin
1)
problem on PUB main after repeat, cognew(testing,@stack) is OK, programm with the
LRFdatas-function.
but when i make cognew(LRFdatas, @stack1) nothing runs.
what make i wrong ???
2)
in my prototype.spin -program
the problem is : if i wrote in line 254 LRFdatas, nothing goes extremly sloow
i think its a timing problem
for this i want make a cognew(LRFdatas,@stack ???)
is this possible ???
in the program LRFdatas are multible access
in line 744
in line 1004
only in the function landing on line 1038 its ok, (the copter should be verry slow landing)
Many Thanks for Help, Hints and tricks
nomad
i have some trouble and problems with cognew and my LRF-Functions
i working on the Software of a Quadcopter with the PropellerProtoBoard
for testing "cognew" and my LRF-Code i make a little testprogram for this
-> as attachment : mylrftest2.spin
1)
problem on PUB main after repeat, cognew(testing,@stack) is OK, programm with the
LRFdatas-function.
but when i make cognew(LRFdatas, @stack1) nothing runs.
what make i wrong ???
2)
in my prototype.spin -program
the problem is : if i wrote in line 254 LRFdatas, nothing goes extremly sloow
i think its a timing problem
for this i want make a cognew(LRFdatas,@stack ???)
is this possible ???
in the program LRFdatas are multible access
in line 744
in line 1004
only in the function landing on line 1038 its ok, (the copter should be verry slow landing)
Many Thanks for Help, Hints and tricks
nomad


Comments
I think it would be very useful if the LRF could measure the altitude of a quadcopter. I'm very skeptical that it would be able to sense the altitude of a quadcopter when used outside. I've tested my LRF outside and found it had a hard time getting a reading in sunlight. When the LRF was able to measure distance outside in the sun, it would only do so for short distances < 2 meters and only if the LRF was held very still. I think the movement of the quadcopter will make it harder for the LRF to work.
Have you done any testing yourself?
I've wondered if using a brighter laser would make it more reliable when using it outside in sunlight.
@ kuroneko
thanks for your answer
excuse, but to programming with cogs (threading) i'm a newbie
and have some troubles to understand your answer
please can you me explain your answer with this code-snippets
- i have translate your answer to german the understanding is not
better for me:
- what i want is this:
1) lrfInit
2) loop
- read LRF-Datas (1.cog)
- working with LRF-Datas (testing) (2.cog)
---code
PUB main
pst.Start(115_200)
LRFinit
REPEAT
cognew(testing,@stack)
LRFdatas
'cognew(LRFdatas,@stack1)
thanks for your help.
@DuaneDegn
thanks for your answer:
i am testing the lrf-datas inside
- the device looks to ground
- i am testing too device looks horizontal to the windows in my room
(sun)
- its run ok
my idea is:
- working with lrf
- on starting from the ground (hover) distance < 2 meters
- landing to control the distance < 2 meters
- for all other distance measure -> GPS-NMEA -> altitude
@ all:
please excuse my bad english. ;-)
thanks for help hints and tricks
nomad
Versuch mal ob Du mit der Version hier klarkommst (Zeile 23 bitte loeschen, der Aufruf simuliert den LRF):
CON _clkmode = XTAL1|PLL16X _xinfreq = 5_000_000 LRF_TX = 1 '5 ' Serial output to LRF (connects to SIN) LRF_RX = 2 '6 ' Serial input from LRF (connects to SOUT) VAR long range ' Distance from LRF module to target object (in millimeters) long cog, ID long stack0[40] long stack1[40] long stack2[40] long temp OBJ pst : "Parallax Serial Terminal" serial : "Extended_FDSerial" PUB main [COLOR="#FFA500"]cognew(fake, @stack2{0})[/COLOR] ' simulate LRF ID := locknew ' grab a lock to serialise pst traffic pst.Start(115_200) ' Set Parallax Serial Terminal to 115.2kbps waitcnt(clkfreq*3 + cnt) ' startup delay pst.clear ' clear screen LRFinit cognew(testing, @stack0{0}) cognew(LRFdatas, @stack1{0}) PRI testing repeat repeat while lockset(ID) ' exclusive access to pst pst.Position(0,5) pst.hex(temp++, 8) lockclr(ID) ' release pst waitcnt(clkfreq + cnt) ' Langsam! Nicht uebertreiben. PRI LRFinit serial.Start(LRF_RX, LRF_TX, %0000, 115_200) ' Start serial port, normal mode, 115.2kbps pst.Str(String("Waiting for LRF module...")) waitcnt(clkfreq << 1 + cnt) ' Delay for 2 seconds to let the LRF module start-up serial.Tx("U") ' Send character repeat until serial.RxCheck == ":" ' When the LRF has initialized and is ready to go, it will send a single ':' character, so wait here until we receive it pst.Position(0,16) pst.Str(String("Ready!", pst#NL, pst#NL)) ' Ready to go! PRI LRFdatas repeat serial.Tx("R") ' Send command repeat until serial.RxCheck == "D" ' Wait for the header to be sent... repeat until serial.RxCheck == "=" ' repeat until serial.RxCheck == " " ' range := serial.RxDec ' ...then grab the value repeat while lockset(ID) ' exclusive access to pst pst.Position(0,10) pst.Str(String("Distance = ")) pst.Position(12,10) pst.Dec(range) pst.Str(String(" mm")) ' in milimeter lockclr(ID) ' release pst waitcnt(clkfreq/4 + cnt) OBJ LRF: "FullDuplexSerial" PRI fake | c LRF.start(LRF_TX, LRF_RX, %0000, 115200) repeat until (c := LRF.rx) == "U" LRF.tx(":") repeat repeat until (c := LRF.rx) == "R" LRF.str(string("D = ")) LRF.dec((cnt >> 1) // 10000) LRF.tx(13) DATDiese Version startet beide cogs nur einmal. Sie halten sich dann selbst am Leben (repeat) und koennen ihre Daten dann ueber globale Variablen austauschen.vielen dank fuer deine antwort in deutsch,
erleichtert mir vieles.
vielen dank fuer deinen spin-code.
da ich gestern meinen quadcopter voellig demontiert habe incl. LRF,
muss heute oder besser morgen lrf auf meinen propeller-proto-board wieder zum laufen bekommen,
dann teste ich deinen code.
melde mich dann wieder.
nochmals vielen dank fuer deine hilfe
nomad
@kuroneko:
vielen dank fuer deine Hilfe, dein code ist genau das was ich gesucht habe ,
Code Run OK, tempcounter ok, lrf-distance OK
Thanks :-)
regards nomad