I just purchased my first pic programmer and my first pic. I've already had success programming it using an online project that included a ready made .hex file as seen here; http://picprojects.org.uk/projects/ledchaser/
I've decided to start learning to program using BASIC. I've installed both "Great Cow Graphical Basic" as well as the Great Cow IDE that comes in the GCB@Syn zip file. I kind of like the latter better as it involves typing things out in text and I found GCGB a little bit confusing with the icons.
I consider myself very experienced in electronics. Up until now however I've almost exclusively worked with analog electronics. I can put together power supplies and short wave radios almost from memory but I have pretty much no experience with microcontrollers. I am somewhat familiar with BASIC as I had fun with it for a short while on a vintage computer. After that however I haven't practiced it again and all I have left is a general idea of how it works.
Here are a couple of the road blocks I am so far experiencing.
The only programmer I was able to get my hands on in my city does not seem to be compatble with GCB. Getting another is somewhat impractical for me due to shipping costs and currency exchange, not to mention living on a student budget. My programmer works very well but it doesn't seem to be a very popular one. Here is what I have http://www.steren.com.mx/catalogo/prod.asp?sf=135&f=11&p=2644&s=
Since I can't seem to hook it up directly to GC I plan on compiling hex files on GC and loading them to the chip using my programmers included software.
Secondly, I'd like to use some of the demo programs included with the software but I can't seem to figure out how to make them work with my microcontroller which is a 16F628A. One of the bigger problems is that if I program my microcontroller with one of the demo projects, I don't know how I'm supposed to connect everything physically as there are no instructions on that anywhere I can see.
In summary I'm feeling a bit lost and I'm not sure how to continue. As mentioned I'm pretty experienced with electronics and it seems what I'm struggling with the most is the programming part. I'd really appreciate any help you could offer me as to how to get started programming microcontrollers.
All help is very much appreciated, thank you!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Since you're new and haven't made much of an intellectual or financial investment in hardware yet, I'd like to make a suggestion. As you might know, GCB can compile code for AVR microcontrollers as well as PIC microcontrollers. The AVR is the chip used in the very popular and inexpensive Arduino series of boards. You can buy assembled and tested Arduino boards for under $4 on ebay and not have to fool around building up a development board part by part. Search for Arduino "Nano 3.0 Controller Board"
Also, the Arduino boards have a built-in bootloader, so you don't need an external programmer to program your code in them....just a USB port on your computer and the right free software tools which can be found here. From a hardware capability perspective, there's very little difference between the PIC and the AVR, so you can do almost anything with one that you can with the other. From a programming perspective, GC Basic makes any remaining differences almost transparent.
If you want to give this a go with very little investment except your time and under $4 for the Nano board, you can have a look at this web site for how to do it:
You can find other other references to this approach on this forum. Also, as you get deeper into programming, you'll find that the very excellent GCB@SYN IDE referenced on this forum will give you a lot more programming capability and will streamline the process of developing and downloading your code into your chosen microcontroller board.
Joe
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello Mimu!
I am also the first projects and hex files downloaded from picprojects.org.
I do not see the development of picprojects.org link, there's no new projects.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Your programmer is a constraint which I understand. So, let us try and get that sorted first.
Firstly, I have not ever seen or used this programmer but I have just reseached. I am assuming are you using USBUrn version 1.13a3? If not, please download from the authors website.
From reviewing the German documentation I think the command line parameter 'Usburn -f --in name.hex' should program your chip, where name.hex is your source hex file. Does this work for you?
If the command line 'Usburn -f --in name.hex' command line parameter works then we can adapt @Syn to program your chip via your programmer.
Please let us know if the command line works.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tried to install USBurn but everytime I try to install it I get the error message "This application has failed to start because mpusbapi.dll was not found."
Is there a way I could add this file manually or what else can be done to remove this error?
As for hardware, I have my 16F628A and as far as other parts go there shouldn't be an issue. I've already built a stable and clean 5V power supply and I have plenty of resistors, LEDS, transistors, etc on hand as well as a prototyping board and experience in making printed circuit boards.
Last edit: Mimu 2014-08-16
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hey I got it to work! I just extracted it to a folder on my desktop this time. Didn't think the location would make a difference. It's not an installation though, it just runs out of the folder the files are extracted to.
Looking at you PDF. Let us get the Blink routine working, see your page 13.
This code is the GCB version of the code on page 16 of your PDF. Try to understand the differences then hook up the LEDS via a resistor (or resistors) and see the results.
GCB is very similar to the programming language in your PDF. There are differences. A major difference is the need to define the chip and the clock speed first. Then, it is normally down to your own creativity.
In the code below I have assumed that you can use the internal oscillator, this will get you going faster.
'****************************************************************************** 'microcontroller:16F628A' 'Project:Led_blinking' This project is designed to work with PIC 16F628A; 'withminoradjustments,itshouldworkwithanyotherPICMCU.' 'ThecodedemonstratesblinkingofdiodesconnectedtoPORTB.' Diodes go on and off each second. '******************************************************************************#chip16F628A,4#configINTOSC_OSC_NOCLKOUTmain:' Beginning of program Dir PortB Out 'ConfigurepinsofPORTBasoutputPORTB=0b11111111' Turn ON diodes on PORTB wait 1 s 'Waitfor1secondPORTB=0b00000000' Turn OFF diodes on PORTB wait 1 s 'Waitfor1secondgotomain' Endless loop end 'Endofprogram
Good luck, let us know the results.
Last edit: Anobium 2014-08-18
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I also modified the program a bit to make my own version like this,
#chip 16F628A
#config INTOSC_OSC_NOCLKOUT
main:
Dir PortB Out
PORTB = 0b10101010
wait 1 s
PORTB = 0b01010101
wait 1 s
goto main
end
With all 8 pins of port B hooked up to LEDs this makes an alternating pattern.
You'll notice that I forgot to add the ,4 at the end of the first line but it still worked. I'm assuming it went to a default clock speed? That is the clock speed right? 4mhz?
Man that was awesome, it put a big smile on my face!
So here are a couple questions/doubts.
I notice the differences between this program and the one written on that pdf I linked. Instead of "TRISB = 0" we used "Dir PortB Out". Instead of % at the beggining of the binary we used 0b. Instead of "Delay_ms(1000) we used "Wait 1s". What exactly is the reason for these differences? This is the reason I was getting errors when I tried this by myself, I was using the syntax as it's written in that pdf. Out of curiosity I tried compiling the program using % instead of 0b infront of the binary and it didnt work. I know 0b and % are both valid ways of identifying binary. So why the syntax change?
Also for some reason, both with the version of USBurn that came with the programmer (which is nothing more than USBurn re-labeled PIC-600) and USBurn 1.13A3 I often get some errors when Im trying to set up my pic. Sometimes when I try to identify the pic in the programmer it identifies it as 16F84 and it takes a few tries, and sometimes unplugging and plugging the programmer back in, to make it appear as 16F628A. This other issue I had when trying to load the program above, sometimes USBurn 1.13 would give me an error while PIC-600 didn't. From what I can tell it seems to be related to the routine I use when plugging in and setting up the pic. IE whether I plug in the programmer before starting the program or start the program before plugging in the programmer. I still havent figured out the exact pattern. I'm not too concerned with this and It's worked fine the last few tries I've given it.
Awaiting further input! :)
Last edit: Mimu 2014-08-18
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well done. You should be pleased. That took me many more hours than you took!
I will answer the second question first. I do not know why the programmer does not work. I had a cheap programmer once - I got grey hair trying to use it. I gave up and I now use a real (not a clone) programmer. My advice - find your process that works and stick with it. :-)
Now the differences. Your PDF is written for a different dialect of Basic. Each dialect has it own 'variations on the theme' and there are many differences. You have found one with respect to the use of binary numbers. The GCB Help File should help you understand the differences. GCB supports a lot of methods within the dialect, an example of defining the number 255 is shown below. As with any language - it is about practical knowledge and usage. :-)
The question on TRISB or PORTB.... You can use both methods but I think, I hope you agree, that Dir PortB Out is more meaningful than the alternative. One of the benefits of GCB is the complexity has been removed from created embedded computer solutions. Again, the Help File is a great resource when trying to get to grips with the dialect.
And, the missing clock speed.... :-) GCB will make some assumptions with respect to the many aspects the configuration but... I recommend you specify the clock speed. If you specify that is possible within the chip then you will be OK but if your specify a clock speed that is not possible you will get an error message and/or incorrect operation of the chip.
My question. What is next for you?
:-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a few goals set in mind for this. Probably the one I can achieve the soonest will be to drive an LCD screen. I've always wanted to do that!
Further down the road I'd love to put together a project I've wanted to make for a long time now. It's a sort of sound effect trigger device, either by having the uC make the sound effects itself or have some kind of system with an mp3 decoder. Although with the latter I'm not sure if an mp3 decoder would be fast enough to produce instant action. Idealy I'd be able to swtich around sound effects with a menu. My other goal is to make a power inverter by having a uC produce a sine wave or something close to a sine wave.
I have a lot of ambitions for this and I'm very happy to finally be getting my feet wet. Still have to do some more reading and experimenting!
Thanks for all the help, I'll definately save this forum as one of my resources.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi everyone,
I just purchased my first pic programmer and my first pic. I've already had success programming it using an online project that included a ready made .hex file as seen here; http://picprojects.org.uk/projects/ledchaser/
I've decided to start learning to program using BASIC. I've installed both "Great Cow Graphical Basic" as well as the Great Cow IDE that comes in the GCB@Syn zip file. I kind of like the latter better as it involves typing things out in text and I found GCGB a little bit confusing with the icons.
I consider myself very experienced in electronics. Up until now however I've almost exclusively worked with analog electronics. I can put together power supplies and short wave radios almost from memory but I have pretty much no experience with microcontrollers. I am somewhat familiar with BASIC as I had fun with it for a short while on a vintage computer. After that however I haven't practiced it again and all I have left is a general idea of how it works.
Here are a couple of the road blocks I am so far experiencing.
The only programmer I was able to get my hands on in my city does not seem to be compatble with GCB. Getting another is somewhat impractical for me due to shipping costs and currency exchange, not to mention living on a student budget. My programmer works very well but it doesn't seem to be a very popular one. Here is what I have http://www.steren.com.mx/catalogo/prod.asp?sf=135&f=11&p=2644&s=
Since I can't seem to hook it up directly to GC I plan on compiling hex files on GC and loading them to the chip using my programmers included software.
Secondly, I'd like to use some of the demo programs included with the software but I can't seem to figure out how to make them work with my microcontroller which is a 16F628A. One of the bigger problems is that if I program my microcontroller with one of the demo projects, I don't know how I'm supposed to connect everything physically as there are no instructions on that anywhere I can see.
I tried this tutorial but it requires Chipino.
http://www.greatcowbasic.com/uploads/9/2/9/8/9298268/greatcowbasic_programming_manual_v1_2.pdf
In summary I'm feeling a bit lost and I'm not sure how to continue. As mentioned I'm pretty experienced with electronics and it seems what I'm struggling with the most is the programming part. I'd really appreciate any help you could offer me as to how to get started programming microcontrollers.
All help is very much appreciated, thank you!
Mimu
Since you're new and haven't made much of an intellectual or financial investment in hardware yet, I'd like to make a suggestion. As you might know, GCB can compile code for AVR microcontrollers as well as PIC microcontrollers. The AVR is the chip used in the very popular and inexpensive Arduino series of boards. You can buy assembled and tested Arduino boards for under $4 on ebay and not have to fool around building up a development board part by part. Search for Arduino "Nano 3.0 Controller Board"
Also, the Arduino boards have a built-in bootloader, so you don't need an external programmer to program your code in them....just a USB port on your computer and the right free software tools which can be found here. From a hardware capability perspective, there's very little difference between the PIC and the AVR, so you can do almost anything with one that you can with the other. From a programming perspective, GC Basic makes any remaining differences almost transparent.
If you want to give this a go with very little investment except your time and under $4 for the Nano board, you can have a look at this web site for how to do it:
http://www.w3jdr.com
You can find other other references to this approach on this forum. Also, as you get deeper into programming, you'll find that the very excellent GCB@SYN IDE referenced on this forum will give you a lot more programming capability and will streamline the process of developing and downloading your code into your chosen microcontroller board.
Joe
Welcome to Great Cow Basic.
We can help, hopefully! :-)
Hello Mimu!
I am also the first projects and hex files downloaded from picprojects.org.
I do not see the development of picprojects.org link, there's no new projects.
Your programmer is a constraint which I understand. So, let us try and get that sorted first.
Firstly, I have not ever seen or used this programmer but I have just reseached. I am assuming are you using USBUrn version 1.13a3? If not, please download from the authors website.
From reviewing the German documentation I think the command line parameter 'Usburn -f --in name.hex' should program your chip, where name.hex is your source hex file. Does this work for you?
If the command line 'Usburn -f --in name.hex' command line parameter works then we can adapt @Syn to program your chip via your programmer.
Please let us know if the command line works.
Your second issue.
Can we start with some basic information? I am assuming you have a 16F628A what other hardware/leds etc do you have? Prototype boards?
We can assist in porting the ChipIno code or any other code :-).
Let us know what you have.
Anobium
Thanks for all the help guys.
I tried to install USBurn but everytime I try to install it I get the error message "This application has failed to start because mpusbapi.dll was not found."
Is there a way I could add this file manually or what else can be done to remove this error?
As for hardware, I have my 16F628A and as far as other parts go there shouldn't be an issue. I've already built a stable and clean 5V power supply and I have plenty of resistors, LEDS, transistors, etc on hand as well as a prototyping board and experience in making printed circuit boards.
Last edit: Mimu 2014-08-16
Let sort out USBurn. Can you tell us your operating system and platform etc.?
I downloaded 1.13a3 and installed with Windows 7 with no issues.
Let us know as much information as practical.
Hey I got it to work! I just extracted it to a folder on my desktop this time. Didn't think the location would make a difference. It's not an installation though, it just runs out of the folder the files are extracted to.
I'm starting to get the hang of how BASIC relates to the PIC. I'm currently reading this http://www.freeinfosociety.com/media/pdf/3134.pdf.
What should I do next?
Last edit: Mimu 2014-08-18
Well done.
Looking at you PDF. Let us get the Blink routine working, see your page 13.
This code is the GCB version of the code on page 16 of your PDF. Try to understand the differences then hook up the LEDS via a resistor (or resistors) and see the results.
GCB is very similar to the programming language in your PDF. There are differences. A major difference is the need to define the chip and the clock speed first. Then, it is normally down to your own creativity.
In the code below I have assumed that you can use the internal oscillator, this will get you going faster.
Good luck, let us know the results.
Last edit: Anobium 2014-08-18
Hey it worked!
I also modified the program a bit to make my own version like this,
With all 8 pins of port B hooked up to LEDs this makes an alternating pattern.
You'll notice that I forgot to add the ,4 at the end of the first line but it still worked. I'm assuming it went to a default clock speed? That is the clock speed right? 4mhz?
Man that was awesome, it put a big smile on my face!
So here are a couple questions/doubts.
I notice the differences between this program and the one written on that pdf I linked. Instead of "TRISB = 0" we used "Dir PortB Out". Instead of % at the beggining of the binary we used 0b. Instead of "Delay_ms(1000) we used "Wait 1s". What exactly is the reason for these differences? This is the reason I was getting errors when I tried this by myself, I was using the syntax as it's written in that pdf. Out of curiosity I tried compiling the program using % instead of 0b infront of the binary and it didnt work. I know 0b and % are both valid ways of identifying binary. So why the syntax change?
Also for some reason, both with the version of USBurn that came with the programmer (which is nothing more than USBurn re-labeled PIC-600) and USBurn 1.13A3 I often get some errors when Im trying to set up my pic. Sometimes when I try to identify the pic in the programmer it identifies it as 16F84 and it takes a few tries, and sometimes unplugging and plugging the programmer back in, to make it appear as 16F628A. This other issue I had when trying to load the program above, sometimes USBurn 1.13 would give me an error while PIC-600 didn't. From what I can tell it seems to be related to the routine I use when plugging in and setting up the pic. IE whether I plug in the programmer before starting the program or start the program before plugging in the programmer. I still havent figured out the exact pattern. I'm not too concerned with this and It's worked fine the last few tries I've given it.
Awaiting further input! :)
Last edit: Mimu 2014-08-18
Well done. You should be pleased. That took me many more hours than you took!
I will answer the second question first. I do not know why the programmer does not work. I had a cheap programmer once - I got grey hair trying to use it. I gave up and I now use a real (not a clone) programmer. My advice - find your process that works and stick with it. :-)
Now the differences. Your PDF is written for a different dialect of Basic. Each dialect has it own 'variations on the theme' and there are many differences. You have found one with respect to the use of binary numbers. The GCB Help File should help you understand the differences. GCB supports a lot of methods within the dialect, an example of defining the number 255 is shown below. As with any language - it is about practical knowledge and usage. :-)
' All these work
#define Test0 b'11111111' 'Binary
#define Test1 0b11111111 'Binary
#define Test2 0B11111111 'Binary
#define Test3 255
#define Test4 0xFF 'Hex
#define Test5 0xff 'Hex
#define Test6 0XFf 'Hex
The question on TRISB or PORTB.... You can use both methods but I think, I hope you agree, that Dir PortB Out is more meaningful than the alternative. One of the benefits of GCB is the complexity has been removed from created embedded computer solutions. Again, the Help File is a great resource when trying to get to grips with the dialect.
And, the missing clock speed.... :-) GCB will make some assumptions with respect to the many aspects the configuration but... I recommend you specify the clock speed. If you specify that is possible within the chip then you will be OK but if your specify a clock speed that is not possible you will get an error message and/or incorrect operation of the chip.
My question. What is next for you?
:-)
Very cool!
I have a few goals set in mind for this. Probably the one I can achieve the soonest will be to drive an LCD screen. I've always wanted to do that!
Further down the road I'd love to put together a project I've wanted to make for a long time now. It's a sort of sound effect trigger device, either by having the uC make the sound effects itself or have some kind of system with an mp3 decoder. Although with the latter I'm not sure if an mp3 decoder would be fast enough to produce instant action. Idealy I'd be able to swtich around sound effects with a menu. My other goal is to make a power inverter by having a uC produce a sine wave or something close to a sine wave.
I have a lot of ambitions for this and I'm very happy to finally be getting my feet wet. Still have to do some more reading and experimenting!
Thanks for all the help, I'll definately save this forum as one of my resources.
And, have fun!
:-)