Jump to content
OMRON Forums

Velocity Control with joystick


Recommended Posts

Good Morning


With a Power Brick AC, I want do motor velocity control with a joystick. The correct steps are:


1 Using a PLC, put the raw ADC data through a cubic function. The


data can be found in the high 16 bits of

PowerBrick[0].Chan[0].AdcAmp[2], for example.


2 Dump the result of the cubic into user buffer memory (e.g. in



3 Create an encoder conversion table (ECT) entry to integrate the

result that's in user buffer.


4 Use the result of this ECT entry as the new master position of your



kindly, is possilbile to have a code example to perform this 4 steps?


thanks in advance

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

This should get you started:




ptr RawAdc->PowerBrick[0].Chan[0].AdcAmp[2]; // 32-bit register with ADC data in high 16 bits

ptr FiltAdc->Sys.Idata[2]; // 32-bit integer register in user shared memory buffer


open plc 0 // Real-time PLC executing under real-time interrupt

// Basic first order filter shown for simplicity

FiltAdc = 0.95 * FiltAdc + 0.05 * RawAdc / 65536; // Exponential low-pass filter on top 16 bits of input register



// Process filtered ADC data to prepare for motor

// Use 9th entry if first 8 entries auto-assigned


EncTable[9].type = 1; // Single-register integer read

EncTable[9].pEnc = Sys.Idata[2].a; // Address of source data

EncTable[9].index1 = 0; // No shift

EncTable[9].index2 = 0; // No shift

EncTable[9].index3 = 0; // No change limiting

EncTable[9].index4 = 1; // Integrate once

EncTable[9].EncBias = 0; // ? Possible offset before integration

EncTable[9].ScaleFactor = 1.0; // User-selectable output scaling


Motor[1].pMasterEnc = EncTable[9].a

Motor[1].MasterPosSf = 0.001; // User-selectable "gear ratio"; set low to start for safety

Motor[1].MasterCtrl = 1; // To enable following, set to 0 to disable

Motor[1].MasterMaxSpeed = ? // Possible speed clamp for safety

Motor[1].MasterMaxAccel = ? // Possible accel clamp for safety



You have indicated that you want to use a higher-order filter in your PLC program, which would be easy to do.


Many joystick users want to create a "deadband" around the 0 input voltage, so there is no drift when the joystick is in its rest position. This is also easy to do in the PLC program.

Link to comment
Share on other sites

A simple routine to provide "deadband" on the ADC from the joystick


global DbSize = 100; // Size of deadband in LSBs of 16-bit ADC

global DbAdc; // Modified reading


open plc 0

DbAdc = RawAdc >> 16; // Take top 16 bits of 32-bit register containing ADC

if (DbAdc > DbSize) DbAdc -= DbSize;

else if (DbAdc < - DbSize) DbAdc += DbSize;

else DbAdc = 0;

// Now filter modified ADC; simple 1st order filter example

FiltAdc = 0.95 * FiltAdc + 0.05 * DbAdc;


Link to comment
Share on other sites

This topic is now closed to further replies.

  • Create New...