1

I'm playing with a motor board, a PWR.A52.A, that is mapping the ENA and ENB of its L298P to the BCM13 and BCM20.

The problem is that Android Things is mapping the PWM to BCM13 and BCM18.

enter image description here

I don't think there is a software solution to this problem due to Android Things (I have opened an feature request for this), but maybe there is an hardware solution...

Sorry for the silly question but this is not my field: what will happen if I short BCM18 and BCM20 and I keep BCM20 to low set BCM20 as an input and use BCM18 as PWM?

Probably I'm going to damage something, but that's why I'm asking. short This is a graphical representation of what I mean by shorting BCM18 and BCM20.

Is there any other safe and easy solution that can help me with this problem?

This is the pin mapping of the board:

PWR.A53.A pin mapping schematics

6
  • It would probably be okay if it is set as an input, since they are on a high resistance circuit.
    – goldilocks
    Dec 3, 2017 at 17:23
  • @goldilocks I have tried but didn't work. Probably due to the board internal wiring. I've added a schematic of it (that I can't understand). My try was to connect the PWM0 to the ENB_1 of the board. Dec 3, 2017 at 20:19
  • You'd still need to use BCM18 for the hardware connection. Can you stick a probe on that line and see what is being output. Dec 3, 2017 at 20:25
  • Sure, that was what I did, I connected the GPIO18 pin of the board, which is connected directly to the BCM18 of the Pi, to the ENB_1 of the board. I have a multimeter and not a lot of experience with electronics, should I just check the voltage or you need something more? Dec 3, 2017 at 20:34
  • BTW I wasn't claiming it would work, just that you would at least not be shorting the system. I am a bit surprised it doesn't though, since set as an input the pin is basically a just a piece of metal.
    – goldilocks
    Dec 3, 2017 at 20:43

2 Answers 2

1

Currently there is still no way to have hardware PWM on pins different from BCM13 and BCM18, but I wrote a software PWM library that works on any GPIO pin, allows frequencies up to 300 Hz and is good enough to control a DC motor via L298, if the accuracy of the speed is not that important.

The library is published on JCenter. Source and info: https://github.com/leinardi/androidthings-pio/tree/master/pio-softpwm

0

You can use software timed PWM on all accessible GPIO. That will have some jitter but may be good enough for your usage.

You can also use hardware timed PWM on all accessible GPIO. Have a look at (my) pigpio, or servoblaster, or the RPIO.GPIO module (not RPi.GPIO which is software timed PWM only).

7
  • hey, probably I should have put more emphases on the OS I'm using: it's Android Things, so I can't use those libraries. But thanks anyway. Dec 3, 2017 at 17:32
  • You could still use pigpio as long as Android Things supports Python. The pigpio Python module runs okay on my Android based phone.
    – joan
    Dec 3, 2017 at 17:34
  • AFAIK python isn't available out of the box on Android Things and currently I'm looking for solutions that don't require for the user any additional configuration step beside installing the Apk on the Pi. Dec 3, 2017 at 17:38
  • @RobertoLeinardi Might be useful to update the question line to mention Android things. There are lots of ways to provide PWM on GPIO20 in other operating systems.
    – joan
    Dec 3, 2017 at 17:41
  • Android Things doesn't support python, but OP could probably port your library to Android as it probably won't be too difficult. Dec 3, 2017 at 20:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.