Author Topic: Need help with touchless on/off switch - detailed working principle and ltspice  (Read 1083 times)

0 Members and 1 Guest are viewing this topic.

Offline AyyaTopic starter

  • Newbie
  • Posts: 3
  • Country: pl
First of all i would like to say hello to all of you as it's my first post here.

I came here because obviously i need help. To be more specific i'm working with a circuit that will act something like wireless/touchless switch.

I have those 2 schematic. Schematic 1 is the one i'm basing on my project and 2nd is what modifications i've done.

D2 is a IR diode
IC1 is a CA3140 op amp ( in lt spice i used a universal op amp)
Q2 is replaced by the suggestion of teacher on MOSFET transistor ( still dont know which one exactly i need to use)
Q1 is a phototransistor ( in lt spice schematic it'a current source because it's easier to implement it there)
R4 is a potentiometer used to set a sensivity (in lt spice i did a voltage divider because of same reason as Q1)
I replaced D1 and RL1 by inserting a diode

Here i added a D flip flop.
The working principle i'm planning to achieve is when voltage source of 5 V is connected, a IR diode emits it's rays on phototransistor (right?) Q1 and when u pass a hand over IR Diode it should light up the LED behind mosfet and when you pass a hand 2nd time over IR diode it will switch off. Dflop is here to provide such an action.
Next for what i've already searched on and i think i know that when hand is passed over IR Diode pin 3 non inverting it's turning into high state right?. Pin 2 - inverting is connected to potentiometer and it works only for sensivity (right?) So now a result of turning pin 3 ino high state the signal goes on a pin6 output and it is remembered by d flop and led is lighted up and so turn it off second hand move is needed?

I don't know if i explained it well but thanks for any help.
 

Offline drussell

  • Super Contributor
  • ***
  • Posts: 1855
  • Country: ca
  • Hardcore Geek
Are you essentially asking for someone to do your homework assignment for you instead of you experimenting to discover how things work?
 

Offline AyyaTopic starter

  • Newbie
  • Posts: 3
  • Country: pl
Obviously not, all i'm asking is a little help with understanding it, i'm a completly newbie with lt spice as well and can't operate it that good to check if it's either working or not. If this isn't right place to ask such a questions tell so and i will delete my thread. Thanks.
 

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
Have you right-clicked over the D flip flop and set Vhigh 5V, the digital parts default to 1V.

An easy way to simulate a photo transistor is to use the one in an opto isolator and supply a couple of mA to it's input LED.

Here's a working version to tweak.
.  That took much longer than I thought it would.
 
The following users thanked this post: Ayya

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12862
Actually, LTspice A device digital primitives need a couple more settings to reliably behave as you would expect an ordinary CMOS logic gate to.  Ignoring output impedance (as the series 3K3 resistor swamps it), and slew rate (as its negligible with respect to the RC time constant with the MOSFET gate capacitance), you *should* set:
Code: [Select]
Vhigh=5, Td=14n, Tripdt=2nin the component attribute editor, which is based on the typical propagation delay of a 74HC74 @5V Vcc.

If you don't set an appropriate propagation delay more complex sequential logic will often fail to behave as expected.  Tripdt controls how closely spaced simulation timesteps are round gate transitions (if nothing else is forcing close timesteps), and is required to get LTspice to honor specified propagation delays and rise/falltimes.  See LTspice Help: LTspice(R): Circuit Elements: A. Special Functions for details of other A device parameters. 

N.B. setting separate Rhigh and Rlow rather than a single  Rout can make the simulation an order of magnitude slower!

N.B.2. You can use any of the four attributes Value through SpiceLine2 for A device parameters, and also control whether or not each attribute is visible on the schematic.  In logic designs with a variety of propagation delays, I like to make that visible, though you may wish to put the other parameters that are common to all or most gates in a different attribute and hide them to avoid an excessively cluttered schematic.
« Last Edit: March 22, 2021, 11:39:19 pm by Ian.M »
 
The following users thanked this post: Ayya

Offline AyyaTopic starter

  • Newbie
  • Posts: 3
  • Country: pl
Have you right-clicked over the D flip flop and set Vhigh 5V, the digital parts default to 1V.

An easy way to simulate a photo transistor is to use the one in an opto isolator and supply a couple of mA to it's input LED.

Here's a working version to tweak.
Really appreciate your help. Thank you very much but it lead me to another questions. Really sorry if they are trivial and stupid but ye...
 i haven't changed anything to dflop my bad. I noticed that in your ltspice simulation when i'm checking the voltage over the wires form voltage source the signal is square and in mine is straight line, what causes this? I've tried adding coil as a relay to see if it's it but no. And 2nd question what is the purpose of this 1Meg R5 connected to the I/O ouf op-amp? It's a inverting op amp to ensure it stability in simulation?
And 3rd question - how you choosed those values to current source? They are realted to how much current would phototranistor give?

Actually, LTspice A device digital primitives need a couple more settings to reliably behave as you would expect an ordinary CMOS logic gate to.  Ignoring output impedance (as the series 3K3 resistor swamps it), and slew rate (as its negligible with respect to the RC time constant with the MOSFET gate capacitance), you *should* set:
Code: [Select]
Vhigh=5, Td=14n, Tripdt=2nin the component attribute editor, which is based on the typical propagation delay of a 74HC74 @5V Vcc.

If you don't set an appropriate propagation delay more complex sequential logic will often fail to behave as expected.  Tripdt controls how closely spaced simulation timesteps are round gate transitions (if nothing else is forcing close timesteps), and is required to get LTspice to honor specified propagation delays and rise/falltimes.  See LTspice Help: LTspice(R): Circuit Elements: A. Special Functions for details of other A device parameters. 

N.B. setting separate Rhigh and Rlow rather than a single  Rout can make the simulation an order of magnitude slower!

N.B.2. You can use any of the four attributes Value through SpiceLine2 for A device parameters, and also control whether or not each attribute is visible on the schematic.  In logic designs with a variety of propagation delays, I like to make that visible, though you may wish to put the other parameters that are common to all or most gates in a different attribute and hide them to avoid an excessively cluttered schematic.

Thank you very much for those informations, they will certainly help with me the next steps where i will have to perform a simulations, for now i'm stuck on what parameters should i choose for current source, and why those.
« Last Edit: March 23, 2021, 07:22:22 pm by Ayya »
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12862
Post (attach) your sim .asc file, then we can check what you are doing wrong.
I would suspect you haven't set appropriate rise and fall times ( PULSE() source fourth and fifth parameters).

There's a trap for 'young players': the pulse source ON time does *NOT* include the risetime.  See my comments on PULSE() sources here:
https://www.eevblog.com/forum/projects/where-is-my-error-in-this-ltspice-simulation/
« Last Edit: March 23, 2021, 07:42:01 pm by Ian.M »
 
The following users thanked this post: drussell

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
I noticed that in your ltspice simulation when i'm checking the voltage over the wires form voltage source the signal is square and in mine is straight line, what causes this?

I'd given the 5V voltage source 0.2R of internal resistance, the supply voltage drops a bit when the relay draws current, it's not really needed in this simple simulation.

"what is the purpose of this 1Meg R5 connected to the I/O ouf op-amp?"

It's just a bit of positive feedback, often needed when the input to a comparator is a slowly changing signal such as a shadow which you want to change into an output pulse with fast edges.

"how you choosed those values to current source? They are realted to how much current would phototranistor give?"

Yes just a guess that there'd be about 1mA flowing through the photo transistor when it's in the IR beam and reduced to 0.1mA when it's in the shadow, about the only way to get closer values would be to measure them. :)
« Last Edit: March 23, 2021, 10:07:18 pm by StillTrying »
.  That took much longer than I thought it would.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf