How-to
How to assign V-memory values and scale analog in ladder
Short answer
A V-memory register holds the raw module count, not volts: on a 12-bit 0–10 V channel, 2048 counts is just over 5 V. Load your own constants with LD k2048 and OUT V2000 on an SP0 first-scan rung, scale with E = Elow + (R − Rlow) × (Ehigh − Elow) ÷ (Rhigh − Rlow), and keep constants, arithmetic, and comparisons in one data format.
On this page
- What does the V-memory register hold after ANLGIN runs?
- How do I watch the register while I turn the pot?
- Is the number in the register BCD, binary, or hexadecimal?
- How do I convert the raw count to volts?
- How do I load a constant into V-memory?
- How do I compare a voltage in ladder logic?
- How do I command a specific output voltage?
- How do I test the logic before the machine moves?
- Questions asked
A V-memory register never holds volts — it holds the raw count your analog module produced, and the module's setup decides what that count means. After ANLGIN executes, the input data appears in the V registers named in the instruction's Input Data Address field. You either scale that count to volts and compare the scaled value, or convert your target to counts and compare raw. To place a constant of your own in V-memory, load it with LD k2048 and store it with OUT V2000 on a rung enabled by the SP0 first-scan contact. The examples assume a DirectLOGIC DL06 programmed in DirectSOFT 5 with 12-bit analog channels; your module's manual is the authority for its endpoints and data format.
What does the V-memory register hold after ANLGIN runs? #
It holds the raw module count, not volts: on a 12-bit channel, the register moves from 0 at the bottom of the span to 4095 at the top, so a reading of 2048 sits just above half-scale.
Once ANLGIN executes, the analog input data shows up automatically in the V registers you specified in that instruction's Input Data Address section, and what those bits represent depends entirely on the module's setup. For the electronics between the terminal screw and the register, read how PLC analog input and output modules convert signals. Treat the register as a number whose meaning the configuration assigns: resolution, range, and encoding all come from the module documentation, and a different card, a 4–20 mA range, or a different resolution changes every value that follows.
How do I watch the register while I turn the pot? #
Open a Data View in DirectSOFT, type the V address, and the value updates live while the pot moves — one minute of watching tells you whether the problem is in the signal path or in your logic.
- Go to Debug > Data View > New View and type the V address from your ANLGIN Input Data Address field.
- Measure the pot terminal with a meter while you turn it, so every register value is paired with a real voltage.
- Record the register value with the pot at each end of its travel, as measured at the terminal; those two pairs are your actual endpoints and should match the manual's numbers.
- Watch mid-travel: the value should step smoothly, one count at a time, with no jumps.
- If the value never moves, stop and fix the signal path — full-scale voltage at the screw with a dead register is a channel assignment, module setup, or wiring fault, not a scaling error.
Is the number in the register BCD, binary, or hexadecimal? #
Whatever the module's data-format setup says: BCD stores each decimal digit in its own four bits, binary treats the word as one magnitude, and a hexadecimal display only shows the pattern without changing it.
The classic symptom of a mismatch: binary 2048 is the bit pattern 0800 in hex, and a BCD readout decodes the nibbles as digits to display 800. Nothing corrupted — the same bits were read in the wrong convention. The k in LD k2048 marks the constant as BCD, so it lines up directly with a module configured for BCD data; arithmetic and comparison instructions interpret the word in the format the rung gives them. Set the module's format first, then keep constants, math, and comparisons in that one format. When the module is set for binary data, use the matching variant of the scaling instructions rather than converting numbers by hand: the ANSCL(B) instructions take the raw reading and convert it to engineering units.
How do I convert the raw count to volts? #
With a straight line: E = Elow + (R − Rlow) × (Ehigh − Elow) ÷ (Rhigh − Rlow), where R is the register value and the endpoints come from your module manual — on a 12-bit 0–10 V channel that reduces to volts = R × 10 ÷ 4095.
Worked example, using that same channel with Rlow = 0, Rhigh = 4095, Elow = 0 V, Ehigh = 10 V:
- Reading check: R = 2048 gives 2048 × 10 = 20480, and 20480 ÷ 4095 = 5.001 V — call it 5 V.
- Target conversion: a 5 V threshold is 5 × 4095 = 20475, and 20475 ÷ 10 = 2047.5 counts, so use 2048.
- Resolution: one count is the span divided by 4095 — 2.4 mV, the smallest step the channel can report.
| Pot voltage | Register (counts) | Scaled (hundredths of a volt) |
|---|---|---|
| 0 V | 0 | 0 |
| 5 V | 2048 (rounded from 2047.5) | 500 |
| Full scale | 4095 | 1000 |
Scale into hundredths of a volt, not whole volts: whole-volt integers give the pot only eleven values, while hundredths keep nearly all of that resolution (2048 × 1000 ÷ 4095 = 500, displayed as 5.00 V). The same raw-to-engineering-units walk on another controller is shown in scaling a 4–20 mA analog input to engineering units in CPM2 ladder.
How do I load a constant into V-memory? #
With two instructions on one rung: LD k2048 puts the BCD constant 2048 into the accumulator, and OUT V2000 stores it — put an SP0 contact in front so the rung executes on the first scan only.
SP0
--| |----------[ LD k2048 ]
[ OUT V2000 ]
SP0 is on for the first scan only, so the rung writes the constant once, and V2000 keeps it until some other rung writes that address — which is why you cross-reference every write to a register you own. The rung executes again after every transition back to RUN: right for fixed targets, wrong for anything an operator edits. The MOVE(D/W) IBox instructions do the same job in one box if you prefer them. Two addressing details bite newcomers here: V-memory addresses count in octal, so there is no V2008 and the word after V2007 is V2010; and the DL06 option-slot setup value in V7701, when it points at your first analog data register, is an octal number for the same reason. Assign separate registers for raw feedback, scaled feedback, the target, and the output command, and write each from one place.
How do I compare a voltage in ladder logic? #
In one consistent format, using the inline comparison contacts (>, <, =): either convert your target to counts and compare 2048 against the raw register, or scale first and compare 500 against hundredths of a volt — never counts against volts.
The comparison contacts act on the stored number in the format the rung assumes, so a BCD target against a binary register compares unrelated values and the logic lies quietly. Use a greater-than-or-equal contact for a stop threshold, not an equals contact: the input steps one count at a time, so equality is true for one scan at most and the rung can slip past a target that lands between scans. For the released program, compare the scaled value — the rung reads in volts and survives a module change as long as the scaling rung gets the new endpoints. During commissioning, prove the raw compare and the scaled compare agree, then delete the raw one.
How do I command a specific output voltage? #
By converting the command to the output channel's counts and loading that number: on a 12-bit channel spanning 0–5 V, 4 V is 4 × 4095 ÷ 5 = 3276 counts and full-scale 5 V is 4095 — writing the number 5 itself stores the number 5, nothing more.
So on that card, V410 equals 5 V when you run LD k4095 and OUT V410, and a 4 V command is LD k3276. Keep the command in volts in its own register for the operator display, and convert in one rung that feeds the register the output instruction reads — ANLGOUT takes its value from the V registers you assign it, exactly as ANLGIN fills the ones assigned to it. The motor direction signal needs none of this: it is a plain discrete output, and only the speed command is analog. The same counts-side conversion applied to a control output is shown in scale a PID real output to analog output counts.
How do I test the logic before the machine moves? #
In the same Data View: it writes values as well as displays them, so force the input register to 2048 and watch the stop rung fire with the servo enable off and machine motion inhibited.
This is the honest substitute for the offline test bench you are missing: download, then exercise the logic by forcing registers instead of wiring hardware. Force 2048 and confirm the stop rung energizes; force 0 and 4095 and confirm the end-of-range behavior; then release the forced values, connect the real pot, and repeat against a meter. Enable machine motion only after the end-stop rungs stop the drive in logic with the mechanism in sight. Sending a first program to the PLC and watching it is a normal step, not a failure — the discipline is making those first downloads unable to move anything.
Questions asked
Does writing the number 5 into the output register command 5 volts?
No. The register is scaled data: 5 counts on a 12-bit 0–5 V channel produces 5 × 5 V ÷ 4095, about 6 mV at the terminal. Full-scale 5 V needs 4095 counts, and 4 V needs 3276. Convert every command to counts for the configured span before the output instruction runs, and keep the volts version in its own register for the operator display.
Can I scale the pot reading to degrees of travel instead of volts?
Yes. Keep the same equation and set the engineering endpoints to your travel unit. Record the raw count at two known positions of the mechanism — the end stops make repeatable reference points — and use those positions as Elow and Ehigh in degrees. The wiring span says nothing about mechanical travel by itself, so the calibration measurement, not the voltage, defines the unit.
Do constants loaded under SP0 survive restarts and power cycles?
They reload rather than survive. SP0 is on for the first scan after every transition to RUN, so the LD and OUT pair rewrites the constant into V2000 each time the controller starts. That is exactly what you want for a fixed target. An operator-adjusted target belongs in a register no first-scan rung writes, or the restart silently overwrites the operator's entry.
Should the comparison use raw counts or scaled engineering units?
Both work when the two sides use the same unit. Comparing raw counts against a counts target needs no math and the fewest rungs, but the program is then tied to that module's resolution — change the card and every target needs new numbers. Comparing scaled hundredths of a volt keeps targets in engineering units and survives a module change as long as the scaling rung is updated to the new endpoints.