Liberty BASIC Community Forum
« LB 4.5.0 W10 Com not working 2 ARDUINO »

Welcome Guest. Please Login or Register.
Jun 25th, 2017, 12:16am


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1 2  Notify Send Topic Print
 poll_icon  Poll  Poll Question: will comm port to arduino work on W10
yes VotesVotesVotes 1 (100%)
No VotesImageVotes 0 (0%)
Hell No VotesImageVotes 0 (0%)
Total votes: 1  
 hotthread  Author  Topic: LB 4.5.0 W10 Com not working 2 ARDUINO  (Read 398 times)
xtal
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 20
xx LB 4.5.0 W10 Com not working 2 ARDUINO
« Thread started on: Mar 15th, 2017, 2:22pm »

LB 4.5.0 W10 GRBL 1,1F
After getting a GUI FORM built, big surprize, cannot talk to ARDUONO
Tried 2 open methods with 2 UNO's connected Com12,Com13
open port$;":115200,n,8,1,ds0,cs0,rs" for random as #com
open port$;":115200,n,8,1," for random as #com
w10 USBSerial Microsoft 10.0.14393.0 6/21/2006 com13
w10 USBSerial wch.cn 3.3.2011.1 11/4/2011 com12
Other GCode senders work with no comm issues.....
User IP Logged

Dan Teel
Guru
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1124
xx Re: LB 4.5.0 W10 Com not working 2 ARDUINO
« Reply #1 on: Mar 15th, 2017, 3:57pm »

From MSDN CreateFile's page.
Quote:
To specify a COM port number greater than 9, use the following syntax: "\\.\COM10". This syntax works for all port numbers and hardware that allows COM port numbers to be specified.

https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspx

I think this might be your issue, and if you cant address it in LB's open command you can probably use CreateFile and the like just fine.
« Last Edit: Mar 15th, 2017, 3:58pm by Dan Teel » User IP Logged

ZPtr.net
xtal
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 20
xx Re: LB 4.5.0 W10 Com not working 2 ARDUINO
« Reply #2 on: Mar 15th, 2017, 4:13pm »

Its not a problem addressing the com port ---the com12 port sometime will sometime show the GRBL welcome etc when port is opened , it also did a $H [home] command 1 time , that port uses the ch340 driver ,
its rather intermittant....the com13 port has never worked with LB

I will see If I can get a lower port # to see If any difference....
User IP Logged

xtal
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 20
xx Re: LB 4.5.0 W10 Com not working 2 ARDUINO
« Reply #3 on: Mar 15th, 2017, 4:22pm »

Changed to com7 makes no difference
« Last Edit: Mar 15th, 2017, 4:23pm by xtal » User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5312
xx Re: LB 4.5.0 W10 Com not working 2 ARDUINO
« Reply #4 on: Mar 16th, 2017, 02:28am »

If the com port talks to other software and it is only Liberty that does not talk to it then the issue is probably about the opto isolation. DTR probably needs set, but have you tried lower baud rates?


http://lbpe.wikispaces.com/AccessingSerialPort
« Last Edit: Mar 16th, 2017, 02:30am by Rod » User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5312
xx Re: LB 4.5.0 W10 Com not working 2 ARDUINO
« Reply #5 on: Mar 16th, 2017, 02:31am »

Also show us your code to see how you are formatting and sending messages, perhaps you have that wrong.
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5312
xx Re: LB 4.5.0 W10 Com not working 2 ARDUINO
« Reply #6 on: Mar 16th, 2017, 04:06am »

browse at the gbrl page. Baud rate of 115200 should be ok. I have not had problems using com11 com12. If you are receiving the welcome message then the port works.

This throws us back to your code and how it is handling the port. The correct set up code is

Code:
open port$;":115200,n,8,1,ds0,cs0,rs" for random as #com 


The ds0,cs0 and rs switches are important, the port simply wont work unless you have these set.

I read that command strings are sent with a terminating CR, it is the CR that signals the Arduino to act on the string. If you are just printing the command string to the port Liberty will be adding a CR LF pair that may be confusing the Arduino. Suppress the CR LF pair by appending ; to your print command and add your own CR character.

But more importantly show us your code, you might be stuck in a loop somewhere.
User IP Logged

xtal
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 20
xx Re: LB 4.5.0 W10 Com not working 2 ARDUINO
« Reply #7 on: Mar 16th, 2017, 1:34pm »

I think that later drivers may work,,,although other programs
Universal Gcode Sender UGSplatform work fine with the existing drivers. Attached is test code - now working with vid 1A86 after loading a new driver. I have 1 vid 1A76 now working and 3 Vid 2341's that just time out ...... yea working port 20, havn't tried Bluetooth ??? , don't know if I can work the GRBL code from the Tx/Rx pins.... The attatched code is from another post and modified
for my test purposes.

Code:
'This modified code from some other post.....
'This initially failed with microsoft usbserial driver 10.0.14393.0  vid-2341 pid 0043 dated 2006
'This initially failed with whn.cn    ch340     driver 3.3.2011.1    vid-1A86 pid 7523 dated 2011
'vid-1A86 pid-7523 works with         ch340     driver 3.4.2014.8    [ very hard to find driver]
'vid-2341 pid-0043 unable to find any driver  W10 stays with 2006 dated driver

crlf$=chr$(13)+chr$(10)
'set to correct message length
messagelength=5
'keep in mind that there may be carridge return
'and line feed characters added to the message

'open the com port
open "com20:115200,n,8,1,ds0,cs0,rs" for random as #com
'open port$;":115200,n,8,1," for random as #com
'set a repeating timed call to [read]
'if the device is sending a message every
'second, check every half second and you
'will keep in sync with the messages
timer 500, [read]
wait
 print #com, "$$";crlf$

[read]
if lof(#com) >=messagelength then
    dataRead$ = input$(#com, lof(#com))
    print dataRead$, len(dataRead$);crlf$
    'timer 500, [nx]
   ' wait
[nx]
    print " Tx ------> $$"+crlf$
    print #com, "$$";crlf$;crlf
    watchtimer=0
else
    watchtimer=watchtimer+1
    if watchtimer>30 then
        timer 0
        print "No data for 30 seconds"
        print "Closing port"
        close #com
        end
    end if
end if
wait
''' loaded new [very hard to find] ch340 driver --- this now works [com 20] keeps sending $$ 

 


Anybody know where I can get a later USBSERIAL [Usbser.sys] driver
that will install and work on W10 -64

SPOKE TOO SOON It works until you stop pgm , Resetting ARDUINo
has no effect, You have to REPLUG the port before it will work again.....

Unerversal GCode sender and UGSplatform apear to still work ok...
« Last Edit: Mar 16th, 2017, 2:11pm by xtal » User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5312
xx Re: LB 4.5.0 W10 Com not working 2 ARDUINO
« Reply #8 on: Mar 16th, 2017, 3:16pm »

Did you close the port? Early drivers probably don't use 115200 baud. Some way to go with the code.

Best to plan a simple gcode movement, it is move and respond that is recommended so your code will need to be much more sophisticated. Send a step, get the response, send the next step.

But have fun.
User IP Logged

xtal
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 20
xx Re: LB 4.5.0 W10 Com not working 2 ARDUINO
« Reply #9 on: Mar 16th, 2017, 6:53pm »

I think the fun may be short lived using LB......
maybe I give java a try....
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5312
xx Re: LB 4.5.0 W10 Com not working 2 ARDUINO
« Reply #10 on: Mar 17th, 2017, 02:18am »

To be clear, the port works and I have never had a problem driving any arduino board.

The issue is that you don't yet understand how to code a working solution in Liberty BASIC.

If you showed us what the conversation with the GRBL on the arduino should look like, character by character command, response then folks would be in a position to show working code. As it stands I don't have the time to learn GRBL messaging.

Liberty is by far the easiest software to lash up working code, so unless know java well I don't think it will help.

Perhaps the easiest solution for you is to learn how to use the tool sets that ship with and support GRBL.
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5312
xx Re: LB 4.5.0 W10 Com not working 2 ARDUINO
« Reply #11 on: Mar 17th, 2017, 03:55am »

This is a simple start, it sends the $$ message then starts reading the response. I can't test it but see how you get on.

You have to move the serial port contents into a buffer string and then parse out your messages. This is because you cannot see the CR character inside the serial buffer you can only see it once extracted to a string variable.

Code:
   'GBRL uses chr$(13) as end of line marker
    cr$=chr$(13)

    'change the com port to the port you know the arduino is connected to
    'only the latest driver will run at 115200 baud change to 9600 for older drivers

    'open the com port
    open "com20:9600,n,8,1,ds0,cs0,rs" for random as #com

    'wait till the port gets established
    timer 1000, [pause]
    wait

    [pause]
    timer 0

    [send]
    'send the status query
    'suppressing the crlf pair with an ending ;
    #com "$$";cr$;

    [read]
    'start reading the port on a timed basis
    timer 100, [getbuffer]
    wait

    [getbuffer]
    if lof(#com) >=0 then
        'add the contents of the serial buffer to dataRead$
        'dataRead$ may contain the remnants of the last read
        dataRead$ = dataRead$+input$(#com, lof(#com))
        watchtimer=0
    else
        watchtimer=watchtimer+1
        if watchtimer>300 then
            timer 0
            print "No data for 30 seconds"
            print "Closing port"
            close #com
            end
        end if
    end if

    [getmessage]
    'check if we can see a cr$
    delimitposition=instr(dataRead$,cr$,1)

    [loop]
    if delimitposition>0 then
        'get the first message
        message$=left$(dataRead$,delimitposition)
        'shorten dataRead$
        dataRead$=right$(dataRead$,len(dataRead$) - delimitposition -1)
        print message$
    end if
    'check if we can see another cr$
    'if so loop back
    delimitposition=instr(dataRead$,cr$,1)
    if delimit>0 then [loop]

    'now wait for more from the serial port
    'the previous timer statement will check it every 100ms
    wait




 
« Last Edit: Mar 17th, 2017, 05:11am by Rod » User IP Logged

xtal
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 20
xx Re: LB 4.5.0 W10 Com not working 2 ARDUINO
« Reply #12 on: Mar 17th, 2017, 08:22am »

Thx Rod -- you snip shows great promise, but the 2 com ports act diffently - com 20 reports the normal response to the open
manual close then reopen shows the response to the $$ cmd
com7 all opens show the response to the $$ cmd
and do not show the normal open response...
-by normal response -- is what I see from other GCode senders

Code:
  
COM20   ch340 driver --  1st run/open  

Normal Response when opening 
   Grbl 1.1f ['$' for help]
   [MSG:'$H'|'$X' to unlock]
port does not close after no activity - X off'ed 

--second+ run/open  
Response is from $$
$0=10
$1=25
$2=0
$3=0
$4=0
$5=0
$6=0
$10=1
$11=0.020
$12=0.002
$13=0
$20=0
$21=1
$22=1
$23=0
$24=25.000
$25=500.000
$26=250
$27=2.000
$30=12000
$31=0
$32=0
$100=157.475
$101=49.950
$102=157.475
$110=4000.000
$111=8000.000
$112=4000.000
$120=249.800
$121=249.800
$122=199.840
$130=230.000
$131=190.000
$132=50.000
ok

COM7 - microsoft driver  Replug  --1st run/open  
Response is from $$  --Missed the 1st normal response
-- same response to all opens
$0=10
$1=25
$2=0
$3=0
$4=0
$5=0
$6=0
$10=1
$11=0.020
$12=0.002
$13=0
$20=0
$21=1
$22=1
$23=0
$24=25.000
$25=500.000
$26=250
$27=2.000
$30=12000
$31=0
$32=0
$100=157.475
$101=49.950
$102=157.475
$110=4000.000
$111=8000.000
$112=4000.000
$120=249.800
$121=249.800
$122=199.840
$130=230.000
$131=190.000
$132=50.000
ok 
 
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5312
xx Re: LB 4.5.0 W10 Com not working 2 ARDUINO
« Reply #13 on: Mar 17th, 2017, 09:01am »

I am not sure why you are opening and closing the port, open it once then have an ongoing conversation and close it only when you are done.

Use the ladybug icon and use the single arrow to step through the program a line at a time, look at the contents of the variables and it will help understand what is going on.

You should not be missing any messages. The device wont send the welcome message till the port is open so it should always be the first thing you get out the buffer.

Time to debug and experiment.
User IP Logged

xtal
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 20
xx Re: LB 4.5.0 W10 Com not working 2 ARDUINO
« Reply #14 on: Mar 17th, 2017, 10:18am »

Using real term -- when opening ANY port using Arduino/GRBL,
the port responds with:

crlf ---- this does not always happen
Grbl 1.1f ['$' for help] crlf
[msg:|'$x' to unlock]crlf

I do not think Realterm is sending anything when opening, but may be wrong...may have to use another port to monitor Tx line

The reason for closing is because you snip fails to close lof(#com)>=0
so watchtimer is ignored

Now what is real interesting if I open the port using LB, wait 10 seconds lof(#com) returns 0 huh where's my GRBL msg?
never had problems like this B 4.....

Last time I used LB with com was with W7 and accessing PIC with Bluetooth then send/rcv data via ESP8266 -- had no issues

I will plug on, maybe I'll discover something interesting rolleyes
« Last Edit: Mar 17th, 2017, 11:16am by xtal » User IP Logged

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

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls