BasicMicroUK - Forums

www.basicmicro.co.uk
It is currently Thu Jul 19, 2018 4:26 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: HSERVOPOS problem and errors
PostPosted: Wed Apr 17, 2013 3:00 am 
Offline
Guru

Joined: Fri Feb 10, 2012 9:34 pm
Posts: 73
Hello All!
I am trying to write a simple program to read servo position using HSERVOPOS and display the value returned.
The code is below.
Code:
ENABLEHSERVO2
SetHSerial1 H9600,H8DATABITS,HNOPARITY,H1STOPBITS
i var byte
posit var word
main
;hserout ["All servos Zero", 13]
;   for i = 0 to 31
      posit = hservopos 0
      hserout ["position ", dec posit, 13]
;      hservowait [i]
;   next
; hservo [p4\0,p5\0,p6\0,p7\0,p8\0,p10\0]

goto main

I have tried hservopos in capitals as well as these variations : hservopos p0, heservopos (0) and hservopos (p0).
I also changed ENABLESERVO2 to ENABLESERVO
I can't get this to compile and ger past linking - I get the error lines below:

Starting Compiler...
Preparing files...
C:\BRAT-STUFF\SERVO-POS-TEST.BAS
Compiling...
Linking...
C:\Program Files\BasicMicro\Basic Micro Studio\bin\ld.exe : Unsupported .stab relocation
c:\brat-stuff\servo-pos-test.o(.text+0x854): undefined reference to `HSERVOPOS'
Errors Detected


Why am I getting this error ? What is the correct way to use HSERVOPOS to find the current position of a servo ?
Thanks
Gopal


Top
 Profile  
 
 Post subject: Re: HSERVOPOS problem and errors
PostPosted: Wed Apr 17, 2013 2:19 pm 
Offline
Master

Joined: Tue Nov 21, 2006 5:34 pm
Posts: 662
I am pretty sure HSERVOPOS will only tell you where the ARC32 thinks the servo is, given the last HSERVO command you gave to that servo. It will either be at that location, or depending on your timings of the HSERVO command it could still be in motion and be at computed location given where it was starting from and where it was going to and the proportion of time of your request versus how long the move was going to take...

Also I am pretty sure that ENABLEHSERVO2 is not used anymore, the compiler looks for the HSERVO command to bring in the hservo sub-system.

So if you simply add an HSERVO command to your program, it does compile...

Kurt


Top
 Profile  
 
 Post subject: Re: HSERVOPOS problem and errors
PostPosted: Mon Apr 29, 2013 7:10 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 7:00 pm
Posts: 1316
Location: Temecula, CA
Kurt is correct. HSERVOPOS does not read anything from the Servo. It is assuming the servo is where it has been told to be at.

And yes, ENABLEHSERVO2 is no longer needed.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: HSERVOPOS problem and errors
PostPosted: Fri May 17, 2013 7:18 pm 
Offline
Guru

Joined: Fri Feb 10, 2012 9:34 pm
Posts: 73
Thank you Kurt and Nathan!

So why I am getting that error ? Is it because of ENABLESERVO2 ?

Gopal


Top
 Profile  
 
 Post subject: Re: HSERVOPOS problem and errors
PostPosted: Sun May 19, 2013 1:53 pm 
Offline
Master

Joined: Tue Nov 21, 2006 5:34 pm
Posts: 662
As I mentioned (not overly clearly), you need to put in an hservo statement someplace in the code. The compiler triggers on this to include the hservo code base, which includes hservopos into the generated program...


Top
 Profile  
 
 Post subject: Re: HSERVOPOS problem and errors
PostPosted: Sat May 25, 2013 3:34 am 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 7:00 pm
Posts: 1316
Location: Temecula, CA
And without an hservo command somewhere there would be no pos to read(using hservopos) from memory either.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: HSERVOPOS problem and errors
PostPosted: Mon Jun 03, 2013 11:21 pm 
Offline
Guru

Joined: Fri Feb 10, 2012 9:34 pm
Posts: 73
Thanks guys - I understand it now!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO