Before going into testing your code, I'd like to just give a bit of a
review below to try to understand some of your motivations....

BTW, what version of BoneScript are you running?


On Sat, Mar 1, 2014 at 1:12 PM, <suie...@gmail.com> wrote:

> Hallo
> I am writing here beacause i have problem with my program. I am debuging
> in cloud9 ide. Program is running through few seconds, they works, but
> later i have this error. "timers.js:103
>             if (!process.listeners('uncaughtException').length) throw e;"
> . Can anyone help me.
>

Was there not a full stack trace? I guess we could start to look at the
timers.js source to see why it was looking for 'uncaughtException'
handlers, but I suspect you'll be happier if we just remove the source of
the exception.


> var b = require('bonescript');
>>
>> var k = 63;
>>
>> var  f = 174.5;
>>
>> var  re = 130;
>>
>> var  rf = 119.5;
>>
>> var sqrt3 = Math.sqrt(3);
>>
>> var sin120 = sqrt3/2.0;
>>
>> var cos120 = -0.5;
>>
>> var duty_min = 0.1250;
>>
>> b.pinMode('P9_14', b.OUTPUT);
>>
>> b.pinMode('P9_14', b.OUTPUT);
>>
>> b.pinMode('P9_14', b.OUTPUT);
>>
>>
Why are you doing this 3 times?


> check();
>>
>> function check(){
>>
>> var analogone =(120*b.analogRead('P9_40')-60).toFixed(2);
>>
>> var analogtwo =(120*b.analogRead('P9_39')-60).toFixed(2);
>>
>> var analogthree =(80*b.analogRead('P9_38')-180).toFixed(2);
>>
>> console.log([analogone,analogtwo,analogthree]);
>>
>>
If this was running a few seconds, I assume this provided some output. Why
didn't you provide that in the log so that we know where your program might
be failing?


> calcinverse(analogone,analogtwo,analogthree);
>>
>> }
>>
>> function updateDuty(thetaone,thetatwo,thetathree) {
>>
>>     var duty_cycleone = (thetaone*(-0.0006944))+duty_min;
>>
>>     var duty_cycletwo = (thetatwo*(-0.0006944)) + duty_min;
>>
>>     var duty_cyclethree = (thetathree*(-0.0006944)) + duty_min;
>>
>>     b.analogWrite('P9_14', duty_cycleone, 60);
>>
>>
Are you confident these duty values are floating-point numbers between 0
and 1?

If you know how to do things on the command-line, you can check out some of
these values:

root@beaglebone:/var/lib/cloud9# cat /sys/devices/bone_capemgr*/slots
 0: 54:PF---
 1: 55:PF---
 2: 56:PF---
 3: 57:PF---
 4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
 5: ff:P-O-L Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
 8: ff:P-O-L Override Board Name,00A0,Override Manuf,am33xx_pwm
10: ff:P-O-L Override Board Name,00A0,Override Manuf,bspwm_P9_14_e
root@beaglebone:/var/lib/cloud9# cat /lib/firmware/bspwm_P9_14_e-00A0.dts
/*
 * Copyright (C) 2013 CircuitCo
 * Copyright (C) 2013 Texas Instruments
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * This is a template-generated file from BoneScript
 */
/dts-v1/;
/plugin/;

/ {
        compatible = "ti,beaglebone", "ti,beaglebone-black";

        /* identification */
        part-number = "BS_PWM_P9_14_0xe";

        /* state the resources this cape uses */
        exclusive-use =
                /* the pin header uses */
                "P9.14",
                /* the hardware IP uses */
                "ehrpwm1A";

        fragment@0 {
                target = <&am33xx_pinmux>;
                __overlay__ {
                        bs_pwm_P9_14_0xe: pinmux_bs_pwm_P9_14_0xe {
                                pinctrl-single,pins = <0x048 0xe>;
                        };
                };
        };

        fragment@1 {
                target = <&ocp>;
                __overlay__ {
                        bs_pwm_test_P9_14 {
                                compatible      = "pwm_test";
                                pwms            = <&ehrpwm1 0 500000 1>;
                                pwm-names       = "PWM_P9_14";

                                pinctrl-names   = "default";
                                pinctrl-0       = <&bs_pwm_P9_14_0xe>;

                                enabled         = <1>;
                                duty            = <0>;
                                status          = "okay";
                        };
                };
        };
};
root@beaglebone:/var/lib/cloud9# cat
/sys/devices/ocp*/bs_pwm_test_P9_14*/period
16666667
root@beaglebone:/var/lib/cloud9# cat
/sys/devices/ocp*/bs_pwm_test_P9_14*/duty
8333334



>     b.analogWrite('P9_21', duty_cycletwo, 60);
>>
>>     b.analogWrite('P8_13', duty_cyclethree, 60);
>>
>>     console.log([duty_cycleone,duty_cycletwo,duty_cyclethree]);
>>
>>     check();
>>
>> }
>>
>> function theta(x0,y0,z0)
>>
>> {
>>
>>     var y1 = (-0.5) * 0.57735 * f;
>>
>>     var y2 = y0 - (0.5 * 0.57735 * k);
>>
>>     var  a = (x0*x0 + y2*y2 + z0*z0 +rf*rf - re*re - y1*y1)/(2*z0);
>>
>>     var b = (y1-y2)/z0;
>>
>>     var d = -(a+b*y1)*(a+b*y1)+rf*(b*b*rf+rf);
>>
>>      if (d.value < 0)
>>
>>      {
>>
>>     return;
>>
>>      }
>>
>>      var yj = (y1 - a*b - Math.sqrt(d))/(b*b + 1);
>>
>>      var zj = a + b*yj;
>>
>>      var h;
>>
>>      if (yj>y1)
>>
>>      {
>>
>>       h=180;
>>
>>      }
>>
>>      else
>>
>>      {
>>
>>      h=0;
>>
>>      }
>>
>>    var thetaa = (180.0*Math.atan(-zj/(y1 - yj))/Math.PI)+h ;
>>
>>    return thetaa;
>>
>> }
>>
>>     function calcinverse(x0, y0, z0)
>>
>>     {
>>
>>      var thetaone =theta(x0,y0,z0);
>>
>>      var thetatwo= theta(x0*cos120 + y0*sin120, y0*cos120-x0*sin120, z0);
>>
>>      var thetathree= theta(x0*cos120 - y0*sin120, y0*cos120+x0*sin120,
>>> z0);
>>
>>      console.log([thetaone,thetatwo,thetathree]);
>>
>>      updateDuty(thetaone,thetatwo,thetathree);
>>
>>  }
>>
>>                                                                       ^"
>
> --
> For more options, visit http://beagleboard.org/discuss
> ---
> You received this message because you are subscribed to the Google Groups
> "BeagleBoard" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to beagleboard+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beagleboard+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to