Javascript PID Control #280
Replies: 7 comments
-
Posted at 2014-06-12 by DrAzzy I think you want to do: var p=new PID(...); (Also, I'm pretty sure the code won't work without a bit of work to port to the Espruino) . |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-06-13 by JumJum Take a look to this node.js module. Its a simple solution. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-06-13 by @gfwilliams I haven't tried it, but it should work with minor tweaks. I guess the first things to try would be:
If it works well, I guess we could add the module to Espruino? Have you done much work in other Object oriented languages? It's probably wrong but I tend to think of the prototype system as follows (and it works for me :) :
It all stems from some pretty simple rules in the interpreter. Each object is nothing more than a list of key/value pairs, and: When you say Then, if you access
So it's actually a really simple way of getting something like an Object Oriented language. I always find if I want to know what's going to happen, I can basically walk through the steps above. Does that help explain it at all? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-06-13 by StuntMonkeh @jumjum - I did find that one first, but I figured if we are going to have a module for the Espruino it had better have all the bells and whistles. @gordon - No never really done any object oriented stuff, just simple bits and pieces. I seem to learn best by hacking away at other examples to understand whats going on. But I will definitely refer to your example. I had pretty much figured it out what you had with the PID code. The only issue may be when the value that is returned from getTime() rolls over. It appears to be working using a few simple tests (finger on thermistor) watch demand decrease, finger off thermistor watch demand increase. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-06-13 by @gfwilliams Great! I did an example with a simple relay and really nasty control system. I'd love to see something similar with PWM and temperature sensing :) As far as the rollover, getTime() returns a double (which realistically will never roll over), and internally it's calculated from the RTC, which will only roll over after 136 years of continuous use - so I'm not sure it's such a big deal. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-06-13 by @gfwilliams Just to say, that library is expecting the Arduino-style 'loop', so |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-06-13 by StuntMonkeh Unfortunately I don't have the appropriate kit. Ideally the standard DIY reflow oven project would probably be a useful example. I do have an example project but its work in progress right now. I need to send the PCB gerbers off to SEEED. The only problem is when I open up the files I keep tweaking stuff ;) Yes I can't see anything being used for 136years so I think we are safe LOL. I am calling 'compute' from setInterval.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2014-06-12 by StuntMonkeh
Has anyone used this javascript PID controller code? Everything looks good but I can't figure out how to call it. Can someone point me in the right direction?
I'm still trying to wrap my head around this 'prototype' concept in javascript. Yet to reach that ah ha moment!
Beta Was this translation helpful? Give feedback.
All reactions