PI Freezes

Anyone else encounter this, my PI freezes when calling PinMode:

	Const kLEDPin = 18
	
	Dim i As Integer
	Dim result As Integer
	
	GPIO.SetupGPIO
	Print "GPIO initialized..."
	
	GPIO.PinMode( kLEDPin, GPIO.PWM_OUTPUT )
	Print "Pin initialized..."

Is there anything on the pin ? or is it not connected to anything ? (Wondering here if you got something on it taking to much current for example or other such fail)

Hi Björn,

Yes the hardware is working fine, I have written a C and Python program that uses the setup fine. All I’m trying to do is translate the program into XOJO.

James.

Are you sure things are hooked to the right pin? My chart shows GPIO 18 as a PCM pin. I see that standard pin 18 = GPIO 24.

Hi Paul,

Unfortunately your image is missing…

This is the table I have been using up to now and it has worked fine for all my other little experiments.

And this is my original C program:

So I really don’t know…

Hi James,

I tried to run the example with the print command and it did not work. When the code was changed to MsgBox, it worked on my Raspberry Pi 3 when I compile on Windows 10 on Xojo 2016 R 4.1. Here is my code:

[code]Const kLEDPin = 12

Dim i As Integer
Dim result As Integer

GPIO.SetupGPIO
MsgBox “GPIO initialized…”

GPIO.PinMode( kLEDPin, GPIO.PWM_OUTPUT )
MsgBox “Pin initialized…”[/code]

Does this work on the Pi?

Note: Please only call GPIO.SetupGPIO once in the program - this line of code usually goes in an open event. I used pin #12.

Perhaps You are not running it as root?

[quote=313043:@Eugene Dakin]Hi James,

I tried to run the example with the print command and it did not work. When the code was changed to MsgBox, it worked on my Raspberry Pi 3 when I compile on Windows 10 on Xojo 2016 R 4.1. Here is my code:
[/quote]
Eugene, Print is for console apps and msgbox is for desktop apps

Thanks Eugene, unfortunately I’m not going to get a chance to look at this again until the weekend. But your answer begs the question: what numbering system is XOJO GPIO using??

Because here: https://forum.xojo.com/38184-can-t-get-the-light-to-blink/p1#p311315 I needed to map pin 11 to 17 to get the example working and hence I was using 18 in this example…

You tell with GPIO.SetupGPIO what numbering system you use:
http://wiringpi.com/reference/setup/

This would mean BCM numbering so 18, not 12, should be the answer… BTW, this the setup:

Resistor is a 220k

220R, I hope, 220k will be about 23uA and I would say you will see no light!

Yes my mistake. And yes the setup works with both a Python and C program already.

My apologies for the confusion James. I just randomly chose the number 12, you are correct that pin 18 should be used.

Any luck with this? I have an LCD screen that uses pin 18 in PWM mode to set the backlight.
I’m trying to add a screen blank timer to my program.

The entire Pi freezes at

GPIO.PinMode(18,GPIO.PWM_OUTPUT)

Hi John,

No I’m afraid not, I got dragged into some other stuff and stopped the investigation. In my case it worked in both C and Python but died in XOJO, so for me it looks to be some kind of issue between the wiring module and it. Does it work in Python? There should be a few examples around that you can test with.

You can use a shell and pigpio commands if installed. Should be there in current distro’s

Or try:

Const kLedPin As Integer = 18

Or, of course, you could try the pigpio library for Xojo – just one numbering scheme!
https://github.com/UBogun/Xojo-pigpio

My program works sudo .

Non-root access to normal GPIO in/out/on/off also works,
but PWM access for non-root is still unstable and can crash the whole system.

A direct shell command works, too:

gpio mode 1 pwm; for i in 1000 900 800 700 600 500 400 300 200 100 0; do echo $i; gpio pwm 1 $i; sleep 0.10; done

(wiringPi pin 1 is broadcom GPIO18)

I would like to make a smooth 1 second fade (20-30 steps) without shell executes to either wiringPi’s gpio or pigpio.

Until PWM access works non-root, I can treat GPIO 18 as a switch and blank immediately.