Pwm for RPi GPIO

I would appreciate some help on using PWM for RPi GPIOs.

My Julia script is as follows:


using PiGPIO

red_pin = 17 # GPIO17 = :11

p=Pi()

PiGPIO.set_PWM_frequency(p, red_pin, 50) # assume sample rate = 5 microsec.

PiGPIO.set_PWM_dutycycle(p, red_pin, 128 )

PiGPIO.set_servo_pulsewidth(p,red_pin,0)
#sleep(1)
PiGPIO.set_servo_pulsewidth(p,red_pin,1000)
#sleep(1)
PiGPIO.set_servo_pulsewidth(p,red_pin, 1500)


Script fails with output:
ERROR: LoadError: UndefVarError: int not defined
Stacktrace:
[1] set_servo_pulsewidth(::Pi, ::Int32, ::Int32) at /home/pi/.julia/packages/PiGPIO/zdssl/src/pi.jl:674
[2] top-level scope at none:0
[3] include at ./boot.jl:317 [inlined]
[4] include_relative(::Module, ::String) at ./loading.jl:1044
in expression starting at /home/pi/Documents/julia_servo.jl:42

Iā€™m pretty sure that is a typo in PiGPIO/src/pi.jl:675. That int should be Int, try changing that on your local copy and restarting Julia. If that works, it is probably worthwhile filing a bug report.

I can confirm that. Julia 1.05 on Raspberry pi
pkg> dev PiGPIO
edit the pi.jl file and change int to Int
pkg> build PiGPIO

This is an issue in PiGPIO.jl. Can you please open a bug? int was deprecated and after removed from Julia.

You are correct. I changed int to Int and it works correctly. Many thanks for your great support !
Julia is great. I am switching all my codes from Py to Julia in RPi.

I uploaded a bug report at Github, issue in PiGPIO.jl. #36109.
I thank you all for this great support.

1 Like

Dear Russel,

I followed your suggestion and it worked okay ! I also uploaded a bug at Github.

With such support, Julia will thrive pretty fast. Many thanks !!

Best

George