Skip to main content

duty cycle testing



Now that I saw a physical response, I should try to make it similar to how a servo should be controlled.

Servos are actuators that receive (expect) position input (as opposed to motors, which receive speed/intensity input). Simply put, it registers input as pulses, decoding the ratio of high (a "on" signal) to low in a given period as a position value. 

As I am waiting for my servo to be shipped, I will continue to work with the LED light. 

As opposed to my previous setup of having the light turn on every time the request is given, I will have the light turn on and off in a regular pattern until a request is given, upon which the pattern will change for one "cycle" (on-and-off pair).

The on-and-off logic (previously the LED control logic) will be run in a separate thread:

def dCycle(*args):
   global dCVal
   var = 1
   while var==1:
     dutyCycle = dCVal
     GPIO.output(17, GPIO.HIGH)
     time.sleep(dutyCycle)
     GPIO.output(17, GPIO.LOW)
     time.sleep(2-dutyCycle)

This code says that the total "cycle" will be 2 seconds, with "dutyCycle" being the length of time that the LED will be on. The global value "dCVal" will contain the length of time the light will be on. 

In the beginning, "dCVal" will be set to 0.15 seconds:

if __name__ == "__main__":
   global dCVal
   dCVal = 0.15
.
.
.
  thread.start_new_thread(dCycle,())

Every time the request is received, the value of dCVal will be changed to give it a different cycle pattern:

(in request received logic)
     dCVal = 1
     time.sleep(2)
     dCVal = 0.15

The LED will be on for a solid second when requests are received then return back to the short length once that is achieved. 

The time.sleep value of 2 somewhat resembled a setup/hold time in digital logic (reminded me of it, at least)... but not really at the same time. 

Comments

Popular posts from this blog

quick recollection on setting things up

If I can swear that the password is correct, then it's possible that I'm getting the ID wrong. Hadn't logged into the web server in a couple of months and was unable to SSH into it. After an hour or so, I ended up deleting the instance and recreating a clean instance (read: erasing everything). I then realized I'd been putting the wrong ID.   apt-get install sudo apt-get install Anyways, some links I visited when setting things up (pretty much a dump of whatever I copy-pasted to notes) : Raspberry Pi http://www.makeuseof.com/tag/optimize-the-power-of-your-raspberry-pi-with-raspbian/ Logging http://docs.python.org/2/howto/logging-cookbook.html Tornado - Python webserver that supports Websocket http://stackoverflow.com/questions/2924991/what-popular-webservers-have-support-for-html5-websocket http://lowpowerlab.com/blog/2013/01/17/raspberrypi-websockets-with-python-tornado/ http://stackoverflow.com/questions/11695375/tornado-identify-tra...

warming up

I still don't have all the parts I need to do what I need to do, but I started working with what I had around. I had a 4-digit 7-segment led which I had ordered previously, but for the longest time I had thought I needed additional parts to make it work. It was only today that I realized that that was not the case. Getting some help from this site , I was able to get the digits fired up: This method uses way more wires than this guy  (which uses a serial communications protocol called I^2C), but it's good to see it work. I still do want to try the less-wire led setup, as I would like to try playing around with I^2C. In addition, I had recently purchased an Arduino Pro Mini , which contains all the capabilities of the above Arduino Uno but requires pins/connections to be soldered into the board. I had attempted to solder one part of it (the serial/USB connections) a few days ago (note that this was my first attempt ever at soldering), and the USB-to-Serial interface...

chunk update: most parts printed and assembled

currently: stuff that happened are: wired the fingers added screws to necessary assemblies witnessed first failed print during this: servos haven't come yet, but once they do, we can start installing them into the hand/forearm. as always, credit to the Inmoov project.