• Hi !

    I'm currently trying to get some servos working nicely with an original Espruino board ( and also within a chrome browser ).

    The overall goal is to have a video & synchronized servo movements ( controlled, if can do so, by the audio channel within the video, or within a "tied" audio file, or on-the-fly-generated signals )

    I solved the "45° mystery" thanks to http://forum.espruino.com/conversations/­316585/, which now allows me to move each of the servos I have using the following:

       /*
       micro servo SG90 on C8:
       Position "0" ( 1.5 ms pulse ) is middle,
               "90" (~2 ms pulse) is all the way to the right,
               "-90" (~1 ms pulse) is all the way to the left.
       */
       //var s2 = require("servo").connect(C9);
       // servo.move() doesn't work for my microservo ( SG90 ): here's what works
       analogWrite(C9, 0.03, {freq:50}); // -> full left ( -90deg )
       analogWrite(C9, 0.07, {freq:50}); // -> middle ( 0deg )
       analogWrite(C9, 0.115, {freq:50}); // -> full right ( 90deg )
    

    Now, I'm looking for a replacement for the servo.move() fcn ( or a tweak of it ) that'd allow me to go to a certain position & taking some time to do so - not sure of what to change, one of my guesses is tweaking the following part ?

    digitalPulse(pin, 1, offs+E.clip(currentPos,0,1)*mul);
    // IDEA: clip to 0.03..0.115 ?
    

    On a close subject, I'm also trying to get the same servos to move:

    • using an audio file ( or an audio channel of a video ) with "recorded" movements from the servos ( when controlled from an Espruino running some code to generate the signals )
    • using the WebAudioAPI to generate the necessary signals

    I stumbled on 2 related posts ( http://www.massmind.org/techref/io/servo­/wav.htm & https://github.com/pendragon-andyh/WebAu­dio-PulseOscillator ) which led me to messing around & try stuff, but I didn't achieve ( yet :/ ) my goal of controlling the said servos using purely on-th-fly-generated signals from the WebAudioAPI

    Last but not least, I'm aware of the 'ontimeupdate' evt that's available when a video is playing ( & yup, I plan to use it to trigger generating on-the-fly signals sync-ed with the video content )

    This being said, here's the code I have so far, I'll be hacking around with it today & the coming days, hopefully coming to a success .. ( .. thanks to hints from here ? ;p )

    Thanks in advance for reading this,
    Looking forward to reading anything on the subject

    ps: test files attached ;)


    3 Attachments

About

Avatar for stephaneAG @stephaneAG started