looking for help about serial communication commands.
for the Ser1Print command the first 3 bytes are not similar to what has been sent
the Ser1Send command all the bytes are received ok.
#option explicit#chip tiny10, 8;-----Includelibrary#include<SoftSerial.h>;-----ConfigSerialUARTforsending:#define SER1_BAUD 4800 ; baudrate must be defined#define SER1_TXPORT PORTB ; I/O port (without .bit) must be defined#define SER1_TXPIN 0 ; portbit must be defined#define SER1_INVERT OnDOPAUSE50;firstdatasegmentSer1Print"ABCDEFabcdef"pause50;seconddatasegmentSer1Send65;ASer1Send66;BSer1Send67;CSer1Send68;DSer1Send69;ESer1Send70;FSer1Send97;aSer1Send98;bSer1Send99;cSer1Send100;dSer1Send101;eSer1Send102;fLOOP
These chips are very limited in terms of RAM. I am surprised you can even create a string of "ABCDEFabcdef". Try preallocating the string RAM handler. These chips have some limitations. :-)
#DEFINE SYSDEFAULTCONCATSTRING 14
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I was able to send separate string of 18 char. max with the Ser1Print,
but I had to use this instead "#DEFINE SYSDEFAULTCONCATSTRING 0" to work
the Ser1Send work only with byte var, and it's ok for commend control for the LCD (FRM010)
on the other hand the Ser1Print "xxxxxx" string is sent ok, but I think it need a delay between
each byte sent like the Ser1Send so the LCD can catch all the characters.
(I tried to get the same result as PBP3 Serout Pc: Pace var needed to work)
SerOut GPIO.1,N4800,**Pc**,[254,128,"1234567890ABCDEFGHIJ"] ; Line 1
DelayMS D1
Here's the PulseView chart I was able to get from Ser1Print
Here's a timing for "Ser1Print" at 300uS avr/ between stop-start bit
and "Ser1Send" at 1.4mS avr.
The "Ser1Send" is working fine with all 80 characters at the display
but the "Ser1Print" the first character of "ABCD" A is ok all sub-sequent are not
Listed below both listing code.
Thanks again Evan.
;**Ser1Send**;gosub/returnokEvan.#option explicit#chip tiny10, 1;-----Includelibrary#include<SoftSerial.h>;-----ConfigSerialUARTforsending:#define SER1_BAUD 4800 ; baudrate must be defined#define SER1_TXPORT PORTB ; I/O port (without .bit) must be defined#define SER1_TXPIN 0 ; portbit must be defined#define SER1_INVERT OnDimCountasbyteDimCount1asbytepause1000;BackLightOn/Offser1send255;BackLightOnpause1ser1send8;8=On,0=Offpause1DO;CountCharforcount=128to167Count1=count-80gosubmainnextforcount=192to231Count1=count-104gosubmainnextpause1000;ClearLCDser1send254pause1ser1send1pause1pause1000loopMain:ser1send254pause1Ser1Sendcountpause1Ser1SendCount1pause1return
;**Ser1Print**#option explicit#chip tiny10, 1;-----Includelibrary#include<SoftSerial.h>;-----ConfigSerialUARTforsending:#define SER1_BAUD 4800 ; baudrate must be defined#define SER1_TXPORT PORTB ; I/O port (without .bit) must be defined#define SER1_TXPIN 0 ; portbit must be defined#define SER1_INVERT OnDimCountasbyteDimCount1asbytepause1000;BackLightOn/Offser1send255;BackLightOnpause1ser1send8;8=On,0=Offpause1;ClearLCDser1send254pause1ser1send1pause1pause500DO;ClearLCDser1send254pause5ser1send1pause5pause500ser1send254pause5Ser1Send128pause5Ser1Print"ABCD";PAUSE1;Ser1Print"B";PAUSE1;Ser1Print"C";PAUSE1;Ser1Print"D"pause500loop
like this the delay between bytes is working, but some characters are not sent properly.
'Write Data
for SysPrintTemp = 1 to PrintLen
Ser1Send PrintData(SysPrintTemp)
wait Ser1PrintInterCharDelay ms
next
;Line sent
Ser1Print "ABCDEFGHIJKLMNOPQRST"
Ser1Print "12345678901234567890"
Ser1Print "abcdefghijklmnopqrst"
Ser1Print "stuvwxyz[]\<>?,./+[]"
see pic for display result.
`
; Ser1Print "ABCDEFabcdef" TEST
;
;
option explicit
chip tiny10, 1
;#DEFINE SYSDEFAULTCONCATSTRING 14
; ----- Include library
#include <softserial.h></softserial.h>
Replace the LCD with a serial terminal - still got the same issue ? If the same issue then it points to timing in the Tiny10 program. I think you need to do this test to eradicate the LCD being at fault.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
since I don't use CR,LF I did put ";" on the 'CR sub
and I can adjust the Pc = 1ms , and the Ser1PrintInterCharDelay to 1.
Thank you Evan excellent work.
My regards.
DEFINE SYSDEFAULTCONCATSTRING 0
;Ser1Print"ABCDEFabcdef"TEST;;#option explicit#chip tiny10, 1#DEFINE SYSDEFAULTCONCATSTRING 0;-----Includelibrary#include<SoftSerial.h>;-----ConfigSerialUARTforsending:#define SER1_BAUD 4800 ; baudrate must be defined#define SER1_TXPORT PORTB ; I/O port (without .bit) must be defined#define SER1_TXPIN 0 ; portbit must be defined#define SER1_INVERT OnDimPCasbytePC=1pause500ser1send254;mustclearLCDfirstpausepcser1send1pausepcpause500ser1send255pausepcser1send8;LCDBackLightOnpausepcser1send254pausepcser1send128;Line1pausepcSer1Print"ABCDEFGHIJKLMNOPQRST"pausepcser1send254pausepcser1send192;Line2pausepcSer1Print"12345678901234567890"pausepcser1send254pausepcser1send148;Line3pausepcSer1Print"abcdefghijklmnopqrst"pausepcser1send254pausepcser1send212;Line4pausepcSer1Print"stuvwxyz[]\<>?,./+[]"pausepc#DEFINE Ser1PrintInterCharDelay 1SubSer1Print(InPrintDataAsString)DimPrintLen,SysPrintTempasByte'PrintLen=LEN(PrintData$)PrintLen=PrintData(0)ifPrintLen=0thenGotoSer1PrintStrEnd'WriteDataforSysPrintTemp=1toPrintLenSer1SendPrintData(SysPrintTemp)waitSer1PrintInterCharDelaymsnext'CRSer1PrintStrEnd:;#IFDEFSerPrintCR;Ser1Send13;#ENDIF;#IFDEFSerPrintLF;Ser1Send10;#ENDIF;#IFDEFSer1PrintInterCharDelay;waitSer1PrintInterCharDelayms;#ENDIFEndSub
I had to get Notepad++, and edit the softserialch1.h
test after edit :
with #DEFINE Ser1_TXDELAY ms = 1
text get on display very slow, and some characters at the end are random.
without
; #DEFINE Ser1_TXDELAY ms = 1
display is very fast annd accurate
;#option explicit#chip tiny10, 1#DEFINE SYSDEFAULTCONCATSTRING 0;-----Includelibrary#include<SoftSerial.h>;-----ConfigSerialUARTforsending:#define SER1_BAUD 4800 ; baudrate must be defined#define SER1_TXPORT PORTB ; I/O port (without .bit) must be defined#define SER1_TXPIN 0 ; portbit must be defined#define SER1_INVERT On;#DEFINESer1_TXDELAYms=1DimPCasbytePC=1dopause500ser1send254;mustclearLCDfirstpausepcser1send1pausepcpause50ser1send255pausepcser1send8;LCDBackLightOnpausepcser1send254pausepcser1send128;Line1pausepcSer1Print"ABCDEFGHIJKLMNOPQRST"ser1send254pausepcser1send192;Line2pausepcSer1Print"12345678901234567890"ser1send254pausepcser1send148;Line3pausepcSer1Print"abcdefghijklmnopqrst"ser1send254pausepcser1send212;Line4pausepcSer1Print"stuvwxyz[]\<>?,./+[]"loop#DEFINE Ser1PrintInterCharDelay 1SubSer1Print(InPrintDataAsString)DimPrintLen,SysPrintTempasByte'PrintLen=LEN(PrintData$)PrintLen=PrintData(0)ifPrintLen=0thenGotoSer1PrintStrEnd'WriteDataforSysPrintTemp=1toPrintLenSer1SendPrintData(SysPrintTemp)waitSer1PrintInterCharDelaymsnext;'CRSer1PrintStrEnd:;;#IFDEFSerPrintCR;;Ser1Send13;;#ENDIF;;#IFDEFSerPrintLF;;Ser1Send10;;#ENDIF;;#IFDEFSer1PrintInterCharDelay;;waitSer1PrintInterCharDelayms;;#ENDIFEndSub
with : #DEFINE Ser1_TXDELAY ms = 2
it's very slow and last 3 characters of line are not right
with all wait remove except first pause 500 for the display refresh, and clear.
with : #DEFINE Ser1PrintInterCharDelay 8
the Ser1Print (String) work fine
but still I need the wait for each Ser1Send (Line/Col)
from the softserial1 file, the "String" portion is ok,
but can't find the byte Ser1Send section to add (#DEFINE Ser1PrintInterCharDelay 8)
Hello,
looking for help about serial communication commands.
for the Ser1Print command the first 3 bytes are not similar to what has been sent
the Ser1Send command all the bytes are received ok.
These chips are very limited in terms of RAM. I am surprised you can even create a string of "ABCDEFabcdef". Try preallocating the string RAM handler. These chips have some limitations. :-)
#DEFINE SYSDEFAULTCONCATSTRING 14
Hello ,
I was able to send separate string of 18 char. max with the Ser1Print,
but I had to use this instead "#DEFINE SYSDEFAULTCONCATSTRING 0" to work
the Ser1Send work only with byte var, and it's ok for commend control for the LCD (FRM010)
on the other hand the Ser1Print "xxxxxx" string is sent ok, but I think it need a delay between
each byte sent like the Ser1Send so the LCD can catch all the characters.
(I tried to get the same result as PBP3 Serout Pc: Pace var needed to work)
Here's a timing for "Ser1Print" at 300uS avr/ between stop-start bit
and "Ser1Send" at 1.4mS avr.
The "Ser1Send" is working fine with all 80 characters at the display
but the "Ser1Print" the first character of "ABCD" A is ok all sub-sequent are not
Listed below both listing code.
Thanks again Evan.
A bit confused - does "#DEFINE SYSDEFAULTCONCATSTRING 0" resolve?
as for the "#DEFINE SYSDEFAULTCONCATSTRING 0" ,
the max. string it can send is 18 characters but still the display is receiving random characters.
for the
Ser1Send: sending one byte at the time
is working well but need a pause of at least 1ms between each send.
for the
Ser1Print: sending a string ,bytes etc..
will need some kind of delay between each byte it send
( #define SER1_Delay )
Thanks Evan
I am not the expert on the Software Serial - but, try adding this to your program. This is change the Ser1Print to this new code.
I have added a constant called
Ser1PrintInterCharDelay
this can be any value. I have set to 50. Type different values. Does this work ?I tried 5,50,500,5000.
the delay work between each Ser1Print command ,
but not between each byte it's send.
You could move the test I added re the new contants to Ser1Send. look in the Ser1.h file. You will have to check that filename.
like this the delay between bytes is working, but some characters are not sent properly.
'Write Data
for SysPrintTemp = 1 to PrintLen
Ser1Send PrintData(SysPrintTemp)
wait Ser1PrintInterCharDelay ms
next
;Line sent
Ser1Print "ABCDEFGHIJKLMNOPQRST"
Ser1Print "12345678901234567890"
Ser1Print "abcdefghijklmnopqrst"
Ser1Print "stuvwxyz[]\<>?,./+[]"
see pic for display result.
`
; Ser1Print "ABCDEFabcdef" TEST
;
;
option explicit
chip tiny10, 1
;#DEFINE SYSDEFAULTCONCATSTRING 14
; ----- Include library
#include <softserial.h></softserial.h>
Dim PC as byte
PC =3
pause 500
ser1send 254 ; must clear LCD first
pause pc
ser1send 1
pause pc
pause 500
ser1send 255
pause pc
ser1send 8 ;LCD BackLight On
pause pc
ser1send 254
pause pc
ser1send 128 ;Line 1
pause pc
Ser1Print "ABCDEFGHIJKLMNOPQRST"
pause pc
ser1send 254
pause pc
ser1send 192 ;Line 2
pause pc
Ser1Print "12345678901234567890"
pause pc
ser1send 254
pause pc
ser1send 148 ;Line 3
pause pc
Ser1Print "abcdefghijklmnopqrst"
pause pc
ser1send 254
pause pc
ser1send 212 ;Line 4
pause pc
Ser1Print "stuvwxyz[]\<>?,./+[]"
pause pc
Sub Ser1Print (In PrintData As String)
Dim PrintLen, SysPrintTemp as Byte
'PrintLen = LEN(PrintData$)
PrintLen = PrintData(0)
if PrintLen = 0 then Goto Ser1PrintStrEnd
'Write Data
for SysPrintTemp = 1 to PrintLen
Ser1Send PrintData(SysPrintTemp)
wait Ser1PrintInterCharDelay ms
next
'CR
Ser1PrintStrEnd:
#IFDEF SerPrintCR
Ser1Send 13
#ENDIF
#IFDEF SerPrintLF
Ser1Send 10
#ENDIF
#IFDEF Ser1PrintInterCharDelay
wait Ser1PrintInterCharDelay ms
#ENDIF
End Sub
`
Replace the LCD with a serial terminal - still got the same issue ? If the same issue then it points to timing in the Tiny10 program. I think you need to do this test to eradicate the LCD being at fault.
Good News Evan.
with this on my code it's working.
since I don't use CR,LF I did put ";" on the 'CR sub
and I can adjust the Pc = 1ms , and the Ser1PrintInterCharDelay to 1.
Thank you Evan excellent work.
My regards.
DEFINE SYSDEFAULTCONCATSTRING 0
We should get Frank to add the optional delay to add the Ser1 commands. Then, you would remove all the delays in your source. Is the best approach?
Something as ( #define SER1_Delay ? )
easier to read
These are the Ser1 related Constants.
So, as this is specific to Ser1 then maybe SER1_TXDELAY would be best.
Do you want to make these changes?
go for it, it's make sense
this will be in the new gbasic.exe ?
Last edit: JB 2024-04-26
Do you want to edit this in softserialch1.h ?
I'll need some guidance for this if you don't mind
and how to implement in my code (syntax)
Of course,
If you edit softserialch1.h in the appropriate place(s).
Add
This will only add the wait if Ser1_TXDELAY exists. This is called conditional compilation.
You could put at the end of Sub Ser1Send (In STxDataByte) just before the END SUB
Test, removing the waits in your program and add the constant Ser1_TXDELAY.
Let me look at it first .. and I'll comeback
I had to get Notepad++, and edit the softserialch1.h
test after edit :
with #DEFINE Ser1_TXDELAY ms = 1
text get on display very slow, and some characters at the end are random.
without
; #DEFINE Ser1_TXDELAY ms = 1
display is very fast annd accurate
and the edit with notepad++
Did you remove all the pause and waits from your program? You may have to leave the pause 500. Othewise you are getting lots of waits.
And, you should remove the modified Ser1Print from you program. Again, this is no longer needed.
with : #DEFINE Ser1_TXDELAY ms = 2
it's very slow and last 3 characters of line are not right
with all wait remove except first pause 500 for the display refresh, and clear.
with : #DEFINE Ser1PrintInterCharDelay 8
the Ser1Print (String) work fine
but still I need the wait for each Ser1Send (Line/Col)
from the softserial1 file, the "String" portion is ok,
but can't find the byte Ser1Send section to add (#DEFINE Ser1PrintInterCharDelay 8)
when using
Ser1Print 254 ,
Ser1Print 128 ; Line 1
it's sent as text not byte.
otherwise I'll use this to remove the wait.
let me know if I'm on the right track.
Thank you