Shop OBEX P1 Docs P2 Docs Learn Events
using the Prop to create visual arrays for animatronics — Parallax Forums

using the Prop to create visual arrays for animatronics

DarcyDarcy Posts: 31
edited 2011-08-02 17:48 in Propeller 1
Hey there, fellow propeller noob, and I am working on an animatronic project where the movements will be controlled by pneumatic cylinders hooked up to a solenoid valve, so it is a simple on/off function.

I need to know how to get the propeller to read through a pattern, and to repeat that pattern once it gets to the end. I'm hoping to construct the code so it will have an easy to edit visual display, so that you can see how the valves will be triggered in relation to one another.

i'm assuming the code could look something like this:
Larm = %11001100110011001100110011001100
rarm = %00110011001100110011001100110011
tails = %00001111000011110000111100001111
bdup = %00000111111000011111100001111100
eyes = %00001111100110000111100110000111
mout = %00001111000000001111000000111100
sond = %00000011000000000111000000011100

by listing it in this format, i would be able to tell how the left and right arm would work together, i would be able to trigger the mouth to open before the audio goes off so it looks more natural, etc...

I know that i'm still early in my hunt for the proper code, but i wanted to see if you knew how to make a pinout cycle through this sequence, and then return to the beginning and repeat once it gets to the end of the code. I would adjust the timing of how quickly it goes through the cycle with the waitcnt(clkfreq + cnt)

i've typed up several pseudo codes, i just havent been able to get it to repeat one of these patterns.

any suggestions would be really beneficial for my quest.

Comments

  • localrogerlocalroger Posts: 3,452
    edited 2011-07-12 14:46
    This is easy. Start with a 1-bit mask and use the shift or rotate instruction to move it left or right one bit at a time, then test the bitwise and (& in propland) of your mask with your pattern and turn the pin on or off according to zero or not zero. If you use rotate it will cycle forever, if you use shift you'll have to reload the mask bit to restart.
  • tonyp12tonyp12 Posts: 1,951
    edited 2011-07-12 15:17
    How long is the animation?,
    Is 1/10second control precise enough?

    Say 1/10th is OK,
    Using 1 long and 'ROL wc' it, you would only have 3.2seconds before it restarts.
    With 4 longs and you get 12.8 secoinds.

    Nice thing is that you have RCL.
    TEST larm,_mybit31 wc ' needed as we need to set intial c status
    RCL larm+3,#1 wc
    RCL larm+2,#1 wc
    RCL larm+1,#1 wc
    RCL larm,#1 wc
    MUXC outa,_larmpin

    _larmpin long 1<<12 ' pin 12 for an expample.
    _mybit31 long 1<<31
    larm long %00000000_00001001_00011100_11111000, %00000000_00001111_00011100_11111000, %00000000_00001111_00011100_11111000, %00000000_00001111_00011100_11111000
    rarm long %00110000_00001111_00011100_11111000, %00000000_00001100_00011100_11111000, %00000000_00000011_00011100_10011000, %00000000_00001111_00011100_11001000

    It's easy to see how the left and right arm relate when all the data are aligned underneath each other. (resize windows explore max sideways)
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-07-12 16:13
    I do this kind of thing a lot; in fact, some of my code (identical to this) is running in a little product in a few Disney parks. The attached demo shows my table-driven approach that supports up to 16 outputs with timing for each record with 1ms resolution. A global variable called speed allows you to modify the overall sequence speed (100 is normal, lower is faster, higher is slower)

    This could be adapted to be run from an SD card for very long sequences. I suggest any software you're working on export a DAT section like the ones in my program -- at least until you get a handle on this and develop your own strategy.

    The program will run on a demo board or QuickStart as is.

    [ EDIT ] I simplified the interface to make the code easier to use.
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-07-13 07:44
    Here's a version of the program that's easier to use -- no more copy-and-paste of the cognew line (which can be unwieldy). This version also ensures that calling a new show while one is running will stop the first.
  • DarcyDarcy Posts: 31
    edited 2011-07-13 08:17
    Thank you for the suggestions, ill be away from the comp for a few days, but this'll really help me out when i get back, the global speed variable is a good thing too, i knew there was a more efficient way of speeding up/slowing down the sequence beyond adjusting the clockfreq... Some of the things i need to address for the final product is an audio repeater/amplifier, and at the least the sounds need to be read from an sd card, if not the code itself. The sequence will need to last at least a minute, you shouldnt ever be able to tell that the sequence starts and ends, the movements are for an animatronic dinosaur, so somewhat slow is a good thing. Cant wait to play around with your suggestions, thanks!
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-07-13 08:35
    With EFX-TEK (I'm a partner) I helped create the AP-16+ audio player that is available through Parallax. It uses the Propeller and plays WAV files from an SD card through two 20w amps (one for each channel of a stereo file). There is plenty of information on playing WAVs here in the forums -- sample code similar to what we use in the AP-16+ can be found in this thread:

    http://forums.parallax.com/showthread.php?123900-EFX-TEK-shows-the-Propeller-AP-16-WAV-Audio-Player-at-Parallax-wow!&highlight=ap16
  • DarcyDarcy Posts: 31
    edited 2011-07-13 10:44
    That Audio repeater from efx-tek is great, we had previously used one made by gilderfluke, which has almost the same specs as efx, but the one made by EFX-TEK will save you hundreds of dollars. Im definitely a fan of efx-tek, and I cant wait till we weed out the need for those expensive gilderflukes.
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-07-13 12:28
    Among many great features (if I do say so myself), the AP-16+ is definitely easier to control through a serial link. Last week I helped Hollywood creature creator, Steve Wang, add control, sounds, and lighting effects to a display. I'm not at liberty to share photos yet, but the display has the male and female characters, as well as the "thumper" machine seen in the video on this page:

    www.firefallthegame.com

    The game company was so happy to have a programmer involved (this is not the norm for these things) and and audio board (AP-16+) that could support their desires, that they sent me a bunch of audio assets from the game to be incorporated into the display. The first display went to China, a second is under construction now (it will go to Seattle).
  • DarcyDarcy Posts: 31
    edited 2011-07-23 20:45
    I just got back from my travels, tried out the code that you showed me, it seems neat, i'll have to slow down how quickly it cycles through the movements, but it is a major step in the right direction. Ultimately i will be controlling an average of 8 channels, potentially up to 20 depending on the size of the creature, the movements will be much slower since it is pneumatic, so you have to give the cylinders a second to fill with air, and the pressure is turned down so that the movement runs slowly and smoothly. I'll be in touch, thank you for your help, it makes this adventure so much more productive and fun.
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-07-24 08:50
    Hi Darcy,
    so you have to give the cylinders a second to fill with air, and the pressure is turned down so that the movement runs slowly and smoothly.

    I was working in a company that developed machines that used pneumatic cylinders a lot. For slow and smooth motion that starts instantly after opening the valve
    it is very common to use exhaust air throttles. These throttles reduce air-flow only in one direction. They were inserted on both sides of the two-way-cylinders.

    valve-ou1-throttle1-cylinder-throttle2-valve-out2. Opening valvle-ou1 drives the piston out. Opening valvle-out2 drives the piston back in.

    Now if valve-out1 opens throttle1 will let in the air without resistance. as the cylinders moves air goes out at the opposite. for air coming from the cylinder and then going into throttle2
    there is an adjustable resistance for the air. This combines two advantages: The air that goes into the cylinder can be at high pressure filling up the cylinder very fast. The movement is still
    slow and smoothly because of throttle2 and the speed is constant as the mechanical friction of the piston is low compared to the force created by the high pressure.

    If you use a low pressure or only one throttle on the side where the air goes in the piston will move and stop move and stop because compared to the low pressure the piston-friction
    is high.

    best regards

    Stefan
  • DarcyDarcy Posts: 31
    edited 2011-07-24 14:40
    StefanL38 wrote: »
    Hi Darcy,



    I was working in a company that developed machines that used pneumatic cylinders a lot. For slow and smooth motion that starts instantly after opening the valve
    it is very common to use exhaust air throttles. These throttles reduce air-flow only in one direction. They were inserted on both sides of the two-way-cylinders.

    valve-ou1-throttle1-cylinder-throttle2-valve-out2. Opening valvle-ou1 drives the piston out. Opening valvle-out2 drives the piston back in.

    Now if valve-out1 opens throttle1 will let in the air without resistance. as the cylinders moves air goes out at the opposite. for air coming from the cylinder and then going into throttle2
    there is an adjustable resistance for the air. This combines two advantages: The air that goes into the cylinder can be at high pressure filling up the cylinder very fast. The movement is still
    slow and smoothly because of throttle2 and the speed is constant as the mechanical friction of the piston is low compared to the force created by the high pressure.

    If you use a low pressure or only one throttle on the side where the air goes in the piston will move and stop move and stop because compared to the low pressure the piston-friction
    is high.

    best regards

    Stefan

    I have some adjustable one-way restrictors on both sides of the pneumatic valve to slow down the cylinder movement, similar to what you have described, so we'll visually tweak the air pressure as needed to create a more realistic movement
  • DarcyDarcy Posts: 31
    edited 2011-07-26 20:00
    I just saw a video about 12Blocks, which is a visual language that makes programming simpler and more visual. I wonder if this may be a possible solution for developing the code i need, while keeping it easy to edit.
  • kwinnkwinn Posts: 8,697
    edited 2011-07-26 20:13
    Why not give it a try? You can download a 30 day free trial version. See http://12blocks.com/.
  • HannoHanno Posts: 1,130
    edited 2011-07-27 20:07
    Hi,
    12Blocks lets you change parameters while your program is running.
    Just type a new value for the parameter (like a servos position) and the next time the block is executed it'll use that value.

    A while back I heard from a customer who was programming animatronic owls with 12Blocks. A bunch of servos controlled the owl's movements, he stubbed out a program to control the servos and then he adjusted the exact position of each servo while the program was running. Taking out the need to recompile/load made him more productive. And by not needing to remember spin vocabulary/syntax/grammar he could focus on other things- like owl mechanics :)
    Hanno
  • DarcyDarcy Posts: 31
    edited 2011-07-28 21:26
    yes, i downloaded the trial and explored the different settings. I saw that the program was very well written for working with servos, but i'm working with pneumatic valves, so i simply need to set an output pin to high for set intervals of time, and at an overall pattern that would last for at least a minute or so, so that you wouldn't be able to easily tell that it was just cycling through a series of movements. If the 12 blocks program would be able to achieve this i would most happily utilize the software. I think it is a great platform, i just am not sure if i will be able to utilize it for what i am needing. The servo setting does look great though, as well as the music applications that it could be used for, i look forward to trying it out for those experiments, i'm just not clear if it would be usable for what i'm needing to do.
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-07-30 06:28
    Have you tried jm_bitplayer_ez that I attached above? It allows you to "paint" your output sequences (in code) and includes a method that runs in its own cog so you can play sequence (or multiple sequences with a minor adjustment) concurrent with your main program.
  • DarcyDarcy Posts: 31
    edited 2011-07-30 15:14
    JonnyMac wrote: »
    Have you tried jm_bitplayer_ez that I attached above? It allows you to "paint" your output sequences (in code) and includes a method that runs in its own cog so you can play sequence (or multiple sequences with a minor adjustment) concurrent with your main program.

    Yes, i've been working with the code that you provided, thanks so much for your input. I'm still rather new to working with the propeller, so i'm experimenting with trying to manipulate the code you provided. I'm still a novice though so i'm working with a lot of trial and error on my part.
  • DarcyDarcy Posts: 31
    edited 2011-07-31 17:49
    Is the jm_bitplayer_ez set up for servos?
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-08-02 17:48
    Darcy wrote: »
    Is the jm_bitplayer_ez set up for servos?

    Nope, it's setup for pure digital outputs (hence the name "bit player" -- just what you asked for.

    That said, it would be easy to create a servo-player cog (would require a servo driver -- I have a really good one that I just used in my Nuts & Volts column), so you end put using two cogs for servo control. Still, you could have a cool little show controller with a main cog calling the bit outputs and the servo outputs at the same time; four cogs and cool show control -- though there is a small matter of programming (no WYSIWYG/GUI programming) on your part.
Sign In or Register to comment.