PBASIC code to C
StingzLD
Posts: 2
Hey guys,
I am still pretty novice in this big and fantastic world, but I feel that I am ready to move on.
I am starting to research PICs and all of their glory, but obviously I cannot use PBASIC on them!
I would like to learn C, but it is so completely different than PBASIC. And as a novice, it is very
confusing trying to figure out how everything works.
Does anybody have information that could make this transition easier? I am basically hoping for
a conversion chart so-to-speak that shows how things are done in PBASIC and translates them
into how it is done in C.
Any help would be great!
I am still pretty novice in this big and fantastic world, but I feel that I am ready to move on.
I am starting to research PICs and all of their glory, but obviously I cannot use PBASIC on them!
I would like to learn C, but it is so completely different than PBASIC. And as a novice, it is very
confusing trying to figure out how everything works.
Does anybody have information that could make this transition easier? I am basically hoping for
a conversion chart so-to-speak that shows how things are done in PBASIC and translates them
into how it is done in C.
Any help would be great!
Comments
There's no guide for converting PBasic to C because most of the significant operations in PBasic are not available in C or are very very different. Things like PULSOUT or HIGH or LOW or SEROUT simply don't exist in C. Something like these would need to be provided as library calls, but those would be dependent on the vendor of the C system. You might look at the Arduino's C libraries for equivalent functionality.
You could also move on up to the Propeller chip and even continue to program in basic using PropBasic.
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
Then you can easily display things from your programs on your pc monitor and see that your programming is working.
Also read a book on C programming. So far as books go, C was developed using the "UNIX" operating system and there are many books out there which frequently mention UNIX things which don't apply to a PC.
Unix things would use a $ "command prompt" in the books examples to compile something. Like this...
$ cc myfile.c
Whereas a PC "command prompt" would look like this...
C:\> cc myfile.c
So best to look through the book and at least see that it uses PC examples as opposed to UNIX examples. Then you willl know what·the book·is talking about.
You can get an IDE or Integrated Development Environment. These add all sorts of additional files to your programming making everything even more confusing. There would be a book length document on just how to use the IDE and you are best to read that.
And then there is something like Microsoft Visual C++ which has all sorts of "objects" to learn about in addition to learning C.
I would suggest avoiding the IDE and Visual C++ things for your very first C program on your PC. There should be a simple free windows C compiler/linker out there somewhere?
Then write your first "Hello World!" program using that...
http://en.wikipedia.org/wiki/Hello_world_program
PIC programming is done with the Microchip IDE called MPLAB. This comes with a free C compiler for other than PIC 18 devices.
Then there is an add-on·free MCC18 PIC C compiler. You are best to install that in the C:\ directory of your PC as this compiler will·not work with long directory/file names.
Then any programs you work on should also be very close to C like in a C:\Pic directory. If the program is buried too deep in a directory tree, C18 will say·it can't find the·folder/file!
There is also a paid for C compiler called the Hi-Tech C compiler. Sample C programs written for that compiler will not work on the C18 compiler!
So there are many different C compilers out there! (To add to all the confusion!) A C program which works for one C compiler many not work on another C compiler. So also read the compiler documentation.
This stuff can take years to learn.
·
Anyway, he presents the information very clearly making it very easy to follow. He uses the Dev C++ compiler by Bloodshed - it's free.
I highly recommend it, it's worth paying for.
Rich H
edit: I found it. The first three chapters are free. I had overlooked the first Google hit because it looked like so many other useless hits.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.
Post Edited (W9GFO) : 6/20/2010 8:15:45 PM GMT
The Arduino has it's own IDE that allows you to program in a C/C++ "manner". I say "manner" because the IDE is really a front end to the GCC compiler, but it is designed to hide some of the development steps that are involved in the process. So an Arduino "sketch" gets converted into a valid C/C++ program, then is compiled with GCC, and the output is loaded into the Arduino, managed by the bootloader+ide.
The benefit here is that it provides a gentle introduction to C/C++ syntax & concepts, as well as a library of funtions that make it fairly easy to get started. When/if you decide that you want to get more involved in the process, you can program the Atmega328 chip directly using an AVRISP MKII programmer (approx. $35), and AVR Studio (free). In doing this, you are bypassing (or overwriting) the Arduino bootloader altogether, and essentially using the Duemilanove as a development/programming board for the Atmega328.
All of that said, there is one caveat. There are a lot of Arduino "kits" on the market, and they vary considerably in the quality of the instructional material included. The closest that I've seen to the "What's a Microcontroller" manual is the book written by Earthshine Electronics: www.earthshineelectronics.com/files/ASKManualRev3.pdf. They sell kits based on the book, but they are located in the UK, so depending on your location, the price will vary. Just be aware that if you do pick up an Arduino, you'll likely need to spend a little more research time than you would with a BS2.
Lastly, while I've not used one, but have been considering purchasing one, Andre' LaMothe has a couple of kits available that are very comprehensive, with very god documentation. If you're looking for C/C++, you'll want to look at his AVR & PIC based products. He does have a few kits based on Parallax chips (SX & Propeller), but they don't use C/C++ as the target language.
I just started learning C myself (assembler is my playpen) Codevision has a free download for limited size files and is low cost as well to buy.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
As far as the Arduino goes, I would actually recommend getting one. I bought one about 8 months ago, and it is a cool little device. The only downside I found really quickly is that it is insufficient when it comes to the projects I am trying to get going. But that doesn't mean it isn't something you shouldn't buy and play around with! There is a lot that you can do with them that I have not had enough time to play with, but one day I will get to attempt to fully explore the Arduino and all of it's glory.
Anyways, thanks once again y'all!