November 23, 2024, 07:13:06 AM

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.


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

August 14, 2017, 10:33:20 PM Last Edit: August 16, 2017, 07:47:15 PM by davisgraveyard
I am trying to convert a project from a Prop2  to the HC-8+.  What would the code look like?

Current Prop2 layout and logic
I have 3 servos on P8,9,10  (Nod, Tilt,Turn)
LCD Eye power on OUT 0
LED spotlight power OUT 1 PWM
Serial IO on P14 to a AP-16+
the red and white wires are active on the pins.  The black wire is wired to external power  and everything to GND.

1. PWM the LED spotlight
2. Power on the LCD eyes
3. Start playing SFX.WAV
4. Read data and position servos Nod,Tilt,Turn X times 20ms see data.csv  (add smoothing code data2.csv)
5.  Loop through all data checking if audio stops.  Start data over if audio still playing
6.  Power off LCD eyes
7.  PWM LED spotlight to off
8.  Wait 2 minutes
9.  Loop back to top

I have a HC-8+ labeled Rev C 2011 with a MicroSD board (c) 2012 on it

JonnyMac

Okay -- the first thing we have to do is write a driver that will read a line from the file and then convert it into four values. I will post that later so that you can try it on your HC-8+. Once we can read that table (converting from text into numbers), things should be fairly straightforward.
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

Seems like I recall attempting this when the HC-8+ first came out and I ran into an issue with GND and the servo outputs.  something about the way I wired it on the Prop2 and the way the power connections work on the HC-8+?   That ring a bell?


JonnyMac

I don't recall what happened early on, but from the beginning, the HC-8+ was designed for servos. We even went so far as to provide a method of "hacking" the board so that a separate power supply could be used for the header.

Back to the project at hand... I'm always for taking a "make sure the pieces work first" approach. I gathered all the pieces that you need and wrote a test program that does the hard part: read the file and parse the values from each line. Once it was working, I even made the display run in real time (I think). The loops value in the data is multiplied by 20ms for the delay, right?

As you can see, the program displays the current line from the file, the raw string, then the parsed position and looped values.

Move the data file to the SD card, install it on the HC-8+ (make sure all the option switches are off), and run the program. Note that I changed the name of the file on my end.

The code and a screen-shot from my system are attached. Note that I also measured the show time of the file.
Jon McPhalen
EFX-TEK Hollywood Office

davisgraveyard

yes the loops were every 20ms for the Prop2.   Tested the program.  Seems to run fine.   I'm using v 1.3 of the Propeller Tool is that current enough.  Any major updates I'd want?

I dug through my spare parts bin and found the Power Supply adapter you were talking about.   So even that issue can be resolved. 

I hunted through your code until I realized this is just testing the reading of the servos.txt file and playing it back.  No servo movement or AP-16 commands being sent.   

I've done the same thing.  I have the HC-8+, 3 servos, 2 12V LED's,  and a spare AP-16+ all sitting on my workbench.  Should be able to test all the parts first before adding the board to my existing project.

Jeff
 

JonnyMac

August 21, 2017, 06:07:58 PM #5 Last Edit: August 25, 2017, 02:41:20 PM by JonnyMac
This adds audio and servo output. If this works, we'll strip out all the debugging code and go to the final prop version.


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

davisgraveyard

Not seeing any servo movement.  According to the code they should be on h5,h6,h7?   I also made sure that the Dip switches 1-256 are are ON.  Code runs and the the debugger displays all the values as they are read but the servos don't move?


JackMan

Not sure what you mean as to h5, h6, h7. I think you're on the wrong header, those are inputs and are labeled "In" not"h". Servos outputs are the header toward the bottom.

davisgraveyard

wasn't wearing my glasses.  Yes those were In7,6,5   I tried the others first with no success but I moved them back.  The debug display still shows the values being read but the servos are not moving.  Tried the power switch at 1 and 2 didn't make a difference.  Saw the AP16 code and wired up the serial connection to the AP16+ but it didn't play the file.  I tested the board and it played the SFX.WAV file just fine manually.   But not with the HC-8+. 

davisgraveyard

Here is a pic of my setup

JackMan

Check to see if you're getting 5v on the R output pins.
Also, I can't see the config. switches under the SD card adapter, is BR off?

davisgraveyard

I totally forgot about that switch block under the card reader.   BR was off so I turned it on.  the other 3 switches are off.

I tried switching A1,A2 to on but then the card reader failed to read the file every time.  Turned them back off and the card reads the data but still no servos.  I'll grab my voltmeter tonight and test the pin for 5v.

Still no audio being played.


JackMan

You want the BR switch on the HC-8 off because that's where you have the BR switch on the AP-16, they have to match. (off is 2400)

davisgraveyard