Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Draft 1 of Junebug Lesson 1

Status
Not open for further replies.

3v0

Coop Build Coordinator
Forum Supporter
This is a first draft of a tutorial for using Junebug with the C18 compiler.

It covers enough to setup the processor and turn on a single LED. The first lesson may be the hardest to write because it needs to cover a lot of diverse ground.

The PIC hardware and C language info has been integrated into a single document.

Comments are welcome, even if you just want to say it sucks. I am not looking for help with grammar and spelling. What I want to know is if the organization of information works.

EDIT https://www.rocklore.com/3v0/OO DOCS/Junebug1A.pdf
 
Last edited:
Looks good so far. If this is intended for people who don't know C then the thing I can see that is missing is a description of the use of semi-colon and braces. I find this confuses newbies more than anything else. The other thing is variable scope. Are you intending to cover these things at a later stage.

I assume you deliberately skipped over the linker description at this time.

Mike.
 
Pommie said:
Looks good so far. If this is intended for people who don't know C then the thing I can see that is missing is a description of the use of semi-colon and braces. I find this confuses newbies more than anything else. The other thing is variable scope. Are you intending to cover these things at a later stage.

I assume you deliberately skipped over the linker description at this time.

Mike.

This an attempt to teach PIC and C at the same time. I will add a short bit about what a statment is. I touch on code blocks in passing and that is enough for this lesson.

In this lesson I inserted just enough of hardware and software to get the program to compile and turn on a LED. There will be some number of additional lessons. Maybe I should add a paragraph in about the edit->compile->link->program->debug cycle. Actual manipulation of the linker file will come much latter.

As I said the first lesson is the most difficult because it is way to easy to put too much info in and overload the user.

Thanks
 
Minor change

One thing that I would reccomend doing is change the include for p18f1320.h to p18cxxx.h The reasoning is that by doing that when you port the code to another type of Pic you don't have to go messing with the headers. You just change the target.
 
  • Like
Reactions: 3v0
August Treubig said:
One thing that I would reccomend doing is change the include for p18f1320.h to p18cxxx.h The reasoning is that by doing that when you port the code to another type of Pic you don't have to go messing with the headers. You just change the target.

I think that is a really bad idea because when they post their non working code on here then the processor is unknown. I am a great believer in a little more typing a little less debugging.

Mike.
 
August the tutorials are for people who do not understand what they are doing. I took care to make the first program simple. The ambiguous include of p18cxxx.h would need to be explained and as Mike said it will cause problems or at least doubt.

It is my opinion that the only time the ambiguous include should be used is when the code will work on all members of the processor family specified.
 
I'm on the road so I can't look at the PDF, I'm looking forward to reading it.
I've been working with C for the last week or so and once you get used to the braces its not so bad ;)
When is "void" mandatory?
 
Looking good...

What a good read....but being a beginner at both the MPLAB and C18 you may even want to step back a bit. Before you even get into the programming part, maybe put a link on where to download the software that you are using to do this tutorial with. Then also maybe a couple of screen shots of the actual programming environment as well. Then maybe some basics of how to use the MPLAB and if there are any particular things you need to set up in either MPLAB or the complier...

Just a thought...great work though...what are planned for the other lessons??
 
Professionals

If you look at most of the examples, the generic is used. But you may do as you say. But I will bet when you get to coding with the big boys, you will be using the "model". I am not sure at what level you are teaching for. I know that it saves me much trouble when I move between chips. Boost C has an even more generic one where you include system.h and it finds the right one based on the target platform.
If you are teaching at University level, I would suggest that using the generic creates the habits that will move forward.

Micro cpus like Pics create an interesting swimming pool of folks.
  • Electronic hardware geeks who really don't know programming
  • Software geeks who really don't know electronics
  • And a few of us who know both sides (maybe one better than the other)
When I was in college, the EE folks did transistors, resistors, etc.
The Computer Science folks did programming
and the two really didn't meet except for when the EE folks had to take the programming course taught by crotchety old computer EE prof. They hated it. The CS folks ate it up. Was on a DEC PDP-11. Most modern PICs could outrun it today easily.

Times change. My brother who is an EE (same school, 11 years later) is more of a programmer than an EE. He designs stuff, but spends more time writting code.

But the issue is to come up with some good guide lines. Maybe for lesson 1 you are right. But at some point (maybe lesson 3 or so) the code has to be better.

All in Fun ;)
 
There are many times on here when people post code and the answer is simply that they have missed out ANSEL=0 or CMCON=7 or some other such thing. Without knowing the processor these things cannot be spotted. Your generic argument just doesn't work in these situations and especially with beginners. As I stated earlier, a little typing saves a lot of debugging.

Mike.
Edit, Big boys comment removed. :rolleyes:
 
blueroomelectronics said:
I'm on the road so I can't look at the PDF, I'm looking forward to reading it.
I've been working with C for the last week or so and once you get used to the braces its not so bad ;)
When is "void" mandatory?

Here is what I know.

As you know void is the type name used when no data is present.

With a uC the type (return type) of main must be void. There is no program/code to pass a value back to.

Because on a uC we can not pass values into main the parameter list should technically be (void). The empty parameter list () not the same as void. It indicates that data is (may be?) present but does not define what it is.

If you are running a called C program as with a PC or a workstation you C program may be called with arguments. In that case main() would be correct and you would use argc and argv to get at the arguments.
You can also have main return values so int main() would return an number.

That is all I can recall. If anyone knows please fill in the gaps or straighten me out.
 
Last edited:
jbarnaby2000 said:
What a good read....but being a beginner at both the MPLAB and C18 you may even want to step back a bit. Before you even get into the programming part, maybe put a link on where to download the software that you are using to do this tutorial with. Then also maybe a couple of screen shots of the actual programming environment as well. Then maybe some basics of how to use the MPLAB and if there are any particular things you need to set up in either MPLAB or the complier...

Just a thought...great work though...what are planned for the other lessons??

Some things are better shown then explained with text. For things like installing the software and how to step through a program with the debugger I plan to make videos.

There are more tutorials to write then I can do in a short period of time. The first 10 or so will need to be ordered. Multiplexing needs to come soon to explain the charlieplexing. Then we will cover C stuff: flow control, datatypes and structures, union etc. After the C we will switch back to the PIC and start working with the peripherals.

Getting the format and method of presentation down is by far the hardest and one of the most important aspects of this sort of project. This is not my first attempt. I have had a few false starts but I think this one may work. I also expect that it will morph to some degree.
 
Screen shots

3v0,

As far as screen pictures / videos. If you are on windows, (I assume that is true) you may look at a freebe call HoverSnap. With it you can get a jpg of the current window, or choose your own portion of the screen, etc. It may be easier that doing videos and provide the same information.

Works good.

:D
 
An example

This is a snap of the "active" window of a MPLAB session squished down a bit.


capture1-23-2007-1-41-21-pm7-30-2007-7-48-12-am10-3-2007-11-35-03-am3-18-2008-2-43-52-pm-jpg.18046

 

Attachments

  • Capture1-23-2007-1.41.21 PM7-30-2007-7.48.12 AM10-3-2007-11.35.03 AM3-18-2008-2.43.52 PM.jpg
    Capture1-23-2007-1.41.21 PM7-30-2007-7.48.12 AM10-3-2007-11.35.03 AM3-18-2008-2.43.52 PM.jpg
    172.4 KB · Views: 294
Nice work 3V0, it's not easy to write tutorials.
I've put a cover graphic together for the book awhile ago, haven't even named the book but I'd like to get back on track with it.
**broken link removed**
 
August,
Thanks but I will stick with the videos. In some cases a minute or two of video can save hours of editing text. There is a nice little program called CamStudio that records your desktop in real time. That with a bit of voice over works very well. At some point I want to do a set of tutorials on robots and not seeing them move would be criminal!

Bill,
I needed to get moving on these. They will avoid a lot of duplicating with the teaching and tutoring. Life will be much easier when i can say "today we will be doing lesson 23".

The lessons assume a Junebug because it makes life much easier. I would like to include schematics for the tutor section of Junebug for people who have other programmers.

The offer to help with C examples for the book is still good if you are interested.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top