May 04, 2024, 10:43:37 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.


Use HC-8+ to control servos in a talking head

Started by davisgraveyard, August 14, 2017, 10:33:20 PM

Previous topic - Next topic

davisgraveyard

I've tried with both BR on and off.   Not sure which is best?  2400 is probably just as good for AP16  commands.   Checked that 5v is on R with meter.   

Program reads data but servo and AP16 commands not working still?

JackMan

 Really doesn't matter, as long as both BR settings match. At this point I'm out of hardware possibilities, maybe Jon can help.

davisgraveyard

Could it have anything to do with the firmware on the board or the rev of the board.  It is a Rev C  2011? 

davisgraveyard

Just in case I tried uploading both E and F versions of the firmware online.  Still no servo or audio.   But now the card reader isn't working either.  No data being red.  The green light comes on and stays on right after power up.  Nothing else happens.

When I first set the board up and was testing the Propeller Tool IDE I did a Load EPROM but didn't have a BIN file loaded.   Could that have done something?  This was before you ever gave me any code to test.

Jeff

davisgraveyard

Success!  Sort of.  I reloaded the F firmware version.  Reloaded the program and the servos started working.   I am still not getting any audio commands that I can tell?


Jeff

JonnyMac

August 24, 2017, 12:47:59 PM #20 Last Edit: August 25, 2017, 02:41:47 PM by JonnyMac
I'm going change my suggestion about 38400 baud. The AP-16+ (until Rev E) uses a serial interface device that can be finicky*. I also went through and updated some of the AP-16+ routines in your program, based on a general template that I updated today.

This version works on my desk; the servos operate and the play command is sent to the AP-16+. Once audio plays on your end, we can get to a "production" type program. If you're going to want a constant status update from the AP-16+ we'll have to use a secondary cog so that we don't interfere with the main loop timing.

* We have changed the serial interface circuitry on the AP-16+ (Rev E and onward) and AP-8+.


Attachment removed -- see end of thread for final program.
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

August 24, 2017, 10:36:35 PM #21 Last Edit: August 24, 2017, 10:42:04 PM by davisgraveyard
OK got some details to report back.  Prior to getting your latest code I was able to get everything working with the BR set to ON on both boards. 

Couple of strange behaviors though.  I can ONLY get the program to execute if I press F10 and then F12 and then hit enter.  If I power off the board and back on and then hit F12 to debug and hit enter I either get no response or I get a can't read card (mostly no response) it is as if the servos get intialized when the program loads that doesn't happen on power up?

The other odd thing is that my audio file plays fine up until a certain point (about 3/4 of the way in) and then audio cuts out.  Green light still flashing nothing else wrong.  just no sound out the speaker outputs.  I tried both Left and Right screw downs and it did the same thing.

I switched to both boards having BR off and used your new code.  Had to change the file to "sfx"  not "sfx00"  and press F10 and F12 and it runs.  But still not on power up.  and the audio still cuts out after a while.

I don't need to check audio status unless that is the only way to test for the playback end.  If you have to check I am find with 1-2 seconds.  The sound can end and have a 1-2 second delay.  I'll try attaching the audio file so we are in sync.

but I want servo movement to stop after the audio has ended.   I tried using the larger servos2.txt file I upload a earlier in this thread.  It has the movements smoothed out.  Works REALLY well.  But we can also do it in code and use the smaller file too.

here is the audio file.  Too big to upload
https://drive.google.com/open?id=0BzJ0BzAn5tyoQ202alNGRm84Yms



JackMan

 If you manually start the AP-16 audio, does it play completely or does it stop mid-stream?

davisgraveyard

Fixed it.
Even if I manually start the audio file on the AP16+  it stops output but continues to plan about 3/4 of the way through.  I went back to the original MP3 file and converted to a WAV like I do for all my AP16 audio.  Same problem.  This is a Rev C board so I updated to the latest Firmware.  Now it plays through fine.

JonnyMac

August 25, 2017, 02:39:13 PM #24 Last Edit: August 26, 2017, 11:17:13 AM by JonnyMac
Remember... this is a very complex program. I have gone step-by-step so that you can learn those steps and make adjustments as needed. The attached program is "prop ready." It has been running on my desk all morning.

Notes/Comments:
-- While the AP-16+ can play stereo files encoded at 44.1kHz, some SD cards cannot keep up
-- Your original file worked fine with my SD card; still, I re-encoded to mono, 32kHz. This takes a lot of strain off the SD card with no perceptible change in quality.
-- The link to the mono file is in the listing -- note that it's about 36% the size of the original
-- Reformat your SD card before putting the file (named as SFX00.WAV) and NORELAY.TXT on it
-- Set the BR switch on the AP-16+ to OFF for 2400 baud; best with open wire connections
-- If DEBUG is set to YES, you must open the terminal and press a key to start; this lets you watch things in progress
-- I created a scaled milliseconds constant (MS_ADJ) so that the movements end with the audio
-- A red light indicates a problem; the LED with flash green when playing show

Again, there is a lot to learn from this. I have included comments and divided the program into small, atomic methods to make things clean.
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

Do you still use Audacity to re-encode to mono 32Khz?  Or how did you convert the WAV file?


JonnyMac

Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

Here's what I did with my WAV file.  Loaded it into Audacity.  Split the stereo to mono.  Deleted the 2nd mono channel.  Export to WAV (Microsoft) signed 16-bit PCM.  This produced a much smaller WAV file which sounds exactly the same.  Formated the SD card and copies on the new exported WAV

I had the right 2 pins on the PIR of the AP-16+ jumpered so the sfx00.wav would auto start. Renaming the file to sfx.wav works.   So I removed the jumper and then renamed it back to sfx00.wav and it didn't autostart.  Switches 1-6 are OFF.  and the audio selector is set to 0.  Now when I power it up it just waits.

The latest program seems to run very well when I first load it.  Pressing F10 loads it and it runs first fading the LED then powering up the eyes, then starting the audio and then playing the servo data.  When the audio is done the LED fades and the eyes turn off and the servos stop.  There is a 2 minute delay then it starts again.

Couple of issues.

the LED fade up is TOO fast.  Fades up very quickly needs to be 2-3 slower.
I am unable to get the program to start from a cold power on.  Either turning the power switch off/on or unplugging power and replug.  The only way I can get it to start again is to reload the program.  When I press F10 there is an initial servo sync that happens before the program starts.  This does not happen when I power off and on.

we are VERY close.



davisgraveyard

I am able to tweak the line

fade_spotlight(0, 255, 2000)

to

fade_spotlight(0, 255, 6000)

to get the fade slow enough.

One other observation besides the code only runs when compiled.

I am not able to get the debugger to work anymore.  When I press F12 nothing ever gets output even though I see the term.str code?



davisgraveyard

Arrrg....nevermind.   DEBUG = NO

set it to DEBUG = YES and now the debug window works.  Still not getting power on execution though?