Is CTR sort of like the hFe in a tranny ? I see 300 and 500 there at 5v.
Yep, it is exactly the optocoupler equivalent of hFe transistor current gain. CTR = Current Transfer Ratio. For an example of a high gain optocoupler, look at the datasheet CTR for a 6N138.
Incidentally, you can replicate the darlington in the 6n138 by connecting an external transistor to a conventional opto.
Given that it takes very little current to trigger an Arduino pin, I reckon it will work with the lower "gain" of the CTs I'm using...mostly because I found those on hand and I'm trying to keep it as budget as possible
That's another thing I'm thinking of: do I just connect the optocoupler's collector to the arduino pin (along with a pull-up resistor) and the emitter to GND, or do I need a cap there somewhere as well to keep the thing from oscillating and reading multiple successive presses ?
Switch "bounce" ? Well, sort of...while not critical as in other projects, I certainly don't want to tap the button and have the window stop after 1 second
Switch "bounce" ? Well, sort of...while not critical as in other projects, I certainly don't want to tap the button and have the window stop after 1 second
I do not know how you do that with an Arduino
But with a Basic Stamp can either use what called a switch ( button) command or what I like doing is have command that I would use as a counter that counts for so many mill seconds then latches your output or while you have the button pushed
a counter that counts for so many mill seconds then latches your output or while you have the button pushed
My code already does that: you know how on most modern cars the window latches up/down after holding the button for a while and you can let go of it - I implemented this feature also: tap the button to nudge the window up/down to where you want it; press and HOLD the button for 800ms (tweakable of course - just a random amount that seemed appropriate) and the window goes up/down on its own until you press it again to turn it off....it works perfectly on the breadboard with two relays to simulate the outputs that would later go into the H-bridge command pins, so hopefully it operates well on the car as well I was thinking of posting the code here, but it's not quite done yet and I'll probably have the code gurus criticizing me again for not doing "this" or "that" right and I also want to keep it a bit of a trade secret for now....maybe offer to install this gizmo on other cars without "smart windows" and launch a new line of products to make some money
I was thinking of posting the code here, but it's not quite done yet and I'll probably have the code gurus criticizing me again for not doing "this" or "that" right and I also want to keep it a bit of a trade secret for now....maybe offer to install this gizmo on other cars without "smart windows" and launch a new line of products to make some money
[ I tried a few times to use a current sensing IC chip and a Basic Stamp Controller and could not get it to work constantly and never completed the the project it was for what is below
I have a milling machine that I basically use it cut circuit boards but it has a big problem with blowning two amp fuses a real pain in the A** ] so I do not use it very much
But now I have found a solution for this problem with something I found about a month ago
If anyone is interested in this just let me know and I will post it
One note I have for you is to test your code to see if you can get it to hang or worse go out of control
Here is how I test a program code that I write
One while it running I kill the power to it then repower it right away and see how it ack
And basically torture test it to see if I can make it fail
You be surprised what can happen
Go for it if you have time for it
I made a pool timer awhile back that did not care if you lost power you never had a clock to set it was controlled by a Basic Stamp Controller
The setup was really different than anything I could find commercially
It used a green LED as a light sensor and when the sun was out playing
It would start a two hour counting timer then would stay off for three hours and keep repeating until the sun when to sleep it also has a summer and a winter mode the winter mode had shorter running time
It worked great for three or four years and then I had problems with the pool which I have not fixed yet so this pool timer controller has not been working for about three years now
One note I have for you is to test your code to see if you can get it to hang or worse go out of control
I also do that: mash buttons and stuff to see if I can get it to fail. I tried writing the code as fail-proof as possible. For instance, in this particular scenario of the electric window conversion of mine, the UP/DOWN commands must never operate simultaneously - makes sense, it would blow the H-bridge. Even though the rockers physically prevent you from pressing both up and down at the same time, I inserted a simple line of code that ensures this doesn't happen anyway. So imagine on the breadboard right now I got two individual push-buttons which can easily be pressed simultaneously and cause issues. When one is pressed, the other is ignored - simple.
Same goes for the current detection (though I haven't implemented this yet): I won't rely strictly on the current sensors to tell the micro when to stop the windows, I'll also add an universal timer, so if something goes wrong and the micro tries to keep cranking the window even after reaching the top/bottom, it won't drain the battery and burn itself out - it will stop after X seconds, regardless of what the current sensor is reporting....fail-safe I'd call it.
I hope I'll have more luck in implementing the current sensing feature than you did...seems simple enough on paper, especially since the current difference between run and stall states are fairly great in my case: around 6A when running and 15A when stalled, so precision is not that critical - it should be able to pick up a clear difference between the two states.
When I said this earlier I was meaning with it installed in the car to this type of testing
“Here is how I test a program code that I write
One while it running I kill the power to it then repower it right away and see how it ack
And basically torture test it to see if I can make it fail
I shall, of course. It's not easy without a garage to work in - I have to do it all in the parking lot which sucks big time, especially when you realize you forgot a tool you need...
Ok chaps, back on this project, so I hope you're still around and subscribed to the thread
It's been on hold because I've been rather busy obtaining my master's degree and writing the thesis and stuff, so everything else has been irrelevant/unimportant.
It's coming along nicely and I wasn't too far from completion when I left it, but as I was mucking about with the breadboard and testing stuff, I thought about one other thing: current consumption. Since this project is going to get installed in a car, maximum energy efficiency is important. Even though a car battery's capacity is huge compared to the "tiny" current draw of a microcontroller and it would take it thousands of hours to drain its voltage to the point where the car would no longer start, it's still a good idea to minimize said current consumption as much possible, so what can be done ?
For one, I read around that it is possible to tweak the arduino (it's a Mini in case you're wondering) and make it "sleep". Haven't tried it so far, but I heard it IS possible to make it enter a very low power state while still listening to the pins, so feel free to correct me or shed light on this.
Now: is there any significant difference in current between using active high or active low for reading the pins ? My mind would tell me that an "active LOW" setup draws "more" current than an "active HIGH" setup, though this could very well be incorrect or irrelevant:
-in an "active LOW" setup, to read the pin as "ON", you pull it to GND ; to turn it back "OFF", you pull it to VCC.
-in an "active HIGH" setup, to read the pin as "ON", you pull it to VCC ; to turn it back "OFF", you pull it to GND....the complete opposite
For the most part, the pins are "OFF" in my active LOW setup below, so they are pulled to VCC via 10k resistors. There's a "debounce" capacitor in parallel with the pin to GND.
Even though the 10K value is rather high and the current draw is probably below the measurable limit of my meter it IS there, drawing power, whereas with an "active HIGH" setup, the pins are permanently pulled to GND, drawing no current....again, this is probably bogus, but I don't claim to know anything, so I am open to suggestions and criticism What do you guys think ?
Ok chaps, back on this project, so I hope you're still around and subscribed to the thread
It's been on hold because I've been rather busy obtaining my master's degree and writing the thesis and stuff, so everything else has been irrelevant/unimportant.
Comment