Mike,
I was corrected an sub syntax error, I made some changes , so the first 2 parameters decoded ok,but the third (LCDString(4)) not.... for now I can't find a way to select a graphic and connect that with the third parameter of GLCDBMPLoad ....another problem is that for now I haven't a PLC to send commands with correct timing....so, cls and delays at code wiil be corrected later....now I'll try to decoding third parameter ....
Here is what I got. I don't have a graphics display but all but the chardisplays was working on my LCD.
I am assuming you are sending ascii chars for the numbers to locate and select the graphic.
Let me know if it works?
So is $7f going to be the command for a select icon
and
Some other number command could seelct drawing a flashing alarm
and
s ome other number plot the following numbers?
Certainly on some of these converting to ascii to send would be a burden. Consider reading the holding registers directly which saves overhead on both ends.
Mike,
thank you very much for your help....the code works well for text and graphic...a detail only must corrected....when I send the text chars all that displayed to glcd , after that I send chars for 3 parameters of graphic , to set the bmp on glcd screen....so, the text is covered from the new chars..I would like to retain the first chars (text) on glcd , with graphic , that is to have graphic and text on screen permanently until next command , not the chars that corresponding to the parameters...
Basil
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
sub BasilsGLCDParser
BuildString
GLCDCLS
CLS
Locate 4, 22
print LCDstring
If LCDstring(1) = 0x7F Then
Select Case LCDstring(4)
Case 0x31
GLCDBMPLoad( LCDstring(2)-48,LCDstring(3)-48,GCB)
Case 0x32
GLCDBMPLoad( LCDstring(2)-48,LCDstring(3)-48,Anobium)
End Select
end if
end sub
You are doing 4 things in this sub. Can you name them?
1) BuildString - convert Holding registers to string
2) Clear the graphics screen
3) print the string you just made to the GLCD
4) If there is a graphic BMP cmd then display it
So you don't want to Clear the screen every time. When do you want to clear the screen? Do you want to clear it only when you display a bmp?
If LCDstring(1) = 0x7F Then
GLCDCLS
CLS
Select Case LCDstring(4)
Case 0x31
GLCDBMPLoad( LCDstring(2)-48,LCDstring(3)-48,GCB)
Case 0x32
GLCDBMPLoad( LCDstring(2)-48,LCDstring(3)-48,Anobium)
End Select
Do you want to make a subordinate command to clear the screen?
If LCDstring(1) = 0x7F Then
Select Case LCDstring(4)
Case 0x31
GLCDBMPLoad( LCDstring(2)-48,LCDstring(3)-48,GCB)
Case 0x32
GLCDBMPLoad( LCDstring(2)-48,LCDstring(3)-48,Anobium)
End Select
ElseIf LCDstring(1) = 0x12 Then
GLCDCLS
CLS
Else
Locate 4, 22
print LCDstring
end if
Printing text could also be a subordinate command. Or it could be the default command.
Like shown above after the Else.
It all depends how you want to do it. but here lies the pieces. put them together as you want.
Remember to remove what you don't want and remeber to rename the file.
The IF -elseIf -else could be another select case statement with all you subordinate commands.
BR
mike
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So first you need to choose an osc and a speed.
your choices are "OSC=LP,XT,HS,RC,EC,ECIO,HSPLL,RCIO".
So internal "int" osc is not a choice.
look in the PIC18FXX8 data sheet for explanations.
look in the 18F458.dat file for GCB possible parameters..
The other config parameters in the code above don't exist for the 18f458
Once the osc is in place the baud rate should be generated ok.
The only other concern is the timer2 prescaler which roughly depends on the osc chosen. Timer2 is being used to detect the end of the transmitted frame. There is no end of frame character in RTU.
br
Mike
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The design intent of Great Cow BASIC is to handle the config automatically. So, I dont use OSC as I assume this is handled automatically. Many other config items may need to added but the intent for all oscillator be set for you.
Yes... I know this does not always work as expected to set the frequency, but, if we know what does not work we can resolved in the next release(s). :-)
So, this code should work... with my silly typos removed, to set the frequency to 64mhz
with the associated INITSys, also in the ASM - this should set to 64mhz
;OSCCON1 = 0x60 ' NOSC HFINTOSC; NDIV 1 - Common as this simply sets the HFINTOSC
movlw 96
banksel OSCCON1
movwf OSCCON1,BANKED
and
;OSCFRQ = 0b00001000 '64mhz
movlw 8
movwf OSCFRQ,BANKED
If this example is intended to set to 64mhz. I inspected a real microcontroller using this test code and measured the frequency,.
#chip 18F47K42 ,64
#option explicit
#config EXTMCLR
dir porta.3 out
do
porta.3 = !porta.3
loop
This test generates a square wave of 891khz with the code above, and a second test, the same frequency was generated with Osc = HFINTOSC_64MHZ added. So, this shows the OSCFRQ the key setting not the config (in the case of Great Cow BASIC automatically set the frequency). Config RSTOSC set the Power-up Default Value for COSC bits... the default.... so, we are not overly concerned as we want to automatically set in INITSYS.
All that said. There will 1000's upon 1000's of cases where you will want to set the config, and set your own frequency setup. This a valid use case.
Our design intent is to make the internal oscillatorwork automatically.
So, hopes this helps.
And, excuse my typo in that last post.
Last edit: Anobium 2019-03-07
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Mike,
some questions about printing text and image(s) on GLCD .
1. how can we display text and image in the same frame without affecting text?...I noted that the first four chars of text is for image coordinates and select , so covers the original text....
2. how can we display a new text at the next row (s), in the same frame ? also with a new image beside to text....
3. how many chars can we display in one row ,and with every new frame ? how we can change that number in the code ?
4. what software in your opinion can I use to convert images to .bmp , or make a custom image and insert in the code ? how can I handle and insert .h files to the code , and what is the best method to add new images to code ?
below is the code that works generally fine...
thanks.
"1. how can we display text and image in the same frame without affecting text?..."
You need to separate the Text and Picture commands and save them to memory. One way is to send them to different Holding Registers and then rewrite the screen (gcls, draw picture,draw text) using data from those separate HR's.
Another way is to make a "text" command ( remember you have a graphics command $7F) . It would have : text command, screen coordinates and the text . Then when received put them in storage where you can find them. Then when you redraw the screen you would gather them from the storage.
Questions 2, 3 ,4 I don' know the answers. i don't have the graphics display.
Organize your thoughts! it has been 2 months. Write down what you are trying to do , step by step. Like:
PLC sends command to display different picture
My Program saves the command in HR 10 - 17
PLC sends text
My Program saves the text is HR 1-8
My program sees that there is new data
My Program Clears graphics screen
My program Writes picture pointed to by HR 10-17
My program writes text from HR 1-8
My program waits for next exchange
Grass is growing and garden calls so i have much less time for programming now.
I will answer specific questions but not do your programming .
BR
Mike
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Mike,
I would like to thank you for your answer ....about programming never ask you to make a code for me....just some instructions, or your opinion only if you know of course....I prefer to do something of my own...it's better if you want to learn I think...so, about to add a new image as a table in the code, I ask your opinion for the way only, or If you know a software that convert a .bmp file to hex arrays...a tool like BMP-LCD (from hobbytronics.co.uk), do the job, but the output is hex arrays in horizontal rows, not in vertical one by one as it needs to make a table for the GCGB code....my question is, if there is a tool to make the conversion in that form....must be, because there are 2 tables in the code ...anyway thanks for any info...
best regards
Basil
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Mike,
I was corrected an sub syntax error, I made some changes , so the first 2 parameters decoded ok,but the third (LCDString(4)) not.... for now I can't find a way to select a graphic and connect that with the third parameter of GLCDBMPLoad ....another problem is that for now I haven't a PLC to send commands with correct timing....so, cls and delays at code wiil be corrected later....now I'll try to decoding third parameter ....
Last edit: BASIL HATZILAIOS 2019-02-27
Here is what I got. I don't have a graphics display but all but the chardisplays was working on my LCD.
I am assuming you are sending ascii chars for the numbers to locate and select the graphic.
Let me know if it works?
So is $7f going to be the command for a select icon
and
Some other number command could seelct drawing a flashing alarm
and
s ome other number plot the following numbers?
Certainly on some of these converting to ascii to send would be a burden. Consider reading the holding registers directly which saves overhead on both ends.
Br
Mike
Mike,
thank you very much for your help....the code works well for text and graphic...a detail only must corrected....when I send the text chars all that displayed to glcd , after that I send chars for 3 parameters of graphic , to set the bmp on glcd screen....so, the text is covered from the new chars..I would like to retain the first chars (text) on glcd , with graphic , that is to have graphic and text on screen permanently until next command , not the chars that corresponding to the parameters...
Basil
Basil,
Here is Your sub:
You are doing 4 things in this sub. Can you name them?
1) BuildString - convert Holding registers to string
2) Clear the graphics screen
3) print the string you just made to the GLCD
4) If there is a graphic BMP cmd then display it
So you don't want to Clear the screen every time. When do you want to clear the screen? Do you want to clear it only when you display a bmp?
Do you want to make a subordinate command to clear the screen?
Printing text could also be a subordinate command. Or it could be the default command.
Like shown above after the Else.
It all depends how you want to do it. but here lies the pieces. put them together as you want.
Remember to remove what you don't want and remeber to rename the file.
The IF -elseIf -else could be another select case statement with all you subordinate commands.
BR
mike
Mike,
can I use PIC18F458 instead of PIC16F1939 , and what are the changes at configuration ?
Basil
Basil,
I am no expert on the configuration of micros but my thoughts follow. Maybe someone else could jump in and help?
So first you need to choose an osc and a speed.
your choices are "OSC=LP,XT,HS,RC,EC,ECIO,HSPLL,RCIO".
So internal "int" osc is not a choice.
look in the PIC18FXX8 data sheet for explanations.
look in the 18F458.dat file for GCB possible parameters..
The other config parameters in the code above don't exist for the 18f458
Once the osc is in place the baud rate should be generated ok.
The only other concern is the timer2 prescaler which roughly depends on the osc chosen. Timer2 is being used to detect the end of the transmitted frame. There is no end of frame character in RTU.
br
Mike
A total no re the 18F458. This is not to be used for new projects. Not recommended.
I remembering asking when you started this asking why the 16f1939?
So, I should ask 'what are needs ?' but I will recommnend the PIC18F47K42 - this is best I can recommend. And, then all you will need to do is....
I cannot think that you will have any porting issue.
Last edit: Anobium 2019-03-06
Thanks Mike and Anobium ....I agree for PIC18F47K42. I'll test it...
Basil
Anobium,
Are we missing something in your bit of code?
Should it be?
From the 18F47K42 dat file
This is new to me.
Should MCLRE_ON be MCLRE = INTMCLR ?
Thanks for helping Anobium
BR
Mike
Last edit: mmotte 2019-03-06
The design intent of Great Cow BASIC is to handle the config automatically. So, I dont use OSC as I assume this is handled automatically. Many other config items may need to added but the intent for all oscillator be set for you.
Yes... I know this does not always work as expected to set the frequency, but, if we know what does not work we can resolved in the next release(s). :-)
So, this code should work... with my silly typos removed, to set the frequency to 64mhz
If we look at the generated asm we can see the automatic insertion for config.
with the associated INITSys, also in the ASM - this should set to 64mhz
If this example is intended to set to 64mhz. I inspected a real microcontroller using this test code and measured the frequency,.
This test generates a square wave of 891khz with the code above, and a second test, the same frequency was generated with Osc = HFINTOSC_64MHZ added. So, this shows the OSCFRQ the key setting not the config (in the case of Great Cow BASIC automatically set the frequency). Config RSTOSC set the Power-up Default Value for COSC bits... the default.... so, we are not overly concerned as we want to automatically set in INITSYS.
All that said. There will 1000's upon 1000's of cases where you will want to set the config, and set your own frequency setup. This a valid use case.
Our design intent is to make the internal oscillatorwork automatically.
So, hopes this helps.
And, excuse my typo in that last post.
Last edit: Anobium 2019-03-07
Mike,
some questions about printing text and image(s) on GLCD .
1. how can we display text and image in the same frame without affecting text?...I noted that the first four chars of text is for image coordinates and select , so covers the original text....
2. how can we display a new text at the next row (s), in the same frame ? also with a new image beside to text....
3. how many chars can we display in one row ,and with every new frame ? how we can change that number in the code ?
4. what software in your opinion can I use to convert images to .bmp , or make a custom image and insert in the code ? how can I handle and insert .h files to the code , and what is the best method to add new images to code ?
below is the code that works generally fine...
thanks.
Basil,
Please reread previous posts but specifically - mmotte - 2019-02-28.
"1. how can we display text and image in the same frame without affecting text?..."
You need to separate the Text and Picture commands and save them to memory. One way is to send them to different Holding Registers and then rewrite the screen (gcls, draw picture,draw text) using data from those separate HR's.
Another way is to make a "text" command ( remember you have a graphics command $7F) . It would have : text command, screen coordinates and the text . Then when received put them in storage where you can find them. Then when you redraw the screen you would gather them from the storage.
Questions 2, 3 ,4 I don' know the answers. i don't have the graphics display.
Organize your thoughts! it has been 2 months. Write down what you are trying to do , step by step. Like:
PLC sends command to display different picture
My Program saves the command in HR 10 - 17
PLC sends text
My Program saves the text is HR 1-8
My program sees that there is new data
My Program Clears graphics screen
My program Writes picture pointed to by HR 10-17
My program writes text from HR 1-8
My program waits for next exchange
Grass is growing and garden calls so i have much less time for programming now.
I will answer specific questions but not do your programming .
BR
Mike
Mike,
I would like to thank you for your answer ....about programming never ask you to make a code for me....just some instructions, or your opinion only if you know of course....I prefer to do something of my own...it's better if you want to learn I think...so, about to add a new image as a table in the code, I ask your opinion for the way only, or If you know a software that convert a .bmp file to hex arrays...a tool like BMP-LCD (from hobbytronics.co.uk), do the job, but the output is hex arrays in horizontal rows, not in vertical one by one as it needs to make a table for the GCGB code....my question is, if there is a tool to make the conversion in that form....must be, because there are 2 tables in the code ...anyway thanks for any info...
best regards
Basil