May 18, 2024, 09:43:33 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.


Vex Transmitter to Prop-SX to Servos + PC (via Serial)

Started by JonnyMac, May 27, 2008, 07:24:22 PM

Previous topic - Next topic

JonnyMac

Use zero to exit the servo data processing, any no-zero value to hold at the stated positions.  The final record will probably be manually coded so that you can set the "resting" positions of the servos.
Jon McPhalen
EFX-TEK Hollywood Office


davisgraveyard

I am finally getting back to this project.   I made a HUGE discovery yesterday that I think will make this work SO much better.   I was trying to capture jaw movements while playing audio and storing the data to a text file.   I was having trouble with the Prop-SX code failing in the middle of the routine (had to reset to keep going).  And I wasn't happy with my jaw sync movements using the VEX.   So I hooked up a cowlicous  audio controller to the jaw servo to see how it would look with the audio (wanted some sort of reference).   By gosh it looked great!   So while the audio boad was moving the jaw I started moving the VEX using the Prop-SX for the head turn, nod, and tilt.  There are a LOT less movemnents for those movements than the jaw. 

So I'm thinking of just going back to a Prop-2 for the show.  But I am going to use the Prop-SX w/ VEX to capture the head movements.   Then in the Prop-2 I am going to fire off the UMP3 player while will have its output split to the Cowlicious audio board and to the speakers.   I'll play the head movement data through the Prop2 since it isn't that much data.   The rest of the show which is just LED fades and triggers is all sequencial so nothing is happening at the same time anyway.

I REALLY like the idea of using an audio controller for the jaw movement along with the Prop-2 or SX for subtle head movement.   Having the dedicated jaw movement frees up a lot of resources and it looks so much better.

Jeff

JonnyMac

At the risk of sounding defensive, I have trouble with the phrase "Prop-SX code failing" -- I've run that code through the ringer and it doesn't fail, and I've done lots of data captures on the serial output and it is always correct. 

I believe there is something in your electrical circuit that is wreaking havoc with the controller; my guess is that your servos are overloading the electrics and causing the Prop-SX to hang -- I think this can be corrected by using an external supply for the servos.  You could make a power supply adapter for the Prop-SX using a Proto PCB.

That said, if an audio follower works by all means use it.  I've been wanting to experiment with one of those circuits, but time is just not on my side at the moment.
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

Ok "Prop-SX code failing" was a poor description of the problem.    The issue I think is what you described.  You called it  "brownout" in a previous post and suggested changing the BOR42 to BOR26 in the DEVICE section to reduce the brownout threshhold.  That didn't seem to help.  Just to repeat the behaviour is that I start using the Prop-SX and the VEX to move the servos and randomly (sometimes right away sometimes after a short while) the program just shuts down and all the servos go dead.   I have to press the reset button to get control again.    None of the servos are binding and are able to move freely without much resistance.    I am using a 12VDC 200ma power supply to run the 4 servos.  I have also disconnected the Jaw servo (which had the most strain)  and the same thing still happens. 

One observation I noticed.   When I started using the audio servo driver board  for the jaw movement I noticed that the board moved the servo with a LOT more force.  When using the VEX with the PROP-SX the jaw movement was slower and had less torque.  I didn't notice it until I used the other board and watched how it threw the servo all over the place with MUCH more force than the Prop-SX ever did?  Granted I am using a separate 6v power supply for the board to drive the single server and maybe that is what you are suggesting about using a separate power supply for the servos?

I appologize if I indicated that the program you wrote in any way was faulty.  That is not what I was trying to say.  I just wanted to point out that all the programmed data required to drive jaw movements could be saved by using an audio servo driver board instead.  Using the VEX and Prop-SX works great to puppeteer the head without having to worry about the jaw movements.  It is also a LOT less of a syncing issue since the had turn, nod,tilt can start and stop just about anywhere in the speach and still look good. 

Jeff

livinlowe

For what its worth:
200 mA is REALLY low for 4 servos. That would be a max of 50 ma each during movement, and I really think that is too small for a servo.
Also, are you powering your Prop-SX off that as well or do you have a seperate supply?
Shawn
Scaring someone with a prop you built -- priceless!

davisgraveyard

I suspected that was the issue when I posted my msg saying I was using 200ma supply.   I grabbed a 1.5a 12VDC adaptor and tried it.  And low and behold no brownout?  And the servos have a lot more life to them like the audio board does.  And Yes I am powering the Prop-SX and the 4 servos with the supply.

Doug,  what do you think about the combo audio talker board and Prop-2 for head movement?   Have you tried that?

Jeff

JonnyMac

On the apparent torque improvement using the audio talker: what you may be seeing is a quicker [direct] jump between one value and another, whereas with the VEX you're moving a joystick through a set of values -- instead of jumping directly from one to another -- so the response seems slower.
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

I am trying to convert the data coming out of serial port on the Prop-SX when hooked to the VEX running Jon's program to DATA statements that the Prop-2 can understand.

I am getting values like 165,161,162 etc from the Prop-SX.    My little VB app reads the data from the RS-232 and dumps it to a binary file.  I then have another step in the program that can convert the binary file to a text file formated like this   DATA value1,value2,value3,value4,timer where timer is the number of times the 4 values stay the same.

But I seem to recall that the values for the Prop-2 for servo movements are different?  Am I wrong?  What would I need to change in my text file to use these DATA statements in a Prop-2 servo player?

Jeff



davisgraveyard

One other problem.  The data that I have captured  from puppeteering the head for a 2min speech is about 79K.    I didn't move the head around that much during the speach.  Most of the entries have a timing value of 1 where only one of the 3 servos (nod,tilt,turn) changed 1 value like this...

DATA 165,161,162,3
DATA 166,161,162,2
DATA 168,161,162,1
DATA 170,161,162,1
DATA 171,161,162,1
DATA 172,161,162,1
DATA 174,161,162,1
DATA 176,161,162,1
DATA 179,161,162,1
DATA 181,161,162,4
DATA 182,161,162,1
DATA 185,161,162,1
DATA 188,161,162,1
DATA 190,161,162,1
DATA 191,161,162,4
DATA 192,161,162,1
DATA 194,161,162,5


There are over 4000 lines like this and it is going to be too much to use in a Prop-2 Program?  Any ideas on how I could condense the data down? 

Jeff


JonnyMac

You could use an simple RLE scheme, but I think implementing that would be more trouble than it's worth, and you may end up with less show space in the EEPROM anyway.  But let's say you want to give it a go... instead of using four bytes every 20 milliseconds, you could collapse redundant records by using five bytes, the fifth being how many 20 millisecond cycles to hold those values.

The problem with this scheme is that any changes from one record to another force a new record; you might want to use a PC to filter the data so that very small changes are cleaned up.  Noise in the system will cause small changes that will defeat your compression scheme.

By my calculation you can fit about 2 minutes of "show" into the EEPROM without compression.  Is this not enough?

32 x 1024 = 32,768; 32,768 / 4 = 8,192; 8,192 x 0.02 = 163.8 seconds.
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

One of the things I am doing is only using 3 servos for the show even though the Vex program controls 4.  The 4th is for the jaw.  My PC program compresses the raw captured data by only recording changes in the 3 servos and compressing duplicates into a single DATA line and increasing the timer.   That said the data I captured while puppeteering for 2 minutes after compressing generated 4000+ lines and is 79K.  When I try to paste that into my Prop-2 code and load it it says the program is over 64k and won't load.

I could try to be a little more subtle about my movements and hold the joysticks a little more still so there isn't a constant change going on.  That should reduce the data? 

Not sure how you are coming up with your "show" calculation?

Jeff

JonnyMac

I still think think that noise in the system will be problematic with subtle movements.

My "show" calculation:

A) The Prop-SX has a 32K byte EEPROM (32 x 1024 = 32768 bytes)
B) Controlling four servos you can squeeze 8192 records into the EEPROM
C) If each record runs for 0.02 seconds the total time is 163.8 seconds (2:43)

If you knock that down to three servos you get 218.4 seconds (3:38)
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

Yes but I am trying to do this with a Prop-2.   Capture the data with Prop-SX but store the show in a Prop-2?  Do I not have enough room?

I was also asking how to convert the data for the Prop-2?   The values for the Prop-SX / VEX program are 100-200.  But isn't the range for the Prop-2 higher?  What is the conversion?


Jeff

JonnyMac

September 02, 2008, 06:04:42 PM #44 Last Edit: September 02, 2008, 06:31:36 PM by JonnyMac
Sorry, I misunderstood.  No way, no how, no can do, Buckaroo!  I have some servo compression code posted here in the forums but you're going to be seriously limited as to the amount of "show" you can squeeze into a 2K EEPROM that is also holding your program.

[Edit] I found one of those programs an bashed it up to work with an external device (STAP) and three servos; the length of your show will depend on the changes in your moves.

' =========================================================================
'
'   File...... Servo_Blender-3x.BS2
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 02 SEP 2008
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


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


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


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

AudioStart      PIN     15                      ' pulsed audio start
Trigger         PIN     14                      ' trigger input
Servo3          PIN     10
Servo2          PIN     9
Servo1          PIN     8


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

IsOn            CON     1
IsOff           CON     0

RecLen          CON     4                       ' record length (servos + 1)

EOS             CON     $FF                     ' end of show marker


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

timer           VAR     Byte                    ' for trigger debouncing

record          VAR     Word                    ' movement record
pntr            VAR     Word                    ' table byte pointer
s1Pos           VAR     Byte                    ' servo 1 position
s2Pos           VAR     Byte                    ' servo 2 position
s3Pos           VAR     Byte                    ' servo 3 position
repeats         VAR     Byte                    ' repeats for record data


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

Reset:
  OUTH = %00000000
  DIRH = %10000111                              ' set outputs

  record = 0                                    ' point to home positions
  GOSUB Get_Servo_Pos


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

Main:
  timer = 0
  DO WHILE (timer < 200)
    GOSUB Refresh_Servos
    timer = timer + 20 * Trigger                ' debounce trigger
  LOOP

Start_Audio:
  AudioStart = IsOn                             ' "blip" audio output
  GOSUB Refresh_Servos
  AudioStart = IsOff

Move_Engine:
  record = 1                                    ' start of moves
  DO
    GOSUB Get_Servo_Pos
    IF (s1Pos = EOS) THEN EXIT                  ' abort if at end
    DO WHILE (repeats > 0)                      ' count down repeats
      GOSUB Refresh_Servos
      repeats = repeats - 1
    LOOP
    record = record + 1                         ' point to next record
  LOOP

  GOTO Reset


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

' Call with "record" set to table line to read

Get_Servo_Pos:
  pntr = record * RecLen
  READ (Moves + pntr), s1Pos, s2Pos, s1Pos, repeats
  RETURN

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

' Update servos -- time consumed is 18 to 21 ms

Refresh_Servos:
  PULSOUT Servo1, s1Pos * 5
  PULSOUT Servo2, s2Pos * 5
  PULSOUT Servo3, s3Pos * 5
  PAUSE 15                                      ' pad for loop timing
  RETURN


' -----[ EEPROM Data ]-----------------------------------------------------

' Note on servo movement timing:
'
' Time spent on each record is ~20 ms x (repeats + 1) so a repeats value
' of 0 is ~20 ms and a repeats value of 255 (max) is ~5.1 seconds at
' that position.
'
'               s1   s2   s3   rpts

Moves   DATA    150, 150, 150, 1                ' home positions
        DATA    150, 150, 150, 1                ' start of moves
        DATA    150, 150, 150, 1
        DATA    150, 150, 150, 1
        DATA    150, 150, 150, 1
        DATA    EOS, EOS, EOS, 0                ' end of show
Jon McPhalen
EFX-TEK Hollywood Office