Issues replicating halloween motion tracking skull

I’m trying to replicate this 2016 project and am having several issues:
I’ve used exactly the updated script that uses the proportional coefficient. I’ve also tried the original code with the “endif swap” correction. batteries are fresh/new and have tried 4 different ones. as noted, I’ve tried 2 different boards and two different servo’s. All settings in the control center remain as default except that I changed the channel 0 to servo, channel 1 and 2 to input and changed the USB rate to 9600.

  1. The skull always returns to the far right position instead of the middle. I would like it to stay where it was when the field of motion is no longer disturbed or at least back to the middle position.
  2. the motion sensors are not sensing anything beyond about 12". they are supposed to be rated for up to 5’.? no skull motion happens unless within the ~12".
  3. there seems to be some feedback or bad signal affecting the servo. when no motion is detected the servo is shaking back and forth slightly and it almost sounds like static. when the servo slowly (via the static) meanders back to the right hand stop, the static typically stops. it then starts again once the servo stops after detecting motion. I don’t notice the sound as much when the plastic skull isn’t attached so I’m wondering if it is the torque of the head causing the servo to readjust or if there is some other feedback loop issue. however even without the skull attached, the servo slowly ratchets back to the far right position. I have tried two different micro maestro boards and two different servo’s.
  4. the setup won’t run when only on the battery power and not connected via usb. I’ve set the script to run on startup. I connect the jumper wire from the board pin to the I/O controller power pin. the unit starts but then stops immediately, the red led flashes for a second, unit restarts, red led flashes, etc… no errors are shown when I reconnect via the USB.

thanks in advance for help

a little more info on issue 3… even when I stop the script completely the skull continues to shake back and forth like a bobblehead at the full right position… and the buzzing sound continues… i have a video if there is a way to send it.

also i noticed that the servo actually doesn’t turn the full available travel all the way to full left or full right that is available when I take readings if I turn it manually with nothing attached.

Hello.

It sounds like there is a lot going on, and I suspect there could be multiple issues based on your descriptions. The video you mentioned would probably be very helpful. If the video is less than 5120KB, you can upload to the forum it by dragging and dropping it into your reply window, or using the “upload” button above the text box when writing your reply. If it is larger than that maximum file size, you might try posting it to a file sharing website and linking to it here. Alternatively, you could upload it to a site like YouTube.

Could you also post pictures of your setup that show all of your connections? What kind of batteries are you using you when you try powering the Maestro separately from the computer? Also, could you post your Maestro settings file? You can save your settings file by selecting the “Save settings file…” option with in the “File” drop-down menu in the Maestro Control Center (while the Maestro is connected to your computer).

By the way, it sounds like you might be expecting the servo to center itself if it does not see anything; please note that both versions of the code in the “Motion tracking skull Halloween prop” blog post only center the servo when the code is first started. After that, it should move solely based on the sensor readings. You might also double check that your sensors are connected to the same pins I used. If you have them flipped from what the code expects, it could try to move away from sensing anything instead of toward it. For reference, I connected the sensor under the skull’s left eye to channel 1 and the one under the skull’s right eye to channel 2.

Brandon

thanks for the help. link for the videos:

IMG_2541[1].MOV

IMG_2542[1].MOV

IMG_2542[1].MOV

Shared with Dropbox

IMG_2541[1].MOV

Shared with Dropbox

note that the 9V battery in the pic is just for clearance… not attached for power. I used the 4 AA battery holder you used and 4 new energizer 1.2V AA batteries (i also swamped them for 4 other new ones).

Regarding the pins for the sensors, I figured that part out when it moved the opposite direction, so that doesn’t seem to be an issue. unfortunately I disassembled the setup to move everything but the wiring was exactly as shown in your original pictures. Also, I’ll have to reconnect it all to get a Maestro settings file saved; but I didn’t change any settings from the default except for the selecting the serial Baud 9600, activating Pin 0 as a Servo and, 1 &2 as inputs and checking the Run script on setup box. everything was as installed. software version 1.2.

My main concern is the wobbling of the servo back and forth and the noise. Second is the sensor distance. these sensors are rated for a few inches to about 5 feet. I’ve tried them facing various directions with various lights on and off and blinds open and closed but can get anything to register more than a few inches away. granted 5’ is probably to small of a voltage to trigger the skull; but i would expect that middle range of 2.5’-3’ should…

Any help and insights appreciated!

It is hard to tell if there was anything in front of the sensors in your test. Which version of the script were you running in those videos? The first script works by taking a reading of both sensors and subtracting them. Then it compares this difference to some threshold values (±140) and only moves the servo if the difference is larger. You could try increasing the threshold to make it less sensitive to noise.

If that does not help, could you post a video showing the “Status” tab of the Maestro Control Center while your program is running? Also, during this test, could you try moving a white sheet of paper toward and away from each sensor to show what kind of signals they are giving?

The problems you have when you try to run the Maestro without the USB connection might be from your batteries. Please note that the minimum operating voltage for the Maestro is 5V. If you are using rechargeable batteries, the fully-charged voltage should be enough (even though the nominal voltage is 4.8V). However, with the servos moving and the sensors drawing bursts of current, it might be dropping the voltage too low and causing the Maestro to brown out. Do you have another power source you could try?

Additionally, if you have access to an oscilloscope, captures of the sensor readings as well as the supply voltage while the script is running would probably be helpful.

By the way, since your sensors are not connected to the skull, it probably won’t actually track and settle on the target. For example, if someone is standing just to the right of center, the skull would turn all the way in that direction, since the sensor readings would never equalize.

Brandon

please be assured that all of the things you have suggested I have tried. your NiMh batteries in your post have no more or no less voltage or voltage drop or mAhrs than a standard AA battery. Since I have tried multiple batteries straight from a new package with each setup, the batteries are not the problem. especially considering that the static problem persists even when on usb power…

everything is exactly as you have told the build to be. the batteries have no less or no more capability than what you described in your post. i don’t have an oscilloscope.

I can set everything back up to show you the status tab, and will post that in a couple days… I assure you that it will confirm everything I have already described, shown and tried.

I have tried moving the +/- 140 from everything from 50 to 250 in increments of 5… I have monitored the status tab to see the movement and registration of voltage or none thereof for anything beyond 6"…

I had originally connected the sensors to skull directly by the eye sockets and the result was even worse than shown in the video.

thanks again for your help and investigative troubleshooting… I’ve uploaded a bunch of videos and pictures to a new folder. including the Maestro setting file… operation with and without computer attachment (without seems to be mysteriously working with red led errors now)… also performance from various distances… seems to have improved in the night with same overhead lights on even though blinds were closed during the day… so must be light sensitive which is odd? which would prove problematic…

link to folder: skull

skull

Shared with Dropbox

thanks for any insights.

Thanks for the videos. The skull does seem to be tracking you, but it has a lot of overshoot and is oscillating instead of settling in the middle. I did run into similar oscillating problems every now and then in particular spots, but it looks like you are getting quite a bit of noise in your environment. I suspect the noise is making the sensors not work so well at longer ranges. The output of the sensor is not linear with distance, so noise is an even bigger proportion of the reading at longer ranges. You can see a graph of the output voltage vs distance in the datasheet, which can be found in the “Resources” tab of the GP2Y0A60SZLF sensor’s product page.

Part of the reason I recommended using a white piece of paper was to try to give the sensors the best chance of getting a strong signal back. If you have not tried that yet, you might do so just to see if the performance is any different. Also, have you tried the setup in a different location to see how much the environment is impacting the system?

I modified the second example to use a slightly different method of updating the servo position and use a speed limit. You might try it to see if it performs any better for you.

6000 0 servo #initialize servo position
255 0 speed #set speed limit
5000 delay #delay for set up purposes
  
begin

  #calculate error between sensors
  1 get_position
  2 get_position
  minus

  #apply proportional coefficient (1/60)
  10 divide

  #read the servo's current position and update it
  0 get_position
  plus	 0 servo
  
repeat

By the way, it looks like you are using Alkaline batteries, which have a slightly higher voltage than NiMH ones. Four Alkaline batteries (as you measured) should be around 6V, which is actually above the operating voltage range of the GP2Y0A60SZLF sensors (2.7-5.5V). They seem to still be working for you, but I recommend swapping to rechargable NiMH batteries.

Brandon