Borderlands style jewelry box research thread - Page 1
Forum section: electronics / projects

author: Youkai
author_rank: Regular Contributor
timestamp: April 06, 2018, 05:45:26 am
content: Hello everyone. New member here; thank you for having me. I'm pretty new to this type of thing and I have no real electronics background. If you would like to get an idea of my current level of knowledge you can take a look at this youtube playlist of a previous project I attempted (it failed).https://www.youtube.com/playlist?list=PLBDD0A3B6E5C15862That was pretty rough but I learned a fair amount while working on it.I'm currently endeavoring to build a motorized jewelry box inspired by the Borderlands treasure chests. Attached are two pictures of a rough model I have created. Blue is the lid which would hinge at the back where the blue cylinders would match up with the grey cylinders on the back of the base. Purple are a couple of trays which would rotate forward and out. Purple cylinders would sit on top of the grey cylinders they are above.The dimensions of the final product will be approx: 20cm wide, 16cm deep, 12cm tall. All of the cylinders are 4cm in diameter. The lid will rotate up 90 degrees. I'm thinking the trays will rotate 180 degrees probably. I'm still very early in the design/planning phases so if the electronics dictate I can change some of the dimensions.So my questions are how to make the items move. In my previous project I used servos and that worked fine but I was watching some videos on youtube later and learned that stepper motors are a thing that exists. Would one of those be better than the other for this application or is there some other type of motor that I'm not aware of which would be good? I also need to consider the size of the motor. It either needs to fit in the 4cm pillar or I'll need to find some way to adjust the design to hide it's bulk inside the body of the chest.Whichever type of motor I decide to use is there a way for me to "know" it's position or will I need to have sensors/switches of some kind to tell me when the parts reach certain positions?Finally I'm likely going to use and arduino board to control it unless someone knows of a better way.Thank you all for your time!

author: Ian.M
author_rank: Super Contributor
timestamp: April 06, 2018, 07:05:19 am
content: With a small design change so the rear cylinder pillars merge into the grey hinge cylinders, most of the mechanism could go into the base. You'd need a vertical shaft in each of the front pillars to swing out the trays and a vertical shaft in one of the rear pillars to drive a pair of bevel gears to operate the lid.I see little point in using steppers or even servos - they are bulky and only needed if you want to be able to stop at arbitrary intermediate positions.Put a large cam in the base with three tracks machined into its face, one for each swingout tray and one for the lid. Drive the vertical shafts via cranks from pushrods with roller ends to fit the cam tracks. Drive the cam with a belt on its rim (so the mechanism slips if its jammed rather than destroying itself) from a tiny 3V motor. The cam will need limit sensors or switches, and possibly an extra one for the lid open but trays not yet swung out position. Run the whole lot off 3x AAA batteries for a nominal 4.5V dropping to around 2.7V at end of life, in the base (or 6x AA if you want to add lighting). PWM the H-bridge driving the motor to maintain 3V as long as possible as the batteries discharge. Alternatively use a 18650 LiPO - get a dollar store single cell USB powerbank and hack it for its cell and charger/boost board. Run the Arduino straight of the cell, and disable the boost circuit by removing the inductor if you don't need 5V for anything.

author: Youkai
author_rank: Regular Contributor
timestamp: April 06, 2018, 03:51:37 pm
content: Wow there is a lot of information there. Thank you Ian.M. A fair portion of it I don't understand though or have questions about.I get the bevel gear to operate the lid.I think I understand what you are saying about the cam in the base. Couple questions though. I originally thought I would have the front face of the two drawers be part of the front face of the chest. Then I realized if I just have a flange on the lid that covers them I don't have to have such tight tolerances on them to prevent gaps in the outside wall. So the lid will need to open a little before the drawers start swinging out. I think you cam idea will allow for this correct?Also this design is incomplete. I could leave the main body of the chest as a big cavity but I was thinking about having a tray under the drawers that would swing up/out after the drawers are out of the way. I'm not sure if this feature would be possible with the cam idea. Possibly a second motor? I guess since it's my first project I could scrap that as too complex.There obviously needs to be a button on it somewhere to activate the mechanism. Additionally I was thinking about having some LED on the inside of the lid's flange to light the inside of the chest when it's open. Also a few LED mounted to the bottom of the chest to light up the surface it's on would be cool. The LED would be RGB LED's possible a short section of an LED strip so I could do cool things with the colors using Arduino. I don't think either of these has much influence on your comments.I get the sensors or switches for the cam. I could have a very light trigger switch that the cam runs into to tell the Arduino when to stop the motor.After a quick google search I see that the H-Bridge will allow me to run the motor in reverse. Will applying PWM to that really save a noticeable amount of battery? What would you set the duty cycle of the PWM to?Also how do I insure that it doesn't move/wobble in the open position? I was thinking there would be hooks in the lid to hang necklaces on the inside. So there will be minimal amounts of force applied when it is resting in the open position. Will the motor/cam/band hold it steady enough?Finally I don't understand too much about what you were saying with the LiPO cell and disabling the boost circuit, etc. Do you have some links to blogs/tutorials that cover that topic? The arduino runs off 5v so couldn't I just plug the battery pack directly into the arduino using a USB cable to power it? Actually to power the whole thing I was thinking since it's going to be sitting on a counter top/desk anyway maybe I could just use one of those USB wall outlet charger blocks and plug the arduino in using USB that way. Then if I can power the motor and LED off of the arduino (possibly PWM outputs for the motor?) then I can power the whole thing with only one plug/power source. Thoughts?Thank you for your time and help!

author: Ian.M
author_rank: Super Contributor
timestamp: April 06, 2018, 05:08:45 pm
content: Here's a face cam connected to a crank that partially rotates a wheel.For your application it would have more than one track and follower, but the tracks would only go a third of the way round the cam. The relative sequencing of the push rods with respect to the cam rotation is set by how each track changes radius as the cam turns.Additionally, it would need to have something to trip a limit switch at the ends of the cam's 120 deg rotation so the Arduino knows its reached the fully open and fully closed position, and probably an extra switch detecting the intermediate position with the lid fully open, but before the swing-out trays move.You could prototype the mechanism on a much much larger scale than is going to go into the box, using a disk of 1/2" plywood for the cam, cutting the tracks with a wood router. The final version would need to be machined from aluminium or brass or cast from glass fibre reinforced epoxy (in a mould that forms the tracks) as I doubt the easy option of a 3D printed cam would be strong enough.As long as the cam track is at a constant radius at (and close to either side of) the fully open position, so pushing on the lid cant turn the cam, the lid will be as rigid as the slop in the linkages and geartrain allows. However you may want to include a spring in the linkage so forcing the lid doesn't break the mechanism.

author: Youkai
author_rank: Regular Contributor
timestamp: April 07, 2018, 11:56:08 pm
content: A appreciate the help and video Ian.M but I think I'm going to stick with servo's. I have used them before and I think they will be more dependable than my hacked together cam setup.I did a little research and found this threadhttp://www.instructables.com/id/Servo-Feedback-Hack-free/about how to hack a feedback loop in a hobby servo. Also I found that analog feedback servos are a thing that exist so maybe I can get those.https://www.robotshop.com/en/analog-feedback-micro-servo-metal-gear.htmlThat servo and this one that I have some of alreadyhttps://www.servocity.com/hitec-hs-55-servoare both small enough to fit within the 4cm pillars. If I can check the position of the servo's then I can do multiple moving parts without worrying about the pieces colliding.So I think 3 servo's will handle the moving parts. Now to look into momentary press button switches and RGB LED strips that I can use to light the thing.

author: NiHaoMike
author_rank: Super Contributor
timestamp: April 08, 2018, 12:59:21 am
content: Are you looking to make a commercial product or will it stay a one-off? (It sounds like you're just making a few at most.)The bottom part doesn't look very 3D printing friendly. Try to avoid overhangs wherever possible.

author: Youkai
author_rank: Regular Contributor
timestamp: April 08, 2018, 01:23:05 am
content: This is just a personal hobby project. There will only ever be one. If it turns out well I might make an adjusted/upgraded version in the future but there will really only be one of this.Here is a better picture of the bottom. There aren't really any overhangs other than the cylinders on the top-back. Though when I hollow one of them out to make room for servo's that might change. Something I'll need to consider when I'm farther along in the planning.

author: Ian.M
author_rank: Super Contributor
timestamp: April 08, 2018, 02:06:34 am
content: The trouble with servos is the very limited torque available in a small size. An alternative to using a cam would be to use two small gearmotors, with worm gear reduction between their output shafts and the vertical drive shafts in the pillars. Unless a worm gear is very coarse pitch, it cannot be back driven.One would handle the lid and the other both swing-out trays. Additionally, if using DC motors you'd need H-bridges that can sense the motor current - it might be simpler to use small stepper motors. Both the lid and the trays would have physical limit stops.The strategy would be to simply run each motor in sequence , with PWM for torque control if using DC motors, until it stalls at the limit of its travel. Steppers would be run a fixed number of steps, sufficient to drive from one limit to the other with a few excess that the motor will stall for to ensure its right at the limit.

author: Youkai
author_rank: Regular Contributor
timestamp: April 08, 2018, 02:31:51 am
content: Hmm. Ian.M, could you expand on what you mean by "PWM for torque control". I googled it a little but I still don't really understand. I think based on your note you are saying that I could have some kind of physical barrier set up so that the moving piece would run into it and the motor wouldn't be able to move it anymore. Then I somehow detect that and shut off the motor?I am still trying to understand how the variables work with my very limited electronics knowledge. Based on the sites and videos I have just seen it seems like the PWM adjusts the average voltage of going to the motor which would affect how fast the motor turns correct? Are the motor's rotation speed and torque linked? Also how do I know when the item has run into it's end of motion and shut off the motor so it doesn't burn out or break parts?

author: NiHaoMike
author_rank: Super Contributor
timestamp: April 08, 2018, 04:09:42 am
content: It looks like the bottom is elevated and thus a big overhang? Or is that just an illusion/incomplete part of the design?

author: Youkai
author_rank: Regular Contributor
timestamp: April 08, 2018, 04:23:22 am
content: Oh yes you are right. That could be solved pretty easily by making the part of the pillar that goes below the base of the box an extension. The feet can have a post that slots into the main body and I can glue then together

author: Ian.M
author_rank: Super Contributor
timestamp: April 08, 2018, 12:32:31 pm
content: For a PM (permanent magnet) DC motor, torque and speed are closely interrelated, and the relationship is set by the motor design and construction. Seehttp://hades.mech.northwestern.edu/index.php/Brushed_DC_Motor_Theoryfor a brief introduction.A PM motor also acts as a generator, with an output voltage proportional to shaft speed, and even when running as a motor, the induced voltage in the windings from their movement through the stator field is still exactly the same as when it was running as a generator at the same speed, and this voltage (known as the back-EMF) opposes the applied supply voltage, and only the difference is available to drive current through the winding resistance. Theoretically, an unloaded frictionless motor will speed up until its generated voltage matches the supply voltage, at which point, with no current flowing, it cannot draw any more power to accelerate further, so a PM motor's maximum speed is proportinal to the average supply voltage.Neglecting frictional losses and stiction, average torque is directly proportional to average current, and, assuming constant winding resistance (ignoring temperature effects) this results in the straight line torque vs speed 'curve' of an ideal PM DC motor.Now lets get back to your problem - driving a mechanism from limit to limit without bits snapping and flying off, or the motor burning out when it hits the limit. If you ran a motor direct off the supply rail (e.g. using a pair of relays to operate it in either direction), one of three things would happen when the mechanism hits a mechanical end stop. If the torque available exceeds the strength of the weakest part of the mechanism, it will break. That's the one to avoid at all costs. If there is a friction drive (e.g. an untoothed belt drive) or clutch in the drive train, there may be enough torque to cause it to slip. That can be tolerated for a short time, but prolonged and repeated slipping will wear it out so is best avoided. The remaining possibility is that the motor will stall. At that point the current through it is only limited by its winding resistance so it will rapidly heat up. As long as the supply can handle the stall current and you cut power before the winding exceeds its maximum permissible insulation temperature, and the applied voltage isn't high enough for the stall current to demagnetise the stator, no damage will be done.Now lets consider a PM DC motor driven by a H-bridge with current sensing, controlled by a MCU with the current sense voltage fed to an ADC input. Your code can control the average voltage across and current through the motor by varying the PWM duty cycle. If you close the loop in software to prevent the motor current exceeding your desired limit by reducing the PWM duty cycle, you get torque limiting.However the MCU cant react instantaneously, so you need either some resilience in the drive train or resilient (rubber or sprung) end stops so the torque at the limit ramps up slowly enough for the code to read the current increase and react by dropping the PWM duty cycle.Also, you'll want to detect prolonged stall or near stall conditions and fully cut motor power to prevent overheating.It gets easier to code for soeed control if you also have a means of directly monitoring the motor speed rather than having to calculate it from the supply voltage, PWM duty cycle, motor current and the motor's parameters. This can be done electronically by measuring the back-EMF during the off period of the PWM duty cycle, but the voltage is noisy and a circuit to sample it and average it without reading the supply voltage during the PWM on period is quite complex. Its generally preferable to add a sensor that provides a pulse-train at a rate proportional to the shaft speed. At its simplest this can be an optical or hall sensor giving one pulse per turn, although for faster reaction multiple pulses per turn from an encoder disk are preferable.One option for really compact small geared motors is to hack servos to remove the feedback pot and any stops that prevent continuous rotation. The feedback pot is replaced by a trimpot that is adjusted so the motor doesn't turn when a 1ms control pulse is present. Then the output shaft will turn forwards or backwards as the control pulse varies from 1ms, usually with speed proportional to the difference in its width from 1ms. However this arrangement is prone to unwanted motor creep at the supposedly off 1ms pulsewidth, so its advisable to include a MOSFET to cut power to the motor when you want it really off. The built-in drive electronics remove the need for a separate H bridge. Current sensing can be added in the supply wire to the servo, and if you can get access to the side of a gear early in the geartrain. an encoder disk can be printed on a sticky label and used with a retro-reflective optical sensor to get the shaft speed.

author: Youkai
author_rank: Regular Contributor
timestamp: April 08, 2018, 06:14:33 pm
content: Wow lot of information there. Thanks Ian.M. I'll try to digest it all. Probably going to need to do some tests with my Arduino board and the setup you are suggesting (H-bridge, MOSFET). Are there any considerations I need to be aware of when looking for a motor to test with? Can I just google "hobby pm dc motor" and pick whichever?Could I get a 6v motor and use the same 5v power source I'm going to run the Arduino from? For simplicity (especially if I'm going to give this to someone as a gift) I'd like there to be only one power source. If I get motors that need higher than 5v to do what I need them to do then I either have to have a voltage regulator to split some power off for the Arduino or I need two power sources; one for Arduino, one for motors.Also NiHaoMike's comment made me realize there is a big overhang in the design so I updated the model to have the feet of the posts be detached so the base of the main box will sit on the printing bed. After printing a can glue them together and putty/sand the joint before painting to make it seem like one solid post.

author: Ian.M
author_rank: Super Contributor
timestamp: April 08, 2018, 07:32:32 pm
content: Brushed DC Motor voltage is a bit notional anyway - most will be reasonably happy at significant over or under voltages. The limits are mechanical, thermal and magnetic. Far too much voltage and the rotor may destroy itself by overspeeding and bursting, but you are far more likely to cook it by working it too hard before it flies apart. The actual voltage spec will be chosen by the manufacturer to get an acceptable probability of failure over the design operating lifespan, and so the stall current isn't high enough to demagnetise the stator.5V is near enough so a 6V motor will run with about 80% of its nominal performance (i.e 80% of full speed, 80% of max torque). Another option would be a 3V motor and never exceed 60% PWM duty cycle.Also most Arduinos have an on-board regulator. e.g. a Uno or Nano can accept up to 12V Vin and will regulate that down to 5V for the ATmega328P, so you could use higher voltage motors. However if you do that you have to be careful how much current you draw from the Arduino's 5V rail (including current out of Arduino I/O pins configured as outputs at a logic '1' level).as at 12V in, every extra mA drawn is another 7 mW of dissipation from the regulator and its got barely enough copper area to heatsink it as-is. The higher Vin is above the minimum of 7V, or the higher the ambient temperature, the less 5V current you can draw. You'll also run into regulator overheating problems if the board is in a poorly ventilated enclosure. If you need more 5V current than the onboard regulator can safely provide, the best option is a properly heatsinked external regulator if you need a low-noise 5V supply or an external switched mode buck regulator if you need it to run cool but can tolerate some HF ripple on your external 5V rail. If you use an external regulator, be aware that anything running off its output wont be powered if the Arduino is running purely off USB power.

author: Youkai
author_rank: Regular Contributor
timestamp: April 26, 2018, 04:14:38 am
content: Started looking into the power supply for this project. Went to the local thrift shop and found a wall adapter from something that supplies 12VDC and 500mA. My RGB LED strip runs on 12v. Also got a food saver vacuum that runs on 5v but I scavenged the barrel plug from that so I can have something to plug into. Pulled the plug out of the sealer and connected it to my adapter. Was able to power the segment of LED strip using this setup. Yay!Now I just need to get a voltage regulator and some transistors and start working on a circuit diagram.Currently the plan is for the thing to contain the following:2 LED strip of the length shown in the image3 servo: Futaba S3004 or similarArduino (I have an Uno but I'll probably consider getting a board with a smaller footprint)Probably a TLC 5940 PWM driver or two since the arduino probably won't have enough PWM pins.Some transistors between the Arduino and LED stripsVoltage regulatorAny reason to believe the power supply I found will be insufficient? I don't see anything on the box about minimum power needs for the Arduino.Also I still need to do some testing on the servos. I think they will produce enough torque to do what I need since the parts won't be very heavy; but Ian.M has his doubts so I'll need to make sure these will work and come up with something else if not.

author: Youkai
author_rank: Regular Contributor
timestamp: September 03, 2018, 11:59:45 pm
content: Took some time off of the project but I'm thinking about it again. Specifically I was thinking about the opening/closing operation. My plan was to time how long it takes for the servo's to complete their rotation under load and then just have the lid and drawers open in sequence. But this is not ideal for two reasons. 1) It's not as cool as if they all open at the same time. 2) There is no mechanism to detect if there is a bad state and cancel operation until needed.So ideally there would be some mechanism to detect when the lid and drawers get to certain positions. For opening; once the lid opens enough to clear the drawers then the drawers can start opening. For closing I could send the lid to a partially closed position until the drawers finish closing then close it completely.So I was thinking about some kind of switch with a lever arm (e.g.https://www.adafruit.com/product/819) that the lid/drawers would work. Then I had an idea of a photo resistor (e.g.https://www.adafruit.com/product/161) where the lid/drawers operation would just cover the sensor up to trigger it.I don't have any experience with photo resistors though. Are they reliable enough to use for a scenario like this?

author: Ian.M
author_rank: Super Contributor
timestamp: September 04, 2018, 02:23:05 am
content: A CdS photoresistor would be one of the worst possible choices of optical sensor for a position sensing application. They are slow and their resistance value is highly dependent on temperature and their previous illumination history. Also, if you plan to use ambient light, you'd have to cope with several orders of magnitude difference in illumination level (e.g. between direct sunlight on the dressing table in the morning, and in the evening, a room only lit by subdued 'mood' lighting with the dressing table in shadow). Even if you provide a light source for the sensor, strong external illumination could confuse it, and a CdS LDR isn't fast enough to make it practical to use a modulated light source to discriminate between the intended signal and interference from ambient lighting.A better choice would be an IR photosensor with an IR LED and a phototransistor. The IR LED can be modulated by pulsing it at a frequency of a few tens of KHz, and the phototransistor can be optically filtered to reject non-IR sources and AC coupled so that steady ambient illumination has no effect except to reduce its sensitivity ti the desired signal. If the circuit is arranged to reject signals other than of the modulation frequency, the result can be highly resistant to interference from other light sources. Such sensors fall in three categories:Retro-reflective, with the IR LED and phototransistor side by side with a light-proof partition between them so that the only way for the LED to illuminate the phototransistor is for its light to bounce off a reflective surface close in front of the sensor.photo-interrupters, The LED and phototransistor face each other either side of a slot in their housing. The light path between them can be interrupted by anything opaque entering the slot. For positioning applications that could be a metal vane attached to a shaft with its edge notched at positions you want the sensor to detect.Beam sensors, basically the same concept as a photo-interrupter, except separate the LED and phototransistor, and add optics or shades so that the LED emits a relatively narrow beam and the phototransistor can only sense light from one direction.Also the receiver doesn't *have* to be a phototransistor - it could also be a photodiode with or without an integrated amplifier.Adafruit stock one retroreflective sensor:https://www.adafruit.com/product/2349You can get significantly smaller ones from other suppliers.A lever arm microswitch like you linked to could work for your application but they tend to be bulky, to require an accurately made mechanism to operate them consistently, and its a PITA adjusting their mounting position to get them to operate at the exact point you want them to.

author: helius
author_rank: Super Contributor
timestamp: September 04, 2018, 03:47:48 am
content: Quote from: Ian.M on September 04, 2018, 02:23:05 amIs that really a concern? CdS photocells were the standard technology in optical expression pedals used on transistor organs, where they obviously had to respond within a few milliseconds to control the sound.QuoteThis is a real concern.

author: Ian.M
author_rank: Super Contributor
timestamp: September 04, 2018, 04:35:49 am
content: For anything directly controlled by a human, even a few tens of ms delay is imperceptible. We just aren't equipped to notice. However even a couple of ms delay would make them ineffective with modulated light sources, especially as one needs to keep the modulation frequency fairly high to allow spurious signals that commonly modulate modern domestic light sources, (e.g. PWM dimming, typically in the high Hz to low KHz range, and 100Hz or 120Hz from the rectified but insufficiently smoothed supply), to be rejected.There's also the issue of the relatively large area of a typical CdS photoresistor, which makes precise position detection extremely difficult, even with a lens system, a well collimated light source and a focal plane aperture well matched to the active area.

author: Youkai
author_rank: Regular Contributor
timestamp: September 04, 2018, 05:27:09 am
content: I'm not at all worried about a few MS delay in the photo resistor. My plan for the photo resistor was to have them sit in a tiny cavity which would be covered by the moving part. The moving part cover the cavity within about a MM of space. This should effectively block all outside light.Also the inside of the lid will have a RGB led strip in it. Originally I was thinking it might do cool color things while opening and then settle on white when open to illuminate the inside. But I could switch that out for some plain white LED and just have them on any time the thing is in operation. This should flood the inside of the chest with enough light to get a clear difference between dark/light regardless of the ambient light situation. I had considered "what if the room is dark"?The thing I like about the photo resistor is that it's tiny compared to my other options and there are no moving parts.So the question then is will I get a distinct enough difference between light and dark. I would think so but Iam.M noted that temperature can have an effect. Is that difference enough at standard interior room temperatures that it would throw the resistance numbers off so far as to make them unreliable?I'll have to read Ian.M's post in more detail tomorrow to try and understand the difference between his options and my current idea. Thank's everyone.

author: Youkai
author_rank: Regular Contributor
timestamp: September 04, 2018, 05:39:40 am
content: Ok I read the description on the Reflective IR sensor Ian.M posted. So in that case I would mount it on the inside and when the lid was directly in front of the sensor it would see the reflection and get an "On" signal. Then when the lid cleared away leaving a gap of larger than 10mm it would be "off"?My concern here is that I would have to have one of these sensors pointing up to see when the purple drawers from my diagrams cover them. Wouldn't that sensor be severely prone to sensing other sources of IR radiation (Incandescent bulbs, the sun through a window, etc) which would make it impossible to tell when I was getting the IR reflection and when I was getting some other IR source? I don't know if RGB LED produce any noticeable amount of IR light but it would be pointing straight at the LED inside the lid when the chest is open. Is this something Ian.M covered with his AC modulation talk? That kind of went over my head.

author: Ian.M
author_rank: Super Contributor
timestamp: September 04, 2018, 07:06:26 am
content: I mostly covered the false signal issue. There are a couple of things I didn't mention like the brightness of the IR LED - it will typically be pretty bright relative to most ambient sources so unless the phototransistor is pointed at the sun, or is right under a halogen spotlight or a large fire in an open fireplace occupies its field of view, the LED illumination should be stronger. Good quality sensors have optical filters to pass only IR, so non-incandescent lighting typically doesn't effect them much. They can still be fooled by direct sunlight, intense heat sources, IR remote controls and camera flashes that use flash tubes.Also, you'd typically have a highly reflective surface e.g aluminum foil tape where you want it detected, and matte black or nothing in range where you don't want detection to get a good contrast ratio.On the modulation side of things, assuming an analog output sensor, if you PWM the LED with 50% duty cycle and sample the sensor twice within the PWM period, near the end of the on time and near the end of the off time, then the difference must be either due to the additional illumination of the LED or due to rapid fluctuations in the ambient light level, which if you average over a few PWM cycles, will cancel out.Unfortunately an AVR based Arduino has an max. ADC sample rate of 9.615KHz (hardware limit base on clock speed) and in practice you'll be lucky to get close to half that unless you program in assembler, so that strategy isn't viable if you need to get the modulation frequency well above the likely range of LED lighting PWM frequencies. An alternative would be to do it in hardware with a synchronous detector driven by the same PWM as the LED. Another alternative would be simply be to leave the LED on until you detect something then toggle the LED on and off a few times and check the detected signal follows the LED.However the smartest way to handle it is to put the sensor where its least likely to be affected by ambient light. Assuming your servos are in the base, simply get a narrow slot photo-interruptere.g:https://www.jameco.com/z/H21A3-Major-Brands-Photointerrupter-Transmissive-3-3mm-Phototransistor-4-Pin-Rail_320901.htmland have a vane or flag somewhere on the servo shaft, horn or linkage that moves through the slot. Because of the narrow slot and opaque body, its shielded against indirect ambient light, and if mounted in the base with an opaque cover over the mechanism, there wont be much ambient light anyway, so it shouldn't need modulation. Caution: many black plastics and paints are *NOT* opaque to I.R. Test before you build the mechanism!Another option for sensors in the base would be 2mm dia subminiature Neodymium magnets in holes drilled in the moving parts and hall effect sensors. e.g.:https://www.adafruit.com/product/158You probably wouldn't want to use them up in the lid or tray due to the risk of a magnetic clasp or other fastener on an item of jewellery ending up close enough to the sensor to 'jam' it, and you might even need a soft iron sheet between the mechanism and the box bottom for magnetic shielding.Back to the CdS photoresistor (LDR) - there is no substitute for getting a couple and experimenting. Also get a can of freezer spray so you can easily chill it. If you mount it recessed in a small block of aluminum (drill a hole, then drill two tiny holes from the other side for its leads, which will need to be sleeved with insulation, and also drill another separate hole for the tip of a thermocouple. Use a little thermal grease on the back of the photocell and on the thermistor), you can easily characterise how its resistance varies with temperature.If you want to look at its time response, hook it up with a 9V battery for bias and a 10K series resistor to a scope then shine a flashing LED at it, or put a disk with two 90 deg segments cut out (leaving a bow-tie shape) on a motor shaft and spin it just in front of the cell to interrupt the light to it.Another issue with CdS LDRs is ageing. Typically the dark resistance decreases and the light resistance may also increase. Factors that may contribute to accelerated ageing may include UV, moisture and elevated temperatures. An order of magnitude reduction of sensitivity due to ageing is possible though generally the LDR will have been replaced as failed before it gets that bad.Another quirk of CdS LDRs is their sensitivity to static charge. This isn't normally an issue if you use the type that has a clear plastic cover over the cell with an airgap, and avoid idiocies like dry polishing it with a silk cloth, but if you use the bare cell type that only has a thin plastic film over the CdS surface, one can get a significant resistance chance with only a modest charge buildup. Seehttp://sparkbangbuzz.com/cds-fet/cds-fet.htmfor this effect exploited to turn a CdS cell into a crude MOSFET equivalent.

author: Youkai
author_rank: Regular Contributor
timestamp: September 04, 2018, 08:29:12 pm
content: Ok I like the narrow slot photo-interrupter idea. That seems like it's the same concept as what I was thinking but much more resistant to external interference. I'll order a couple of those and do some testing.

author: Youkai
author_rank: Regular Contributor
timestamp: September 12, 2018, 04:18:12 am
content: I'm getting ready to solder some wires onto my h21a3 phototransistor. Wanted to do some double checking to make sure I don't do anything stupid.The data sheet (http://www.robotstorehk.com/h21a1.pdf) says the emitter has a max forward voltage of 1.7v and a current of 60mA. So with my 5v power source I need a 55ohm or greater resistor. The next standard resistor is 56ohms. I don't know if I have that one but I do have a pack of various resistors. So I should pick the smallest one I have that is > 55ohm correct?I'm pretty sure it doesn't matter but just to triple check it doesn't matter if the resistor is on the cathode or the anode correct?What about for the sensor? I don't see a max voltage in the data sheet. I don't think transistors need them really right? So just two wires off those terminals is fine?

author: Ian.M
author_rank: Super Contributor
timestamp: September 12, 2018, 05:03:55 am
content: You don't want to push the max If limit if you want long term reliability and the datasheet you linked has 50mA max continuous If, not the 60mA you quoted.Most of the datasheet specs are given with emitter LED If of 20mA or 30mA, so I'd use a 120R series resistor for a bit under 30mA If. If you need to save power you could go even higher resistance *IF* you use a large enough load resistor for the detector - the datasheet quotes 0.15mA Ic min. for If=5mA, which would be adequate to pull low against a 10K pullup. To get about 5mA If, a 680R series resistor should be satisfactory.On the sensor side of things its a NPN transistor used as a switch so its emitter (pin 4) must be negative of its collector (pin 3). Its max current is limited by the If of the emitter LED - see datasheet, and you want it to fully saturate when on so the pullup or pulldown resistor should be chosen for about an order of magnitude lower Ic than the 'On-State Collector Current' (at Vce=5V) tabulated in the datasheet.If you put the resistor in series with the LED anode, you can get away with a three wire sensor hookup: LED anode, detector collector, and a single ground wire to both the LED cathode and detector emitter.

author: Youkai
author_rank: Regular Contributor
timestamp: September 12, 2018, 05:50:33 pm
content: I don't think I can do the 3 wire configruation Ian.M because I need to have it connected to Arduino. Does this diagram look correct to you?EDIT: I'm sure I didn't draw the interaction between the LED and the transistor correct there. Would I just draw that as if it were a wire?

author: Ian.M
author_rank: Super Contributor
timestamp: September 12, 2018, 07:31:45 pm
content: That should work, (as long as you don't mix up the transistor emitter and collector) active high when the gap is *NOT* blocked.If you make it active low, by putting the transistor between the Arduino input and Gnd with the 10K resistor as a pullup, you can do three wire.The usual LED symbol has two parallel arrows to represent light.

author: Youkai
author_rank: Regular Contributor
timestamp: September 12, 2018, 09:12:32 pm
content: I re-drew the diagram. Does that look correct?I just bend the two pins together and solder one wine to both of them and use that as the ground?So in this configuration the Arduino pin will read high (5v) through the 10k resistor when the LED is blocked. Then when it's clear it will read low (0v, or close to it) because the path to ground has much lower resistance. Is that correct?

author: Ian.M
author_rank: Super Contributor
timestamp: September 12, 2018, 10:16:03 pm
content: Nearly - you are missing the arrow that indicates the phototransistor emitter and that its NPN. Assuming you've got te emitter at the bottom, the circuit looks OK.If you find it difficult to get a good logic '1' level (>4V) when the gap is blocked, due to stray light or an interruptor that isn't totally opaque, decrease the 10K resistor. Don't go below 2K.

author: Youkai
author_rank: Regular Contributor
timestamp: September 12, 2018, 11:05:52 pm
content: Ah, so like this?https://learn.parallax.com/sites/default/files/content/shield/robo_ch6/series_sch.jpgThe two arrows outside indicate that it's a phototransistor and the one inside indicates the emitter?Cool beans. I'll wire up a test circuit with my breadboard tonight if I have time.

author: Ian.M
author_rank: Super Contributor
timestamp: September 12, 2018, 11:46:06 pm
content: Yes, that link has a good symbol. You'll also see ones with a base lead, most often in opto-couplers.If you have problems identifying the pin numbers of your opto-sensor, find the anode and cathode of the LED using a DMM with a diode test range that goes up to 2V, then match that up to the diagrams in the datasheet.

author: Youkai
author_rank: Regular Contributor
timestamp: September 13, 2018, 02:17:16 am
content: I was able to get it working. Soldered the sensor according to my diagram and using a serial monitor was able to detect when the sensor was blocked or not in Arduino studio. Yay! one more hurdle down.

author: Youkai
author_rank: Regular Contributor
timestamp: September 18, 2018, 10:26:47 pm
content: I have tested the sensor and the button I'm going to use to open/close the thing. So now I'd like to start working on a more complete circuit diagram. But I'd like to do it in a program so I can quickly make adjustments to it without having to re-draw the whole circuit. I'm looking for a good simple editor that I can use to draw a circuit. I don't really need any fancy simulation or anything. I have LTspice and DipTrace on my computer and I'm having trouble getting them to do what I want. I'm sure that it's due to a profound lack of experience with these programs.Does anybody have suggestions for a simple circuit diagram tool or a good tutorial that can show me how to use the ones I have?EDIT: I'm starting to have some luck with DipTrace. I'll keep working with that for now and see if I can come up with something reasonable.

author: Youkai
author_rank: Regular Contributor
timestamp: September 19, 2018, 01:19:06 am
content: Ok so here is my first shot of a schematic. I made it using DipTrace. This is a schematic of a setup that I have wired successfully (though with only one RGB LED in my test). Pressing the button triggers the lights to turn on. Pressing it again turns them off.Any input on the schematic would be appreciated. The next step is to expand the schematic to include the phototransistor and servos.

author: Nominal Animal
author_rank: Super Contributor
timestamp: September 19, 2018, 03:02:05 pm
content: I just received a couple of small geared stepper motors, similar tothese. The axial cross section is 10mm × 12mm, body length about 20mm, so it fits inside a 20mm tall cylinder with 16mm diameter or greater (not including wall thickness). The ones I have have a 1:275 gearbox and 18 degrees per step, i.e. 5500 steps per turn. I haven't tested mine yet, but I do believe they have enough torque to rotate the tray or open the lid directly, without any additional gearing. Forcing the trays (by hand) is likely to strip the metal gears. There is a little bit of backlash.The ubiquitous 28BYJ-48 geared stepper motors have more torque, and since their diameter is 28mm, you could place those too inside your cylinders. However, their axis is 8mm off center, so you cannot fit them inside a 40mm diameter cylinder with the axis at the center.

author: Youkai
author_rank: Regular Contributor
timestamp: September 19, 2018, 11:50:36 pm
content: I revised my drawing. Made a couple custom components to help me out.I included the RGB LED strip and the transistors/resistors into a component.Made a component of the Photo-transistor switch with the 3-wire setup.Made a stupid simple "Servo" because I couldn't find one in the components.My button has a built in LED/resistor which is independent of the switch (4 wires) so I made that a component too.I just used a stock multi-pin component for the Arduino. I might make a custom arduino component in the future so I can actually plan the wire placement.Diagram is still missing the Buck converter. Also The arduino isn't going to have enough PWM pins so I'll need to include a PWM chip at some point. Probably something else I'm forgetting but I think it's pretty close to complete.Please review and provide feedback on the diagram. I'm sure I'm breaking all sorts of best practices. Thank you!

author: Youkai
author_rank: Regular Contributor
timestamp: September 22, 2018, 07:13:47 pm
content: I think this is a complete schematic at this point. I'd really like some feed back. Primarily I have read that the TLC5940 can't handle that much current. Is there any reason to believe running this setup will burn out the chip?I'm using Yellow as my positive wire color because I have RGB LED's and I want the led wire to be the color of the LED. Other than that the wire colors don't mean anything.EDIT: Haha. I'm an idiot. The "Sensor" data pins need to go to the Pro Micro. Not to the TLC. Updating the diagram.

author: Youkai
author_rank: Regular Contributor
timestamp: September 23, 2018, 05:27:22 am
content: Found the issue with the sensors. Also found I was missing a wire for the button. This diagram has the updates.

author: Ian.M
author_rank: Super Contributor
timestamp: September 23, 2018, 07:00:49 am
content: I think its going to be sub-optimal running both the LEDs and the servos from the TLC5940, as that will cause excessive flicker. A Futaba compatible servo signal requires a 50Hz repetition rate, and as the TLC5940 PWM timebase is common to all channels, that would force you to use 50Hz for the LED PWM frequency.As ATmega328P based Arduinos have six hardware PWM pins, you should be able to connect the servo direct to the Arduino so you can run the LED PWM much faster, avoiding any perceptible flicker.

author: Youkai
author_rank: Regular Contributor
timestamp: September 23, 2018, 08:28:19 pm
content: Quote from: Ian.M on September 23, 2018, 07:00:49 amThe Pro Micro uses a ATmega32U4 which only has 5 PWM pins. I guess I need to do a test with the TLC5940/Sevo/LED and see how noticeable the flicker is. If it's bad I will need to consider not having the fade effect, maybe it's better with just setting a sold color; or using my Arduino Uno instead of the Pro Micro since that has 6 PWM pins.Is there any good way for me to know/see the PWM repetition rate for a pin? How can I tell if it's using the standard or the 50hz?EDIT: I'm also reading this stuff about DCPRG and whether it should be tied to HIGH or LOW. I guess the difference has something to do with the EEPROM value of 63, or not. I really don't understand it though. Can someone give me the ELI5 version? Do I just tie it to GND and not worry about it?

author: Youkai
author_rank: Regular Contributor
timestamp: September 23, 2018, 09:22:03 pm
content: Arg. Looking at the Arduino TLC library it seems that you can't change the pin numbers used. Which means I can't change the pin numbers for the Pro Micro. Sparkfun does have a library for their breakout but I'm not sure if that will work. I guess with this and the servo issue I'm back to using the UNO as my microcontroller.EDIT: Well hell. The wiring diagram for the TLC library does not have configurable pins and connects to 4 PWM pins. Maybe a different library only uses 3? I'm confused.EDIT 2: I guess I can change the pin numbers if I edit the library files. But I don't know which ones are required to be PWM pins so I can't safely change them. I assume all 4 that are assigned to PWM pins must be. Otherwise why would the developer of the library use up a PWM pin?

author: exuvo
author_rank: Contributor
timestamp: September 25, 2018, 04:20:18 pm
content: You could ignore the arduino PWM library and configure the PWM peripheral yourself. Also never look for reason in those libraries, there is little to be found.Find the datasheet for the microcontroller, the sections of interest are the Timers and what pins they allow for output compare / PWM. Each timer should have 2 output pins that are suitable for PWM. Usually you set the pin for output mode like normal, setup the TCCRx registers with a suitable output compare mode and prescaler (for frequency) and load OCRx with a value for length of pulse.You might need to be careful with timer 0 as i think arduino likes to use it for the time keeping functions. If you wont be using those functions you can re-configure the timer for your own use or try to work with whatever frequency it is already running at.The difficult part is usally finding a picture that shows what arbitary number an arduino pin is mapped to in the hardware, ex arduino pin 5 to PORTA bit 6.Some example code from one of my ATmega328 projects if you find it helpful. Comments might be incorrect.Code:void TimersInit() {GTCCR = _BV(TSM) | _BV(PSR10); // pause timers//OCR0A = 0;//timer 0 - CTC toggle - output pulse 500kHzTCCR0A = _BV(WGM01);//timer 0 - prescale factor 8 - 1MHzTCCR0B = _BV(CS01);//122 full 4096 cycles / sOCR1A = 4096*2+1;//timer 0 takes 2 cycles for each pulse, first pulse is ignored. +1 to edge align with timer 0//OCR1B = 0;//timer 1 - Fast PWMTCCR1A = _BV(WGM11) | _BV(WGM10);//timer 1 - prescale factor 8TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS11);//122Hz full cyclesGTCCR = 0; // resume timers}//timer compare to pin#define TIMER0A 6#define TIMER0B 5#define TIMER1A 9#define TIMER1B 10#define TIMER2A 11#define TIMER2B 3void PWM(uint8_t pin, uint8_t val){/*** If PWM is in fast mode val == 0 does not work* if (val == 0) {* PORT &= ~_BV(PIN);* } else {*/if (pin == TIMER1A) {TCCR1A |= _BV(COM1A1);// set PWM dutyOCR1A = val;} else if (pin == TIMER1B) {TCCR1A |= _BV(COM1B1);// set PWM dutyOCR1B = val;} else if (pin == TIMER0A) {TCCR0A |= _BV(COM0A1);// set PWM dutyOCR0A = val;} else if (pin == TIMER0B) {TCCR0A |= _BV(COM0B1);// set PWM dutyOCR0B = val;} else if (pin == TIMER2A) {TCCR2A |= _BV(COM2A1);// set PWM dutyOCR2A = val;} else if (pin == TIMER2B) {TCCR2A |= _BV(COM2B1);// set PWM dutyOCR2B = val;} else {extern void error(uint8_t errorCode);error(12);}}

author: Ian.M
author_rank: Super Contributor
timestamp: September 25, 2018, 06:54:46 pm
content: Another option would be to eliminate the TLC5940 and instead use smart RGB LEDs, e.g. WS2812 (aka:Adafruit Neopixels) or APA102 (aka:Adafruit Dotstar). There's an Arduino Neopixel library that handles the tightly timed WS2812 single wire interface, or if you use APA102 based LEDs, its a two wire SPI interface with no timing constraints, and yes, there is an Arduino library for it.Neopixels don't play well with background interrupts, but for a limited string of them, it would be possible to wait for a safe time in the servo frame to call pixels.show() to update them without causing servo jitter.

author: Youkai
author_rank: Regular Contributor
timestamp: September 25, 2018, 11:42:23 pm
content: This one would probably work perfectly for my needs:https://www.adafruit.com/product/1426So if I were to do this I would use 5 total PWM pins? 1 each for the 2 LED strips and 1 each for the 3 servos? Actually thishttps://learn.adafruit.com/adafruit-neopixel-uberguide/basic-connectionssays "any digital pin" can be the data pin so I wouldn't even need to use a PWM pin necessarily it seems. Yeah I'm just gonna do this. It will make the wiring much easier. Oh also this NeoPixel Stick needs a 5v power supply so I can take the transistors out too! happy days.I'm not sure I understand the comment about background interrupts. Do you mean like if I were to use attachInterrupt() from the Arduino library? I wasn't planning on using that in my code so I think this won't be an issue.EDIT: Ordered the RGBW one instead since I'm going to use one to light the inside when open so having a true white option would be good.https://www.adafruit.com/product/2869

author: Ian.M
author_rank: Super Contributor
timestamp: September 26, 2018, 03:21:55 am
content: The problem is the servo library uses interrupts, and if one occurs during pixels.show(), that would corrupt the data transfer to the LEDs. Therefore the show() method disables interrupts while it is outputting the pixel data. This will make any servo jitter if its servo pulse edge is due to occur while show() is executing. To avoid that, before calling show(), you need to poll the timer controlling the servos to check if its past the end of the last servo pulse and is waiting for the end of the 20ms servo refresh frame.

author: Youkai
author_rank: Regular Contributor
timestamp: September 26, 2018, 04:15:44 am
content: Ok that is way over my head. Do you have any links to examples that do that? Or keywords i can search to learn how?Also correct me if I'm wrong but communication with the servo only happens when I issue a command to change position right? And once that command is complete there is no more communication with the servo. So as long as i don't try to change the LED color for a short time after moving the servos there shouldn't be an issue. Is that correct?

author: Ian.M
author_rank: Super Contributor
timestamp: September 26, 2018, 05:20:17 am
content: Once you activate a servo on a pin with servo.attach(pin), the servo ISR continues pulsing that pin even when you aren't moving the servo. If you stop it, one of four things may happen, depending on the servo - it may stay where it is, or power down, or drive to a preset 'safe' position, or drive to either limit. Unless you know what the servo is specified to do on loss of signal, and that's power down or hold position, it isn't safe to use servo.detach().Most Arduinos will use Timer 1 for the servo library (see ServoTimers.h in the library for exceptions).In Servo.cpp:Code:#define usToTicks(_us) (( clockCyclesPerMicrosecond()* _us) / 8) // converts microseconds to tick (assumes prescale of 8) // 12 Aug 2009defines the relationship between timer ticks and us.In Servo.h:Code:#define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo#define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo#define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached#define REFRESH_INTERVAL 20000 // minumim time to refresh servos in microsecondsgives the limits for one servo pulse, and the total frame length.The servo library outputs pulses to its active channels consecutively during the servo frame. Therefore if you are controlling three servos, there's a gap between approx 7.2ms and 20ms in the servo frame where you can be certain no servo pulses are being output. That's when you need to update the neopixel string(s).As usToTicks() is private in the Servo lib, you need a copy of its definition in your sketch, then you can simply doCode:while(TCNT1<=usToTicks(8192)){};pixels.show();which waits for the gap in the servo frame before updating the neopixels. For 16 RGBW neopixels, show() has 512 bits of data to send, which will take approx 0.7us @800KHz pixel clock.N.B. you can daisy-chain the neopixel strips by connecting DIN to DOUT, so you'll only need one I/O and one call to the show() method for all the neopixels.

author: Youkai
author_rank: Regular Contributor
timestamp: September 26, 2018, 08:19:51 am
content: I see. Thanks for the great info Ian.M. I'll do some testing with that in the near future. I know I can chain the LED together but I wasn't planning on it because they are kind of in opposite directions from where the micro-controller will be. I guess it wouldn't be too far out of the way to chain them. Is one call to show() less than half the time of two calls? I'm only calling it once but I'm sending twice the data correct?Also my schematic is MUCH simpler now. The new LED run on 5V so that takes out the transistors and the buck converter. Here is the new schematic. Wire colors don't mean anything other than Yellow=Positive and Black=Negative. I think it still needs a little work. According to the notes on the Adafruit site I need to have a capacitor in there for the LED's. Need to do a little more research.

author: Ian.M
author_rank: Super Contributor
timestamp: September 26, 2018, 10:22:08 am
content: There's a small overhead in show() for setting up the transfer and the reset gap that latches in the data, so one show() would be ever so slightly faster, but if its physically inconvenience to daisychain them, there's no reason not to put them on separate pins then:Code:while(TCNT1<=usToTicks(8192)){}; // Wait till no servo pulsespixels1.show();pixels2.show();You definitely need a *lot* of bulk decoupling capacitance for the Neopixels and the servos. Unfortunately the USB standard calls for a maximum of 10uF on Vbus in a device, which is far too low for running servos on the same 5V rail as a MCU, and if you exceed the 10uF permitted by the standard significantly, you'll have problems with USB over-current at plug-in, or erosion of the connector contacts due to sparking. It would therefore be preferable to keep the buck converter and power it all from a higher voltage. The Arduino would use its onboard regulator and the servos and Neopixels would be fed by the buck converter. The seperate servo/neopixel +5V and Arduino +5v prevents servo noise crashing the Arduino. Also, it could be programmed via USB with just the Arduino powered, and there'd no USB excessive inrush current problem. You'd use an I/O pin to detect if the buck converter is outputting 5V so that the code would only enable the Neopixels and servos if they are powered.N.B. Adafruit recommend a 470R resistor in series with DIN between the Arduino and the Neopixels to prevent damage to DIN due to transients on the data line. If you don't want dead Neopiexls fit the resistors! Also, similar resistors in the servo control lines would be advisable.

author: Youkai
author_rank: Regular Contributor
timestamp: September 26, 2018, 03:33:34 pm
content: Ok cool beans. I'll update my schema to include the buck again and add the other stuff.I'll obviously power the Pro Micro from USB while programming it but it's going to be powered by the buck converter in live use. That shouldn't be a problem right? The "RAW" input on the Pro Micro has some kind of regulation on it I believe.Do I just put one capacitor across the two output lines of the Buck converter; before any connections to any powered device?

author: Ian.M
author_rank: Super Contributor
timestamp: September 26, 2018, 05:48:44 pm
content: That would be a physically *BIG* capacitor. You'd probably be better off using at least two separate capacitors for a lower profile. You may also want a Schottky diode between the buck converter output and the Neopixel Vcc + bulk decoupling cap, with the servos + their bulk decoupling cap connected on the buck converter side of it so the servos cant glitch the neopixel supply.The Arduino Pro Micro RAW supply pin can tolerate up to 12V. If you want the convenience of using a 12V wallwart, you need to pre-regulate or drop the RAW supply so it can *NEVER* go over 12V. A 78L09 9V 100mA regulator is suitable or a string of four 1N4148 or similar diodes to drop about 3V. If you use a 9V wallwart, don't worry. N.B. the wallwart *MUST* be regulated - avoid old linear unregulated ones as their output can be as much as 50% high when minimally loaded which will blow the Arduino.

author: Youkai
author_rank: Regular Contributor
timestamp: September 27, 2018, 02:08:48 am
content: Alrighty so a few things:1) The purpose of the diode is to prevent power "Backlash" from the servos starting/stopping causing trouble with the Pixels correct? If so then I would need D2 in my new diagram? Is there a reason to put D1 in there? Any reason to put one on the line that has the photointerupters on it?2) Is the Schottky diode for the low forward voltage drop? Is there any other reason to use that instead of another type of diode?3) What power rating should I use for the diode? A quick google seems to indicate that they are rated for voltage; and that the "breakdown voltage" is usually pretty high (like 100V). So just make sure I get a diode with a breakdown voltage way above 5V and I'm good?4) NeoPixels seem fragile. Is that just me not being used to component parts or are they a little more finiky than normal stuff?5) Figuring out power needs:NeoPxel: 16 * 30 ~= 500mA (30 is the rough estimate of power use on an "average" pixel)Servos: 200 * 3 = 600mAPro Micro: 200mAMisc power loss: 200mATotal power needs: 1.5A. Does that seem correct? I'm thinking I'll try to find a 9V, 2A wall plug online. Will that be sufficient?6) I found a 1000mF/16V capacitor that seems a reasonable size. Any reason I shouldn't use it? I know you said a couple smaller ones would work but if just one will do I'd rather keep it simpler.

author: Ian.M
author_rank: Super Contributor
timestamp: September 27, 2018, 03:22:54 am
content: 1. When a servo starts moving, the motor will momentarily draw its stall current which can be 10x its normal running current. This will cause the supply voltage to dip. If you feed 5V to the other devices like the Neopixels and the optosensors via a diode with a reservoir capacitor after it, when the supply dips, the reservoir capacitor after the diode maintains the 5V rail through the dip. D2 should NOT be on your diagram. D1 should feed *EVERYTHING* 5V except for the servos. You *need* a reservoir cap after the diode2. A Schottky would be used exclusively for its low Vf drop.3. Low voltage Schottkys typically have a lower Vf drop than high voltage ones. Also, at a fixed current, a higher current rating diode will typically have a lower Vf drop than a lower current rating one. The tradeoff is: higher current ones have more junction area so higher reverse leakage. A 3A 20V one should be suitable for this project. Don't go below 2A or over 40V.4. They are LEDs + logic. They don't like over-voltage and/or ground bounce, or DIN going outside the supply railsAT THE LEDso if you don't use enough bulk capacitance and your wiring inductance rings with the decoupling caps on the strip it can transiently over-voltage them, or your ground is too flimsy and their local ground is bouncing up and down by a volt or so, and you haven't used a series resistor in the data line, you can blow the internal input protection diodes of the DIN pin. Basically if your circuit is crap they can be killed by it. There have also been reports of quality problems with some suppliers (direct from China) of reels of the 'neopixel' style LEDs, with an excessive percentage being DOA. However Adafruit quality control should have weeded out defective ones after assembly so you shouldn't have any issues.5. The Pro Micro will draw far less than 100mA as none of its outputs are directly driving heavy loads. The sensors will draw about 100mA for all their IR LEDs. 1.5A @5V is 7.5W. assuming 80% efficiency in the buck converter, that's 9.4W in, so fractionally over 1A at 9V. A 1A one will be right on the bleeding edge, but a 1.2A one should do nicely and will be a lot easier to find than a 2A one.6. I'd advise two 1000uF caacitors, one before and one after the Schottky diode.

author: Youkai
author_rank: Regular Contributor
timestamp: September 27, 2018, 05:56:43 am
content: As always excellent information. Thanks Ian.MI updated my schematic with the provided information. The wires are a little more confusing but I rearranged the parts so that I could put everything on the second 5V rail together. Please let me know if I broke any cardinal tenants of schematic design.I tried to make sure that all the items are labeled correctly in this version. e.g. "Lid Servo" so I will know what pins they are attached to. Also I have all of the components labeled with their values so those can be verified.I did a little bit of looking online to find a wall wart that is 9V, 1.2A and didn't have much luck. Sparkfun has a 650mA version. Jameco has a 500mA. I maybe found a couple on some sites I have never heard of before. Do you have any recommendations for a site where I can get the wall plug?EDIT: After a little more searching I found this one at Jameco. It's 9VDC / 2A. Is that overkill?https://www.jameco.com/z/GS18U09-P1J-MEAN-WELL-2-Wire-AC-to-DC-Regulated-Switching-Wall-Adapter-18W-9VDC-2A-2-1mm-Plug_1952847.html

author: Ian.M
author_rank: Super Contributor
timestamp: September 27, 2018, 06:33:49 am
content: The only thing its missing is some ceramic decoupling caps right at each of the Neopixel connectors - at least 0.1uf, but preferably larger, and a 2x 10K potential divider between 9V and Gnd, with the tap connected to an Arduino analog pin so it can sense the supply voltage and only enable the servo control and Neopixel data outputs if the 9V is present.For robustness, you may also want a pair of small Schottkys from DIN to +5V (resevoir), and from Gnd to DIN right at each Neopixel connector, cathodes positive so they are reverse biassed in normal operation - that will save your Neopixels if there is a fault in your code and it attempts to drive them when the 9V is not present.

author: Youkai
author_rank: Regular Contributor
timestamp: September 27, 2018, 07:10:29 pm
content: 1) Don't the decoupling caps you are recommending and the 1000uF capacitor already there do the same thing? Is this just an extra layer of smoothing or is there some other purpose?2) When you say 0.1uF but more is better; what does "More is better" mean? Is there some upper limit to how much is reasonable? I found this 0.33uF cap on jameco:https://www.jameco.com/z/MD-33-Capacitor-Monolithic-Ceramic-0-33-micro-F-50V-plusmn-20-37-_138237.htmlIs that enough-more to be better-enough?3) What is the purpose of sensing the 9V and shutting off the pins? I assume (based on previous posts) that I can not power the whole circuit via USB (while programming). At most I would plug in 2 other components while programming it and the servo will never have a load applied to it while programming. So I would think USB could handle that ok.My plan is to use the Arduino while writing the program since it has a 5v output pin that I could use to power a single component while getting the code correct. Then I would only ever wire up the pro-micro/whole-circuit using the wall wart so there would never me a time when all of the components are attached and the 9V isn't present. Is it an issue if my Arduino is sending commands to a NeoPixel that isn't there?Oh reading your last sentence again I might see it. I remember reading on the Adafruit guide that you want to power the pixels before the micro-controller. So I guess you can somehow brick the pixel if you send an update command to it when it's not fully powered? Cool >.>4) I think I put the new Schottkys in there the way you explained but I don't see how they help with anything. I understand that if the Pixel gets a data input when it is not powered that can cause a problem but I don't see how the diodes somehow prevent the signal from getting through when not powered. I don't see how the ground connected one does anything ever under any condition. And If the positive rail is connected to power then nothing from data is going through because the Voltages will match right? Thus the signal goes to data; perfect. If it's not powered it's a wire with no connection at the end so there is no circuit so thus now power will go through the diode anyway right? Or does one of the capacitors somehow allow a circuit to complete and "eat" the signal?5) Question about actually soldering this together. Maybe this is complex enough that it makes sense to use a Perfboard. If I don't what's the best way to do something like the 5V Reservoir Rail connection where I have 5 wires connected. Would I expose enough of each that I could twist them all together in one group and solder that together; or perhaps expose a lot of one of the wires and solder the other 4 to unique points along it?6) New diagram attached. I think I got the Schottkys in there correctly as it seems if they were the other way it would cause issues. Though can you confirm the attachment points are ok. Do I actually need to go to the 5V rail on the upper ones; or is connecting the 5V and Data pins using the diode ok? They should be effectively the same right; with the exception that if I go back to the 5V rail that puts a capacitor in the circuit that wouldn't be otherwise?

author: Ian.M
author_rank: Super Contributor
timestamp: September 27, 2018, 07:59:38 pm
content: 1 & 2. The 1000uF electrolytic capacitors have a fairly high impedance at high frequencies due to their size and wound foil construction. A 0.1uF or 1uF ceramic has a much lower impedance at high frequencies so you need both in parallel, with the ceramic as close as possible to the load that will be drawing pulses of current. You don't need one for the Arduino as it already has some on-board.3. The Neopixels could be damaged if data is applied without power. If the 9V is missing its preferable to stop and not do anything (except possibly blink the Arduino's on-board LED to indicate its waiting for 9V power), so that's why I recommend sensing the 9V in. If you want to test the board while its hooked up to your PC by USB, supply 9V as well.4. For the DIN protection Schottky diodes, use low current ones. If you are building it using SMD parts BAT54S would be very suitable as it gives you two series connected diodes in a single three pin SOT-23 package. If you are using through hole parts, BAT43 wuld be suitable. Ideally solder the DIN protection Schottkys direct to the Neopixel LED strips, as there they can protect against loose power or ground wiring. If you mount them on your main board, they should go as directly as possible to the Neopixel connector pins.5. I'd build it on Veroboard, with the Arduino soldered down and a full width set of strips for the 5V rails and the Gnd rail just beyond the end of the Arduino to mount the big caps and big Schottky to.6. Your new diagram looks good. Ceramic decoupling and DIN protection Schottkys should be as close as possible to the Neopixels - ideally soldered direct to the strips, otherwise at the three pin connectors for the neopixels on your main board.

author: Youkai
author_rank: Regular Contributor
timestamp: September 27, 2018, 08:53:55 pm
content: I like the idea of the BAT54S. If I'm interpreting the spec correctly:https://www.mouser.com/datasheet/2/308/BAT54S-1118484.pdfData goes to pin 1+5V goes to pin 2GND goes to pin 3Is that correct? Then I just solder the pins on the BAT45S using as short a wire as close as possible to the pins for the Pixels?EDIT: note that the Pixels are going to be in a different physcial location than the board. So I'll have a few components that aren't attached to the board. Specifically anything that needs to be connected as close to the Pixels as possible. I suppose there could be seperate little mini-boards for the pixels. That probably makes the most sense.

author: Ian.M
author_rank: Super Contributor
timestamp: September 27, 2018, 11:35:32 pm
content: Yes. You could superglue the BAT54S direct to the back of the Neopixel strip, and hook it up with individual strands of tinned copper wire, or you could solder it to a scrap of one pad per hole matrix board the width of the neopixel PCB, and put the bare ends of the wires through that then on to the neopixel PCB pads.

author: Youkai
author_rank: Regular Contributor
timestamp: September 29, 2018, 03:20:20 am
content: Ok I have updated the diagram to have the BAT54S in there.I also added the voltage divider for pin 1 to sense 9v. Is that wired correctly?I got my neopixels in the mail today and noticed they have two ground connections. If you look at the last image you can see it:https://www.adafruit.com/product/2869But the images showing them working only have 3 wires connected. I can't find any information about why there are two ground connections. Do I just use the one on the same side as the images from the site? I assume the second one is redundant for some kind of extra safety but not needed?I think it's pretty darn close at this point. Time to start figuring out what I'm missing and order parts.EDIT: I was re-reading the posts some more and saw your comment about the Bat43 for throughole. I'm not really planning on using a board at the LED panels; or if so it will be as small as possible. Is it ok to solder the BAT54S to a board? I'd like to use that because some of the wiring is already done for me and it's harder to mess up (i.e. get the polarity backward).

author: Ian.M
author_rank: Super Contributor
timestamp: September 29, 2018, 03:49:36 am
content: Ignore the spare ground pad - its just there to give you another option for the wire order in a three wire flat cable hooking them up.Whether you use the SOT-23 BAT54S or a pair of BAT43 depends on how good you are at soldering tiny parts. I'd suggest ordering both, as even if you go with the BAT54S, some small Schottkys are useful to have around, and you'll need the through-hole parts if you want to breadboard it so you can start on the Arduino software while you are still figuring out how to make it all fit in the base of the box.

author: Youkai
author_rank: Regular Contributor
timestamp: September 29, 2018, 04:21:38 am
content: Is this what I would use in my chest to connect the wall wart to?https://www.jameco.com/z/CD022-Velleman-2-1mm-x-5-5mm-Female-DC-Plug-to-Screw-Terminal-5-Pack-_2153916.htmlEDIT: Also umm . . . where can I get the BAT54S. The only place I see with them in stock is this and I don't nee 3000 of them:https://www.jameco.com/z/BAT54S-7-Diodes-Zetex-Diode-Schottky-30-Volt-0-2A-3-Pin-SOT-23-Tape-and-Reel_1589814.htmlEDIT 2: Same for the BAT43. Can't seem to find it. Is there a similar product with a different number? I looked to find a 30v 200mA shottky but couldn't.

author: Ian.M
author_rank: Super Contributor
timestamp: September 29, 2018, 07:30:33 am
content: The CD022 is the wrong gender. The wallwart will have a plug like the CD022 (or maybe with a 2.5mm center pin), and you need a matching socket: probably PCB mount with solder terminals, or maybe chassis mount.Try Mouser USA. Their parametric search shows a wide range of Schottkys <50V, <200mA in stock, and minimum order quantity 1(cut tape). Any small Schottkys will do for the protection diodes.

author: Youkai
author_rank: Regular Contributor
timestamp: September 29, 2018, 04:40:12 pm
content: Ok I think I got it sorted. Attached is what I hope is the final schematic. Please review and confirm that looks correct to you.Also here is my "shopping list" to make sure I got the correct parts. You can ignore the numbers in parenthesis; I'm intentional ordering more than I need of some components. Also I left off things I already have: ex. 10k resistors.JamecoHeader Pins (many):https://www.jameco.com/z/2012-254-20-0-100-2-54-mm-20-Pin-Straight-Single-Row-Male-Header-br-Breakable_2229036.htmlWall Adapter (x1):https://www.jameco.com/z/GS18U09-P1J-MEAN-WELL-2-Wire-AC-to-DC-Regulated-Switching-Wall-Adapter-18W-9VDC-2A-2-1mm-Plug_1952847.html1000uf capacitor (x5):https://www.jameco.com/z/EEU-FM1C102-Panasonic-Capacitor-Aluminum-Electrolytic-1000uF-16-Volt-20-10-X-20mm-Radial-5mm-2180mA-5000h-105C_1361561.htmlSchottky 20V 3A - for reservoir rail (x6):https://www.jameco.com/z/1N5820-Major-Brands-Diode-Schottky-20-Volt-3A-2-Pin-DO-201AD_177973.htmlSchottky Diodes 200mA 30V - pixel protection (x20):https://www.mouser.com/ProductDetail/Vishay-Semiconductors/BAT43-TAP?qs=sGAEpiMZZMtQ8nqTKtFS%2fCT6%2f0RNrmfHlPqgqRLTrGU%3d0.1µF capacitor (x10):https://www.jameco.com/z/DC-1-25-Capacitor-Ceramic-Disc-0-1-micro-F-25V-plusmn-20-37-_151116.htmlPhotointerrupter (x3):https://www.jameco.com/z/H21A3-Major-Brands-Photointerrupter-Transmissive-3-3mm-Phototransistor-4-Pin-Rail_320901.htmlStrip board (x3):https://www.jameco.com/z/ST2--Busboard-Prototype-Systems-Traditional-Stripboard-Pattern-Prototyping-Circuit-Board-100-x-80mm_2191496.htmlBarrel Plug receiver (x1):https://www.jameco.com/z/WTJ-020-37A-2-1mm-Male-DC-Power-Jack-Breadboard-PCB-Mount-_2210677.html?CID=MERCHSparkfunPro Micro:https://www.sparkfun.com/products/12640AdafruitNeoPixel (x6):https://www.adafruit.com/product/2869Button (x1):https://www.adafruit.com/product/482Hobby StoreHi-Tech 311 Servo (x3):https://www.servocity.com/hs-311-servo

author: zitt
author_rank: Regular Contributor
timestamp: October 05, 2018, 10:09:11 pm
content: Duuuuuuude.... I totally need one of these to scale for my Pinball project:https://pinside.com/pinball/forum/topic/borderlands-the-pinball

author: Youkai
author_rank: Regular Contributor
timestamp: October 08, 2018, 06:09:31 am
content: HAHA! Well if this one works out maybe you can commission one lolWhenever I finish it I'll post videos.EDIT: Actually that chest would probably be easier than what I'm trying to do; especially if you don't need lights added. 2 Servo's would do it. Just put the shelf on an arm that you rotate up after the lid opens. Actually if you worked out the mechanism you could maybe do it with one servo. If it's going to be in a pinball machine it's probably going to be small and you probably don't care how hollow/thick it is. So one small servo could probably work both the lid and the drawer with the right setup.

author: Ian.M
author_rank: Super Contributor
timestamp: October 08, 2018, 07:40:30 am
content: Sorry I didn't have time and enough patience to check your parts list.When you document this project, *PLEASE* do it in a format other than long video (although you may choose to make one of those anyway if you are a regular vBlogger). Its *MUCH* easier to skim a PDF or web page for the interesting bits than it is to get an overview of a long video.

author: Youkai
author_rank: Regular Contributor
timestamp: October 08, 2018, 02:44:05 pm
content: Quote from: Ian.M on October 08, 2018, 07:40:30 amNo worries. I think it is correct. Just wanted a second eye to make sure I didn't somehow pick the wrong value for the schottky's or something.Quote from: Ian.M on October 08, 2018, 07:40:30 amInteresting. I hadn't ever really thought of that. I haven't been documenting this project at all so far, other than this thread I guess, so I was just going to have a short youtube video where I show it actually working; and maybe show the electronics bits once I get them all wired up before I actually insert them into the shell. I'll definitely keep in mind the PDF idea. Do you have a link to a PDF someone else has made so I can get an idea of how people organize those?

author: Youkai
author_rank: Regular Contributor
timestamp: November 26, 2018, 05:07:10 am
content: Ok took a fair bit of time off of this project but I'm gonna try to get a little more work done on it. Couple things I want to make sure I'm clear on. Please correct me if any of the following are mistaken statements:The bulb of the resistor is not conductive: i.e. if two resistor bulbs are touching they will not complete a circuitDiodes are directional and I want to have the marked end of my diodes (cathode) on the higher voltage wire for the NeoPixel protection (https://www.mouser.com/ProductDetail/Vishay-Semiconductors/BAT43-TAP?qs=sGAEpiMZZMtQ8nqTKtFS%2fCT6%2f0RNrmfHlPqgqRLTrGU%3d)Capacitors are not directionalIf these are all correct and someone could confirm that it would be appreciated. Thank you.

author: Ian.M
author_rank: Super Contributor
timestamp: November 26, 2018, 05:25:32 am
content: Ordinary through hole resistor bodies are covered by non-conductive paint, however its bad practice to let them touch as there may be flaws in the paint, and especially on the metal endcaps, (dogbone outline bodies), that risks a short-circuit.Electrolytic capacitors are polarised - the stripe indicates the negative lead. Tantalum bead capacitors are polarised, the stripe indicates the positive lead. Tantalums are best avoided because they have a nasty habit of catching fire if even slightly abused. All other common capacitors are non-polarised.For diodes the end with a ring-stripe round it is the cathode, and is the direction the arrow points in their schematic symbol and the direction they permit (conventional) current flow in. Their orientation will depend on whether they are supposed to pass or block current in normal operation - see schematic of the specific circuit you are using them in.

author: Youkai
author_rank: Regular Contributor
timestamp: May 06, 2019, 04:46:12 am
content: Hey guys. It's been forever but I'm back! Did a little soldering today to try and set up one of the NeoPixel units. Can some of you take a look at the attached image and see if you can confirm that I wired it properly.Mostly I'm worried that I misinterpreted the schematic and treated something as "all joining together" when they should be in sequence. Also there is the very real possibility that I put the diode's in backwards because I wasn't smart enough to figure that out correctlyI have the images aligned so that the right edge is the same on both. So it's mirrored top/bottom. Please let me know if the images are insufficient and better pictures would help.

author: zitt
author_rank: Regular Contributor
timestamp: May 06, 2019, 07:40:39 am
content: I was going to do something similar for my Borderlands Pinball project...https://pinside.com/pinball/forum/topic/borderlands-the-pinballSadily; I haven't gotten around to even starting the project. With Borderland3 "on the way" now would be a great opportunity to revisit.Good luck with your project … it'd have a great reuse capability for my project if I ever get back to it.

author: Ian.M
author_rank: Super Contributor
timestamp: May 06, 2019, 08:14:58 am
content: Veroboard layout + visible component markings match the schematic.

author: Youkai
author_rank: Regular Contributor
timestamp: May 06, 2019, 03:00:03 pm
content: Quote from: Ian.M on May 06, 2019, 08:14:58 amAwesome! Thanks. Now to wire it up to an Arduino and confirm it works.

author: Youkai
author_rank: Regular Contributor
timestamp: May 06, 2019, 10:10:48 pm
content: No dice so far. I am using an Arduino Uno. I plugged the power (Yellow) into the 5v pin, Ground (Black) into the GND pin, and data (Green) into pin 6. Then I used the below code to run the strip. A simple cycle test of R, G, B, W.Getting no light at all. Does anybody see an issue with my code?If not then I think the next step is to wire up just some wire leads on a bare NeoPixel strip and see if I can get that working with none of the other stuff. Is that a good next step? Is it possible that I just damaged one of the components during soldering and the whole assembly is broken at some point?Code:#include <Adafruit_NeoPixel.h>#define neoPixelPin 6#define neoPixelCount 8Adafruit_NeoPixel lidPixel(neoPixelCount, neoPixelCount, NEO_RGBW + NEO_KHZ800);void setup() {lidPixel.begin();lidPixel.show();Serial.begin(9600);Serial.println("Starting");}void loop() {for (int i = 0; i < lidPixel.numPixels(); i++) {lidPixel.setPixelColor(i, lidPixel.Color(255, 0, 0, 0));}lidPixel.show();Serial.println("Red");delay(1000);for (int i = 0; i < lidPixel.numPixels(); i++) {lidPixel.setPixelColor(i, lidPixel.Color(0, 255, 0, 0));}lidPixel.show();Serial.println("Green");delay(1000);for (int i = 0; i < lidPixel.numPixels(); i++) {lidPixel.setPixelColor(i, lidPixel.Color(0, 0, 255, 0));}lidPixel.show();Serial.println("Blue");delay(1000);for (int i = 0; i < lidPixel.numPixels(); i++) {lidPixel.setPixelColor(i, lidPixel.Color(0, 0, 0, 255));}lidPixel.show();Serial.println("White");delay(1000);}EDIT: I soldered wires on a second strip because I'm going to need it anyway. One of the leads was kind of a mess and I had to use some desoldering wire to clean it up. Anyway this strip with just the wires and nothing else didn't work either. So either I messed up the second pixel as well or there is something wrong with my code. I'm hoping for the latter. I certainly hope the NeoPixels aren't this fragile, I can't imagine how they could possibly be used in anything if they were.

author: Youkai
author_rank: Regular Contributor
timestamp: May 08, 2019, 12:19:31 am
content: Posted another post for just the NeoPixel issue. Wow, Just wow. I'm a dummy. In my "lidPixel" initialization I used "neoPixelCount" twice instead of using "neoPixelPin" for the second parameter. That was the problem.It works now. Moving on!

author: Youkai
author_rank: Regular Contributor
timestamp: May 08, 2019, 02:30:53 am
content: In a previous post in this thread Ian.M was talking about interrupt issues with the servo Library and the NeoPixels. I did a little googling about various color swipe libraries and saw this TiCoServo library that seems to be able to run alongside something like FastLED.https://learn.adafruit.com/neopixels-and-servos/the-ticoservo-libraryDoes anybody know how well these work? Specifically the TiCoServo library.

author: Youkai
author_rank: Regular Contributor
timestamp: May 19, 2019, 04:28:28 pm
content: Ok so I'm thinking the photointerrupter switch is over-engineering based on my initial thought of having a simple photo resistor as the trigger for the drawers. It would be much simpler to have the drawers simply push a button when they are closed. I'm thinking something like this instead:https://www.jameco.com/z/SS-5GL2-Omron-Snap-Action-Switch-N-O-N-C-Single-Pole-Double-Throw-Hinge-Roller-Lever-Solder-5-Amp-250-Volt-AC-14-Volt-0-49n-Screw-Mount_187733.htmlThe thing is that is rated for AC. Can I just assume it will work with my DC circuit? My little 5v won't be pushing anywhere near even a full amp though it.EDIT: I'm also SUPER confused about this barrel plug receiver schematic. I assume I only need to use two of the three pins but I can't make heads or tails of which is which.https://www.jameco.com/z/WTJ-020-37A-2-1mm-Male-DC-Power-Jack-Breadboard-PCB-Mount-_2210677.html?CID=MERCHhttps://www.jameco.com/Jameco/Products/ProdDS/2210677.pdfOk after a little more review I think it's saying pin 1 (the one at the back) is connected to the "pin". Then pins 2 and 3 are tied together to the barrel? Is that correct?What's the standard for the pin being positive or negative? If i'm reading the wall-wart spec correctly I think it's saying the "center" is positive so that would make the "pin" of the jack the positive lead correct?https://www.jameco.com/Jameco/Products/ProdDS/1952847.pdf

author: Ian.M
author_rank: Super Contributor
timestamp: May 19, 2019, 06:02:00 pm
content: I haven't used the Ticoservo library, but as it's written by an Adafruit staff member, it's extremely likely that it will 'do what it says on the tin'.Yes, you could use a microswitch, but that's a mighty big and chunky one for a small project. You can get them half that size and you only need a roller if you are actuating it with a sliding movement in line with the top of it. If the motion simply presses the lever down directly you just need a long lever you can bend to shape to suit.If you read its datasheet carefully, you'll see it does have a DC rating (table "General-purpose 5 A max. (Standard rivet contacts)" on page 2 of the Omron datasheet), but for logic level switching the manufacturer recommends the Microvoltage/microcurrent load 0.1 A max. (Bifurcated crossbar contacts) variant. You should get away with it as long as you put a reasonable wetting current through the contacts (I wouldn't go below 5mA), and youv'e *never* used that individual switch for AC or a high current inductive DC load.The DC jack has three contacts because its designed to disconnect a battery pack when the plug is inserted. If you look at its datasheet, you'll see contact 3 is the one that goes open circuit when the plug is in. 1 is the center pin and 2 the barrel contact. If in doubt, check with your DMM when it arrives. Either ignore contact 3 or connect it to the same track as contact 2. *MOST* kit with DC jacks is center positive nowadays, but that isn't a hard and fast rule. Some Japanese stuff + musical effects boxes/pedals are typically center negative. If not marked and you aren't sure the PSU is the correct one, *ALWAYS* check polarity, opening the device up to find its ground rail if you have to.

author: Youkai
author_rank: Regular Contributor
timestamp: May 19, 2019, 07:44:13 pm
content: Thanks Ian.MI was thinking the roller because for the lid switch I want it to trigger after a little bit of travel on opening / before it's fully closed on closing. So I was thinking the roller would allow that.Do you have a recommendation on what switch would be good; or could you provide me some keywords which would help me narrow my search? Searching for "lever switch" provides a lot of results :/As far as the barrel connector goes; based on your explanation I connect pin 1 to the 9v rail, and pin 2 to the ground rail, and ignore pin 3. Correct?

author: Youkai
author_rank: Regular Contributor
timestamp: May 19, 2019, 11:48:19 pm
content: Hey guys awesome news. It looks like a total rats nest but I wired up most of the circuit and it seems to work. I was able to verify by hooking up the button/led combo to turn the LED on and then off when the button is pressed. I can also run it off of the power supply (i.e. the pro micro specifically off of the 9v source instead of the USB).So this verifies that the wall plug is working and that all of my power rails/capacitors are all working correctly. The LED/Button runs off of the 5V Reservoir Rail which is at the end of the chain. Next I need to hook up some servo's and test that. Then time to solder the LED and photo-interrupters into the circuit.I found that I had already soldered together the three photo-interrupters I needed so I might as well use them instead of the lever switches.EDIT: Oh I meant to ask. How bad would it be if I had the 9v plugged into RAW while I had the USB attached? Would it overload due to two power sources or does the circuitry account for that?

author: Nominal Animal
author_rank: Super Contributor
timestamp: May 20, 2019, 03:42:15 am
content: Quote from: Youkai on May 19, 2019, 11:48:19 pmWhileArduino Microdoes have both 5V and 3.3V voltage regulator,Pro Micros have only one, bypassable via a pair of solder pads (JS1 in the corner, left open for USB +5V):Because Arduino Micro has no RAW pin, we are talking about SparkFunPro Micros or its clones. (The design is known to be pretty good, and thehardware license(CC-SA-4.0) allows clones.)You can open the SparkFun Pro Micro schematics and board layout inEasyEda here(does not require registration or anything), or download the Eagle filesfrom the SparkFun Github repo for the Pro Micro. The Arduino Micro schematics arehere in PDF form. That is, no need to believe me, check for yourself.On the Pro Micros, when the JS1 pads are connected, the USB +5V line goes through a polyfuse (limiting current to 500mA max or so), and from there directly to the board VCC. That is, there is nothing but a 500mA polyfuse between the board VCC and the USB +5V line. The RAW line goes to the voltage regulator input. There is a diode stopping the regulator input from backfeeding to the USB +5V line, but the output is directly connected to the board VCC. (The regulator used must accept a bypass situation, where the regulator output voltage is one diode drop lower than its input, or it will be damaged when the board is connected to USB.)So, there are several possible cases you need to consider:You have a Arduino Micro.There is a supply selection circuit that disconnects USB +5V line when VIN is present.It is safe to provide power to the board using the VIN pin, whether or not the board is connected to USB.You have a Pro Micro (clone), with a 5V low-drop regulator, JS1 pads not connected.The polyfuse and the diode are between USB +5V line and the regulator input. RAW is connected directly to regulator input.This does mean that when USB is connected, RAW voltage is at least (5V - one diode drop), but as long as your RAW supply is at least +6V, this does no harm.Your board always runs on 5V regulated voltage, and it is safe to connect both USB and RAW at the same time.You have a Pro Micro (clone), with a 5V regulator, JS1 pads connected.There is a diode blocking RAW from feeding back to the USB connector; but, the board VCC is connected to the USB +5V.So, if your computer provides a lower USB +5V line than the 5V regulator on board, you may be backfeeding power back to your machine via USB, which is bad.You have a Pro Micro (clone), with a 3.3V regulator, JS1 pads not connected.When you provide the board power via the RAW pin, the board will operate at 3.3V. If you connect it to USB, it will suddenly switch to 5V power.I do not know if this is okay, but I would advise against it.You have a Pro Micro (clone), with a 3.3V regulator, JS1 pads connected.The board always operates at 3.3V. The diode will protect from the board backfeeding power to your USB +5V line.However, when you connect the board to USB, the RAW pin will be at least one diode drop lower than +5V.So, as long as your RAW pin is either disconnected, or connected to a voltage supply higher than +5V, you are safe to connect the board to USB.In summary, cases 1, 2, and 5 are safe. For Pro Micro or clones, check which voltage regulator it has.Personally, when working with Pro Micro (clones) or other USB-programmable microcontrollers (I have a dozen or so!), I use an USB isolator (usuallythis one from fleabay, basically an implementation of the ADuM3160 appnote) and/or an USB cable where the +5V line is disconnected.I prefer the isolator, because that keeps my USB ports safe. (The switch chooses between 1.2 Mbit/s and 12 Mbit/s operation; the latter is suitable for Arduino Micros and Pro Micro clones, as that's the fastest ATmega32u4 can do. The isolator does not support 480 Mbit/s high speed USB devices.) Just note that these isolators cannot provide full 500mA, but somewhat less, something like 300mA maximum (due to losses in the isolated DC-DC converter). TheOlimex USB isolatoris a variant which has an extra power jack (8V to 15V supply, regulated to 5V) that can supply up to 750mA to the device (but note that this supply is isolated only from the computer, not the device; there is only a voltage regulator in between).

author: Youkai
author_rank: Regular Contributor
timestamp: December 18, 2019, 01:34:20 am
content: This project has been stagnant for a while because a friend was going to help me with the modeling/3D printing. But that's has been taking forever so I just ordered myself a 3D printer (arrives tomorrow). Going to get this project out of the muck.To that end I was thinking. Would it make any sense to use stepper motors (instead of servos) and some micro switches to detect the range of motion needed? The "open" position stop doesn't have to be super exact and stepper motors are supposed to be super exact things right? so I could probably get away with switches to confirm the "closed" position is where I expect it to be when it's powered on or closed. Then run the motor to the open position by programming. If the final rest is off by a couple degrees one way or the other it wouldn't matter too much.In either case should I connect the drawer's directly to the motor/servo or do I need some kind of circular hinge to bear the weight? I'm a little worried about the leverage on the drawer if someone puts a heavy watch or something in it causing it to sag or bend the shaft of the motor but I don't know if that's a reasonable concern.

author: Youkai
author_rank: Regular Contributor
timestamp: January 31, 2020, 02:25:43 am
content: Well. I failed for the most part. It kind of works, sort of. I ended up with WAY too much wire and couldn't stuff it all into the cavity. I cut a bunch out of the middle of wires and soldered the wires back together to save some space. Kind of worked. Somewhere in all of that I ended up either blowing out one of the NeoPixels or when I was stuffing the wires in there it just got disconnected. Either way one of the LED doesn't work in the final item. Also one of the servos doesn't work end the end either.Going to start over from scratch with what I've learned and try again. This time I'm going to use micro servos and a lot less wire. Thanks a lot for your help everyone!https://photos.app.goo.gl/6BrS4r74JXfwwvsX9

author: Youkai
author_rank: Regular Contributor
timestamp: May 04, 2020, 06:04:23 pm
content: Version 2 of the project was successful! Here is the demo video if you are interested:Also my build journal for those of you that want more details or don't want to watch the video:https://docs.google.com/document/d/1UCf8qaZgw3GsMXFvT55gbCp3WXba2CDr0ZiEJwghIu4