kizniche / Mycodo

An environmental monitoring and regulation system
http://kylegabriel.com/projects/
GNU General Public License v3.0
2.95k stars 495 forks source link

PWM will not start #617

Closed alonrab closed 5 years ago

alonrab commented 5 years ago

Mycodo Issue Report:

Errors

image

step2: set % and turn on

image

test error log: deamon, image

step 3: in command port sudo pigpiod image

step 4: turn output on again with 50% image

random output that turn off after a few seconds.

For pin 18 the output turned green (on) but same problems accrue

Fool error tests: tested that PWM work: python code:

import RPi.GPIO as IO #calling header file which helps us use GPIO’s of PI

import time #calling time to provide delays in program

IO.setwarnings(False) #do not show any warnings

IO.setmode (IO.BCM) #we are programming the GPIO by BCM pin numbers. (PIN35 as ‘GPIO19’)

IO.setup(19,IO.OUT) # initialize GPIO19 as an output.

p = IO.PWM(19,22000) #GPIO19 as PWM output, with 100Hz frequency p.start(50) #generate PWM signal with 0% duty cycle

yielded the expected 1.62vdc at GPIO pin 19

Any suggestions? many thanks!

Steps to Reproduce the issue:

How can this issue be reproduced?

  1. step 1
  2. step 2...
  3. etc

Additional Notes

Is there anything that should be added to make it easier to address this issue?

kizniche commented 5 years ago

Can you attach a screenshot of your Config -> Configure -> Raspberry Pi page?

kizniche commented 5 years ago

Can you also attach your setup.log?

alonrab commented 5 years ago

config config raspberry pi image

set-up log

setup.log

alonrab commented 5 years ago

uninstalling pigpiod at config-config-raspberry pi with Configure pigpiod and install again with

sudo apt-get install pigpio python-pigpio python3-pigpio

improved the outcome, output torn on (green) image

but % is off (input was 50%)

image

kizniche commented 5 years ago

From your setup.log it doesn't seem as though this is a fresh install of Raspbian you installed Mycodo on. Let me know if this is not true.

alonrab commented 5 years ago

maybe I am doing the fresh install wrong? Did today: Format, install pi, set up raspi config (vnc, i2c, wifi, expand memory), install mycodo, reboot

kizniche commented 5 years ago

That is correct. I just needed verification. Try this command:

sudo /bin/bash ~/Mycodo/mycodo/scripts/upgrade_commands.sh install-pigpiod
kizniche commented 5 years ago

Then reboot. That should get it working. This I believe is the issue, that this command is missing from setup.sh

kizniche commented 5 years ago

I found the actual issue. pigpiod is not supposed to install at startup, but rather be a dependency for the PWM Output. When the PWM Output (or any of the Inputs that use pigpiod) is attempted to be added, the dependency system should install pigpiod for the first time. I just pushed a fix that will be incorporated into the 7.1.6 release.

kizniche commented 5 years ago

An easy workaround for now is to just install a DHT22 Input before trying to install a PWM Output. The dependency system will install pigpiod for the DHT22.

alonrab commented 5 years ago

did install + reboot. There are no error in log but no PWM. Just saw your note, thank you very very much! this is great! will look into this as I'm not familiar with DHT22 but need to resume this later on tonight, best,

kizniche commented 5 years ago

Your messing with pigpiod outside Mycodo may have affected it's ability to install pigpiod internally through Mycodo.

I also noticed you are using a hardware PWM pin but don't have the Hardware Pin Library selected in the Output options. Read the PWM section of the manual for explanations of this.

kizniche commented 5 years ago

Are you using the same pin to measure PWM on the same pin you are generating the PWM signal? If so, I'm not sure if this will yield good results. I would measure the PWM signal on a separate pin than the PWM signal is being generated. A better option would be to use an oscilloscope.

kizniche commented 5 years ago

FYI, these are the Inputs that have pigpio as a dependency and it should have been installed when any of the following Inputs were installed: DHT11, DHT22, HTU21D, Signal: PWM, Signal: Revolutions

alonrab commented 5 years ago

Thanks for the updated version, worked after running the command sudo /bin/bash ~/Mycodo/mycodo/scripts/upgrade_commands.sh install-pigpiod Did fresh install and set up again. this is what i found: step 1. Adding output PWM at GPIO pin 19 at 50% - same problem in deamon log , cant find pigpio step2: Delete output, add sensor DHT22 at GPIO 4; check deamon log, can't find pigpio step3: run command: sudo /bin/bash ~/Mycodo/mycodo/scripts/upgrade_commands.sh install-pigpiod as the end of installation notes prompted a warning run command: udo systemctl daemon-reload Add PWM output, GPIO 19, 50% and turn on power output steady at 1.52V seems to be resolved Thanks

kizniche commented 5 years ago

Okay, I think I finally fixed the issue. The fix I just pushed should now allow it to detect the missing pigpio dependency from a fresh install when a PWM output or an Input that requires pigpiod is attempted to be installed.

alonrab commented 5 years ago

Hi, Tried today again with fresh install with version 7.1.7 Had the same problem with adding the PWM GPIO output for adding GPIO PWM output ,cant find pigpiod checked that it was installed and it was (zero updates installed) Deamon Log:

File "/var/mycodo-root/mycodo/mycodo_daemon.py", line 919, in output_on trigger_conditionals=trigger_conditionals) File "/var/mycodo-root/mycodo/controller_output.py", line 450, in output_on_off self.output_switch(output_id, 'on', duty_cycle=duty_cycle) File "/var/mycodo-root/mycodo/controller_output.py", line 616, in output_switch self.pwm_hertz[output_id]) File "/usr/lib/python3/dist-packages/pigpio.py", line 1542, in set_PWM_frequency _pigpio_command(self.sl, _PI_CMD_PFS, user_gpio, frequency)) File "/usr/lib/python3/dist-packages/pigpio.py", line 983, in _pigpio_command sl.s.send(struct.pack('IIII', cmd, p1, p2, 0)) AttributeError: 'NoneType' object has no attribute 'send' 2019-02-04 12:47:35,702 - mycodo.output - ERROR - Cound not connect to pigpiod 2019-02-04 12:47:35,705 - mycodo.output - INFO - PWM 1feb705b setup on pin 21 2019-02-04 12:47:35,959 - mycodo.output - ERROR - Cound not connect to pigpiod 2019-02-04 12:47:35,960 - mycodo.output - INFO - PWM 1feb705b setup on pin 21 2019-02-04 12:47:44,810 - mycodo.daemon - ERROR - Could not turn output on: 'NoneType' object has no attribute 'send' Traceback (most recent call last): File "/var/mycodo-root/mycodo/mycodo_daemon.py", line 919, in output_on trigger_conditionals=trigger_conditionals) File "/var/mycodo-root/mycodo/controller_output.py", line 450, in output_on_off self.output_switch(output_id, 'on', duty_cycle=duty_cycle) File "/var/mycodo-root/mycodo/controller_output.py", line 616, in output_switch self.pwm_hertz[output_id]) File "/usr/lib/python3/dist-packages/pigpio.py", line 1542, in set_PWM_frequency _pigpio_command(self.sl, _PI_CMD_PFS, user_gpio, frequency)) File "/usr/lib/python3/dist-packages/pigpio.py", line 983, in _pigpio_command sl.s.send(struct.pack('IIII', cmd, p1, p2, 0)) AttributeError: 'NoneType' object has no attribute 'send' 2019-02-04 12:51:12,106 - mycodo.output - ERROR - Cound not connect to pigpiod 2019-02-04 12:51:12,107 - mycodo.output - INFO - PWM cdbdddc8 setup on pin 21

kizniche commented 5 years ago

Thanks for the update. I'll do another fresh install later so we can finally lay this bug to rest.

kizniche commented 5 years ago

Did it prompt you to install pigpio via the dependency page when you attempted to add the PWM Output?

alonrab commented 5 years ago

Report all dependencies for PWM were installed Device: SIGNAL_PWM (Signal (PWM)) All dependencies have been installed for this device.

kizniche commented 5 years ago

That doesn't tell me if pigpio was a dependency that was installed.

alonrab commented 5 years ago

Ok, this is what I obseved wen adding a new PWM output:

  1. Add GPIO PWM - no problem
  2. Assign GPIO pin (e.g. 21) and save - no problem
  3. Assign % and turn on - cannot find pigpiod 2019-02-04 14:18:27,432 - mycodo.daemon - INFO - Mycodo daemon v7.1.7 starting 2019-02-04 14:18:27,814 - mycodo.daemon - INFO - Anonymous statistics enabled 2019-02-04 14:18:27,845 - mycodo.daemon - INFO - Starting rpyc server 2019-02-04 14:18:28,215 - mycodo.output - INFO - Output 3dfb00d6 setup on pin 21 and turned OFF (OFF=LOW) 2019-02-04 14:18:28,216 - mycodo.output - INFO - Output 443621e8 setup on pin 20 and turned OFF (OFF=LOW) 2019-02-04 14:18:28,217 - mycodo.output - INFO - Output controller activated in 111.7 ms 2019-02-04 14:18:28,718 - mycodo.daemon - INFO - All activated Conditional controllers started 2019-02-04 14:18:28,719 - mycodo.daemon - INFO - All activated Trigger controllers started 2019-02-04 14:18:28,719 - mycodo.daemon - INFO - All activated Input controllers started 2019-02-04 14:18:28,720 - mycodo.daemon - INFO - All activated Math controllers started 2019-02-04 14:18:28,720 - mycodo.daemon - INFO - All activated PID controllers started 2019-02-04 14:18:28,720 - mycodo.daemon - INFO - All activated LCD controllers started 2019-02-04 14:18:29,221 - mycodo.daemon - INFO - Mycodo daemon started in 1.788 seconds 2019-02-04 14:18:29,224 - mycodo.daemon - INFO - 38.64 MB RAM in use 2019-02-04 14:20:49,700 - mycodo.output - ERROR - Cound not connect to pigpiod 2019-02-04 14:20:49,701 - mycodo.output - INFO - PWM 99ed85a1 setup on pin 21 2019-02-04 14:22:03,799 - mycodo.daemon - ERROR - Could not turn output on: 'NoneType' object has no attribute 'send' Traceback (most recent call last): File "/var/mycodo-root/mycodo/mycodo_daemon.py", line 919, in output_on trigger_conditionals=trigger_conditionals) File "/var/mycodo-root/mycodo/controller_output.py", line 450, in output_on_off self.output_switch(output_id, 'on', duty_cycle=duty_cycle) File "/var/mycodo-root/mycodo/controller_output.py", line 616, in output_switch self.pwm_hertz[output_id]) File "/usr/lib/python3/dist-packages/pigpio.py", line 1542, in set_PWM_frequency _pigpio_command(self.sl, _PI_CMD_PFS, user_gpio, frequency)) File "/usr/lib/python3/dist-packages/pigpio.py", line 983, in _pigpio_command sl.s.send(struct.pack('IIII', cmd, p1, p2, 0)) AttributeError: 'NoneType' object has no attribute 'send'

There was no prompt to install any need install dependency When I checked if pigpiod is installed it was already installed. It worked for version 1.6

P.S, Was in the process of doulble chek it wasn't my mistake, but in V 7.1.6 the GPIO PWM worked but when turning more then one power GPIO pins on all power outputs (3.3v) went out (no V out ) although system stated they were on. Now GPIO power are all working but cn't generate PWM. I tested my Pi device to make sure it is not faulty by turning all pins on with a separate python code All test were done before fresh install to make sure there is no conflict hope it make sense and let me know if pulling any log file can help?

kizniche commented 5 years ago

It indicating the PWM is on when there was an error preventing it is a bug. Pushing a fix for that.

My previous question seems like it was answered, but it's not clear that it was. When you first attempted to add a PWM Output, there are two scenarios that could have occurred immediately following clicking "Add" on the Output page:

  1. You were taken to the dependency page and instructed to install the pigpio dependency before being able to add the PWM Output.
  2. You were not taken to the dependency page and the PWM Output was added.
alonrab commented 5 years ago

ok thanks!

kizniche commented 5 years ago

Keep in mind this fix does not resolve the issue, it merely doesn't allow the output to show that it's been turned on when that error occurs. My question is still unanswered from comment https://github.com/kizniche/Mycodo/issues/617#issuecomment-460394125

alonrab commented 5 years ago

Is this about the dependency prompt? clarify: there was no prompt to install dependency or any prompt to install/update I was not taken to install/ scenario 2

kizniche commented 5 years ago

I finally fixed this issue and released v7.2.0. Let me know if there are any issues.

alonrab commented 5 years ago

Hi, Did fresh install today (format;install - on other installs) no luck with PWM GPIO see 1) deamon report; 2) setup.log

1) deamon report:

Edit: log deleted by @kizniche because it's way to large to be here. If wanting to share logs in the future, attach them as a file.

alonrab commented 5 years ago

Tried adding DHT22 input and turning on, no error, but did not improved outcome for adding PWM

kizniche commented 5 years ago

You were not redirected to the dependency page and prompted to install pigpio when you attempted to create a PWM output?

I tested this last night and it worked for me. I will do one more fresh install and see if I can replicate the behavior.

alonrab commented 5 years ago

Funny, I was directed as described to install dependencies when I installed atlas pH input, no such redirection for the PWM

kizniche commented 5 years ago

The Atlas pH Input has a dependency, but not pigpio.

https://github.com/kizniche/Mycodo/blob/506dc67a71e48d03a88439c58b4d2ecc7f8fb643/mycodo/inputs/atlas_ph.py#L63

Many Inputs have dependencies. This wasn't an issue with the dependency system as a whole, only adding Outputs. However, you indicating the pigpio dependency for the DHT22 wasn't installed when you attempted to install that Input is concerning.

alonrab commented 5 years ago

yes, no error was raised for DHT22 in log.

kizniche commented 5 years ago

That's not what I was suggesting. Disregard the log. When you add an Input that has a dependency, and that dependency isn't already installed, it should prompt you to install that dependency via the dependency page. If, when attempting to install the DHT22, it did not prompt you to install the pigpio dependency, then it indicates the issue is beyond merely the Output Dependency issue I described.

kizniche commented 5 years ago

Which Raspbian version are you installing? I suspect you are not using the Lite version and this is the source of your issues, as python3-pigpio is coming pre-installed and that is indicating to Mycodo that it doesn't need to install its own scripts.

alonrab commented 5 years ago

That is correct. I am not using the Lite version. This is probably why i encounter some difficulties. Did not know, thanks for pointing this - really wasn't aware they are so different.

kizniche commented 5 years ago

I just released v7.2.1. I think I came up with a solution that works for both the Lite and non-Lite version of Raspbian, however I've only tested on the Lite version. If you're inclined to test, please let me know if it works.

alonrab commented 5 years ago

Of course, will update what i find shortly

alonrab commented 5 years ago

I think it is working as intended - Many thanks! Did upgrade to v 7.2.1, add GPIO PWM was prompted to install the dependency after install, had to reboot -then adding GPIO, set up PWM and turn PWM % on were ok without error report.

I'm away from the lab but will report if the output volt test is wrong - think its probably ok. Best,

kizniche commented 5 years ago

Thanks for the help. I'm going to consider this closed. If you find an issue, we can reopen it.