Triangle wave???

Software questions and issues with the FV-1

Moderator: frank

Post Reply
sad1024
Posts: 34
Joined: Mon May 24, 2010 3:34 pm

Triangle wave???

Post by sad1024 »

Is there anyway to generate a triangle wave, based on the analog model of a comparator followed by an integrator? You could also get a square wave if you sampled the comparator rather than the integrator.
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

Why try to model the analog method in a digital chip?

For triangle wave see this thread http://www.spinsemi.com/forum/viewtopic ... t=triangle
Frank Thomson
Experimental Noize
sad1024
Posts: 34
Joined: Mon May 24, 2010 3:34 pm

Post by sad1024 »

Not as an lfo. As a large range function generator.
sad1024
Posts: 34
Joined: Mon May 24, 2010 3:34 pm

Post by sad1024 »

equ x reg0

sof 0,0
rdax x, 1
skp gez, 1
sof 0, -1
skp neg, 1
sof 0, 0.999
sof 1, 0
mulx pot0
rdax x,1
wrax x,1
wrax dacl,0


Why doesn't this work?
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

Please comment code, makes it much easier to understand your intent at each step and we don't have to try to reverse engineer your thoughts.
Frank Thomson
Experimental Noize
sad1024
Posts: 34
Joined: Mon May 24, 2010 3:34 pm

Post by sad1024 »

equ x reg0 ;setup registry

sof 0,0 ;clear acc
rdax x, 1 ;read x
skp gez, 1 ;if negative let acc =-1
sof 0, -1
skp neg, 1 ;if positive let acc =0.999
sof 0, 0.999
mulx pot0 ;attenuate acc
rdax x,1 ;integrate acc
wrax x,1 ;write x
wrax dacl,0 ;write to output
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

What are you trying to do here? You don't read any inputs nor initialize the "x" register so if it is a negative value it stays negative and if it is positive it stays positive. There is no input to integrate.
Frank Thomson
Experimental Noize
sad1024
Posts: 34
Joined: Mon May 24, 2010 3:34 pm

Post by sad1024 »

Sorry, my error. This oscillates but is unstable.

equ x reg0
equ y reg1
equ z reg2 ;setup registry


sof 0,0 ;clear acc
skp run,2
sof 0,-0.5 ; initialize oscillator
wrax x, 0
rdax z, -1 ; feedback from second integrator
mulx pot0 ; attenuate acc
rdax x,1 ; integrate
wrax x,1
wrax dacl,1 ; write to output
mulx pot0 ; attenuate
rdax y,1 ; integrate
wrax y,1
skp neg,2 ; turn into square wave
sof 0, 0.5
wrax z,0
skp gez,2
sof 0,-0.5
wrax z,0 ; write square wave feedback
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

Only had time to look at it quickly but you probably want to also attenuate the integrator feedback values (i.e. rdax x,0.9).

If this is to do a triangle wave I would just use a counter, count up to a fixed value then count down to 0 then back up to a fixed value, etc.
Frank Thomson
Experimental Noize
Post Reply