Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 03 2019 04:30
    HarshaSatyavardhan commented #74
  • Dec 07 2017 19:59

    alexanderhiam on master

    Update README.md (compare)

  • Dec 07 2017 19:59

    alexanderhiam on master

    Update README.md (compare)

  • Sep 26 2017 16:31
    jlewallen18 commented #93
  • Sep 22 2017 21:05
    jlewallen18 opened #110
  • Sep 16 2017 06:06
    mrjaperez commented #18
  • Sep 16 2017 06:02
    mrjaperez commented #18
  • Aug 14 2017 19:16
    kdheepak commented #74
  • Aug 14 2017 19:07
    kdheepak commented #74
  • Jul 19 2017 03:15
    sarnold commented #82
  • Mar 01 2017 15:13
    jonturner53 commented #109
  • Mar 01 2017 15:13
    jonturner53 reopened #109
  • Mar 01 2017 15:12
    jonturner53 closed #109
  • Mar 01 2017 15:12
    jonturner53 commented #109
  • Mar 01 2017 15:00
    jonturner53 opened #109
  • Feb 27 2017 18:52
    jonturner53 opened #108
  • Oct 07 2016 17:29
    alexanderhiam commented #107
  • Oct 07 2016 17:09
    alexanderhiam commented #106
  • Aug 10 2016 17:36
    MatthewWest edited #107
  • Aug 10 2016 17:35
    MatthewWest opened #107
Alex Hiam
@alexanderhiam
or use 64 then divide the result by your gear ratio
might want to increase the time you're sampling over too, seems like it's going pretty slow
Harshit
@iamharshit
buts its going preety fast
at this point its rpm should be near to 460
i think the pulse per rotation=16*19
=304
  GNU nano 2.2.6           File: pid-v2.py                   Modified  

from bbio import *
from bbio.libraries.RotaryEncoder import RotaryEncoder

pwmPin=PWM1B
encoder = RotaryEncoder(RotaryEncoder.EQEP2b)
pulse_per_rotation=200.

def setup():
        analogWrite(pwmPin,255)
        encoder.setAbsolute()
        encoder.zero()

def loop():
        global pulse_per_rotation
        encoder.setPosition(0)
        delay(1000)
        position = encoder.getPosition()
        rotations = float(position) / pulse_per_rotation
        rpm = rotations / (1/60.)
        print "encoder position : "+encoder.getPosition()
        print "rpm : ",rpm

run(setup, loop)
Alex Hiam
@alexanderhiam
What happens if you comment out the setPosition(0) call? It should keep counting up
Harshit
@iamharshit
then its output :
ubuntu@arm:~/harshit$ sudo python pid-v2.py 
encoder position : -21552

rpm :  -6465.6
encoder position : -21551

rpm :  -6465.6
encoder position : -21552

rpm :  -6465.3
encoder position : -21551

rpm :  -6465.6
encoder position : -21551

rpm :  -6465.6
encoder position : -21552

rpm :  -6465.3
encoder position : -21551

rpm :  -6465.6
encoder position : -21551

rpm :  -6465.6
encoder position : -21552

rpm :  -6465.6
encoder position : -21551

rpm :  -6465.3
^Cubuntu@arm:~/harshit$
are u sure that .getPosition() gives us the no. of pulses
?
Alex Hiam
@alexanderhiam
that's without encoder.setPosition(0)?
Harshit
@iamharshit
yes
Harshit
@iamharshit
@alexanderhiam #any suggestions#
so that i can read my motor rpm
Harshit
@iamharshit
i think the problem lies that my .getposition() method returns just 3 values 0, -1 or 1
even if i increase the time delay between .setposition(0) and .get position()
Harshit
@iamharshit
don't u think .getposition should work only with position encoder and not with a rotary encoder
Alex Hiam
@alexanderhiam
@iamharshit been out of the office. getPosition() just gets the value from the eQEP counter register, and it currently only supports rotary encoders. Do you have any other rotary encoders you can test with?
Harshit
@iamharshit
@alexanderhiam i don't have
Karthik Nayak
@KarthikNayak
Hello, I've been using PyBBIO for building a quadcopter and its been going great until recently I had to re-flash the OS on the BeagleBone due to a silly error on my side causing a kernel panic. After that I find that the PWM pins P8_13 and P9_16 (PWM2B, PWM1B) seem to have stopped working whereas P8_19 and P9_14 (PWM2A, PWM1A) seem to be still working.
I thought it must be a problem with the board, but I tried to run a simple LED blinking program and saw that all pins seem work. I also tested the motors individually and saw that all of those seem to be working too. So Im little lost as to whats happening, Any help would be appreciated.
For the record, using Jessie on 3.8
Karthik Nayak
@KarthikNayak
UPDATE: It's working on Adafruit, but that has weird pin issues and doesn't have a Servo library
Alex Hiam
@alexanderhiam
@KarthikNayak yeah, I think something changed with the PWM driver at some point, and now there's an issue with the way PyBBIO is doing PWM. I have a rewrite of the PWM API planned, but in the mean time there may be a workaround. Can you post your code? You could also try using ECAP0 and ECAP1 on pins P9_42 and P9_28
Karthik Nayak
@KarthikNayak
@alexanderhiam I had a look at the dmesg, figured that it was more of a driver problem
[   84.978822] bone-capemgr bone_capemgr.9: part_number 'PyBBIO-epwmss1', version 'N/A'
[   84.978903] bone-capemgr bone_capemgr.9: slot #7: generic override
[   84.978919] bone-capemgr bone_capemgr.9: bone: Using override eeprom data at slot 7
[   84.978935] bone-capemgr bone_capemgr.9: slot #7: 'Override Board Name,00A0,Override Manuf,PyBBIO-epwmss1'
[   84.979031] bone-capemgr bone_capemgr.9: slot #7: Requesting part number/version based 'PyBBIO-epwmss1-00A0.dtbo
[   84.979047] bone-capemgr bone_capemgr.9: slot #7: Requesting firmware 'PyBBIO-epwmss1-00A0.dtbo' for board-name 'Override Board Name', version '00A0'
[   84.986006] bone-capemgr bone_capemgr.9: slot #7: dtbo 'PyBBIO-epwmss1-00A0.dtbo' loaded; converting to live tree
[   84.986182] bone-capemgr bone_capemgr.9: slot #7: #1 overlays
[   84.990755] bone-capemgr bone_capemgr.9: slot #7: Applied #1 overlays.
[   85.241964] bone-capemgr bone_capemgr.9: part_number 'PyBBIO-ehrpwm1', version 'N/A'
[   85.242036] bone-capemgr bone_capemgr.9: slot #8: generic override
[   85.242052] bone-capemgr bone_capemgr.9: bone: Using override eeprom data at slot 8
[   85.242068] bone-capemgr bone_capemgr.9: slot #8: 'Override Board Name,00A0,Override Manuf,PyBBIO-ehrpwm1'
[   85.242154] bone-capemgr bone_capemgr.9: slot #8: Requesting part number/version based 'PyBBIO-ehrpwm1-00A0.dtbo
[   85.242170] bone-capemgr bone_capemgr.9: slot #8: Requesting firmware 'PyBBIO-ehrpwm1-00A0.dtbo' for board-name 'Override Board Name', version '00A0'
[   85.243674] bone-capemgr bone_capemgr.9: slot #8: dtbo 'PyBBIO-ehrpwm1-00A0.dtbo' loaded; converting to live tree
[   85.243853] bone-capemgr bone_capemgr.9: slot #8: #1 overlays
[   85.244963] ehrpwm 48302200.ehrpwm: unable to select pin group
[   85.245281] bone-capemgr bone_capemgr.9: slot #8: Applied #1 overlays.
[   85.496425] bone-capemgr bone_capemgr.9: part_number 'bone_pwm_P9_16', version 'N/A'
[   85.496496] bone-capemgr bone_capemgr.9: slot #9: generic override
[   85.496511] bone-capemgr bone_capemgr.9: bone: Using override eeprom data at slot 9
[   85.496527] bone-capemgr bone_capemgr.9: slot #9: 'Override Board Name,00A0,Override Manuf,bone_pwm_P9_16'
[   85.496616] bone-capemgr bone_capemgr.9: slot #9: Requesting part number/version based 'bone_pwm_P9_16-00A0.dtbo
[   85.496632] bone-capemgr bone_capemgr.9: slot #9: Requesting firmware 'bone_pwm_P9_16-00A0.dtbo' for board-name 'Override Board Name', version '00A0'
[   85.496654] bone-capemgr bone_capemgr.9: slot #9: dtbo 'bone_pwm_P9_16-00A0.dtbo' loaded; converting to live tree
[   85.496936] bone-capemgr bone_capemgr.9: slot #9: #2 overlays
[   85.501260] bone-capemgr bone_capemgr.9: slot #9: Applied #2 overlays.
[  138.504843] bone-capemgr bone_capemgr.9: part_number 'bone_pwm_P9_14', version 'N/A'
[  138.504911] bone-capemgr bone_capemgr.9: slot #10: generic override
[  138.504927] bone-capemgr bone_capemgr.9: bone: Using override eeprom data at slot 10
[  138.504944] bone-capemgr bone_capemgr.9: slot #10: 'Override Board Name,00A0,Override Manuf,bone_pwm_P9_14'
[  138.505042] bone-capemgr bone_capemgr.9: slot #10: Requesting part number/version based 'bone_pwm_P9_14-00A0.dtbo
[  138.505058] bone-capemgr bone_capemgr.9: slot #10: Requesting firmware 'bone_pwm_P9_14-00A0.dtbo' for board-name 'Override Board Name', version '00A0'
[  138.505079] bone-capemgr bone_capemgr.9: slot #10: dtbo 'bone_pwm_P9_14-00A0.dtbo' loaded; converting to live tree
[  138.505369] bone-capemgr bone_capemgr.9: slot #10: #2 overlays
[  138.514298] ehrpwm 48302200.ehrpwm: Period value conflicts with channel 1
[  138.521512] pwm_test pwm_test_P9_14.16: pwm_config() failed
[  138.534583] pwm_test: probe of pwm_test_P9_14.16 failed with error -22
[  138.534626] bone-capemgr bone_capemgr.9: slot #10: Applied #2 overlays.
[  269.491339] CAUTION: musb: Babble Interrupt Occurred
[  269.654568] CAUTION: musb: Babble Interrupt Occurred
[  269.824219]  gadget: high-speed config #1: CDC Ethernet (ECM)
So I was going through elinux Documentation
cd /opt/scripts/tools/
git pull
sudo ./update_kernel.sh
That updated the kernel, and that fixed the issue, I think you should update your wiki to reflect this, maybe until you take time to convert the code to C, which I guess you were planning to do sometime.
Anyways I think this should be conveyed to the users of PyBBIO so that if they're stuck in this situation, it'll help them out :)
Karthik Nayak
@KarthikNayak
If it helps, you suggest installing linux-image-3.8.13-bone70 on the Wiki (that has the problem), I updated it to linux-image-3.8.13-bone79, which seems to be the latest.
and has no problems.
Alex Hiam
@alexanderhiam
@KarthikNayak nice! I'll update the wiki soon, thanks for figuring that out!
akerbay
@akerbay
PyBBIO, key error on PWM, P8_19
akerbay
@akerbay
I may have gotten past the key error but now have an error in cape_manager.py: with "open(SLOT_FILE, 'wb') as f:, IOError: ....Permission denied: '/sys/devices/bone_capemgr.9/slots" but slots is a file, not a directory. So I'm very confused. Why would cape_manager.py write to the slots file?
akerbay
@akerbay
I see that I can run my program without getting the permission error if I start it with sudo python myProg.py but the PWM pulse rate is 2 kHz, not 100 kHz. Very strange.
akerbay
@akerbay
And now after rebooting the BBB, the PWM is not outputting anything. Very bizarre.
akerbay
@akerbay
I'm pretty sure the capemgr.9 error is causing the problem, requiring me to run my Python program as root. I suspect PyBBIO is writing to SLOT_FILE in order to enable the PWM pins. However, I am already enabling the PWM pins that I need by modifying the uEnv.txt, so I don't need to do the write and I will attempt to modify cape_manager.py to remove the write to /sys/devices/bone_capemgr.9/slots.
akerbay
@akerbay
Ok, I have gotten past the capemgr.9 error by reloading the Debian and all the Python stuff including the PyBBIO. So it seems that somehow it got clobbered. But still I must run my Python program with sudo python myProg.py. Hopefully that won't be a hindrance to getting my program to start up on boot. I will try crontab to see if it will accept a sudo command.
akerbay
@akerbay
Ok, never mind if anyone is following this. I found that I had to put delay in the ADC routine. Otherwise somehow the Debian would get clobbered. Now that ADC is working fine and all code is working fine with the 4D Systems 4DCAPE-70T and my analysis and GUI code. I had to either use a keyboard connected to the BBB USB port and either 1) start my code with sudo python myProg.py thru the Debian terminal program or 2) put a startup icon on the desktop and have it call a script to start my code. So all is well.
Harshit
@iamharshit
@alexanderhiam how can i calculate rpm of a quadrature encoder motor in beaglebone?? is there a direct method other than gpio rising for calculating??
Alex Hiam
@alexanderhiam
@akerbay so yeah, PyBBIO has to be run as root, because of the permissions of the sysfs and dev files used to interface with the kernel drivers. I have some ideas about how to implement a system where PyBBIO can be run as any user, but that won't likely be happening too soon.
@akerbay FYI you can do $ sudo crontab -e to edit the root users crontab, where you can start your program normally
@iamharshit are you still working with the same encoder? where you ever able to get it accumulating with the RotaryEncoder library?
Harshit
@iamharshit
@alexanderhiam I thought of doing multithreading(for timer interrupt)
@alexanderhiam here's my code , u can have a look , i havenot tried it yet
quangdai1406
@quangdai1406
I2C sample code
Michael Bykovski
@bykof
@alexanderhiam Hey, how do you think. Do I have to start my whole application as root if I want to use your library or are there any other possibilities