S11.11.1 Size the Motor Controller

MediumImplement22 minIcarus Verilog · serverReview the topic

Fill in the sizing sheet of a motor controller at 16 kHz with a longer control loop, the way lesson S11.11 does.

Hardware context: A motor controller: centre-aligned PWM with dead time, conversions, an encoder counter and a break input. Size the PWM, walk one period and check the loop budget and the fault path of a motor controller.

This is the controller of lesson S11.11 with other numbers. Walk one PWM period, decide what must be hardware, and size the small buffers.

This worksheet uses named constants. The first three entries show how to record your decisions.

Signals in the Timeline

SignalWidthRole
question8input of each check
Full specification
InputValue
PWMcentre-aligned, 16,000 periods a second; counter clock 100 MHz; dead time 400 ns; at least 1024 steps
Conversionstwo, one after the other, 1500 ns each, started at the valley
Core100 MHz; entry 30 cycles; longest masked section 400 cycles; control loop 3000 cycles; budget 50 percent of a period
Encoder2000 lines, four edges a line, top speed 3000 turns a minute
Faultoutputs off within 1000 ns; a software handler needs 50 cycles after entry
Other requestsa speed loop 1000 times a second
Telemetry16 bytes every 10 periods; the link may stall for 5 ms; the buffer is a power of two
SRAMa sine table of 2048 bytes, the telemetry buffer and 2048 bytes of stack, rounded up to a power of two

Round a tick count up. Enter times in ns, shares in percent rounded down, KiB as a number, and 1 for yes or 0 for no.

EntryYour decision
TOPThe top value of the counter.
DEAD_TICKSThe dead time in counter ticks.
PERIOD_NSThe PWM period in ns.
EDGES_PER_PERIODEncoder edges in one period at top speed, rounded down.
IRQ_TOTALRequests each second, control and speed loops.
ADC_DONE_NSWhen both conversions are done.
ISR_START_NSWhen the handler starts, in the worst case.
ISR_END_NSWhen the new duties are written.
SLACK_NSTime left before the next valley.
SHARE_PCTFrom the end of the conversions to the new duties, as a share of the period.
MEETS_BUDGETDoes that share meet the budget of 50 percent?
SW_FAULT_NSTime from a fault to the outputs off by a software handler.
TELEM_BUFFERBytes of the telemetry buffer.
SRAM_KIBKiB of SRAM.
ISR_END_AT_MThe longest masked section is M cycles. Everything else is as in the tables. At what time, in ns, are the new duties written?

Examples

Example 1

TOP
Input
The top value of the counter.
Output
matches = 1

100,000,000 ÷ (2 × 16,000).

Example 2

DEAD TICKS
Input
The dead time in counter ticks.
Output
matches = 1

400 ns × 100 MHz.

Example 3

PERIOD NS
Input
The PWM period in ns.
Output
matches = 1

1,000,000,000 ÷ 16,000.

Constraints and Contract

  • Keep the parameter and named constants. Use the numeric codes and units on this page.
  • For ISR_END_AT_M, enter a constant expression using M. Only this entry changes with the parameter. The supported integer range is 0 through 800, inclusive.
  • Replace each unfinished 65535 with your number.

Hints

Hint 1

Top, dead time and period follow from the counter clock and the PWM rate.

Hint 2

Conversions, the worst masked section, entry, then the loop. Compare with the next valley and with the budget.

Hint 3

Compare the encoder edges and the fault limit with what software can do.

What the grader checks: Each check compares the full eight-bit answer. Parameter trials change one condition and keep the other decisions fixed.

15 checks on Icarus Verilog · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your source only; samples require the simulation service. A passing result establishes the tested cases, not a proof for all possible inputs.

See all 1 problem on this path

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

TOP

Input
The top value of the counter.
Expected output
matches = 1

100,000,000 ÷ (2 × 16,000).

Run samples executes all 3 public checks. Check all tests runs 15 checks on the server.

Icarus Verilog · server