Digital pins A9

Discussion in 'UDOO NEO' started by alexpol44, Mar 7, 2017.

  1. alexpol44

    alexpol44 New Member

    Joined:
    Mar 5, 2017
    Messages:
    8
    Likes Received:
    1
    Hi Guys,

    I would like to have 3 pwm output signals on the linux side and 3 digital inputs to read a pwm signal from an RC receiver. Is that possible ?

    I had a look on the Device tree editor but I am not sure I could figure it out from there.

    Kind Regards,
    Alexandros
     
  2. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    If you switch the A4 off you have all the Arduino pins available on the A9 side.
     
    alexpol44 likes this.
  3. alexpol44

    alexpol44 New Member

    Joined:
    Mar 5, 2017
    Messages:
    8
    Likes Received:
    1
    Oh thanks very much for that. I didn't know that was possible.

    Disabling it was the easy part. I was having a look on the tutorial here on how to enable the pwm pins on UDOO.

    https://www.udoo.org/docs-neo/Hardware_&_Accessories/PWM.html

    The tutorial assumes that only 2 PWMs will be used . How can I assign the 3 PWMs from the pins of the m4 ?

    I am sure there is a tutorial somewhere out there but I cannot find it. Any references??

    Regards,
    Alexandros
     
  4. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    For each pwm [0-7] you can do the following

    Before configuring a PWM output, it is necessary to export it (replace [0-7] by the desired pwm number:

    echo [0-7] > /sys/class/pwm/pwmchip0/export

    Then set period and duty cycle. For example, to generate a 1kHz signal with 30% of duty cycle, use:

    echo 1000000 > /sys/class/pwm/pwmchip0/pwm[0-7]/period
    echo 300000 > /sys/class/pwm/pwmchip0/pwm[0-7]/duty_cycle

    While you are already into Python with the Magum library you could also checkout the Neo.GPIO libray that has pwm capabilities: https://github.com/smerkousdavid/Neo.GPIO

    But as it has also the sensors reading in it it could conflict on that point with Magum!!
     
    alexpol44 likes this.
  5. alexpol44

    alexpol44 New Member

    Joined:
    Mar 5, 2017
    Messages:
    8
    Likes Received:
    1
    Hi waltervl,

    You have been really helpful thank so much . I try to avoid python as much as possible because I don't really understand it. Already I have modified a few lines of the Magum code to get the output of the sensor readings into a text file and pick them up using BASH.

    I will try use the PWMs using echo [0-7] > /sys/class/pwm/pwmchip0/export first .

    I will give you a shout if I need anymore help. Thank you very much again :).

    Alexandros
     
  6. alexpol44

    alexpol44 New Member

    Joined:
    Mar 5, 2017
    Messages:
    8
    Likes Received:
    1
    Hi waltervl,

    I tried following the previous instructions but I couldn't figure it out. I had a further look on the following diagrams .

    To my understanding the internal pins are controlled by the m4 - arduino ( which I already powered off) and the external by the A9. Now that the m4 is disabled everything is supposed to be working under the A9. So my questions are the following:

    1.Does this mean that /sys/class/pwm/pwmchip0 refers to A9 or M4 and /sys/class/pwm/pwmchip1 refers to the other? If not what is the difference between the two pwmchip directories?

    2.Also when I try export the using echo 0-7 , I can only successfully write 0 to the export file. Any other number gives me an error of no such device.

    3. What exporting 0 / and then enable which pwm pin actually corresponds to PWM 0.

    4. Do I have to configure the PWM s on the device tree editor?

    Alexandros

    [​IMG]
    [​IMG]
     
  7. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    Hmm, after reading some other old topics I think I was wrong assuming switching off m4 would keep the pin assignment.
    You will have to do your own pinmuxing. The device tree editor uses this pinmuxing but your requirements require more pins than the DTE can handle at the moment.

    I never went this far. I did all this pwm work with the Arduino IDE on M4.
     
  8. alexpol44

    alexpol44 New Member

    Joined:
    Mar 5, 2017
    Messages:
    8
    Likes Received:
    1
    No problem, I will try see all the material on pinmux . I will post if I manage to get to anywhere.

    Thanks man, All help was much appreciated
     

Share This Page