How could I go about an animatronic sequencer?

Thread Starter

line_code

Joined Aug 8, 2018
24
Hello everyone!

I am trying to develop a software that I can use to sequence animatronic movements. Essentially, I need to be able to load an audio file, press buttons on the keyboard to sequence each movement, and then be able to play it back with the recorded keyboard presses lined back up exactly with the audio. When I press each button on the keyboard (ASDFJKL; which are assignable to many different movements), a serial command needs to be sent to an Arduino which controls the animatronic. Each movement can be recorded separately or eight of them at the same time. With each additional pass of animation, the previous passes also need to be simultaneously played back.

I have all of this working to a certain degree in a VC# program, but the playback timing is very poor. Each movement is always a little early or late to turn on or off. I am using the multimedia timer on this website for timing. Each time I press or release a key on the keyboard, a serial command is sent to the Arduino and the current timer position is saved in a list box. When the show is played back, each timer tick checks each list box to see if the current position matches the selected entry in the list box. If it does, the corresponding serial command is sent out and the selected entry in the list box is advanced by one.

Is there a way I can improve the timing? I really would like the audio and movements to line up the exact same every time and to exactly match the timing from when I pressed the buttons originally. I am not opposed to trying a totally different approach and starting all over, and I'd prefer to stay using Visual Studio (VB, VC#, or VC++ are all fine), but at this point I'm willing to use anything that would work.

Do I need a real time OS to do this? I really don't think I do because I've seen similar software that works just fine on a regular Windows computer (like this one).

I feel like I may have been a bit unclear, so if anyone wants to see some of my code or needs clarification on something, please ask.
 

John P

Joined Oct 14, 2008
2,026
I'm skeptical about the idea of a PC controlling an external device via a serial port (which I assume really means USB) where timing is important. It might work better if you had all the timing done on the Arduino, with the program started by the PC but free-running after that. But then you say there's a sound file, which you probably want to play on the computer. Could the "start program" command to the Arduino be synchronized adequately with the start of the audio file? It might be OK, if it has the same relationship every time.
 

Thread Starter

line_code

Joined Aug 8, 2018
24
I'm skeptical about the idea of a PC controlling an external device via a serial port (which I assume really means USB) where timing is important. It might work better if you had all the timing done on the Arduino, with the program started by the PC but free-running after that. But then you say there's a sound file, which you probably want to play on the computer. Could the "start program" command to the Arduino be synchronized adequately with the start of the audio file? It might be OK, if it has the same relationship every time.
Though that would probably work, I really don't want to do that.

There just has to be a way to do this. There are lots of programs out there that work similar to how I'd like mine to work (Director by Fright Props, VSA by Brookshire Software, or VenueMagic). My favorite one is Director by FrightProps, but it isn't open source and it only works with their boards. Director pretty much looks and works exactly how I want, minus the fact that I need to control a lot more things than they allow and the fact that I would have to use their boards.

If you really want to, you can download Director for free at this link: Director

And yes, it is USB. Well, its USB to serial, so the computer sees it as a serial port, though it likely functions much differently than a real serial port.
 

John P

Joined Oct 14, 2008
2,026
If this Director program that you mention works only with external equipment, then I wonder if it's really doing what I suggested before--the computer is making up a schedule, and handing it off to a processor on an external board, and that's where the actual timing is done.

There are companies that sell what they claim is real-time processing software for a PC, but I bet it's expensive:
https://www.manufacturingtomorrow.c...ver-software-only-real-time-performance/8131/

You could look at timing functions available on a PC (depends on your programming environment and skills). Maybe this could be a starting point:
https://docs.microsoft.com/en-us/windows/desktop/SysInfo/acquiring-high-resolution-time-stamps
 

Thread Starter

line_code

Joined Aug 8, 2018
24
If this Director program that you mention works only with external equipment, then I wonder if it's really doing what I suggested before--the computer is making up a schedule, and handing it off to a processor on an external board, and that's where the actual timing is done.

There are companies that sell what they claim is real-time processing software for a PC, but I bet it's expensive:
https://www.manufacturingtomorrow.c...ver-software-only-real-time-performance/8131/

You could look at timing functions available on a PC (depends on your programming environment and skills). Maybe this could be a starting point:
https://docs.microsoft.com/en-us/windows/desktop/SysInfo/acquiring-high-resolution-time-stamps
I'm not convinced that the external hardware is doing the timing because you don't have to have the hardware connected to use the software. It functions the same whether the hardware is connected or not.

The Director software only uses 30 "frames" per second, meaning the shortest pulse the animatronic could receive is roughly 30 milliseconds long. This is really as precise as I need. I guess every 30 milliseconds, the software needs to check the keyboard for any new activity, update the hardware, and tick forward one frame.
 

KL7AJ

Joined Nov 4, 2008
2,229
Hello everyone!

I am trying to develop a software that I can use to sequence animatronic movements. Essentially, I need to be able to load an audio file, press buttons on the keyboard to sequence each movement, and then be able to play it back with the recorded keyboard presses lined back up exactly with the audio. When I press each button on the keyboard (ASDFJKL; which are assignable to many different movements), a serial command needs to be sent to an Arduino which controls the animatronic. Each movement can be recorded separately or eight of them at the same time. With each additional pass of animation, the previous passes also need to be simultaneously played back.

I have all of this working to a certain degree in a VC# program, but the playback timing is very poor. Each movement is always a little early or late to turn on or off. I am using the multimedia timer on this website for timing. Each time I press or release a key on the keyboard, a serial command is sent to the Arduino and the current timer position is saved in a list box. When the show is played back, each timer tick checks each list box to see if the current position matches the selected entry in the list box. If it does, the corresponding serial command is sent out and the selected entry in the list box is advanced by one.

Is there a way I can improve the timing? I really would like the audio and movements to line up the exact same every time and to exactly match the timing from when I pressed the buttons originally. I am not opposed to trying a totally different approach and starting all over, and I'd prefer to stay using Visual Studio (VB, VC#, or VC++ are all fine), but at this point I'm willing to use anything that would work.

Do I need a real time OS to do this? I really don't think I do because I've seen similar software that works just fine on a regular Windows computer (like this one).

I feel like I may have been a bit unclear, so if anyone wants to see some of my code or needs clarification on something, please ask.
 

KL7AJ

Joined Nov 4, 2008
2,229
I am a great fan of National Instruments Labview. They have some great motion control VI packages. It's not cheap, but you can get demo versions of Labview to play with.
 

Thread Starter

line_code

Joined Aug 8, 2018
24
I found an article that explains the problems of Windows as a real-time operating system. It says that you can achieve a certain amount, but it's very hard to be sure that it's going to work all the time, on any system. It gives me a definite feeling that this is not something I'd want to get involved with.

https://www.osr.com/nt-insider/2014-issue3/windows-real-time/
So let me ask about my backup idea. Could I get reliable results if I used an external audio player with an LTC track synced up with the audio? What would be a good way to get the LTC from audio to a number in my program? Would using PCTimcode (link) to connect the LTC to my program be reliable(it can be linked to a C# program)?http://www.al-ga.jp/
 
Top