1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 <2023> 2024 2025 | Index | 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 <2023> 2024 2025 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: some motor driver 3 questions |
From: | Mark Rivers via Tech-talk <tech-talk at aps.anl.gov> |
To: | tech-talk <tech-talk at aps.anl.gov>, lynn <lynn0703 at yeah.net> |
Date: | Fri, 26 May 2023 13:27:03 +0000 |
You see this in the output:
2023/05/24 18:30:14.350 serial1 read 11 bytes eom=0
PX;-106202; 2023/05/24 18:30:14.350 192.168.1.5:5001 udp read. 2023/05/24 18:30:16.352 serial1 read from low-level driver returned 1
So the low-level read returned 1, which is asynTimeout. This is interpreted as an error condition.
It expects 0, asynSuccess.
The code is here:
sprintf(pC_->outString_,
"PX;");
comStatus = pC_->writeReadController(); if (comStatus) goto skip;
So if comStatus is not 0 it jumps to "skip" and does not send the ID command.
I don't see any \r or \n in the response from the device. Does it use a semicolon (';') as the terminator? If so you need to set that with asynOctetSetInputEos in your startup script.
2) how to achieve it, if I want to send some initialization command ?
You can send an initialization command in the axis or controller constructor code.
3)
When I send "px;". Device would not send "PX=15926;" back. It would send "px;" first,then "15268;". I means, they are not send together. Does I need to change some in my code?
I think you need to set the terminator to ;. Then you need to do 2 reads to read the response. The first will read px, the second will read the value.
4)
Device required command "PR=1000;", then send "BG;". it would not work if send together.
How to write these code ?
sprintf(pC_->outString_, "BG;"); // I added a line here. Does it ok?
} else {
sprintf(pC_->outString_, "PA=%d;", NINT(position));
sprintf(pC_->outString_, "BG;"); That code is not correct. You need to change it to this: if (relative) {
sprintf(pC_->outString_, "PR=%d;", NINT(position));
comStatus
= pC_->writeReadController();
sprintf(pC_->outString_, "BG;");
comStatus
= pC_->writeReadController();
} else {
sprintf(pC_->outString_,
"PA=%d;", NINT(position));
comStatus
= pC_->writeReadController();
sprintf(pC_->outString_,
"BG;");
comStatus
= pC_->writeReadController();
Mark From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of lynn via Tech-talk <tech-talk at aps.anl.gov>
Sent: Wednesday, May 24, 2023 7:11 AM To: tech-talk <tech-talk at aps.anl.gov> Subject: some motor driver 3 questions Hi all,
Nowadayas i was writing elmo motor driver.
i modified from MCB4BDriver.cpp (model 3 example). I found it was in a loop from AsynTrace message, after starting st.cmd. ********************* AsynTrace out, Begin************************* 2023/05/24 18:30:14.347 wrote 3 to 192.168.1.5:5001 udp, return asynSuccess. 2023/05/24 18:30:14.347 asynOctetSyncIO wrote: PX; 2023/05/24 18:30:14.347 192.168.1.5:5001 udp read. 2023/05/24 18:30:14.350 192.168.1.5:5001 udp (from 192.168.1.5:5001) read 11 PX;-106202; 2023/05/24 18:30:14.350 serial1 read 11 bytes eom=0 PX;-106202; 2023/05/24 18:30:14.350 192.168.1.5:5001 udp read. 2023/05/24 18:30:16.352 serial1 read from low-level driver returned 1 2023/05/24 18:30:16.352 serial1 queueUnlockPort 2023/05/24 18:30:16.352 serial1 asynManager::queueUnlockPort waiting for event 2023/05/24 18:30:16.352 serial1 queueUnlockPort unlock mutex 0x7f605c000e90 complete. 2023/05/24 18:30:16.452 serial1 asynManager::queueLockPort locking port 2023/05/24 18:30:16.452 serial1 asynManager::queueLockPort taking mutex 0x7f605c000e90 2023/05/24 18:30:16.452 serial1 asynManager::queueLockPort queueing request 2023/05/24 18:30:16.452 serial1 addr -1 queueRequest priority 0 not lockHolder 2023/05/24 18:30:16.452 serial1 schedule queueRequest timeout in 2.000000 seconds 2023/05/24 18:30:16.452 serial1 asynManager::queueLockPort waiting for event 2023/05/24 18:30:16.452 asynManager::portThread port=serial1 callback 2023/05/24 18:30:16.452 serial1 asynManager::queueLockPortCallback signaling begin event 2023/05/24 18:30:16.452 serial1 asynManager::queueLockPortCallback waiting for mutex from queueUnlockPort 2023/05/24 18:30:16.452 serial1 asynManager::queueLockPort got event from callback 2023/05/24 18:30:16.452 serial1 flush 2023/05/24 18:30:16.452 192.168.1.5:5001 udp flush 2023/05/24 18:30:16.452 192.168.1.5:5001 udp write. 2023/05/24 18:30:16.452 192.168.1.5:5001 udp write 3 PX; 2023/05/24 18:30:16.452 wrote 3 to 192.168.1.5:5001 udp, return asynSuccess. Another loop begin.
************* AsynTrace out, End ******************
Since loop was about "px;", I checked driver.cpp, found that "PX" only came out in MCB4BAxis::poll function. Here is the code of MCB4BAxis::Poll. ********************* MCB4BAxis::poll Begin ************************* asynStatus MCB4BAxis::poll(bool *moving) { int done; int driveOn; int limit; double position; asynStatus comStatus; sprintf(pC_->outString_, "PX;"); comStatus = pC_->writeReadController(); if (comStatus) goto skip; position = atof(&pC_->inString_[3]); setDoubleParam(pC_->motorPosition_, position); // Read the moving status of this motor sprintf(pC_->outString_, "ID;"); comStatus = pC_->writeReadController(); if (comStatus) goto skip; done = (float(pC_->inString_[3]) > 0.009) ? 1:0; setIntegerParam(pC_->motorStatusDone_, done); *moving = done ? false:true; ********************* MCB4BAxis::poll End ************************* Could someone help me with these questions:
1) why command "ID;" did not work? Both "PX;" and "ID;" were in MCB4BAxis::poll function. Obviously, "PX;" was send ,"ID;" didn't. 2) how to achieve it, if I want to send some initialization command ? 3) When I send "px;". Device would not send "PX=15926;" back. It would send "px;" first,then "15268;". I means, they are not send together. Does I need to change some in my code? 4)
Device required command "PR=1000;", then send "BG;". it would not work if send together.
How to write these code ?
if (relative) {
sprintf(pC_->outString_, "PR=%d;", NINT(position)); sprintf(pC_->outString_, "BG;"); // I added a line here. Does it ok? } else { sprintf(pC_->outString_, "PA=%d;", NINT(position)); sprintf(pC_->outString_, "BG;"); Any suggestion was appreciate.
Thanks.
Regards,
Lynn
|