This is probably going to sound like a lame question but why doesn't GCB include a Debug window or a variables window like Picaxe does? Maybe I just can't find it but it would be nice to be able to write and display a variable's value like in VB6.
It's because unlike PICAXE or Arduino, GCB doesn't have one hardware platform to communicate with, it works with multiple devices. PICAXE all use the same programming/communication cable and Arduino uses the bootloader and IDE.
Though you can easily create this kind of feature, for example on the CHIPINO, I like to use the PICkit 2 programmer then I can send data back through the programming pins RB6, RB7 to the built in terminal application of the PICkit 2 GUI. Then I can just use a SerPrint command as shown in this example. The data is display in the Terminal Window and I can even save it to import into Excel.
This should work with the PICkit 3 GUI app I just haven't tested it.
Note: This is another example that isn't in the CHIPINO folder of GCB demos so I'll send this to Anobium.
'This program reads the potentiometer on AN0 and
'sends the value to the PICkit 2 UART Terminal
'through RB6 and RB7 programming pins.
'Chip Settings
#chip 16F886,16
'Serial settings
#define SerInPort PORTB.6
#define SerOutPort PORTB.7
#define SendAHigh Set SerOutPort off
#define SendALow Set SerOutPort on
#define RecAHigh SerInPort off
#define RecALow SerInPort on
'Set pin directions
Dir SerOutPort Out
Dir SerInPort In
InitSer 1, r9600, 1+WaitForStart, 8, 1, none, invert
Start:
'SerPrint 1, "GCBASIC RS232 Test"
SerPrint 1, "AN0 Reading: "
SerPrint 1, ReadAD(AN0)
SerSend 1, 13
SerSend 1, 10
goto Start
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
CH> “This should work with the PICkit 3 GUI app I just haven't tested it.”
It never made it to the PICKit3 GUI app unfortunately. The UART tool is grayed out permanently.
The Logic tool did made it though, so I use both the PICKit3 to display the Waveform and the PICKit2 to show the Terminal screen when debugging.
I still advise anyone and everyone, to grab a PICKit2 whilst you still can, it is a great tool even if you don’t need it as a programmer.
The Xpress board is the best bang for the buck for entry level debugging. It has Serial to USB built in along with the programer, a Push Button, 4 LED’s a POT and a MikroBus header for expansion / prototyping.
Remember that with GCBasic you can create and test your code on virtually any supported device and once it is working you recompile to the target device. So you can use a board like the Xpress for 90% of your development and only the last 10% needs to be done on the actual target board. That is the true power behind portable code like Great Cow BASIC.
Cheers
Chris
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks Chris, I was originally aware of that about the PICkit 3 and completely forgot it until you mentioned it. I knew there was a reason I preferred the PICkit 2. You can get great clones of PICkit 2 on eBay. I bought one from China for $8.39 plus $1.85 shipping. It works great. http://ebay.to/2p1DfzA
Great point on the developing with another device!
That is so true. I often use my CHIPINO with 28 pin PIC16F886 and Arduino style shields to develop and then program a smaller PIC later on. GCB does that really well.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I generally debug caveman style. I have written a few routines that print out the contents (in binary or hex format) of selected registers to either a terminal or to an LCD display. So far thats all I have needed, even for some rather tricky programs.
TerraTerm is a very nice terminal app that makes a good debug screen. It supports VT100/VT300/XTERM ANSI Esc Codes and has scripting. With scripting the terminal app can draw the main screen, then all the microcontroller has to do is fill in the blanks with register / Variable data..
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I generally use the serial LCD redirector GCB@Syn\GreatCowBasic\Demos\Serial Communications Solutions\Hardare Serial LCD Redirector Solutions
This provides LCD commands to the Serial terminal like Putty(included in the distriution) and TerraTerm.
I recently posted the I2C test screen that I have. This is all completed with the LCD Redirector code where CLS will clear the terminal and Locate 10,10 will put the cursor at position 10,10. You have a very big LCD screen. :-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks to all who responded. The replies have confirmed that I really do need to divorce my VB and Picaxe train of thought when dealing with GCB. I guess my bigest stumbling block was thinking of GCB as a simulator as well as a code editor. It obviously is not. That said I usually simulate my GCB code in Real Pic Simulator or Tina Spice prior breadboarding the circuit or loading Hex into the chip. Thanks to the replies I now see that I can set up RPS with a terminal or LCD to debug my variables. Regardless whether or not my problem below will be resolved using the info posted I did learn something useful, if not imperative.
Please take a peek at this code. I'm obviously doing something wrong but exactly what escapes me. I wrote this simple code to demonstrate GCB to a buddy of mine. I'm trying to migrate him from Picaxe too. When I wrote it I was surprised that it didn't step through the ports as I expected it would. For some reason it fails to pass the current value of "i" to "PortB.i". In my first version I placed the "Dir" port directive within the loop. When it didn't work I remmed it and hard coded all 8 of them prior to the loop. Still nada.
Thank you all,
Chris
#Chip 16F84A, .250 #config osc = RC
Dir PortB.0 Out Dir PortB.1 Out Dir PortB.2 Out Dir PortB.3 Out Dir PortB.4 Out Dir PortB.5 Out Dir PortB.6 Out Dir PortB.7 Out
#Option Explicit Dim i As Integer
For i = 0 To 7 ' Dir PortB.i Out Set PortB.i On Wait 500 ms Set PortB.i Off Wait 500 ms If i = 7 Then i = 0 Next i
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There are far better methods than this... I will let others provide better methods. This is using your approach.
#DefineMyPORTportbDoForeverForii=0To7' Dir PortB.i Out MyPORT = (MyPORT OR FnLSL( 1, ii )) Wait 500 ms MyPORT = (MyPORT AND NOT FnLSL( 1, ii )) Wait 500 ms Next iiLoop
You ask.. why cannot I do what you tried? This is lifted from the Help.
You can use this method to set a bit of a port. Encapsulate it in the SetWith method, this also eliminates any glitches during the update, use this method.
SetWith(MyPORT, MyPORT OR FnLSL( 1, BitNum))
To clear a bit of a port, use this method.
MyPORT = MyPORT AND NOT FnLSL( 1, BitNum))
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Evan, thanks for the explantion. I just skimmed over the Rotate function and will read it thuroughly after I get my honey do list finished today. I'll also run your code examples.
GCB is great and so are the contributors!
Chris
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Rules for the game.
1. You can only change the code after '#Define MyPORT portb'
2. Your code must start '#Define MyPORT portb'
3. Must be portB
4. You can use Great Cow BASIC or ASM
5. You MUST have the Wait 500 ms!
:-)
Last edit: Anobium 2017-04-26
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
To mearly say I'm impressed would not do justice to GCB and especially Evan and Chris R. I ran every single code snippet you guys posted. All of them ran perfectly!!!!
My first attempt to migrate from Picaxe found me stumbling through the pretty but bloated IDE of Microbasica. I never made much headway in that proramming environment. It was meant to be though. After all,... if I had been comfortable with it I wouldn't have looked further and found GCB.
I love you guys and GCB! It and the GCB team truly are a rare gem that keeps getting even better!
THANK YOU!!!
Chris
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Chris, I think your psychic! I was just about to post a question asking how to do just that! Not that I'd want to change it but only to gain a more thorough understanding.
Thank you so much!
Chris S.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Quote: Chris Roper
What I am doing there is setting PortB.7 ON.
b'10000000' is Binary
it could have been 0x80 which is Hex
or it could have been 128 which is decimal.
I thought I understood this but I now realize that don't understand how 128 translates to PortB.7 ON. I feel like an idiot.
Chris S.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You are no Idiot, Binary Arithmetic can be confusing.
The decimal value 128 is the equivalent of the hex value 80 which is the binary value 10000000.
Because Microcontrollers can only work in binary they see all three of the above as 10000000.
PortB is an 8 bit port with the bits numbered from 0 to 7. Bit 0 represents the Least significant bit, or the right hand side of our binary number, and bit 7 is the most significant, or left hand side of our binary number.
So if you write PortB = b'10000000' it is exactly the same result as saying SET PortB.7 ON, and writing PortB = 128 has the same effect.
This is probably going to sound like a lame question but why doesn't GCB include a Debug window or a variables window like Picaxe does? Maybe I just can't find it but it would be nice to be able to write and display a variable's value like in VB6.
Thanks,
Chris
Last edit: Anobium 2017-04-26
It's because unlike PICAXE or Arduino, GCB doesn't have one hardware platform to communicate with, it works with multiple devices. PICAXE all use the same programming/communication cable and Arduino uses the bootloader and IDE.
Though you can easily create this kind of feature, for example on the CHIPINO, I like to use the PICkit 2 programmer then I can send data back through the programming pins RB6, RB7 to the built in terminal application of the PICkit 2 GUI. Then I can just use a SerPrint command as shown in this example. The data is display in the Terminal Window and I can even save it to import into Excel.
This should work with the PICkit 3 GUI app I just haven't tested it.
Note: This is another example that isn't in the CHIPINO folder of GCB demos so I'll send this to Anobium.
CH> “This should work with the PICkit 3 GUI app I just haven't tested it.”
It never made it to the PICKit3 GUI app unfortunately. The UART tool is grayed out permanently.
The Logic tool did made it though, so I use both the PICKit3 to display the Waveform and the PICKit2 to show the Terminal screen when debugging.
I still advise anyone and everyone, to grab a PICKit2 whilst you still can, it is a great tool even if you don’t need it as a programmer.
The Xpress board is the best bang for the buck for entry level debugging. It has Serial to USB built in along with the programer, a Push Button, 4 LED’s a POT and a MikroBus header for expansion / prototyping.
Remember that with GCBasic you can create and test your code on virtually any supported device and once it is working you recompile to the target device. So you can use a board like the Xpress for 90% of your development and only the last 10% needs to be done on the actual target board. That is the true power behind portable code like Great Cow BASIC.
Cheers
Chris
Thanks Chris, I was originally aware of that about the PICkit 3 and completely forgot it until you mentioned it. I knew there was a reason I preferred the PICkit 2. You can get great clones of PICkit 2 on eBay. I bought one from China for $8.39 plus $1.85 shipping. It works great. http://ebay.to/2p1DfzA
Great point on the developing with another device!
That is so true. I often use my CHIPINO with 28 pin PIC16F886 and Arduino style shields to develop and then program a smaller PIC later on. GCB does that really well.
When we get a moment. I have built a version of PK3 GUI with serial enabled. Needs testing and regression testing. May work... may not.
I can share.
Please Do ..
I have been waiting for that for years :)
I generally debug caveman style. I have written a few routines that print out the contents (in binary or hex format) of selected registers to either a terminal or to an LCD display. So far thats all I have needed, even for some rather tricky programs.
TerraTerm is a very nice terminal app that makes a good debug screen. It supports VT100/VT300/XTERM ANSI Esc Codes and has scripting. With scripting the terminal app can draw the main screen, then all the microcontroller has to do is fill in the blanks with register / Variable data..
I generally use the serial LCD redirector GCB@Syn\GreatCowBasic\Demos\Serial Communications Solutions\Hardare Serial LCD Redirector Solutions
This provides LCD commands to the Serial terminal like Putty(included in the distriution) and TerraTerm.
I recently posted the I2C test screen that I have. This is all completed with the LCD Redirector code where CLS will clear the terminal and Locate 10,10 will put the cursor at position 10,10. You have a very big LCD screen. :-)
Thanks to all who responded. The replies have confirmed that I really do need to divorce my VB and Picaxe train of thought when dealing with GCB. I guess my bigest stumbling block was thinking of GCB as a simulator as well as a code editor. It obviously is not. That said I usually simulate my GCB code in Real Pic Simulator or Tina Spice prior breadboarding the circuit or loading Hex into the chip. Thanks to the replies I now see that I can set up RPS with a terminal or LCD to debug my variables. Regardless whether or not my problem below will be resolved using the info posted I did learn something useful, if not imperative.
Please take a peek at this code. I'm obviously doing something wrong but exactly what escapes me. I wrote this simple code to demonstrate GCB to a buddy of mine. I'm trying to migrate him from Picaxe too. When I wrote it I was surprised that it didn't step through the ports as I expected it would. For some reason it fails to pass the current value of "i" to "PortB.i". In my first version I placed the "Dir" port directive within the loop. When it didn't work I remmed it and hard coded all 8 of them prior to the loop. Still nada.
Thank you all,
Chris
#Chip 16F84A, .250
#config osc = RC
Dir PortB.0 Out
Dir PortB.1 Out
Dir PortB.2 Out
Dir PortB.3 Out
Dir PortB.4 Out
Dir PortB.5 Out
Dir PortB.6 Out
Dir PortB.7 Out
#Option Explicit
Dim i As Integer
For i = 0 To 7
' Dir PortB.i Out
Set PortB.i On
Wait 500 ms
Set PortB.i Off
Wait 500 ms
If i = 7 Then i = 0
Next i
There are far better methods than this... I will let others provide better methods. This is using your approach.
You ask.. why cannot I do what you tried? This is lifted from the Help.
I could not resist. :-)
A method... I sure others can make this smaller!
and, again
Last edit: Anobium 2017-04-26
Evan, what is "c" posted in your last code example? It doesn't appear to be defined.
Thanks,
Chris
Great question. The Carry bit of the Status register (STATUS.C) is called C.
STATUS.C acts as a ninth bit of the variable that is being rotated.
Always use set c on|off as this is supported across Microchip and AVR.
For more information please look at the Help for Rotate.
Evan, thanks for the explantion. I just skimmed over the Rotate function and will read it thuroughly after I get my honey do list finished today. I'll also run your code examples.
GCB is great and so are the contributors!
Chris
Another one!
My last go.
Rules for the game.
1. You can only change the code after '#Define MyPORT portb'
2. Your code must start '#Define MyPORT portb'
3. Must be portB
4. You can use Great Cow BASIC or ASM
5. You MUST have the Wait 500 ms!
:-)
Last edit: Anobium 2017-04-26
Ok i'll bite:
~~~
.#chip 16f84A
'Set initial state of port (bit 7 on)
PORTB = b'10000000'
Program Memory: 33/1024 words (3.22%) RAM: 0/68 bytes (0.%) Chip: 16F84A
Cheers
Chris
p.s.
As an example of how well optomised GCBasic is I replaced the line:
rotate PORTB left
With the assembler language version:
rlf PORTB,1
It still used 33 words of flash but is no longer portable between PIC Family members or AVR.
Last edit: Chris Roper 2017-04-26
To mearly say I'm impressed would not do justice to GCB and especially Evan and Chris R. I ran every single code snippet you guys posted. All of them ran perfectly!!!!
My first attempt to migrate from Picaxe found me stumbling through the pretty but bloated IDE of Microbasica. I never made much headway in that proramming environment. It was meant to be though. After all,... if I had been comfortable with it I wouldn't have looked further and found GCB.
I love you guys and GCB! It and the GCB team truly are a rare gem that keeps getting even better!
THANK YOU!!!
Chris
OK, I've read and re-read the "Rotate" description in the help files but it's given me no clue as to this line of code Chris R posted.
Chris' comment indicates that b = 10000000 but I'm clueless why? Sorry for being so dense.
Thanks,
Chris
DUH! Never mind. I didn't realize that '10000000' is not a comment!
Chris
What I am doing there is setting PortB.7 ON.
b'10000000' is Binary
it could have been 0x80 which is Hex
or it could have been 128 which is decimal
so PortB = 128 is the same thing just harder to visualise.
I do that becouse on the first rotate it will move into the C flag so I can save a byyte of code by leaving the Set C ON line out of my version.
Hope that helps
Cheers
Chris
Chris, I think your psychic! I was just about to post a question asking how to do just that! Not that I'd want to change it but only to gain a more thorough understanding.
Thank you so much!
Chris S.
I thought I understood this but I now realize that don't understand how 128 translates to PortB.7 ON. I feel like an idiot.
Chris S.
You are no Idiot, Binary Arithmetic can be confusing.
The decimal value 128 is the equivalent of the hex value 80 which is the binary value 10000000.
Because Microcontrollers can only work in binary they see all three of the above as 10000000.
PortB is an 8 bit port with the bits numbered from 0 to 7. Bit 0 represents the Least significant bit, or the right hand side of our binary number, and bit 7 is the most significant, or left hand side of our binary number.
So if you write PortB = b'10000000' it is exactly the same result as saying SET PortB.7 ON, and writing PortB = 128 has the same effect.
Cheers
Chris
for futher reading:
http://www.electronics-tutorials.ws/binary/bin_2.html
Last edit: Chris Roper 2017-04-28