Tuesday, June 27, 2023

USB HID RELAY (LCUS_HID_X1) Windows software

HID Tester software for USB relay module.

Friday, June 2, 2023

Could not load file Microsoft.CodeAnalysis in VS Code

Possible fix for "... Could not load file or assembly 'Microsoft.CodeAnalysis, Version ..." 

In Visual Studio Code:
0. Switch to Terminal and go to your project folder.
Type:
1. "dotnet add package Microsoft.CodeAnalysis -v X.X.X" // make sure to add appropriate version
2. Press ctrl+shift+p, and type "OmniSharp: Restart OmniSharp"
3  Type (always like this):
   "dotnet restore <enter>"
   "dotnet build <enter>"

Wednesday, March 29, 2023

Wiring of bildge pump with buzzer and float switch


Buzzer works when pump is activated through float switch.
When pump is manually switched, it does not buzz.
(Components: Power PMOS, Power NMOS, bipolar NPN, resistors)

Link to falsad circuit simulation: http://tinyurl.com/yu6lbmbc

Saturday, May 28, 2022

Monday, March 7, 2022

Brutal chess play by white player


White is short of queen and is making a brutal come back which results in black forfeiting.

Wednesday, October 20, 2021

Coupled inductors MAXIMA code


/* ------------------------------- CUT HERE -------------------------------- */
/* Current in Primary at time t
and coupling coefficient k */

m:float(1/1000);

i1_2nd_order(R1,R2,L1,L2,E,k,t):=block(
[
PrimCurrent:float(0.0),
A:float(0.0),
B:float(0.0),
C:float(0.0),
C1:float(0.0),C2:float(0.0),
Lamda1:float(0.0),Lamda2:float(0.0)],
A:L1*L2-k^2*L1*L2,
B:L1*R2+L2*R1,
C:R1*R2,
Lambda1:(-B+sqrt(B^2-4*A*C))/(2*A),
Lambda2:(-B-sqrt(B^2-4*A*C))/(2*A),
C2: -E*A*L2/((L2*L1-k^2*L1*L2)*sqrt(B^2-4*A*C))-Lambda1*E*A/(R1*sqrt(B^2-4*A*C)),
C1: -C2-E/R1,
PrimCurrent:C1*exp(t*Lambda1)+ C2*exp(t*Lambda2)+E/R1,
return (PrimCurrent)
);

/* example */
i1_2nd_order(0.3,12.5,1.5*m,0.8,12,0.95,1.2*m);

/* ------------------------------- CUT HERE -------------------------------- */

Tuesday, June 8, 2021

Ways to write quality software (to be updated)

- Comments should say what the code does, not how it does it.

- Name your routines so that they are self-evident. The same goes for parameters.
  That way, comments' necessity is reduced.

- Keep the number of parameters small. Try not to go over four. Tree to four is optimal.

- Try not to repeat the code.

- Avoid long routines of code.

- Avoid complex conditional statements with large blocks of code. Reduce the complexity.
 

- Extract methods.
  Change long routines to few/many small ones (ca. 20 lines of code).

- Extract conditional and loop blocks of code as separate routines.

- Move related concepts closer together.
  Physically put similar parts/ideas (code that represent those) closer together.

- Reuse same parts of the code extracted earlier.

- Separate concerns/Modularity.
  Make each module (class/routine/...) do only one thing.
  Don't bloat/clog the code.  Goal is to achieve that one goal:)

- Work in small steps.
  Small changes are less prone to errors.

- When you code,try to refactor your code after every small change. Try to clean it up a bit if you can.

Remember: "Our job as programmers is to solve problems, not to write code":)

##References: 
5 Ways to Improve Your Code, https://www.youtube.com/watch?v=1KeJc6V4Jjk,

Refactoring Legacy Code: STEP BY STEP

Bertrand Meyer:Object-Oriented Software Construction:

Thursday, February 18, 2021

Parametric variables in PSPice

To add parametric variable,use PARAM part from special.olb library.
Place PARAM part. Double click it. 
Below first tab is command button "New Property...". Click it.







































Add parametric variable name and default value, click ok.
Close "Add New Property" window. Click "Apply", which is
next to "New Property...".

Next, in schematic, double click part value you want to make parametric.
I.E. for caps you can double click cap value, and type property name 
inside curly brackets, like {CapVal}.
Now, cap(s) with value {CapVal} will have capacitance you
put under (default) value in "Add New Property" window.

Sweeping is done under menu "Pspice"->New/Edit Simulation profile"->"Analysis", 
under options check "Parametric Sweep". Select "Global Parameter". Under "Parameter name:" type variable name without brackets. Under "Sweep type" select type:linear,logarithmic or value list.





Friday, September 18, 2020