Author |
Topic: Serial com in LBB/LB4 - what is different? (Read 2263 times) |
|
flotulopex
Junior Member
member is offline
Gender:
Posts: 94
|
|
Serial com in LBB/LB4 - what is different?
« Thread started on: Apr 24th, 2014, 7:02pm » |
|
Hi,
I'm trying to send simple G-code commands to my 3D printer via a simple LBB program but the printer won't execute the command.
BUT when I use a serial com software (HyperTerminal like), it does work.
As an example, I send this command in the serial com software: G1 X100 Y100 Z100 and <CR> as terminator; this will position the printer's head somewhere I want it to be.
Via LBB, I tried these two small pieces of code; none of them will work:
Code:OPEN "COM3:115200,n,8,1" FOR RANDOM AS #PRINTER
#PRINTER "G1 X100 Y100 Z100" + CHR$(13)
CLOSE #PRINTER
END Code:OPEN "COM3:115200,n,8,1" FOR RANDOM AS #PRINTER
timer 2000, [done]
wait
[done]
timer 0
#PRINTER "G1 X100 Y100 Z100" + CHR$(13)
CLOSE #PRINTER
END
There is obviously a difference between both system used to transmit serial data.
Any idea what it is?
Roger
|
|
Logged
|
Roger
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Serial com in LBB/LB4 - what is different?
« Reply #1 on: Apr 24th, 2014, 8:27pm » |
|
on Apr 24th, 2014, 7:02pm, flotulopex wrote:There is obviously a difference between both system used to transmit serial data. Any idea what it is? |
|
I think you've failed to take account of this comment in the Compatibility section of the LBB docs:
"12. Opening a file in BINARY mode does not prevent PRINT outputting a newline (CRLF). To suppress the newline add a trailing semicolon (;) to the PRINT statement; this will not affect the operation of the program in LB4."
So your code:
Code:#PRINTER "G1 X100 Y100 Z100" + CHR$(13) Will output the string followed by the sequence CR CR LF, which is probably not what you intended. Try adding a terminating semicolon:
Code:#PRINTER "G1 X100 Y100 Z100" + CHR$(13); That may be all you need to make it work. As the LBB docs note, adding the semicolon does not affect compatibility with LB.
LBB cannot emulate LB's (rather peculiar) feature of suppressing the CRLF when the file (or port) is opened in BINARY mode because there is no way it can determine at run-time (i.e. solely from the handle) what mode was specified.
Richard.
|
|
|
|
flotulopex
Junior Member
member is offline
Gender:
Posts: 94
|
|
Re: Serial com in LBB/LB4 - what is different?
« Reply #2 on: Apr 25th, 2014, 10:26am » |
|
on Apr 24th, 2014, 8:27pm, Richard Russell wrote:....I think you've failed to take account of this comment in the Compatibility section of the LBB docs... |
|
No, in fact I did use a semi-colon for some tests but I wrongly wrote my code like this (=semi-colon after the command text): Code:#PRINTER "G1 X100 Y100 Z100"; + CHR$(13 I'll try this tonight ;-)
Meanwhile, you may have an idea how I can make the terminators caracters "visible" in an serial com software or is it simply "not possible"?
|
|
Logged
|
Roger
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Serial com in LBB/LB4 - what is different?
« Reply #3 on: Apr 25th, 2014, 1:11pm » |
|
on Apr 25th, 2014, 10:26am, flotulopex wrote:Meanwhile, you may have an idea how I can make the terminators caracters "visible" in an serial com software |
|
In LBB characters with codes less than 32 (i.e. 'control characters') will never be visible when printed to the mainwin, since those codes have special meanings. To make the characters 'visible' you would need to convert them into something different; that can easily be done but may be rather slow. The code listed below (LBB-specific) displays the control characters in red.
Richard.
Code:string$ = "G1 X100 Y100 Z100" + CHR$(13) + CHR$(10)
print visible$(string$)
end
function visible$(s$)
for i = 1 to len(s$)
c = asc(mid$(s$,i))
if c < 32 then
visible$ = visible$ + chr$(17)+chr$(1)+chr$(64+c)+chr$(17)+chr$(0)
else
visible$ = visible$ + chr$(c)
end if
next
end function
|
|
Logged
|
|
|
|
flotulopex
Junior Member
member is offline
Gender:
Posts: 94
|
|
Re: Serial com in LBB/LB4 - what is different?
« Reply #4 on: Apr 25th, 2014, 4:27pm » |
|
Well...still not working either ways.
I need to trap what serial data I'm sending to the printer via LBB or the com software.
Any idea how to do so?
|
|
Logged
|
Roger
|
|
|
flotulopex
Junior Member
member is offline
Gender:
Posts: 94
|
|
Re: Serial com in LBB/LB4 - what is different?
« Reply #6 on: Apr 25th, 2014, 5:21pm » |
|
How can I modify/set the serial data flow control type in LBB (Xon/Xoff - Hardware - None)?
|
|
Logged
|
Roger
|
|
|
flotulopex
Junior Member
member is offline
Gender:
Posts: 94
|
|
Re: Serial com in LBB/LB4 - what is different?
« Reply #7 on: Apr 25th, 2014, 5:33pm » |
|
The syntax for serial port parameters is slightly different. The basic options are the same, so for example this works:
open "COM1:9600,n,8,1" for random as #comm
but when specifying 'handshaking' parameters the syntax accepted by LBB is as follows:
open "COMn: [baud=b] [parity=p] [data=d] [stop=s] [to=on|off] [xon=on|off] [odsr=on|off] [octs=on|off] [dtr=on|off|hs] [rts=on|off|hs|tg] [idsr=on|off]"
I don't get it.
What would the correct syntax be in my case please?
|
|
Logged
|
Roger
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Serial com in LBB/LB4 - what is different?
« Reply #8 on: Apr 25th, 2014, 9:55pm » |
|
on Apr 25th, 2014, 4:27pm, flotulopex wrote:How can I modify/set the serial data flow control type in LBB (Xon/Xoff - Hardware - None)? |
|
Code:OPEN "COM3: baud=115200 parity=n data=8 stop=1 xon=on odsr=off octs=off" FOR RANDOM AS #PRINTER However I'm not sure whether Xon/Xoff handshaking is always available in Windows; it may depend on your serial port driver. Personally I would prefer to implement it in my own code because that way you know it will always work.
Richard.
|
|
Logged
|
|
|
|
flotulopex
Junior Member
member is offline
Gender:
Posts: 94
|
|
Re: Serial com in LBB/LB4 - what is different?
« Reply #9 on: Apr 26th, 2014, 12:49pm » |
|
Still won't work.
Since the beginning of this thread, when I send the data to the printer , I can see on its LCD some kind of "reset" since it will show up the "start screen" just as when I switch it on. That means, all changes I made to the data sent as in my first post don't modify anything.
If there is no difference in the data itself, no obvious flow control issue, what is still to be investigated?
|
|
Logged
|
Roger
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Serial com in LBB/LB4 - what is different?
« Reply #10 on: Apr 26th, 2014, 5:04pm » |
|
on Apr 26th, 2014, 12:49pm, flotulopex wrote:If there is no difference in the data itself, no obvious flow control issue, what is still to be investigated? |
|
You say the data is correct, but what about the baud rate, parity bit (if any) and number of stop bits? If any of those are wrong it is entirely likely that the receiving device will not respond correctly. An oscilloscope is an invaluable tool to investigate those issues.
There are not that many ways in which the serial signal could be wrong, so if you have appropriate monitoring facilities it should be relatively simple to debug the problem. You are far better placed to do that than I am!
Richard.
|
|
Logged
|
|
|
|
flotulopex
Junior Member
member is offline
Gender:
Posts: 94
|
|
Re: Serial com in LBB/LB4 - what is different?
« Reply #11 on: Apr 28th, 2014, 10:01am » |
|
...yup!
The oscillo is on my table already but I can't still point the problem.
I'll check some more....
|
|
Logged
|
Roger
|
|
|
Rod
Full Member
member is offline
Gender:
Posts: 110
|
|
Re: Serial com in LBB/LB4 - what is different?
« Reply #12 on: Apr 28th, 2014, 3:25pm » |
|
If you say that you can issue the commands via HyperTerminal like software then it can be achieved with LBB.
Couple of guesses, COM3 does not sound right. If you are using a USB based serial module its likely to be a higher number.
Use the Control Panel to double check what Com number and parameters the HyperTerminal like software is using.
Are you sure it just terminates with a CR? Some of these modules use a check digit routine appending a character to the end of the message.
Is the printer home made? who makes the HyperTerminal like software and can you post a link to their support pages?
|
|
Logged
|
|
|
|
flotulopex
Junior Member
member is offline
Gender:
Posts: 94
|
|
Re: Serial com in LBB/LB4 - what is different?
« Reply #13 on: Apr 30th, 2014, 05:50am » |
|
Thanks Rod,
I checked these points already: COM ports, speed and other parameters all are fine.
The com tool lets me choose between different terminators; I just needed to test them one by one to find the correct one, the only one that works is "CR".
The printer is this one http://www.bqreaders.com/gb/products/witbox.html.
I use the "Serial Communicator" software utility coming with this editor http://www.mecanique.co.uk/shop/index.php?route=product/category&path=20_62.
Until now, I sniffed the com port with this tool http://www.eltima.com/products/serial-port-monitor/. But it doesn't shows up any kind of special control er checking character.
I need to look into the transmitted data packet with my oscillo and maybe find if there is a difference.
But I don't have any protocol analyzing tool so if there is a difference, I'll still need to find out what exactly it is.
|
|
Logged
|
Roger
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Serial com in LBB/LB4 - what is different?
« Reply #14 on: Apr 30th, 2014, 08:33am » |
|
on Apr 30th, 2014, 05:50am, flotulopex wrote:The com tool lets me choose between different terminators; I just needed to test them one by one to find the correct one, the only one that works is "CR". |
|
Evidently you don't have a detailed specification of the data format accepted by the printer, otherwise you would not have needed to perform that experiment. Can you not obtain such a specification from the printer manufacturer?
Richard.
|
|
Logged
|
|
|
|
|