May 15, 2024, 02:36:12 PM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Animated Skull using Servo reader code

Started by davisgraveyard, September 04, 2008, 08:30:13 PM

Previous topic - Next topic

davisgraveyard

Here is the latest code for the animated skull.    I thought I would create a new thread since we aren't really dealing with a Prop-SX for this program.  The data for this program was create using the Prop-SX VEX program to capture the data movements.   I wrote a VB program on the PC to save the data and then munge it to compress down to the Prop-2.  But the program still isn't working yet.  The show ends before the sound finishes and the movements are very "robot like" and jerky.

So I am leaning towards trying to smooth out the movements.  The data that gets created actually comes from more smoother movements.

I tried writing some code to do a look-ahead at the next record and do extra PULSOUT's and increment the pos value until it reaches the next record using the extra repeats but the code was too complex and ate up extra program memory and forced me to condense the data even more.   

Maybe some optimized code would help?

Here is what I am trying to acomplish.

given these 2 data statements

DATA 177,161,162,12
DATA 164,162,162,12

I want to read pos1,pos2,pos3,repeats then the do

PULSOUT Servo1, pos1 * 5
PULSOUT Servo1, pos2 * 5
PULSOUT Servo1, pos3 * 5

then save the values
oldpos1 = pos1
oldpos2 = pos2
oldpos3 = pos3

read the next record and then perform extra PULSOUT's until either the values are the same or the repeats have been exausted.  I know from the data manipulation that there will always be more repeats than the difference in values between posx and oldposx

something like this but preferably more condensed?

DO
IF pos1 <> oldpos1 THEN
   IF pos1 > oldpos1 THEN oldpos1 = oldpos1 +1 ELSE oldpos1 = oldpos1 -1
   PULSOUT Servo1,oldpos1 * 5
ENDIF
IF pos2 <> oldpos2 THEN
   IF pos2 > oldpos2 THEN oldpos2 = oldpos2 +1 ELSE oldpos2 = oldpos2 -1
   PULSOUT Servo1,oldpos1 * 5
ENDIF
IF pos3 <> oldpos3 THEN
   IF pos3 > oldpos3 THEN oldpos3 = oldpos3 +1 ELSE oldpos3 = oldpos3 -1
   PULSOUT Servo1,oldpos1 * 5
ENDIF
repeats = repeats - 1
UNTIL pos1+pos2+pos3 = oldpos1+oldpos2+oldpos3 AND repeats > 0


This would add additional PULSOUT's that would make the show longer and hopefully match the audio?

Jeff

davisgraveyard

One other thing.

At the end of the Play_Show there is a

DO
   GOSUB Get_Status
LOOP UNTIL (char="S")

this is exiting even though the audio is still playing?

Why would that be?


JonnyMac

It seems like you're trying to "fix" your data with the BS2; this is chewing through valuable code space and, in my opinion, becoming counter productive.  Perhaps it would be a better idea to manipulate the data with a PC program so that the BS2 gets back to being a simple player.

Don't know why your status check of the uMP3 isn't working; you may want to test the uMP3 in isolation just to make sure everything is hunky-dorey on that end.
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

I agree the approach is "chewing" through valuable code space.   But I am not trying to "fix" the data and I already am manipulating the data with a PC program to get it to fit on the BS2. 

Idealy I suppose the way to handle the problem is to burn the data to the EPROM on the SX and go back to it but that is not a simple task for many reasons.

I think the data compression is as good as I can get it given the space allowed in the BS2.   I have to go from 3000 data points to 400 and maintain the show length.  Something has to give.  We have proven that we can stretch the show out to fit the audio length but at the cost of a more jerky looking movement.  At this point it is just tweaking so I will push on.

Jeff


JonnyMac

You make good point: when you take 3000 data points and crunch them down to 400 the values are going to get really granular, hence the jerky movements you're having with the servos.
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

I came up with something that is working pretty good.

I went back to a more simple Servo_refresh

PULSOUT Servo1, pos1 * 5
PULSOUT Servo2, pos2 * 5
PULSOUT Servo3, pos3 * 5
PAUSE 20

This simple refresh still ends too soon for the audio.  But I know that the number of repeats is the same as the orginal data.   But since we are seeing a faster playback on the BS2  I increased the repeats by 50%  in the record read

READ (Show + pntr), pos1, pos2, pos3, repeats
repeats = repeats + (repeats/2)

I had to tweek the PAUSE until the show played at the same length as the audio.  I settled on somewhere between 22 and 22 but the show now ends at the same time as the audio and it is pretty smooth.  Or as smooth as I can get with the scaled down data.

Jeff



davisgraveyard

Still seeing a strange ending to the program?

The main loop that is reading and updating servos only exits when the EOS or $FFFF is read for pos1.  It then should fall out of the loop and check the audio status and then fade the LED's down and then pause for a while and then restart

What I am seeing is that the servos go dead (limp) and the LED eyes just shut off and then the program starts from the beginning with no pause.  I have put DEBUG statements in and nothing is reporting back?  Almost like the program is reseting and starting over? 

I placed a DEBUG counter and it only gets to the 159th record when it resets.  There are 424 records.    I looked at the record and nothing seems odd about it?

Jeff