I have tried to work with GCB and PICs now more than week.
I have found solutions almost all my problems.
Now I know how to stop GCB going to fault when I had a problem in my code.
Just close under the error message.
Here is my code.
Using the Integer variables.
I know how to calculate the difference
Using the Integer variables
.
But I do no know how to divine single variables.
But I do no know how to divine single variables.
Here is my code.
#chip 16F886, 8
#option explicit
#config INTOSC_OSC_NOCLKOUT, BODEN_OFF 'this is important on GCB and PIC when there is no external oscillator
' Define the USART port
#define USART_BAUD_RATE 9600
#define USART_BLOCKING 'If defined, this constant will cause the USART routines to wait until data can be sent or received.
#define USART_DELAY off 'This is the delay between characters.
#define SerInPort PORTC.7
#define SerOutPort PORTC.6
'Set pin directions
Dir SerOutPort Out
Dir SerInPort In
Dim steinhart as single ' stainahart count for
include <maths.h></maths.h>
sub steinhart1
steinhart = 100.2
steinhart =steinhart/ 4000 ' count this, but this is only example 1/B * ln(R/Ro)
HSerPrint steinhart
HSerPrint 13
end sub
Do
HSerPrint "Test": HSERPRINTCRLF
steinhart1
wait 1 s
Loop
This is the results:
Test
fÈBA&ffÈBzE4ó,ÃRÿï@X® A¹€›ð§òA@XDGa¶ûÿïQ6ßÿR„ÿÿ¿13Test
fÈBA&ffÈBzE4ó,ÃRÿï@X® A¹€›ð§òA@XDGa¶ûÿïQ6ßÿR„ÿÿ¿13Test
fÈBA&ffÈBzE4ó,ÃRÿï@X® A¹€›ð§òA@XDGa¶ûÿïQ6ßÿR„ÿÿ¿13Test
So how I can divide or multiply Single?
Regards Pekka
ps. somehow the row #inlcude <maths.h> were not right. but do not care this row. </maths.h>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
At the moment GCB does not support "single" or decimal values. It does use bit, byte, word, integer, and long. Decimals are under development right now.
"HSerPrint 13" should be "HSerSend 13" because you are trying to give a CR.
HSerPrint is overload to each of the variable types. So if you feed it a string, it will print a string. If you feed it a long , it will print the long. etc. If you need a hex then use "hex(AB)" to change it to string.
Also "USART_BLOCKING" is tricky on receive because if there is no char to receive it sends back a default value. Check out the help section.
Start:
comport=1HSerReceive(InChar)'Subroutine needs the comport set'InChar = HSerReceive 'Thisfunctionwillgetfromcomport1IfInChar<>255Then' check if for received byte'return 255 if old dataHSerSendInChar'send back char to UARTEndIfGotoStart
Checkout the demos for small programs demonstrating the different features.
GL
Mike
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
How GCB works with single variables?
I have tried to work with GCB and PICs now more than week.
I have found solutions almost all my problems.
Now I know how to stop GCB going to fault when I had a problem in my code.
Just close under the error message.
Here is my code.
Using the Integer variables.
I know how to calculate the difference
Using the Integer variables
.
But I do no know how to divine single variables.
But I do no know how to divine single variables.
Here is my code.
#chip 16F886, 8
#option explicit
#config INTOSC_OSC_NOCLKOUT, BODEN_OFF 'this is important on GCB and PIC when there is no external oscillator
' Define the USART port
#define USART_BAUD_RATE 9600
#define USART_BLOCKING 'If defined, this constant will cause the USART routines to wait until data can be sent or received.
#define USART_DELAY off 'This is the delay between characters.
#define SerInPort PORTC.7
#define SerOutPort PORTC.6
'Set pin directions
Dir SerOutPort Out
Dir SerInPort In
Dim steinhart as single ' stainahart count for
include <maths.h></maths.h>
sub steinhart1
steinhart = 100.2
steinhart =steinhart/ 4000 ' count this, but this is only example 1/B * ln(R/Ro)
HSerPrint steinhart
HSerPrint 13
end sub
Do
HSerPrint "Test": HSERPRINTCRLF
steinhart1
wait 1 s
Loop
This is the results:
Test
fÈBA&ffÈBzE4ó,ÃRÿï@X® A¹€›ð§òA@XDGa¶ûÿïQ6ßÿR„ÿÿ¿13Test
fÈBA&ffÈBzE4ó,ÃRÿï@X® A¹€›ð§òA@XDGa¶ûÿïQ6ßÿR„ÿÿ¿13Test
fÈBA&ffÈBzE4ó,ÃRÿï@X® A¹€›ð§òA@XDGa¶ûÿïQ6ßÿR„ÿÿ¿13Test
So how I can divide or multiply Single?
Regards Pekka
ps. somehow the row #inlcude <maths.h> were not right. but do not care this row. </maths.h>
Please see https://sourceforge.net/p/gcbasic/discussion/596084/thread/b867317011/
Do not use floats - they are in development.
So, use integer maths with factorisation to do your maths.
:-)
Pekka,
Welcome to Great Cow Basic!
At the moment GCB does not support "single" or decimal values. It does use bit, byte, word, integer, and long. Decimals are under development right now.
"HSerPrint 13" should be "HSerSend 13" because you are trying to give a CR.
HSerPrint is overload to each of the variable types. So if you feed it a string, it will print a string. If you feed it a long , it will print the long. etc. If you need a hex then use "hex(AB)" to change it to string.
Also "USART_BLOCKING" is tricky on receive because if there is no char to receive it sends back a default value. Check out the help section.
Checkout the demos for small programs demonstrating the different features.
GL
Mike