xtal
Junior Member
Posts: 61
|
Post by xtal on Apr 15, 2018 7:18:53 GMT -5
Attached zip with flowchart of timing loop FLOWCHART.jpg LB program A_GRBL_REDO1X.bas and support files & tooltip text files ToolTips controls deleted from code Default Comport = 13 else use drop down to find With Comm closed appears to have no leakage With Comm Open looks like leakage Opening Comm and doing nothing else [If an Arduino UNO with GRBL 1.1F] a "?" is sent to Arduino approx every 30 seconds A reply is returned - the reply can be different lengths Gcode Sender.zip (635.39 KB) thx
|
|
|
Post by Rod on Apr 15, 2018 10:16:48 GMT -5
Right I didn't fire up a serial link but I don't think I need to. There are three places you can run out of resources, first is graphics, second is lines of text in a text editor/textbox and third would be an ever growing string.
I am pretty sure you are simply running out of graphics memory. You have seven or so graphicboxes in play and nowhere do I see any management of the resources they are using. You should be using CLS, DISCARD or DELSEGMENT if you use FLUSH but you don't use FLUSH. Every drawing action, changing a color or plotting a point consumes memory in Liberty BASIC. Since you don't seem to need FLUSH, which fixes the screen display in place should it be covered by another window, you should be using CLS or DISCARD regularly to erase the base drawing segment that Liberty creates.
There are some tutorials over on the LBPE which would be well worth a read. Have a practice with the demos then apply to your program. But I am pretty confident a CLS or probably more appropriately a DISCARD ahead of each drawing action will solve your problem.
I am assuming that with coms open you start drawing stuff and updating the display, hence coms drives the drawing and memory use.
|
|
xtal
Junior Member
Posts: 61
|
Post by xtal on Apr 15, 2018 13:40:53 GMT -5
Thx Rod... I'll follow up the graphics stuff, after I figure out why I'm not getting GRBLin$ cleared, the length seems to be leveling off @ about 2k. I can't figure out why it appears to level off approx 1791. Unless I rcv faster than I process, but that should not level off....
How would you recommend changing the following code on my STATUS BOX display
function DisplayStatus(color$,data$,pl$,pd$) ' "14" "red" Xm$ "0" "20" 'if olddata$=data$ then [ccc] ' #main.Status, "font Courier_New ";fontsize$ ' ' #main.Status, "cls" ' clr graphics box #main.Status, "fill ";color$ ' fill yellow #main.Status, "backcolor ";color$ ' text background #main.Status, "place ";pl$;" ";pd$ ' from top left over->down #main.Status, "\";data$ ' print data ' olddata$=data$ ' #main.Status, "flush" ' ' #main.Status, "show" ' [ccc] end function '
|
|
|
Post by Rod on Apr 15, 2018 14:24:47 GMT -5
|
|
xtal
Junior Member
Posts: 61
|
Post by xtal on Apr 15, 2018 16:33:13 GMT -5
GRBLin$ was growing due to requesting status too fast, I slowed the request, and that appears to have fixed that issue. My coding can't keep up with the rcv data...
Memory usage still grows usually 31250 bytes every 27 seconds....
The error log has a lot of crap I generated so will clear it and let the pgm run to see if it captures anything...
|
|
xtal
Junior Member
Posts: 61
|
Post by xtal on Apr 18, 2018 12:54:52 GMT -5
DUH! I think I know what is happening, the lightbulb just lit. I have 2 texteditor windows which are constantly being updated, and I've made no attempt to limit their size. How do you cause a texteditor window to wrap after receiving X amount of data
|
|
|
Post by tsh73 on Apr 18, 2018 14:12:50 GMT -5
Like this?
nomainwin
WindowWidth = 416 WindowHeight = 390
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
texteditor #main.texteditor2, 14, 16, 216, 315 button #main.button3, "Start", [button3Click], UL, 270, 16, 122, 25 textbox #main.textbox4, 270, 71, 100, 25 statictext #main.statictext5, "nLines", 270, 46, 144, 20
open "Reset texteditor after 1000 lines" for window as #main print #main, "trapclose [quit.main]"
print #main, "font ms_sans_serif 10"
wait
[quit.main] Close #main END
[button3Click] while 1 scan #main.texteditor2 "Line ";i i=i+1
print #main.texteditor2, "!lines nLines" ; if nLines > 1000 then #main.texteditor2, "!cls" ; end if #main.textbox4 nLines wend wait
|
|
xtal
Junior Member
Posts: 61
|
Post by xtal on Apr 18, 2018 14:51:53 GMT -5
Thx tsh73, But that looks like it will clear all the data? I'll try it to see what happens....
I want to keep scrolling, when the 1000 line arrives add it and remove line 1 [ie] drop old add new, I had assumed that there was a LB limit that would automatically do this, but don't think so.
This might work for me thx.....
Unfortunately it clears all previous data......
|
|
|
Post by Rod on Apr 19, 2018 2:25:57 GMT -5
Hold the data in a log file. Every thirty lines throw the data into the log and cls. Add controls to allow the user to page back through the log.
|
|
xtal
Junior Member
Posts: 61
|
Post by xtal on Apr 21, 2018 7:04:42 GMT -5
I have pretty much got the mem growth under better control using the cls and the following also helped
function DisplayStatus(color$,data$,pl$,pd$) ' "14" "red" Xm$ "0" "20"
'clr graphics box #main.Status, "discard ; fill ";color$ ' fill yellow #main.Status, "backcolor ";color$ ' text background #main.Status, "place ";pl$;" ";pd$ ' from top left over->down #main.Status, "\";data$ ' print data [ccc] end function
Now I want to check this graphic box data ... How do I get the data from this box, nothing stands out to me in the CHM file.
|
|
|
Post by tsh73 on Apr 21, 2018 7:49:35 GMT -5
getbmp then bmpsave
|
|
|
Post by Rod on Apr 21, 2018 8:44:22 GMT -5
If you mean the data you printed as data$ then you need to remember data$, the graphicbox is a display control, though it can read mouse and keyboard. So you need to remember what is on display and check that.
Also be sure you have discard and cls in operation for all graphicbox drawing code blocks.
|
|
xtal
Junior Member
Posts: 61
|
Post by xtal on Apr 21, 2018 10:39:04 GMT -5
Yes I want to verify Data$. I've had a couple of occurances where this text has disappeared, so I want to check if valid data is in the box. IDLE, ALARM, so on & so forth ... so if I can't retrieve it, I guess I'll have save a copy in a var, probably will be easier any way.. Thx....
|
|
|
Post by Rod on Apr 21, 2018 10:42:21 GMT -5
The text is disappearing because you don’t use flush. But don’t start using flush unless you also read and understand how to use delsegment.
|
|
xtal
Junior Member
Posts: 61
|
Post by xtal on Apr 23, 2018 19:15:29 GMT -5
looks like I would "flush SegmentName" then "delsegment SegmentName" I assume segment name can be any var name ? So where in this code would I place these... How can you get the ID if you don't use segmentName... When would you use discard ? function DisplayStatus(color$,data$,pl$,pd$) ' "14" "red" Xm$ "0" "20"
'clr graphics box #main.Status, "discard ; fill ";color$ ' fill yellow #main.Status, "backcolor ";color$ ' text background #main.Status, "place ";pl$;" ";pd$ ' from top left over->down #main.Status, "\";data$ ' print data end function
This seems to work --- do I need the discard #main.Status, "segment segIDa"
#main.Status, "font arial ";fontsize$ '
#main.Status, "cls;discard ; fill ";color$ ' fill yellow
#main.Status, "backcolor ";color$ ' text background
#main.Status, "place ";pl$;" ";pd$ ' from top left over->down
#main.Status, "\";data$ ' print data
#main.Status, "flush" ' retain info if minimized
#main.Status, "delsegment segIDa" ' reclaim old seg memory
|
|