Closed SAM26K closed 5 years ago
For PWM Outputs?
Yes. Plan on using GPIO for PWM and a level shifter to boost to 10VDC.
And you're suggesting this be a Dashboard widget?
Yes. Would be more convenient to use a slider vs discrete numbers or arrow button.
Would be nice to have slider combined with number input for fine adjustment.
Just started looking at the GPIO PWM signal with a Fluke 199 scope-meter and it looks like there might be some PW jitter in the signal. Seems to be random but not sure if it's a scope triggering problem or real jitter. Which library does Mycodo use for GPIO PWM control? TIA!
Using a new 3B.
Screen shot of the output control: Tried different frequencies from 60-22000 Hz same jitter. ie it looks like P W jitters randomly up to 10-20%. Think it might be a lib problem.
Have you tried a dedicated hardware PWM pin?
Also, PWM is controlled by pigpio. You can change the sample rate of pigpio in the configuration menu.
what is the difference between "any pin" and "hardware pin"?
Changing Configure pigpiod from 1msec to 5msec helped a lot. Now jitter is only around 2%.
Browsers have an integrated range selector input. I added a PWM Output widget with this. This is what it looks like in Firefox:
Do I need to upgrade to master? Upgraded t0 the latest Mycoco rev and get this in Firefox: Earlier rev of Mycodo works ok (cert is bypassed not accepted).
Also it looks like the output control is no longer compatible with chrome.
Guess I have to open a new issue since you closed this one?
You can reopen this one if it's about the Output PWM Slider desktop widget. I'm not exactly sure what your issue is or the steps to replicate it. You'll need to provide more information.
I don't see an option to re-open (using chrome). Need some time to organize the details. Thanks.
Turned out the certificate error was unique to the new RPi3B and Firefox. Got that working now but don't see the new slider feature. Is there a Firefox plugin I need to install? Have V7.7.9 installed. TIA.
You can check the changelog to see the release status of changes. To test the code for 7.7.10 prior to release, you'll need to upgrade to master.
Upgraded to master and got PWM (any pin) working but still haven't got hardware pin (12) working. Also getting a db version error:
Python Version: 3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516] Database Version: 895ddcdef4ce (Incorrect Version. Should be 0ce53d526f13) Daemon Status: Running Daemon Process ID: 4524 Daemon RAM Usage: 67.564 MB Daemon Virtualenv: Yes Frontend RAM Usage: 74.348 MB Frontend Virtualenv: Yes
Tried pin 18 PWM no luck with Hardware Pin library but works with any pin library. That is the BCM pin 18 that maps to hardware pin 12 right? TIA,
No errors in daemon log. Output Control shows green and active but a scope on the pin shows 0V.If I select "any pin" it works but not with "hardware pin" selected.
The new slide control works great but only with "any pin". Thanks.
Working fine for me. Though, there may have been something fixed with the latest code you're not running (from master). Are you able to verify the PWM signal? Can you explain more by what you mean by it not working? It's very hard for me to figure out the cause of an issue without a good amount of information to investigate.
Any ideas on how to fix this problem? Complete re-install?
Database Version: 895ddcdef4ce (Incorrect Version. Should be 0ce53d526f13)
You can just install from master (git clone), then just restore one of your backups when you want to go back to a release.
To answer the question, there are a lot of potential reasons why the database version doesn't match the expected version. The upgrade log will give an idea, but if you're on master, it's too much work for me to diagnose such an issue that's likely resolved in the latest commit. Again, I'd recommend a git clone of master and install from that, and after you're done testing, use the restore page to go back to a stable release you have in the backup list.
How do I git clone from master? I am hooked up as shown in your pix above. By not working I meant there is no square wave on the gpio BCM pin 18 using a scopemeter when "hardware pin" is selected in the PWM output control.
upgrade log says "........successful." After upgrading to master.
Having mixed results. PWM "Hardware Pin" 18 is working now and much more stable than "any pin". Did the following:
I don't want to try the rework instructions for db errors in the database before you have a chance to suggest something else. TIA!
Ah, the mismatch is because I haven't yet updated config.py to reflect the latest DB version. This is expected behavior.
Updated the config.py file with the expected dB name and mismatch is gone now.
Since this control will control grow light intensity, I want it to conserve the PWM setting across reboots in case of a power interrupt. Is there anyway to update the Mycodo code to do that? Thanks again.
What is setting the PWM? If it's a Trigger or Conditional, then it should be set back to whatever duty cycle it was at shortly after the daemon starts back up after a reboot.
First attempt is just a GPIO PWM output control controlled by the new PWM dashboard widget and works well. Looking at the manual but so far haven't figured out how to preserve PWM after a reboot without writing a python or linux code control.
I assume if it's growing something, you're going to want it on a regular, automatic cycle. The Trigger (daily time) can accomplish this. A Conditional can as well, but is more complex (and powerful) and requires experience writing Python.
Basically I'm using a mechanical timer to turn the lights on and off and using the rpi and Mycodo only for dimming. Want to preserve what ever the slider value on the dashboard is set to be restored for the PWM output across reboots.
Is it possible to somehow make the PWM control static so the last setting is restored after a reboot?
Is there a get-measurement command to return PWM duty cycle?
Tried this control to return %duty cycle but it always returns 0's and turns the GPIO off after every measurement:
errors:
2019-10-05 18:57:45,420 - DEBUG - mycodo.controllers.controller_input_516513a3 - Adding measurements to InfluxDB with ID 516513a3-2650-4866-8faa-da072926b386: {0: {'measurement': 'frequency', 'unit': 'Hz', 'timestamp_utc': None, 'value': 0.0}, 1: {'measurement': 'pulse_width', 'unit': 'us', 'timestamp_utc': None, 'value': 0.0}, 2: {'measurement': 'duty_cycle', 'unit': 'percent', 'timestamp_utc': None, 'value': 0.0}} 2019-10-05 18:58:45,259 - ERROR - mycodo.inputs.rpi_signal_pwm_516513a3 - InputModule raised an exception when taking a reading: unsupported operand type(s) for /: 'float' and 'NoneType' Traceback (most recent call last): File "/var/mycodo-root/mycodo/inputs/base_input.py", line 122, in read self._measurements = self.get_measurement() File "/home/pi/Mycodo/mycodo/inputs/rpi_signal_pwm.py", line 87, in get_measurement self.value_set(2, read_pwm.duty_cycle()) File "/home/pi/Mycodo/mycodo/inputs/rpi_signal_pwm.py", line 173, in duty_cycle return 100.0 * self._high / self._period TypeError: unsupported operand type(s) for /: 'float' and 'NoneType' 2019-10-05 18:59:45,327 - DEBUG - mycodo.controllers.controller_input_516513a3 - Adding measurements to InfluxDB with ID 516513a3-2650-4866-8faa-da072926b386: {0: {'measurement': 'frequency', 'unit': 'Hz', 'timestamp_utc': None, 'value': 0.0}, 1: {'measurement': 'pulse_width', 'unit': 'us', 'timestamp_utc': None, 'value': 0.0}, 2: {'measurement': 'duty_cycle', 'unit': 'percent', 'timestamp_utc': None, 'value': 0.0}}
The PWM Input is for detecting a PWM signal and writing it to the measurement to the database. You can't both generate and detect a PWM signal on the same pin. You could connect the pin generating the signal to another pin that is measuring the PWM signal, but that's unnecessary because the PWM signal being generated is stored in the database when the duty cycle is changed. So, you're attempting to measure something that's already stored in the database.
For solving your problem of desiring to set the last known duty cycle of a PWM output back to that duty cycle after a reboot, it's not an easy task. It could be done with a Conditional or Trigger, but that would work best if it was also defining the timer for the light itself.
I improved the Output startup/shutdown options, so PWM Outputs will now have the option to have the duty cycle at startup to be set to a user-specified value or the last known value.
Trying to use terminal mycodo daemon commands to turn on GPIO PWM outputs and nothing works. Tried:
mycodo-client --dutycycle 44.0 73697cab-bfb3-40a8-b630-09dd49a50f2e (returns error: unrecognized arguments:73697cab-bfb3-40a8-b630-09dd49a50f2e)
mycodo-client --outputon 73697cab-bfb3-40a8-b630-09dd49a50f2e (returns: 2019-10-06 19:48:09,786 [Remote command] Turn on output with ID '73697cab-bfb3-40a8-b630-09dd49a50f2e': Server returned:) and output stays off.
Edit: I didn't see your post above. Trying new version now.
The command should be mycodo_client.py --outputon ID --dutycycle DUTYCYCLE
Still no preservation of settings after reboot:
ie the PWM is low inactive after reboot.
This command does work: mycodo-client --outputon aab93daf-8be1-494d-a547-c034849e2964 --dutycycle 44
progress :)
PWM setting sticks after a daemon restart but not after a system restart.
Seems to be working now. :)
Mycodo Feature Request:
Request a slide bar type output control. Reason: Want to use it for a light dimmer.