November 23, 2024, 08:23:46 AM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


3-axis Skull

Started by davisgraveyard, September 04, 2009, 06:39:47 PM

Previous topic - Next topic

davisgraveyard

September 04, 2009, 06:39:47 PM Last Edit: September 04, 2009, 06:41:44 PM by davisgraveyard
I want to create a REAL simple program for a 3-axis skull with 4 servos (Turn, Tilt, nod, jaw) using a Prop1.   This is NOT a talking skull.  Just a simple random movement skull.  Each servo movement can happen in sequence (turn then nod, then tilt etc).   I want to hard code a turn left/right  a nod up/down a tilt left/right and a jaw open close.  Then I want to randomly select the sequence.  

I can handle all the code but my real issue is the range for the servos will take me forever doing it trial and error.    Is there a simple code example that uses a Prop-Pot for input that will move a servo and display the value in debug mode?  So I can find my start and end points for each servo?

Jeff

JonnyMac

September 04, 2009, 08:17:15 PM #1 Last Edit: September 04, 2009, 08:18:50 PM by JonnyMac
This should get you started.  It reads the Prop-Pot and scales the span of the pot reading (255) to the desired span of the servo (100 units) using the ** operator.  To get the value for ** I used this formula

100 / 255 x 65536

... where 100 is the pot position span (200 - 100), 255 is the pot reading span (255 - 0), and 65536 is required to convert the value to an integer for **.  There is no need for a PAUSE after the PULSOUT as DEBUG uses a lot of time.  

' =========================================================================
'
'   File...... Servo_Check.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2009 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 04 SEP 2009
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  PosCtrl         = 7                     ' no SETUP or ULN
SYMBOL  Servo           = 0


' -----[ Constants ]-------------------------------------------------------


' -----[ Variables ]-------------------------------------------------------

SYMBOL  pos             = B2


' -----[ Initialization ]--------------------------------------------------

Reset:
 PINS = %00000000                              ' clear all
 DIRS = %00000001                              ' set output pins (1s)


' -----[ Program Code ]----------------------------------------------------

Main:
 POT PosCtrl, 100, pos                         ' ~0 to ~255
 pos = pos ** $6464                            ' x0.392 (100 / 255)
 pos = pos + 100                               ' add min position

 PULSOUT Servo, pos                            ' update servo

 DEBUG pos

 GOTO Main


' -----[ Subroutines ]-----------------------------------------------------


' -------------------------------------------------------------------------


' -----[ User Data ]-------------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

Ok, that was WAY to easy.  I guess my head was into the program and couldn't see how simple what I wanted needed to be.


davisgraveyard

Spoke too soon.  Not working?  pos always returns 100 or 101?   The Prop-Pot doesn't seem to do anything?  I have the cable wired correctly and on PIN7. 

I was clever and hooked up my LCD panel to pin 6 and am trying to return the value on the LCD but I can't figure out how to do a SEROUT  of pos as a string?

Too tired.  Will try again tomorrow.

Jeff

JonnyMac

A couple things:

1) Make sure that the SETUP jumper on P7 is removed
2) Make sure there is no ULN influence on P7
3) Run the Pot Scaling Program from the Run menu to get the correct Scale factor for your pot.

On my system I'm getting final output values from 101 to 199 -- pretty close to perfect for a quickie program.
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

I downloaded the Prop-Pot demo and docs and was still having trouble.  Since this is a servo only prop I removed the ULN and it started working.  Yea, I know you said make sure there was no ULN influence.   I just hate cutting pins on my ULN (too many recycled Prop-1's). 

Oh and I found out the "#" is what I needed to format the pos value for my serial LCD. 

Now I have a nice little setup to test the values for servo movements.