Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to read the analog input value from channel 1.
PLC Programming
AnalogValue := AI_Channel[1];Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 as the channel number which may not exist.
Confusing channel numbers with sensor numbers.
✗ Incorrect
Channel numbering usually starts at 1 for analog inputs, so AI_Channel1 reads the first channel.
2fill in blank
mediumComplete the code to scale a 4-20mA input to a 0-100% value.
PLC Programming
ScaledValue := (RawInput - [1]) * 100 / ([2] - [1]);
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 instead of 4 as the lower limit.
Not subtracting the lower limit before scaling.
✗ Incorrect
BLANK_1 is 4mA (lower limit) and BLANK_2 is 20mA (upper limit) for the 4-20mA signal. Subtracting 4 normalizes the input before scaling by the span (16mA) to 0-100%.
3fill in blank
hardFix the error in the voltage scaling formula for 0-10V input.
PLC Programming
ScaledVoltage := RawVoltage [1] 10;
Attempts:
3 left
💡 Hint
Common Mistakes
Multiplying instead of dividing.
Adding or subtracting instead of dividing.
✗ Incorrect
To scale a 0-10V input to a 0-1 range, divide the raw voltage by 10.
4fill in blank
hardFill both blanks to convert a 4-20mA input to a percentage.
PLC Programming
Percentage := (RawCurrent [1] [2]) * 100 / 16;
Attempts:
3 left
💡 Hint
Common Mistakes
Adding instead of subtracting the lower limit.
Using the wrong range value.
✗ Incorrect
Subtract 4mA from the raw current to normalize, then divide by 16mA (20-4) to get the fraction.
5fill in blank
hardFill all three blanks to create a dictionary mapping channel names to scaled values for 0-10V inputs.
PLC Programming
ScaledInputs := { [1]: (RawInputs[[2]] [3] 10) for [1] in Channels };Attempts:
3 left
💡 Hint
Common Mistakes
Using multiplication instead of division for scaling.
Using the loop variable incorrectly as a string.
✗ Incorrect
Use 'ch' as the loop variable (BLANK_1 and BLANK_2 for key and access), and '/' (BLANK_3) to divide RawInputs[ch] by 10 to scale the voltage.
