# Converting continuous signal to digital signal

Posted 10 months ago
1476 Views
|
3 Replies
|
2 Total Likes
|
 Hi, I am trying to create a neuron model that fires action potentials (spikes) when a certain threshold is reached. The spikes are slowly reduced and eventually reaches noise level in the refractory period and again fires after the refractory period. The initial input is a continuous signal. Thanks
3 Replies
Sort By:
Posted 10 months ago
 Hi Lakshmi,You can use events (if, when statements) to convert your continuous signal to discrete signals. A simple model that mimics the first part of your case is as follows: model Model Real contSignal; Real outputSignal(start = 1); parameter Real slope = 2; parameter Real threshold = 5; equation der(contSignal) = slope; if contSignal < threshold then der(outputSignal) = 0; else der(outputSignal) = -outputSignal; end if ; 
 I think you want to do this. 'Slope' was just a parameter I used to define the continuous signal.  model EventGen Modelica.Blocks.Sources.ExpSine source(amplitude = 10, freqHz = 1, damping = 1) ; parameter Real threshold = 1; Real outputSignal(start = 0); equation der(outputSignal) = -outputSignal; when source.y < threshold then reinit(outputSignal,1); end when; end EventGen;