Keyboard Shortcuts
Likes
Search
Locked Raspberry Pi Servo pHAT
Hello Group,
Thank you to all who commented on my earlier post where I was trying to connect servos directly to my Arduino Mega running the DCC++ sketch. With everyone's help, I have decided to abandon that approach. I have ordered a Pi Servo pHAT for my Raspberry Pi that is running JMRI. This $10.95 product has 16 channels that allow for direct connection and management of 16 servos. Here is information on how it works: Has anyone used a this product, or something similar? I am assuming I will be able to configure and operate this within the JMRI environment. Richard |
开云体育Hello Jason, ? Your project sounds very similar to what I am investigating. A few comments: ?
? I am more of a software guy (40 years’ experience in the industry) who still looks at the hardware like a magic black box. That being said, I do not like to write code … it is much easier and much more reliable to find code that already works. That I why I love JMRI … it is a platform with significant functionality right out-of-the-box (and free as well). ? Richard ? ? From: sigs@... <sigs@...>
Sent: Thursday, July 25, 2019 10:01 PM To: [email protected]; Richard Sauerbrun <Richard@...>; [email protected] Subject: Re: [jmriusers] Raspberry Pi Servo pHAT ? Richard, ? I have a project I have been working off and on with for the last few months using a Raspberry Pi Zero W and custom 16 channel PWM board I created, similar to the one you are using.? The difference is I wanted to make the power interface a little more easy to work with. ? My general goal is to create 16 channel "nodes" for driving 16 servo turnouts around a layout through an IP/web based control interface. ? I have attached a couple of pictures.? I am working on the code in Python.? So far my limited coding ability has been my major blocking point for really getting this working the way I want it to.? I'm having a hard time getting getting any web access to control the IO pins directly, to talk with the PWM controller.? I'm really a hardware guy, forced to write crummy code :o) ? Jason Rausch RPC Electronics, LLC ? ? ? ?
|
开云体育Hello Richard, On Jul 25, 2019, at 9:42 AM, rsauerbrun <richard@...> wrote:
The two products actually use the same I2C controller. That said JMRI does not currently support I2C connections on the RaspberryPi, but, the Pi4j library we use to provide support actually does support them, so this should just be a matter of figuring out the correct hooks to use in that code. I’ll see if I can play with it over the next few days and get something working, probably as a script. Paul |
Thanks Paul,
My board should arrive tomorrow so I can start experimenting. I have already prepared my JMRI preferences (running on the RPi) by adding the Raspberry Pi Foundation as a connection, and configured as RPi GPIO. Once set up in preferences, you can add turnouts in the table associated with this connection. My assumption is that you connect each turnout servo to a specific GPIO pin for control. We will see if that works. Looking forward to your script as well ... Richard |
开云体育Richard,On Jul 30, 2019, at 9:53 AM, rsauerbrun <richard@...> wrote:
The chip on the servo boards provides another set of GPIO pins that are used to control servos. There is a Java example showing how to use the chip in question here: And here: The second of those shows how to control a servo. My intention is to use that second file as a guide for writing the script, with the changes required to make this work within JMRI. Paul |
Jason Rausch
Richard, Yes, that is why I added the coaxial style power socket to my board.? I wanted a robust power connection that would also provide enough current for all 16 servos.? As for Steve Todd's work, I have attempted to contact him several times on various forums with no luck.? I am curious about this, as I have not found much information on setting it up and using it.? I have been using JMRI for several years off and on and while I'm no expert, I have a pretty good handle on it.? I mostly run it on a Raspberry Pi in a headless configuration and just RMD into it when I need to. I plan to still make my version of the board available at my website, once I can work out any changes I want to make. Jason Rausch www.ke4nyv.com
On Friday, July 26, 2019, 09:26:50 AM EDT, Richard Sauerbrun <Richard@...> wrote:
Hello Jason, ? Your project sounds very similar to what I am investigating. A few comments: ?
? I am more of a software guy (40 years’ experience in the industry) who still looks at the hardware like a magic black box. That being said, I do not like to write code … it is much easier and much more reliable to find code that already works. That I why I love JMRI … it is a platform with significant functionality right out-of-the-box (and free as well). ? Richard ? ? From: sigs@... <sigs@...>
Sent: Thursday, July 25, 2019 10:01 PM To: [email protected]; Richard Sauerbrun <Richard@...>; [email protected] Subject: Re: [jmriusers] Raspberry Pi Servo pHAT ? Richard, ? I have a project I have been working off and on with for the last few months using a Raspberry Pi Zero W and custom 16 channel PWM board I created, similar to the one you are using.? The difference is I wanted to make the power interface a little more easy to work with. ? My general goal is to create 16 channel "nodes" for driving 16 servo turnouts around a layout through an IP/web based control interface. ? I have attached a couple of pictures.? I am working on the code in Python.? So far my limited coding ability has been my major blocking point for really getting this working the way I want it to.? I'm having a hard time getting getting any web access to control the IO pins directly, to talk with the PWM controller.? I'm really a hardware guy, forced to write crummy code :o) ? Jason Rausch RPC Electronics, LLC ? ? ? ?
|
Hey Jason,
That sounds great ... Here is the URL for Steve Todd's site ...? You should find all you need on his RPi JMRI image. If you have an extra micro SD card available, you might burn his image and see what he has done. I know Steve is very busy with a real job, in addition to his work on model railroading. If you were not aware, he is the author of the Engine Driver app for Android phones/tablets that connects to the JMRI WiThrottle server. Thanks again for your help, Richard |
On Tue, Jul 30, 2019 at 11:46 AM, Paul Bender wrote:
Paul, this sounds great! I use lots of servos on my layout, currently driven by the excellent Tam Valley QuadLN-S boards, but I also have the SparkFun pHat board and would love to be able to use it from JMRI. I'd be glad to help with testing or even coding once you get the basic JMRI framework in place. --SteveT |
开云体育Steve,Richard, and anyone else
interested,
On 08/05/2019 09:58 PM, Steve Todd wrote: On Tue, Jul 30, 2019 at 11:46 AM, Paul Bender wrote: I've had a chance to get this working. It turns out there is an issue in the Pi4j servo support for the the PCA9685 BUT if you use the raw GPIO from the PCA9685, you can control the servo. I've uploaded both scripts (i.e. the working one that doesn't use the Servo implementation and the non-working one that does) to /g/jmriusers/files/RaspbberryPi%20PCA9685%20Scripts The example with "Gpio" in the name is the one that actually works (I labeled it as such).? I've left both of them there in case someone working on the Pi4j code eventually fixes it (This has been reported on other forums, so It's not isolated to what we are doing here). Consider these a starting point that proves the communication to the board and (ultimately) the servo actually works, but this is no where near production ready code. Paul |