Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: davidbgtx on June 06, 2016, 10:42:43 AM
-
I'm trying to send an ascii string to a Fenner drive unit out the H2-Serio-4 as rs232, with no luck at all. I believe the port setup and wiring are correct, I see the transmit led blink on the rs422 port when I pulse the streamout rung. In pic below is an example provided by the drive manual. I've tried about every combination I can think of. I'm thinking maybe I'm not doing the stx etx correct.
Can someone suggest what to load into strprnt using the example in the pic below.
As an example with the WINPLC I used chr(2)+"0130300080"+chr(3)succesfully.
-
Not sure if you are using any variables, but the hardcoded Do-more STRPRINT string for the example in their manual (STX 0 4 3 1 6 0 5 2 3 0 ETX) would be
"$020431605230$03"
however, with embedded variables, it will be different. Make sure you have the STRPRINT "Automatically insert space after each term" UNchecked. You may need to utilize STRPRINT's FmtInt() command to get the widths right/leading zeroes, etc. for any variable terms you have.
-
Not sure if you are using any variables, but the hardcoded Do-more STRPRINT string for the example in their manual (STX 0 4 3 1 6 0 5 2 3 0 ETX) would be
"$020431605230$03"
however, with embedded variables, it will be different. Make sure you have the STRPRINT "Automatically insert space after each term" UNchecked. You may need to utilize STRPRINT's FmtInt() command to get the widths right/leading zeroes, etc. for any variable terms you have.
Thanks so much, I wasn't using the $ to get the stx etx correct. I will be using a variable, I think I can get it now.
-
Say you have your "new acceleration time" stored as an integer as tenths of a second stored in V100. You will want it to have leading zeroes (e.g. "0523" if V100 equaled 523). Your STRPRINT script would then be
"$0204316" FmtInt(V100,dec,4,zeropad) "0$03"
-
To help you debug, the Data View has a hybrid Hex/ASCII format for string variables. This shows you the low level hexadecimal values AND the ASCII values in the same Data View entry (see the attached example). Note that non-displayable ASCII characters (such as STX and ETX) are shown as a DOT/PERIOD in the right-hand ASCII column, but you can still see their raw hex byte value in the left-side portion of the status (best of both worlds).
The Hex/ASCII Data View formats are great when debugging custom protocols such as this.
-
Say you have your "new acceleration time" stored as an integer as tenths of a second stored in V100. You will want it to have leading zeroes (e.g. "0523" if V100 equaled 523). Your STRPRINT script would then be
"$0204316" FmtInt(V100,dec,4,zeropad) "0$03"
zeropad, that's cool, saves several rungs of code. It was much more difficult with the WINPLC ThinkNDo, had to examine the value for number of digits and then add appropriate number of zero's before sending as ASCII. Wish I had the budget to replace all my WINPLC's, well maybe I can budget 3-4 a year.
I had discovered the Hex/ACII view and that's how I knew I was coding stx and etx wrong, but couldn't figure out what to use. Where in help would look for that "$", does mean a hex value or what?
Thanks again
-
Where in help would look for that "$", does mean a hex value or what?
Look at Help Topic DMD0168 String Scripting Language Reference (there is a link to it in both the STRPRINT and EMAIL instruction Help Topics). Near the top is a section on Control Characters ($-based escape sequence for control codes).
-
I looked and looked for this thread and boom, I just found it again accidentally. It's a Fenner/Contrex I have been playing with. The cool thing was I was able to figure out the code without too much trouble* (but I am sure having seen this didn't hurt none), it was the wiring that I got hung up on.
* I didn't find this thread again but another that addressed the hex code syntax.