Emlid

Send PWM Signal Directly To Rail


(Corbin Wilhelmi) #1

EMLID Community and Support Personnel:

I am trying to write PWM signals directly to the output rail without going through mavlink, mavros, ardupilot, etc. I have gone through the examples provided as part of the information for developers as well as searched through the source code and documentation published on GitHub. I have also searched through the forums and cannot find one that pertains closely. The closest I can find are these two:

The second link asks that the alive status is pinged.
sudo cat /sys/kernel/rcio/status/alive returns a “1”

If I missed anything else in the forums then I apologize.

Before I continue, yes I have checked all wiring, tried to reboot, powered the Navio2 directly, ensured good connection between Navio2 and Raspberry Pi 3 B, etc. I have also reflashed the unit to ensure that I am using Emlid’s official iso image, 4.14.34.emlid-v7+. The general solutions do not work in this case.

The end goal of this is to use my custom flight software instead of an off the shelf one such as Ardupilot (in this case) or PX4/APM. I am a pseudo flight control engineer and need to test my software against others. I am also using my custom ground station and not QGroundControl or others like it. All of my message handling has been unit tested and found to be correct.

Currently, I am able to read all sensory information from the Navio2 unit (acceleration, gps, barometer, rc unit, etc). When I run the Servo (c++ and python, as sudo) example, the program will run but nothing happens.

Please correct me if I am wrong; however, it looks as though both scripts are writing information to:
“/sys/class/pwm/pwmchip0/*”.

I’m going to use python here since it’s easier to visualize in forums for me…

In the Servo.py script, I printed out pwm.is_enabled and pwm.is_initialized. Both print as “True”.

  • The program does not write the channel path:
    SYSFS_PWM_PATH_BASE = “/sys/class/pwm/pwmchip0/”
    self.channel_path = self.SYSFS_PWM_PATH_BASE + “pwm{}/”.format(self.channel)
  • List of files in that folder are: device export npwm power subsystem uevent unexport
  • */pwmchip0 has read, write, execute ability

Question 1: Is there any reason why the script cannot create a folder or file in that directory. I do not get an error message stating that it cannot.

Question 2: I could not find anything in the image, scripts or files that looks for those written files (grep commands). Is there a distinct location I could look at to see the message handling/calling this?

Question 3: Is there a command that I am missing that allows me to write/publish directly to the pwm rail?

I hope that this made sense and I appreciate everyone’s time in resolving this issue.


(Tatiana Andreeva) #3

Hi @corbin.wilhelmi,

Could you please post here a photo of Navio2 hardware setup?


(Corbin Wilhelmi) #4

Tatiana,

Attached below are two images of the current setup.

Picture 1:

  • Navio2 powered through 5v power input
  • Rail powered by 5v on Pin 14, through KDE UAS 22+ UBEC
  • Pin 1 output is signal and ground going to KDE UAS 95HVC+

Picture 2:

  • Same setup, but can see power wiring
  • Wall outlet to motor red/black to yellow/black adapters at top.
  • Pin 1 signal / ground to signal / ground of KDE UAS 95HVC+, slight lower right
  • Wall outlet red/black to Navio2 power adapter red/black, middle on left

EDIT #1:: I apologize, the uploader changed orientations (or my editor when I scaled them). Rotate 90Deg counter-clockwise when going from text to image.

NavioWiring1Small

NavioWiring2Small

I have also tried to power the rail from the KDE 95HVC+ with the same outcome.

Servo.py is looking for PWM_OUTPUT = 0
Servo.cpp is looking for #define PWM_OUTPUT 0

Any ideas will be appreciated.

EDIT #2:: In my opinion, the motors are not getting “armed” through the Servo.py / Servo.cpp scripts. Is there a way to “arm” them through the navio or is that RC control only?


(Corbin Wilhelmi) #5

The important lesson of the day is to RTFM, more importantly make sure it’s the correct manual. According to KDE’s information from their Q/A section: they use White/Red/Black instead of Yellow/Red/Brown for their motor output.

Screenshot%20from%202018-11-23%2011-11-21

If anyone else comes across this problem: You only need to connect white (signal) and black (ground). Both Servo.py and Servo.cpp will work.

EMLID: I am still curious as to what is reading the PWM output files / information. Is there a background thread / queue waiting for information?

My apologies for wasting everyone’s time.


(Tatiana Andreeva) #6

Hi @corbin.wilhelmi,

It’s great that you’ve managed to resolve it. That was tricky!

You can control GPIO and write PWM values to servo rail pins using sysfs. However, it’s not possible to read PWM values.