Parallax Forums
  HomeLog InRegisterCommunity CalendarSearch the ForumHelp
   
Parallax Forums > Public Forums > Propeller Chip > Servo32v3  Forum Quick Jump
 
New Topic Post Reply Printable Version
[ << Previous Thread | Next Thread >> ] | Show Newest Post First ]

agodwin
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jun 2008
Total Posts : 70
 
   Posted 8/8/2008 7:52 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
I've got a problem caused by the code in the library routine Servo32v3. I can see a fix for it, but don't want to creat another problem by failing to understand what's going on. Can someone advise, please ?

In Servo32v3, method Set, the pin being modified is first enabled in DirA and then the value of DirA recorded in ServoPinDirection for later use by the cog dedicated to servo outputs. The most important problem I have with this is that ServoPinDirection also records any other output pins active at the time. If some are subsequently set to be inputs, the servo cog will still have them set as outputs until Set is called again with the proper state.

I also have some misgivings about the state of the OutA register - Dira has also been set for the calling cog but OutA has not.

I would like to change the code to read ..

PUB Set(Pin, Width)
Width := 1000 #> Width <# 2000
Pin := 0 #> Pin <# 31 'This isn't too safe either ..
ServodataPin[Pin] := (clkfreq / _1us * Width)
ServoPinDirection |= |<Pin


i.e. don't set DirA at all for the cog using Set() and save only the servo pin bitmask for the servo cog, not ALL pins as stated in the comment.

What do you think ? Am I missing something ?

-adrian
Back to Top
 

Timmoore
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined May 2008
Total Posts : 745
 
   Posted 8/8/2008 8:21 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Couple of comments, the default state of outa for a pin is 0 so unless your code changed it to 1 for one of the servo pins is doesn't have any impact on the servo code.
ServoPinDirection is read by the asm cog once on startup (when you call Start) (look just before Zone1 in the asm code), so it will copy the dir of any other pin to the asm cog and if you change the direction later then the asm cog will have it set to output.
If you dont set to output any pins you want to change direction on before calling servo start you will not have a problem.
If you really need to call servo start after you have initialized to output other pins that you need to change to input later then your change should work, if you dont want to change the servo code then just move the servo start and other init code earlier in your start up sequence
Back to Top
 

agodwin
Registered Member



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Jun 2008
Total Posts : 70
 
   Posted 8/8/2008 9:12 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
yes, I realise the asm cog reads ServoPinDirection : it does indeed set it's own pins correctly but I don't understand why it would want to set any other pins. Is this just a bug or is there some important reason ?

Also, is there any reason to set dira in the Set code ? I suppose it will force the pin to zero immediately but I can't think of any more important reason.

I changed the code in the IDE and was slightly irritated to find that it happily changed the library sources : I think I shall have to set them read-only as I'd prefer changed library modules to be kept within the project directory !

Thanks,

-adrian
Back to Top
 

Timmoore
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined May 2008
Total Posts : 745
 
   Posted 8/8/2008 10:58 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
I dont think there is a reason why it changes dira, its just an easy way to or the pins together. I prefer your method.
I copy all the lib modules to another directory and use those including any mods I do to them mainly because when I write a driver I add it to the lib directory so I can use it easlier from multiple projects.
Back to Top
 

Beau Schwabe (Parallax)
IC Layout Engineer



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Aug 2004
Total Posts : 3522
 
   Posted 8/13/2008 9:07 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
agodwin,

Sorry, I have been out of town with limited internet.

To answer your question, there is no particular reason to why I did it the way I did it other than it was my first assembly program attempt and I was trying to understand the Propeller myself. The way it is though, when I program, I typically think that anything that could potentially influence something in the "outside world" from the microcontroller perspective, you really should address first or early on upon program initialization ... other stuff, such as visual or any kind of input can wait. Applying this method of thinking and simply placing the servo initialization routines first should solve your problem in most cases.


Beau Schwabe

IC Layout Engineer
Parallax, Inc.

Back to Top
 

bobbylox
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Mar 2008
Total Posts : 5
 
   Posted 10/20/2008 6:09 AM (GMT -8)    Quote This PostAlert An Admin About This Post.
Can you be more specific? I'm having a similar problem, where if I have the servo32v3 set method in a loop, and if anything else effects the output, the servo locks up. My code is attached.

What I'm trying to do here is to place the values of a pot. into an array for a time, then read them out again with a servo.

Thanks in advance!

-Rob

File Attachment :
basicTest.spin   1KB (application/octet-stream)
This file has been downloaded 31 time(s).
Back to Top
 

Beau Schwabe (Parallax)
IC Layout Engineer



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Aug 2004
Total Posts : 3522
 
   Posted 10/20/2008 7:34 AM (GMT -8)    Quote This PostAlert An Admin About This Post.

bobbylox,

 

I didn't see any evidence of your program locking up.  I am curious about what SERVOPOW is.  Is it power or ground to the servo? ... and if so, the servo should not be powered through any of the I/O pins.  That said, you are initializing SERVOPOW as an output, but it remains LOW in your program.  Is it supplying ground?  Even so, the Propeller I/O's should not sink or source any power to a servo.

 

"What I'm trying to do here is to place the values of a pot. into an array..."

If you are reading a POT, then you should be using the RCTIME command rather than the COUNT command.

 

I ran your program as-is, and the servo on pin 18 puts out a 1ms pulse correctly.  Assuming that the COUNT command is returning a value of zero from pin 13, the formula that you have ... Value*20-300 ... would return a -300 which is considered out of bounds to the "Servo32v3" object.  As a result, the "Servo32v3" object will limit the lowest value to 1000 (likewise, the highest value to 2000), hence the 1ms servo signal that your program is producing and what I can see on my scope.

 

 
 
 
 


Beau Schwabe

IC Layout Engineer
Parallax, Inc.

Back to Top
 

bobbylox
Registered Member

Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Mar 2008
Total Posts : 5
 
   Posted 10/20/2008 1:24 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
It actually is the base of a transistor that grounds the servo. I've also hooked the pot. to a bicore Nv circuit, so it is pulsing on its own, and I'm using Count to count the pulses. What's going on?

-Rob
Back to Top
 

Beau Schwabe (Parallax)
IC Layout Engineer



Email Address Not AvailablePersonal Homepage Not AvailablePrivate Messaging Not AvailableAIM Not AvailableICQ Not AvailableY! Not AvailableMSN Not Available
Date Joined Aug 2004
Total Posts : 3522
 
   Posted 10/20/2008 1:59 PM (GMT -8)    Quote This PostAlert An Admin About This Post.
bobbylox,
 
Can you provide a schematic and/or pictures of your setup?


Beau Schwabe

IC Layout Engineer
Parallax, Inc.

Back to Top
 
[ << Previous Thread | Next Thread >> ]
New Topic Post Reply Printable Version
 
Forum Information
Currently it is Friday, November 20, 2009 6:01 PM (GMT -8)
There are a total of 393,697 posts in 55,520 threads.
In the last 3 days there were 88 new threads and 710 reply posts. View Active Threads
Who's Online
This forum has 17684 registered members. Please welcome our newest member, Dogg.
44 Guest(s), 10 Registered Member(s) are currently online.  Details
boeboy, Peter Jakacki, Phil Pilgrim (PhiPi), jazzed, Michael O'Brien, Cluso99, localroger, adranus, potatohead, pharseid