Swinging movements and the analog computer

Previous topic - Next topic


I'm glad it works. It saves a COS() and SIN() calculation. It's an emulation of 2 integrating op-amps in a loop producing a sin and a cos signal. The integration factor -frequency dependent- is not compensated yet. Before asking many questions please study the analog computer, or the theory of servos and feedback stability. It's a great tool to produce nice or unexpected movements. Wish you fun and creative experimenting. Please share your examples.
Code (glbasic) Select
// --------------------------------- //
// Project: sinosc1
// Start: Saturday, September 14, 2013
// IDE Version: 10.283
//Emulates the analog computer, with 2 integrators and a loop.

SETSCREEN 800,200,0
CONSTANT cx%=400, theta=0.115 //time constant
// signal 1 and signal 2: (initial state)
GLOBAL s1=0,s2=33, _s1,_s2
DRAWRECT cx+s1, 12, 20,60, RGB(255,155,0)
DRAWRECT cx+s2, 94, 20,60, RGB(0,255,255)
FOR i%=0 TO 800 STEP 40
DRAWLINE i,166, i,200,0xffffff

FUNCTION integrate:
_s1=s1 ; _s2=s2
s2=s2-theta *_s1*0.8
s1=s1-theta *(-_s2)

IF s2>220 THEN s2=220+(s2-220)*0.92 // knee-clip the 1st op-amp.
IF s2<-220 THEN s2=-220+(s2+220)*0.92 //necessary but not too hard please.


Offtopic: here is an interesting test; imagine the blue and red bars are mounted at the edge of rotating disc. When you see the disc in motion, does it turn to the right or the left?
On the day the atom is a cube I will start believing in the square pixel.