Teach lesson
Control two pumps from three level sensors · Verilog
A storage tank supplies a variable demand. Your team must design its refill policy. The water, sensors and pumps are simulated. The controller you program runs on a physical Spartan-7 FPGA.
Sign in with an educator account to prepare a class session. Students join with a class code.
New to LabsLand? Create your teacher account
Learning Outcomes
Translate a three-band control policy into HDL and use simultaneous inlet readings to test an edited hardware controller.
Student activity preview
Activity Content
Preview only. In a class session, students can fill in responses and submit their work to the teacher.
Predict
8 min
A storage tank supplies a variable demand. Your team must design its refill policy. The water, sensors and pumps are simulated. The controller you program runs on a physical Spartan-7 FPGA.
Each sensor is 1 when the water reaches its mark. Each inlet has two command bits. Keep bit0 at zero and use bit1 to switch that inlet on. The model displays the pair in bit0, bit1 order. At or above the middle mark, stop both inlets. Between low and middle, use pump 2 alone. Below low, use both pumps. A high or middle sensor reading of 1 always commands a stop.
Write the two pump commands just above the middle mark, just below it, and below the low mark. Write each pump label in panel order, bit0 then bit1. For each case give the sensor bits in low, middle, high order. Which reading would distinguish your design from one that runs pump 1 in the middle band?
Build and test
40 min
Starting circuit
Your starter has working sensor ports and inactive pump outputs. Write both enable equations. Use the high and middle sensors as stop conditions. Decide which equation also needs the low sensor.
Use ! for a one-bit complement and && to require conditions together. Leave both bit0 outputs tied low.
Start with this complete file. Change the two marked assignments.
module leds_mirror(
input wire wt_low_sensor, wt_mid_sensor, wt_high_sensor,
output wire wt_pump1_bit0, wt_pump1_bit1,
output wire wt_pump2_bit0, wt_pump2_bit1
);
assign wt_pump1_bit0 = 1'b0;
assign wt_pump2_bit0 = 1'b0;
assign wt_pump2_bit1 = 1'b0; // *
assign wt_pump1_bit1 = 1'b0; // *
endmoduleConnect the simulated tank
Copy these seven lines into a plain-text file named tank.xdc. The constraints connect the model’s signals to pins on the physical FPGA. In the editable lab use Add in the project file list to upload tank.xdc. Its filename should appear beside the main HDL file. Return to the HDL file before typing your design.
set_property -dict {PACKAGE_PIN A13 IOSTANDARD LVCMOS33} [get_ports {wt_low_sensor}]
set_property -dict {PACKAGE_PIN A14 IOSTANDARD LVCMOS33} [get_ports {wt_mid_sensor}]
set_property -dict {PACKAGE_PIN D12 IOSTANDARD LVCMOS33} [get_ports {wt_high_sensor}]
set_property -dict {PACKAGE_PIN B13 IOSTANDARD LVCMOS33} [get_ports {wt_pump1_bit0}]
set_property -dict {PACKAGE_PIN B14 IOSTANDARD LVCMOS33} [get_ports {wt_pump1_bit1}]
set_property -dict {PACKAGE_PIN E12 IOSTANDARD LVCMOS33} [get_ports {wt_pump2_bit0}]
set_property -dict {PACKAGE_PIN C13 IOSTANDARD LVCMOS33} [get_ports {wt_pump2_bit1}]Open the editable Boolean Board lab. Paste the starting circuit into the main file (leds_mirror.v) and keep leds_mirror as the top-level design.
Replace the two marked assignments. Trace each port to its entry in the supplied constraints.
Under User interface, choose Change, select Watertank simulation (Deusto, no temperature) and close the picker. Confirm that the selected interface names the tank. Wait for the edit to save, choose Synthesize, wait for success, then choose Upload to FPGA. The board can open directly. If the board picker stays open, choose Upload now under Boolean Board. If it reports temporary unavailability, wait briefly and retry there. Your saved HDL stays in the editor. Find the tank panel below the board camera.
With Automatic unchecked and demand at zero, read the water level and both upper inlet displays. Tick Automatic. When the water falls below middle but remains above low, read both inlets in the same frame. Repeat that observation a few seconds later. If the level recrosses middle, wait for the next time it drops. If the water drops below low, save both inlet readings for your final explanation. Turn Automatic off before leaving.
After your last reading, leave the board and return to this activity. Choose Attach saved code and check that a file appears. Select Mark practice as done and confirm. After filling in your bench notes and explanation, choose Submit work and confirm your submission.
Available in a class session
Read the tank panel
Read the two upper pipes at the same instant. The display on the front of the tank measures outlet flow.
Bench notes
Write the sensor band and both inlet values at the same instant. Record the two upper pipes, not the outlet on the tank. If a band was too brief, name the reading you could not resolve and repeat.
| Test | Observed output |
|---|---|
Tested source
Capture the project you synthesized using the activity's code snapshot control.
Defend your result
7 min
Use one pair of readings to trace the feedback loop from water level through the FPGA and back to the tank. A colleague proposes running both pumps whenever the middle sensor is dry. Which observation tests that proposal? Which predicted bands did you actually observe?
Turn this preview into a live class session
Continue to LabsLand Teach to use this lesson with your students and review the access available to your account.
New to LabsLand? Create your teacher account