Add/Remove Board and PWM

13 views
Skip to first unread message

fohnbit

unread,
Apr 22, 2016, 2:28:03 AM4/22/16
to libbulldog
Hello,

when I create an instance of my class, I run this commands:
private final Board board = Platform.createBoard();

public void init() {
pwm1 = board.getPin(BBBNames.EHRPWM0B_P9_29).as(Pwm.class);
                    pwm2 = board.getPin(BBBNames.EHRPWM0A_P9_31).as(Pwm.class);
                    pwm1.setFrequency((float) getPropertyFrequenz9_21_22());
                       pwm1.setDuty((float) getPropertyDutycyclep9_21_22());
                  pwm1.enable();
                 
                       pwm2.setFrequency((float) getPropertyFrequenz9_21_22());
                       pwm2.setDuty((float) getPropertyDutycyclep9_21_22());
                  pwm2.enable();
}


When I destroy my class, I made this before:
        public void cleanup() {
        board.shutdown();
      }


But sometimes the board will not be creadet ... send error Message when I have it


Then I setup the PWM:

   
pwm1 = board.getPin(BBBNames.EHRPWM0B_P9_29).as(Pwm.class);
                        pwm2
= board.getPin(BBBNames.EHRPWM0A_P9_31).as(Pwm.class);
                        pwm1
.setFrequency((float) getPropertyFrequenz9_21_22());
                        pwm1
.setDuty((float) getPropertyDutycyclep9_21_22());
                        pwm1
.enable();
                       
                        pwm2
.setFrequency((float) getPropertyFrequenz9_21_22());
                        pwm2
.setDuty((float) getPropertyDutycyclep9_21_22());
                        pwm2
.enable();

I get Frequenz and Duty Cycle with:
getPropertyFrequenz9_21_22()
getPropertyDutycyclep9_21_22()

But how I can change Frequenz?

with:
        public void onPwmp921(boolean value) {
               
if (value) {
                        pwm1
= board.getPin(BBBNames.EHRPWM0B_P9_29).as(Pwm.class);
                        pwm1
.setFrequency((float) getPropertyFrequenz9_21_22());
                        pwm1
.setDuty((float) getPropertyDutycyclep9_21_22());
                        pwm1
.enable();
               
} else {
                        pwm1
.disable();
               
}

       
}


Disable work.
Apr 22 06:24:20 bone kernel: [  808.782079] bone-capemgr bone_capemgr.9: Removed slot #29

But when set "value = true" I get:
Apr 22 06:24:56 bone fohn[619]: java.lang.reflect.InvocationTargetException
Apr 22 06:24:56 bone fohn[619]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Apr 22 06:24:56 bone fohn[619]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
Apr 22 06:24:56 bone fohn[619]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Apr 22 06:24:56 bone fohn[619]: at java.lang.reflect.Method.invoke(Method.java:483)
Apr 22 06:24:56 bone fohn[619]: at com.fohn.core.base.Node.incomingEventMethod(Fohn.java:755)
Apr 22 06:24:56 bone fohn[619]: at com.fohn.core.base.EventManager$NodeQueueThread.run(EventManager.java:436)
Apr 22 06:24:56 bone  fohn[619]: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
Apr 22 06:24:56 bone fohn[619]: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
Apr 22 06:24:56 bone fohn[619]: at java.lang.Thread.run(Thread.java:745)
Apr 22 06:24:56 bone fohn[619]: Caused by: java.lang.NullPointerException
Apr 22 06:24:56 bone fohn[619]: at org.bulldog.beagleboneblack.gpio.BBBPwm.enableImpl(BBBPwm.java:155)
Apr 22 06:24:56 bone fohn[619]: at org.bulldog.core.gpio.base.AbstractPwm.enable(AbstractPwm.java:23)
Apr 22 06:24:56 bone fohn[619]: at com.fohn.home.base.fohn.onPwmp921(GDfohn.java:951)
Apr 22 06:24:56 bone fohn[619]: ... 9 more



So how I can change the PWm settings in Lifetime?

Thank you!
Reply all
Reply to author
Forward
0 new messages