November 21, 2024, 10:00:03 PM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


Animated Skull

Started by davisgraveyard, March 14, 2007, 11:26:59 PM

Previous topic - Next topic

JonnyMac

I have ideas for a new Vixen-to-BS2 code driver but we haven't worked it out yet.  It will be based on servo blending code that I initially created for the Prop-1 and have since updated for the Prop-2.  Another forum regular, Brian, is working on a skull project that will use this code.  It is a manual process for the time being, ultimately, though, we will make it automated.

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


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


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


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

Sio             PIN     15                      ' no ULN or SETUP for serial
Trigger         PIN     14                      ' SETUP = DN (active-high)

Servo4          PIN     11
Servo3          PIN     10
Servo2          PIN      9
Servo1          PIN      8

DigOuts         VAR     OUTL                    ' P0..P7 or OUT0..OUT7


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

IsOn            CON     1
IsOff           CON     0

RecLen          CON     6                       ' six bytes per record

EOS             CON     255                     ' end-of-show marker


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

timer           VAR     Byte                    ' debounce timer
record          VAR     Word                    ' movement record
pntr            VAR     Word                    ' table pointer

s1Pos           VAR     Byte                    ' servo positions
s2Pos           VAR     Byte
s3Pos           VAR     Byte
s4Pos           VAR     Byte
repeats         VAR     Byte                    ' repeats for record data


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

Reset:
  OUTS = $0000                                  ' all low
  DIRS = $0FFF                                  ' P0..P11 are outputs

  ' read idle state for servos + outputs
  '
  READ Idle_Pos, s4Pos, s3Pos, s2Pos, s1Pos,    ' move servos it idle
                 DigOuts                        ' preset dig outputs


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

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

Start_Audio:
  ' your code here

Reset_Moves:
  record = 0                                    ' point to start of moves

Move_Engine:
  pntr = record * RecLen                        ' point into table
  READ Moves+pntr, s4Pos, s3Pos, s2Pos, s1Pos,  ' get servo positions
                   DigOuts, repeats             ' get digital outs and repeats

  IF (s4Pos = EOS) THEN Show_End                ' abort if at end

Servo_Hold:
  GOSUB Refresh_Servos
  IF repeats = 0 THEN New_Record                ' time left at this pos?
    repeats = repeats - 1                       ' yes, decrement timing
    GOTO Servo_Hold

New_Record:
  record = record + 1
  GOTO Move_Engine

Show_End:
  ' clean-up code here

  GOTO Reset                                    ' clear everything


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

' Update servos; time consumed is ~16 to ~24 ms
' -- assuming servo data is 0.5 to 2.5 milliseconds (180 degrees)

Refresh_Servos:
  PULSOUT Servo1, s1Pos * 5
  PULSOUT Servo2, s2Pos * 5
  PULSOUT Servo3, s3Pos * 5
  PULSOUT Servo4, s4Pos * 5
  PAUSE 14                                      ' 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 sseconds at that
' position.
'
'                       S4   S3   S2   S1   DigOuts    Rpts
'                       ---  ---  ---  ---  ---------  ----
Idle_Pos        DATA    150, 150, 150, 150, %00000000, 255

Moves           DATA     55, 150, 150, 150, %00000001, 4
                DATA     55, 150, 150, 150, %00000010, 4
                DATA     55, 150, 150, 150, %00000100, 4
                DATA     55, 150, 150, 150, %00001000, 4
                DATA     55, 150, 150, 150, %00010000, 4
                DATA     55, 150, 150, 150, %00100000, 4
                DATA     55, 150, 150, 150, %01000000, 4
                DATA     55, 150, 150, 150, %10000000, 4
                DATA    245, 150, 150, 150, %01000000, 4
                DATA    245, 150, 150, 150, %00100000, 4
                DATA    245, 150, 150, 150, %00010000, 4
                DATA    245, 150, 150, 150, %00001000, 4
                DATA    245, 150, 150, 150, %00000100, 4
                DATA    245, 150, 150, 150, %00000010, 4
                DATA    245, 150, 150, 150, %00000001, 4

End_Of_Show     DATA    EOS, 150, 150, 150, %00000000, 0
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

This program makes complete sense and was what I was thinking of writing.   My main concern is the EPROM data.  Of course you could just build a table of values and tweak them until the head moves the way you want and the jaw moves correctly to the audio track.  Thats the most manual way.  There is also the issue of how many lines of data will the Prop-2 hold?

Is there a way to capture the data from a RC transmitter/Reciever?  Even if the values were not the same as the way they are being stored as EPROM data.  I could always convert the data.  But it would be easier to massage the data than manually create them even in Vixen.  Trying to create the tilt,turn and nod movements during the audio track is a LOT tricker than doing Jaw movements.  It is easier to puppet the movements at the same time.    Unless you can create the movements in layers but I don't see how you could do that.   Playback movements while adding a new one.   Record servo3 while servo1 and servo2 are playing?   

Just thinking out loud.



JonnyMac

KC and I have started talking about a program generator that would create this kind of output for the Prop-2.

Capturing live data from an RC receiver is not going to be possible with the Prop-2; perhaps with a Prop-SX but it would take some serious code to handle the timing, capture and storage of all four channels.  I did a little 2-channel waldo project for my Nuts & Volts column but that was using a standard analog joystick that I could read with an ADC -- that's easier than trying to read

Now that I'm typing, let me think out loud.  I just did a Vex RX to servo project for the May issue of Nuts & Volts.  You can get a VEX transmitter and receiver for $30 from All Electronics.  This has four analog channels and two digial channels (though all drive servos).  Capturing the data from that would be easier than a standard receiver, I think.

The real problem is editing one channel at a time.  I can be done, but it's not easy to do in a stand-alone controller because of the limited memory.  All of my servo-based projects use a compression scheme to conserve memory; that's what the timing element int he table does (by eliminating redundant data records).  You would have to capture the data raw in order to be able to do it one channel at a time -- even then it would be a huge challenge for the Prop-SX.  I haven't played with version 2 of Vixen yet but it's supposed to have joystick input; maybe that's the better solution as the PC has far more horsepower and resournces than a stand-alone controller.

What I'd like to convey is all this stuff that seems "easy" requires an enormous amount of energy to engineer; if it was easier, you'd see more and cheaper products doing what you want.
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

My goal is to use a EFX-TEK controller (preferably a Prop-2 but SX if we have to) to operate a 3-axis skull by playing a preprogrammed show.   The program you posted will do just that given the data matches the audio track.   

I don't see any reason the data has to be captured and or stored to begin with using an EFX-TEK controller.   Thats what PC's are good for.  Fast processing, lots of data storage.    Why not use the VEX TX/RX and pupeteer the skull capturing the data to a PC.  Then write a conversion program that compresses the data into EPROM Data statements for a PBASIC program.  You could even recapture and recompress over and over until you were under the number of allowable lines that would fit on the Prop-2. 

The process doesn't have to be so elegant as a code generator or a all-in-one solution.  Dont' get me wrong, it would be cool if Vixen had a RC interface so I could set data points from a RC Transmitter,  but that isn't as important as having some way of coming up with the EPROM Data needed to play the show on the controller.

I'll check into the VEX transmitter and see what I can do.  My weakness is the electronics side of things.   I can handle the programming and manipulation of the data.  I am just not a hardware (or hardware into software) guy.

Jeff

JonnyMac

Again, data capture can be done, and it's simple -- it's just not easy as it requires hardware and firmware design.  The Prop-2 doesn't have a lot of memory, and some of that is used for your code so the show length will be limited.  That's why I had the idea to use the Prop-SX, but then we get back to that work effort, and I have (I'd like to think reasonably) been applying my efforts to new product development.

Again, I'm working with KC on a Prop-2 generator which will give us a foundation for a Prop-SX version.  No promises on delivery, though, as we have pending projects the consume most of our time.
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

Is there a way I can get access to the Nuts & Volts Article about the VEX Transmitter/Reciever?

Jeff

JonnyMac

You can pick it up on newstands in May!
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

You say data capture is simple.  But I have no idea how it is done.  Servo metrics always makes my head spin and converting the analog data that probably comes out of any capture solution to data that a PULSOUT statement needs doesn't seem as straight forward or "simple" to me.

Here's what I'd like to be able to do.  Using a PC write a Visual Basic program that could capture transmitter/reciever data while the servos are connected.   Then convert this data into EPROM Data statements that could be pasted into a PBASIC app that is loaded onto a Prop-2.   I would add a media player control into the application so the MP3 audio track could be playing while you are using the joysticks.  The scenario would be something like:   An animated head sitting next you your PC monitor, the Transmitter in your hands.   You click a "record" button on your application which starts the audio track and then you use the transmittter to animate the head while the audio is playing.  Once the track is done you press a save button and it spits out a text file with a series of EPROM Data statements.  You could even have some threshold number of lines and it could tell you if your data is too big to fit.  You could then redo the process moving the head a little less until you get it to fit within the length of the audio track.  

I can write the UI and even do data crunching if I knew the conversion routines.    I just don't know what type of hardware interface I'd need to get it to work?

Jeff

davisgraveyard

I forgot to mention that the scenario would also mean that the Transmitter was cabled to the PC.   I am wondering if the Buddy cable that most RC trasmittters support would work?   Could the VB App interpret the serial interface while the transmitter was talking to the real servos?   How would that work?

Jeff

JonnyMac

I think it would be very trick to capture the PPM stream from a buddy cable directly by a Windows PC -- the OS would make cricital timing measurements really tough. 

I'll make you a deal: You order a Prop-SX starter kit and I'll write a program that will use the Prop-SX to measure the PPM steam data (I have to use the VEX which has six channels) and converts it to a serial output that you can capture with VB.  I won't be able to get to the program until next week, but I know it's doable as I have already done stuff with the VEX PPM output.
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

Jon I would buy a Prop-SX starter kit if it helps whether I used it or not.     But I am confused?  How does this help?   Are you suggesting that the VEX transmitter interfaces with the Prop-SX that drives the servos?  How is the PC connected?  How would VB interface into this?  What would the data look like? AAAGGGGG I don't get it?   BTW I am not in a huge hurry for this solution.  The reason for my flurry of posts is that I am trying to determine up front if I will be using a Prop-2 or SX to drive this guy and how the programming will work.   I have some more work to do on the mechanics but I am close.  I was hoping to bring the skull with me to RMG in June to show you guys.  I figure after that weekend I would get started on programming the actual show (record audio track and animate). 

I was planning on buyng a Prop-SX starter kit from you guys at Hauntcon along with 4 long extensions and at least  a couple of Prop-1's for other projects.   

JonnyMac

This week is bear, but next week I may be able to do the PPM to serial interface.  If I can pull it off I'll bring my VEX transmitter to HC and we can experiment with it.
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

OK, I bought my Prop-SX starter kit at Hauntcon.   I have almost got the mechanics to the talking skull done.    Here is a video of it if anyone is interested.  I have it hooked up to a 4 channel Futaba Transmitter/Reciever right now to test the movements.   As soon as I get some fine tuning done I want to get started on the programming.   I already have my uMP3 hooked up for the audio and I have my 12V LED spotlights to light the face up.

http://www.youtube.com/watch?v=0Bnhpvc4d60


robomaster-1

I have an Idea on how to break the PC connection. I use the VSA program that Skulltronics uses and it has an option the allows you to put the sequences onto an audio CD. The VSA company use to sell a modified CD player that had some circuitry the took the control information and convert it back into the serial data that is sent to the servo board. I am currently working on my own version of this circuitry. I am going to end up with is a way to store this data on a Pin drive and be able to play back shows form it.  John can your board be made to be VSA compatible?
Tim J. Lewis
Magic and Technology

JonnyMac

Quote from: robomaster-1 on May 20, 2008, 01:47:18 PM
<snip> John can your board be made to be VSA compatible?

Can you be more specific?  I've already demonstrated that the Prop-SX can be programmed to act as a servo and PWM driver for VSA, and I've supplied programs to just that in our Library section
Jon McPhalen
EFX-TEK Hollywood Office