-
Notifications
You must be signed in to change notification settings - Fork 0
State Machine
Nicolas Peschke edited this page Apr 5, 2024
·
8 revisions
To implement the droplet sorting functionality a so called state machine was used. The concept relies on states that perform actions and specific conditions that determine when a transition from one state into another should happen.
The FADS state machine has the following six states depicted in the UML diagram.
Note that the states also correspond to the equally numbered LED on the RedPitaya, where the state can be notified visually in real-time.
- On
fads_reset
- regardless of the current state,
fads_reset
will always land here. - resets all counters to 0
- regardless of the current state,
- Waits for
droplet_acquisition_enable
- Waits until intensity rises over
min_intensity_threshold
- Starts droplet acquisition once intensity is reached
- Updates
droplet_intensity_max
with new maximum intensity values for this droplet - Continually increments
droplet_width_counter
for this droplet - Until intensity falls again below
min_intensity_threshold
- increments the respective counters for positive/negative, long/short and high/low intensity droplets
- updates the output registers with
droplet_id
,cur_droplet_intensity
andcur_droplet_width
- keep logging caveats in mind!
- starts sorting delay
- Variable delay (
sort_delay
) until droplet reaches sorting junction
- Activates
sort_trig
for a variable duration (sort_duration
)
The sort_trig
signal can be used by the asgs
widget as a trigger source
called fads
to turn on the signal generator for the duration.
stateDiagram-v2
[*] --> Base : reset
Base --> WaitForDroplet: droplet_acquisition_enable
state WaitForDroplet {
state if_state_1 <<choice>>
[*] --> ReadADC_1
ReadADC_1 --> if_state_1
if_state_1 --> ReadADC_1 : if ADC < min_intensity
if_state_1 --> Reset_droplet_width_counter: if value >= min_intensity
Reset_droplet_width_counter --> Update_droplet_intensity_max_1
Update_droplet_intensity_max_1 --> [*]
}
WaitForDroplet --> AcquiringDroplet : if ADC >= min_intensity
state AcquiringDroplet {
state if_state_2_1 <<choice>>
state if_state_2_2 <<choice>>
[*] --> ReadADC_2
ReadADC_2 --> Increment_droplet_width_counter
Increment_droplet_width_counter --> if_state_2_1
if_state_2_1 --> if_state_2_2: if ADC <= droplet_intensity_max
if_state_2_1 --> Update_droplet_intensity_max: if ADC > droplet_intensity_max
Update_droplet_intensity_max --> if_state_2_2
if_state_2_2 --> [*]: if ADC <= min_intensity
if_state_2_2 --> ReadADC_2: if ADC > min_intensity
}
AcquiringDroplet --> EvaluateDroplet : if ADC < min_intensity
state EvaluateDroplet {
[*] --> IncrementCounters
IncrementCounters --> Set_droplet_classification
Set_droplet_classification --> [*]
}
state if_state_sorting <<choice>>
EvaluateDroplet --> if_state_sorting
if_state_sorting --> Base : if not sorting_enabled
if_state_sorting --> SortingDelay : if sorting_enabled
state SortingDelay {
state if_state_4 <<choice>>
[*] --> Update_sort_delay_counter
note right of Update_sort_delay_counter
Reset sort_delay_counter to 1 if entering SortingDelay state
Otherwise increment sort_delay_counter
end note
Update_sort_delay_counter --> if_state_4
if_state_4 --> Update_sort_delay_counter : if sort_delay_counter < sort_delay
if_state_4 --> [*] : if sort_delay_counter >= sort_delay
}
SortingDelay --> Sorting
state Sorting {
state if_state_5 <<choice>>
[*] --> Enable_sort_trig
Enable_sort_trig --> Update_sort_counter
note right of Update_sort_counter
Reset sort_counter to 1 if entering Sorting state
Otherwise increment sort_counter
end note
Update_sort_counter --> if_state_5
if_state_5 --> Update_sort_counter : if sort_counter < sort_duration
if_state_5 --> Disable_sort_trig : if sort_counter >= sort_duration
Disable_sort_trig --> [*]
}
Sorting --> Base