b-morgan / octoprint-fanspeedmirror Goto Github PK
View Code? Open in Web Editor NEWMirror the parameter(s) of GCode commands M106, M107 to scripts on the OctoPrint host
Mirror the parameter(s) of GCode commands M106, M107 to scripts on the OctoPrint host
cool idea, but what's the use case? I'm assuming it's to control auxiliary fans?
Hi there!
As I mentioned before I am trying to control a laser by a PWM output from a GPIO pin. I really know near to nothing about python or bash. So far I got the script which I added at the bottom. I am trying to execute it in Putty and it gives me the error:
Traceback (most recent call last):
File "fan.py", line 8, in
s = int(sys.argv[1])
IndexError: list index out of range
If I just enter a number for s it works perfectly fine (I am monitoring the pin with an oscilloscope). However I want s to be the number entered behind every M106 command. The PWM output should stay on till the next M106 command is entered therefore the 'while 1:'
I don't know if that is the right way to do it. When I enter the script path in the plugin and then issue a M106 S128 command nothing happens.
fan.py script:
#!/usr/bin/python3
import sys
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.OUT)
s = int(sys.argv[1])
dc = s*100/255
p = GPIO.PWM(11,1000) # channel=11 frequency=1kHz
p.start(0)
try:
while 1:
p.ChangeDutyCycle(dc)
except KeyboardInterrupt:
pass
p.stop()
GPIO.cleanup()
Please tell me if you need any further information. Thank you for your time! :)
Hello I want Set GPIO14 to control PWM fan,
how to change the py script, can you give me a hint?thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.