LB Booster
« Serial com in LBB/LB4 - what is different? »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:46am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1 2 3  Notify Send Topic Print
 veryhotthread  Author  Topic: Serial com in LBB/LB4 - what is different?  (Read 2263 times)
flotulopex
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 94
xx 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
User IP Logged

Roger
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx 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.
« Last Edit: Apr 24th, 2014, 8:28pm by Richard Russell » User IP Logged

flotulopex
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 94
xx 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"?

User IP Logged

Roger
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx 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 
User IP Logged

flotulopex
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 94
xx 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?
User IP Logged

Roger
flotulopex
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 94
xx Re: Serial com in LBB/LB4 - what is different?
« Reply #5 on: Apr 25th, 2014, 4:42pm »

Just found a serial com capturing tool http://www.eltima.com/products/rs232-data-logger/

I'll have a go and see what happens wink
User IP Logged

Roger
flotulopex
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 94
xx 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)?
User IP Logged

Roger
flotulopex
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 94
xx 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?
User IP Logged

Roger
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx 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.
User IP Logged

flotulopex
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 94
xx Re: Serial com in LBB/LB4 - what is different?
« Reply #9 on: Apr 26th, 2014, 12:49pm »

cry

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?
User IP Logged

Roger
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx 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.
User IP Logged

flotulopex
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 94
xx 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....
User IP Logged

Roger
Rod
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 110
xx 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?
User IP Logged

flotulopex
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 94
xx 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.
User IP Logged

Roger
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx 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.
User IP Logged

Pages: 1 2 3  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls