Author Topic: Borderlands style jewelry box research thread  (Read 11883 times)

0 Members and 1 Guest are viewing this topic.

Offline YoukaiTopic starter

  • Regular Contributor
  • *
  • Posts: 227
  • Country: us
Borderlands style jewelry box research thread
« on: April 06, 2018, 05:45:26 am »
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=PLBDD0A3B6E5C15862 That 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!
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12807
Re: Borderlands style jewelry box research thread
« Reply #1 on: April 06, 2018, 07:05:19 am »
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.
 

Offline YoukaiTopic starter

  • Regular Contributor
  • *
  • Posts: 227
  • Country: us
Re: Borderlands style jewelry box research thread
« Reply #2 on: April 06, 2018, 03:51:37 pm »
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!
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12807
Re: Borderlands style jewelry box research thread
« Reply #3 on: April 06, 2018, 05:08:45 pm »
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.
 

Offline YoukaiTopic starter

  • Regular Contributor
  • *
  • Posts: 227
  • Country: us
Re: Borderlands style jewelry box research thread
« Reply #4 on: April 07, 2018, 11:56:08 pm »
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 thread http://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.html That servo and this one that I have some of already https://www.servocity.com/hitec-hs-55-servo are 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.
 

Offline NiHaoMike

  • Super Contributor
  • ***
  • Posts: 8973
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
Re: Borderlands style jewelry box research thread
« Reply #5 on: April 08, 2018, 12:59:21 am »
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.
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline YoukaiTopic starter

  • Regular Contributor
  • *
  • Posts: 227
  • Country: us
Re: Borderlands style jewelry box research thread
« Reply #6 on: April 08, 2018, 01:23:05 am »
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.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12807
Re: Borderlands style jewelry box research thread
« Reply #7 on: April 08, 2018, 02:06:34 am »
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.
« Last Edit: April 08, 2018, 02:17:06 am by Ian.M »
 

Offline YoukaiTopic starter

  • Regular Contributor
  • *
  • Posts: 227
  • Country: us
Re: Borderlands style jewelry box research thread
« Reply #8 on: April 08, 2018, 02:31:51 am »
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?
 

Offline NiHaoMike

  • Super Contributor
  • ***
  • Posts: 8973
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
Re: Borderlands style jewelry box research thread
« Reply #9 on: April 08, 2018, 04:09:42 am »
It looks like the bottom is elevated and thus a big overhang? Or is that just an illusion/incomplete part of the design?
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline YoukaiTopic starter

  • Regular Contributor
  • *
  • Posts: 227
  • Country: us
Re: Borderlands style jewelry box research thread
« Reply #10 on: April 08, 2018, 04:23:22 am »
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
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12807
Re: Borderlands style jewelry box research thread
« Reply #11 on: April 08, 2018, 12:32:31 pm »
For a PM (permanent magnet) DC motor, torque and speed are closely interrelated, and the relationship is set by the motor design and construction.  See http://hades.mech.northwestern.edu/index.php/Brushed_DC_Motor_Theory for 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.
« Last Edit: April 08, 2018, 12:44:03 pm by Ian.M »
 

Offline YoukaiTopic starter

  • Regular Contributor
  • *
  • Posts: 227
  • Country: us
Re: Borderlands style jewelry box research thread
« Reply #12 on: April 08, 2018, 06:14:33 pm »
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.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12807
Re: Borderlands style jewelry box research thread
« Reply #13 on: April 08, 2018, 07:32:32 pm »
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.
 

Offline YoukaiTopic starter

  • Regular Contributor
  • *
  • Posts: 227
  • Country: us
Power supply
« Reply #14 on: April 26, 2018, 04:14:38 am »
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 image
  • 3 servo: Futaba S3004 or similar
  • Arduino (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 strips
  • Voltage regulator

Any 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.
 

Offline YoukaiTopic starter

  • Regular Contributor
  • *
  • Posts: 227
  • Country: us
Re: Borderlands style jewelry box research thread
« Reply #15 on: September 03, 2018, 11:59:45 pm »
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?
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12807
Re: Borderlands style jewelry box research thread
« Reply #16 on: September 04, 2018, 02:23:05 am »
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/2349
You 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. 

« Last Edit: September 04, 2018, 02:25:23 am by Ian.M »
 

Offline helius

  • Super Contributor
  • ***
  • Posts: 3632
  • Country: us
Re: Borderlands style jewelry box research thread
« Reply #17 on: September 04, 2018, 03:47:48 am »
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.
Is 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.

Quote
Also, if you plan to use ambient light, you'd have to cope with several orders of magnitude difference in illumination level
This is a real concern.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12807
Re: Borderlands style jewelry box research thread
« Reply #18 on: September 04, 2018, 04:35:49 am »
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.
 

Offline YoukaiTopic starter

  • Regular Contributor
  • *
  • Posts: 227
  • Country: us
Re: Borderlands style jewelry box research thread
« Reply #19 on: September 04, 2018, 05:27:09 am »
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.
« Last Edit: September 04, 2018, 05:31:04 am by Youkai »
 

Offline YoukaiTopic starter

  • Regular Contributor
  • *
  • Posts: 227
  • Country: us
Re: Borderlands style jewelry box research thread
« Reply #20 on: September 04, 2018, 05:39:40 am »
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.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12807
Re: Borderlands style jewelry box research thread
« Reply #21 on: September 04, 2018, 07:06:26 am »
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-interrupter
e.g: https://www.jameco.com/z/H21A3-Major-Brands-Photointerrupter-Transmissive-3-3mm-Phototransistor-4-Pin-Rail_320901.html
and 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/158

You 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.  See http://sparkbangbuzz.com/cds-fet/cds-fet.htm for this effect exploited to turn a CdS cell into a crude MOSFET equivalent.
« Last Edit: September 04, 2018, 07:36:35 am by Ian.M »
 

Offline YoukaiTopic starter

  • Regular Contributor
  • *
  • Posts: 227
  • Country: us
Re: Borderlands style jewelry box research thread
« Reply #22 on: September 04, 2018, 08:29:12 pm »
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.
 

Offline YoukaiTopic starter

  • Regular Contributor
  • *
  • Posts: 227
  • Country: us
Re: Borderlands style jewelry box research thread
« Reply #23 on: September 12, 2018, 04:18:12 am »
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?
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12807
Re: Borderlands style jewelry box research thread
« Reply #24 on: September 12, 2018, 05:03:55 am »
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.
« Last Edit: September 12, 2018, 05:14:59 am by Ian.M »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf