Dear all,
I’m struggling to write a motor driver for an old piezo controller that goes by the name CN30 or PiCo 33 from Mechonics.
I guess my problem is that this controller talks only in command-bytes and I’m trying to use the model 3 driver which is based on ASCII-commands. I attached a pdf with a description of the RS232 command-byte and I also
found a SPEC driver for this controller: BLISS: SPEC Macro documentation / Macrofile: mechonics.mac (esrf.fr)
This is my move function from the driver:
asynStatus CN30Axis::move(double position, int relative, double baseVelocity, double slewVelocity, double acceleration)
{
asynStatus status;
size_t nwrite;
int steps, steps2Go;
char nsteps[4];
// static const char *functionName = "CN30Axis::move";
// calculate how many steps to do, ca. 200nm/Step and we drive in mm
steps2Go = static_cast<int>(position / 200e-7);
while (steps2Go > 0) {
if (steps2Go >= 100) strcpy(nsteps, "111"), steps = 100;
else if (steps2Go >= 50) strcpy(nsteps, "110"), steps = 50;
else if (steps2Go >= 20) strcpy(nsteps, "101"), steps = 20;
else if (steps2Go >= 10) strcpy(nsteps, "100"), steps = 10;
else if (steps2Go >= 5) strcpy(nsteps, "011"), steps = 5;
else if (steps2Go >= 2) strcpy(nsteps, "010"), steps = 2;
else if (steps2Go >= 1) strcpy(nsteps, "001"), steps = 1;
sprintf(pC_->outString_, "00000%s", nsteps);
pC_->writeController();
epicsThreadSleep(0.001);
steps2Go = steps2Go - steps;
}
return status;
}
Here is the IOC console output with asynTraces turned on when trying to do a 1mm move (I also need to work on the step-resolution but this is not the issue right now):
00000111
2024/01/31 16:44:55.492 CN30Port queueUnlockPort
2024/01/31 16:44:55.492 CN30Port asynManager::queueUnlockPort waiting for event
2024/01/31 16:44:55.492 CN30Port queueUnlockPort unlock mutex 0x7f5098000ee0 complete.
2024/01/31 16:44:55.493 CN30Port asynManager::queueLockPort locking port
2024/01/31 16:44:55.493 CN30Port asynManager::queueLockPort taking mutex 0x7f5098000ee0
2024/01/31 16:44:55.493 CN30Port asynManager::queueLockPort queueing request
2024/01/31 16:44:55.493 CN30Port addr -1 queueRequest priority 0 not lockHolder
2024/01/31 16:44:55.493 CN30Port schedule queueRequest timeout in 2.000000 seconds
2024/01/31 16:44:55.493 CN30Port asynManager::queueLockPort waiting for event
2024/01/31 16:44:55.493 asynManager::portThread port=CN30Port callback
2024/01/31 16:44:55.493 CN30Port asynManager::queueLockPortCallback signaling begin event
2024/01/31 16:44:55.493 CN30Port asynManager::queueLockPortCallback waiting for mutex from queueUnlockPort
2024/01/31 16:44:55.493 CN30Port asynManager::queueLockPort got event from callback
2024/01/31 16:44:55.493 192.168.99.20:4001 write.
2024/01/31 16:44:55.493 192.168.99.20:4001 write 8
00000111
2024/01/31 16:44:55.493 wrote 8 to 192.168.99.20:4001, return asynSuccess.
2024/01/31 16:44:55.493 asynOctetSyncIO wrote:
00000111
2024/01/31 16:44:55.493 CN30Port queueUnlockPort
2024/01/31 16:44:55.493 CN30Port asynManager::queueUnlockPort waiting for event
2024/01/31 16:44:55.493 CN30Port queueUnlockPort unlock mutex 0x7f5098000ee0 complete.
2024/01/31 16:44:55.495 CN30Port asynManager::queueLockPort locking port
2024/01/31 16:44:55.495 CN30Port asynManager::queueLockPort taking mutex 0x7f5098000ee0
2024/01/31 16:44:55.495 CN30Port asynManager::queueLockPort queueing request
2024/01/31 16:44:55.495 CN30Port addr -1 queueRequest priority 0 not lockHolder
2024/01/31 16:44:55.495 CN30Port schedule queueRequest timeout in 2.000000 seconds
2024/01/31 16:44:55.495 CN30Port asynManager::queueLockPort waiting for event
2024/01/31 16:44:55.495 asynManager::portThread port=CN30Port callback
2024/01/31 16:44:55.495 CN30Port asynManager::queueLockPortCallback signaling begin event
2024/01/31 16:44:55.495 CN30Port asynManager::queueLockPortCallback waiting for mutex from queueUnlockPort
2024/01/31 16:44:55.495 CN30Port asynManager::queueLockPort got event from callback
2024/01/31 16:44:55.495 192.168.99.20:4001 write.
2024/01/31 16:44:55.495 192.168.99.20:4001 write 8
00000111
2024/01/31 16:44:55.495 wrote 8 to 192.168.99.20:4001, return asynSuccess.
2024/01/31 16:44:55.495 asynOctetSyncIO wrote:
00000111
2024/01/31 16:44:55.495 CN30Port queueUnlockPort
2024/01/31 16:44:55.495 CN30Port asynManager::queueUnlockPort waiting for event
2024/01/31 16:44:55.495 CN30Port queueUnlockPort unlock mutex 0x7f5098000ee0 complete.
2024/01/31 16:44:55.496 CN30Port asynManager::queueLockPort locking port
2024/01/31 16:44:55.496 CN30Port asynManager::queueLockPort taking mutex 0x7f5098000ee0
2024/01/31 16:44:55.496 CN30Port asynManager::queueLockPort queueing request
2024/01/31 16:44:55.496 CN30Port addr -1 queueRequest priority 0 not lockHolder
2024/01/31 16:44:55.496 CN30Port schedule queueRequest timeout in 2.000000 seconds
2024/01/31 16:44:55.496 CN30Port asynManager::queueLockPort waiting for event
2024/01/31 16:44:55.496 asynManager::portThread port=CN30Port callback
2024/01/31 16:44:55.496 CN30Port asynManager::queueLockPortCallback signaling begin event
2024/01/31 16:44:55.496 CN30Port asynManager::queueLockPortCallback waiting for mutex from queueUnlockPort
2024/01/31 16:44:55.496 CN30Port asynManager::queueLockPort got event from callback
2024/01/31 16:44:55.496 192.168.99.20:4001 write.
2024/01/31 16:44:55.496 192.168.99.20:4001 write 8
00000110
2024/01/31 16:44:55.496 wrote 8 to 192.168.99.20:4001, return asynSuccess.
2024/01/31 16:44:55.496 asynOctetSyncIO wrote:
00000110
2024/01/31 16:44:55.496 CN30Port queueUnlockPort
2024/01/31 16:44:55.496 CN30Port asynManager::queueUnlockPort waiting for event
2024/01/31 16:44:55.496 CN30Port queueUnlockPort unlock mutex 0x7f5098000ee0 complete.
2024/01/31 16:44:55.497 CN30Port asynManager::queueLockPort locking port
2024/01/31 16:44:55.497 CN30Port asynManager::queueLockPort taking mutex 0x7f5098000ee0
2024/01/31 16:44:55.497 CN30Port asynManager::queueLockPort queueing request
2024/01/31 16:44:55.497 CN30Port addr -1 queueRequest priority 0 not lockHolder
2024/01/31 16:44:55.497 CN30Port schedule queueRequest timeout in 2.000000 seconds
2024/01/31 16:44:55.497 CN30Port asynManager::queueLockPort waiting for event
2024/01/31 16:44:55.497 asynManager::portThread port=CN30Port callback
2024/01/31 16:44:55.497 CN30Port asynManager::queueLockPortCallback signaling begin event
2024/01/31 16:44:55.497 CN30Port asynManager::queueLockPortCallback waiting for mutex from queueUnlockPort
2024/01/31 16:44:55.497 CN30Port asynManager::queueLockPort got event from callback
2024/01/31 16:44:55.497 192.168.99.20:4001 write.
2024/01/31 16:44:55.497 192.168.99.20:4001 write 8
00000101
2024/01/31 16:44:55.497 wrote 8 to 192.168.99.20:4001, return asynSuccess.
2024/01/31 16:44:55.497 asynOctetSyncIO wrote:
00000101
2024/01/31 16:44:55.497 CN30Port queueUnlockPort
2024/01/31 16:44:55.497 CN30Port asynManager::queueUnlockPort waiting for event
2024/01/31 16:44:55.497 CN30Port queueUnlockPort unlock mutex 0x7f5098000ee0 complete.
2024/01/31 16:44:55.498 CN30Port asynManager::queueLockPort locking port
2024/01/31 16:44:55.498 CN30Port asynManager::queueLockPort taking mutex 0x7f5098000ee0
2024/01/31 16:44:55.498 CN30Port asynManager::queueLockPort queueing request
2024/01/31 16:44:55.498 CN30Port addr -1 queueRequest priority 0 not lockHolder
2024/01/31 16:44:55.498 CN30Port schedule queueRequest timeout in 2.000000 seconds
2024/01/31 16:44:55.498 CN30Port asynManager::queueLockPort waiting for event
2024/01/31 16:44:55.498 asynManager::portThread port=CN30Port callback
2024/01/31 16:44:55.498 CN30Port asynManager::queueLockPortCallback signaling begin event
2024/01/31 16:44:55.498 CN30Port asynManager::queueLockPortCallback waiting for mutex from queueUnlockPort
2024/01/31 16:44:55.498 CN30Port asynManager::queueLockPort got event from callback
2024/01/31 16:44:55.498 192.168.99.20:4001 write.
2024/01/31 16:44:55.498 192.168.99.20:4001 write 8
00000101
2024/01/31 16:44:55.498 wrote 8 to 192.168.99.20:4001, return asynSuccess.
2024/01/31 16:44:55.498 asynOctetSyncIO wrote:
00000101
2024/01/31 16:44:55.499 CN30Port queueUnlockPort
2024/01/31 16:44:55.499 CN30Port asynManager::queueUnlockPort waiting for event
2024/01/31 16:44:55.499 CN30Port queueUnlockPort unlock mutex 0x7f5098000ee0 complete.
2024/01/31 16:44:55.500 CN30Port asynManager::queueLockPort locking port
2024/01/31 16:44:55.500 CN30Port asynManager::queueLockPort taking mutex 0x7f5098000ee0
2024/01/31 16:44:55.500 CN30Port asynManager::queueLockPort queueing request
2024/01/31 16:44:55.500 CN30Port addr -1 queueRequest priority 0 not lockHolder
2024/01/31 16:44:55.500 CN30Port schedule queueRequest timeout in 2.000000 seconds
2024/01/31 16:44:55.500 CN30Port asynManager::queueLockPort waiting for event
2024/01/31 16:44:55.500 asynManager::portThread port=CN30Port callback
2024/01/31 16:44:55.500 CN30Port asynManager::queueLockPortCallback signaling begin event
2024/01/31 16:44:55.500 CN30Port asynManager::queueLockPortCallback waiting for mutex from queueUnlockPort
2024/01/31 16:44:55.500 CN30Port asynManager::queueLockPort got event from callback
2024/01/31 16:44:55.500 192.168.99.20:4001 write.
2024/01/31 16:44:55.500 192.168.99.20:4001 write 8
00000011
2024/01/31 16:44:55.500 wrote 8 to 192.168.99.20:4001, return asynSuccess.
2024/01/31 16:44:55.500 asynOctetSyncIO wrote:
00000011
2024/01/31 16:44:55.500 CN30Port queueUnlockPort
2024/01/31 16:44:55.500 CN30Port asynManager::queueUnlockPort waiting for event
2024/01/31 16:44:55.500 CN30Port queueUnlockPort unlock mutex 0x7f5098000ee0 complete.
2024/01/31 16:44:55.501 CN30Port asynManager::queueLockPort locking port
2024/01/31 16:44:55.501 CN30Port asynManager::queueLockPort taking mutex 0x7f5098000ee0
2024/01/31 16:44:55.501 CN30Port asynManager::queueLockPort queueing request
2024/01/31 16:44:55.501 CN30Port addr -1 queueRequest priority 0 not lockHolder
2024/01/31 16:44:55.501 CN30Port schedule queueRequest timeout in 2.000000 seconds
2024/01/31 16:44:55.501 CN30Port asynManager::queueLockPort waiting for event
2024/01/31 16:44:55.501 asynManager::portThread port=CN30Port callback
2024/01/31 16:44:55.501 CN30Port asynManager::queueLockPortCallback signaling begin event
2024/01/31 16:44:55.501 CN30Port asynManager::queueLockPortCallback waiting for mutex from queueUnlockPort
2024/01/31 16:44:55.501 CN30Port asynManager::queueLockPort got event from callback
2024/01/31 16:44:55.501 192.168.99.20:4001 write.
2024/01/31 16:44:55.501 192.168.99.20:4001 write 8
00000010
2024/01/31 16:44:55.501 wrote 8 to 192.168.99.20:4001, return asynSuccess.
2024/01/31 16:44:55.501 asynOctetSyncIO wrote:
00000010
2024/01/31 16:44:55.501 CN30Port queueUnlockPort
2024/01/31 16:44:55.501 CN30Port asynManager::queueUnlockPort waiting for event
2024/01/31 16:44:55.501 CN30Port queueUnlockPort unlock mutex 0x7f5098000ee0 complete.
2024/01/31 16:44:55.502 CN30Port asynManager::queueLockPort locking port
2024/01/31 16:44:55.502 CN30Port asynManager::queueLockPort taking mutex 0x7f5098000ee0
2024/01/31 16:44:55.502 CN30Port asynManager::queueLockPort queueing request
2024/01/31 16:44:55.502 CN30Port addr -1 queueRequest priority 0 not lockHolder
2024/01/31 16:44:55.502 CN30Port schedule queueRequest timeout in 2.000000 seconds
2024/01/31 16:44:55.502 CN30Port asynManager::queueLockPort waiting for event
2024/01/31 16:44:55.502 asynManager::portThread port=CN30Port callback
2024/01/31 16:44:55.502 CN30Port asynManager::queueLockPortCallback signaling begin event
2024/01/31 16:44:55.502 CN30Port asynManager::queueLockPortCallback waiting for mutex from queueUnlockPort
2024/01/31 16:44:55.502 CN30Port asynManager::queueLockPort got event from callback
2024/01/31 16:44:55.502 192.168.99.20:4001 write.
2024/01/31 16:44:55.502 192.168.99.20:4001 write 8
00000010
2024/01/31 16:44:55.502 wrote 8 to 192.168.99.20:4001, return asynSuccess.
2024/01/31 16:44:55.502 asynOctetSyncIO wrote:
00000010
2024/01/31 16:44:55.502 CN30Port queueUnlockPort
2024/01/31 16:44:55.502 CN30Port asynManager::queueUnlockPort waiting for event
2024/01/31 16:44:55.502 CN30Port queueUnlockPort unlock mutex 0x7f5098000ee0 complete.
epics>
I can see the axis moving, but it is the wrong axis because Bit 7 and 6 are actually 0 (see attached pdf).
Also, the command 00000111 in the output looks right I’m not sure if the controller understands it. Is it right to use:
sprintf(pC_->outString_, "00000%s", nsteps);
pC_->writeController();
when I want to send a byte-command? Does it matter?
So far, I only have experience in write ASCII-based motor drivers, based on examples of model 3.
Can someone help?
Thanks, and best regards!
Michael
Michael Sintschuk
Bundesanstalt für Materialforschung und –prüfung (BAM)
8.5 - X-ray Imaging
Unter den Eichen 87
12205 Berlin
GERMANY
P: +49 30 8062-15063 (BESSY, Adlershof)
michael.sintschuk at bam.de