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.

New to PIC'S and programming???

Status
Not open for further replies.
once i have everything up and running, and i have downloaded BASIC where can i obtain the code's to program the Pic, eg: output go high for 1second and then low for 1second, do i have to seach the web everytime i want to do something? or is there a site for it all, or at least most of it?
 
shaneshane1 said:
once i have everything up and running, and i have downloaded BASIC where can i obtain the code's to program the Pic, eg: output go high for 1second and then low for 1second, do i have to seach the web everytime i want to do something? or is there a site for it all, or at least most of it?
:confused: Why would you want to copy code from others? You don't learn anything that way. Make your own. It's easier than you think. You can start with very simple stuff and gradually get into more complex subjects. Burn thru some tutorials and you'll be doing interesting things in no time. :D

At the on the Datasheeets page. There's help there for all kinds of kewl stuff.

Like I said, I'm getting one too, so if you have questions I can probably assist. I used to be a heavy BASIC programmer, thousands of years ago before I switched to assembly and C.
 
i just downloaded the Picaxe programming editor about 40minutes ago, and have been testing simple commands using the simulator, and im finding it really really easy to use, eg:

main:
high 1
pause 1000
low 1
pause 1000
goto main

so when i buy the PICAXE-18A Starter Pack - USB i will have a head start on things.

when i buy the (AXE002/030U) kit, what do all the pins on the PIC mean, i tried looking up the data sheet for it but the page is unavailable

i know what the output pins do, and +V and 0V

and i assume that serial in & serial out are sum what connected to the computer :confused:

and i would assum that reset would just be like the reset on an ordinary IC :eek:

But what about the inputs? what are they for?



can someone help me on the matter


futz :D
 

Attachments

  • pic.PNG
    pic.PNG
    6.6 KB · Views: 146
Last edited:
shaneshane1 said:
im finding it really really easy to use,
Told ya! ;)

and i assume that serial in & serial out are sum what connected to the computer :confused:
Usually you would use those pins for various communications protocols like RS-232 or SPI or others, either to communicate with a PC or with another microcontroller or even a display (serial LED or LCD) or other peripheral.

and i would assum that reset would just be like the reset on an ordinary IC :eek:
Yup.

But what about the inputs? what are they for?
Those can read analog voltage levels or be used to read switches or other things like that. They allow the microcontroller to sense the outside world in various ways.
 
So am i right in saying that if i just want to use the outputs, i can remove the PIC and connect it to a breadboard using pins +V, 0V, Reset to +V using a pullup resistor, and the outputs to my application?

So can i use my inputs to activate an output?
if so i assume i will need to command the infomation through BASIC to do so

Thanks!!!
 
shaneshane1 said:
So am i right in saying that if i just want to use the outputs, i can remove the PIC and connect it to a breadboard using pins +V, 0V, Reset to +V using a pullup resistor, and the outputs to my application?
You could, but why risk breaking a pin? Just leave it in the board. Install some headers and build some cables to connect the board to your breadboard.

Something like **broken link removed** from my 18F452 board to the breadboard.

Another reason to leave the PIC on the board is that board gives you a darlington array for outputs, allowing you to connect fairly big loads (up to 800ma per pin). The PIC's pins are only good for maximum 25ma.

I can see you're going to have some grief though. That CHI030 board uses non-standard pin spacing (trying to cater to newbs, but in doing so just making things difficult) and you may have to solder wires individually to a header and plug into that.

Or you can set the whole thing up on a breadboard instead. You'd have to hack together some way of plugging the programming jack into the breadboard, or do it with wires from the CHI030.

If you're going to move the chip from board to board more than once or twice, definitely buy yourself a machine-pin IC socket. Put the PIC chip in the socket and pull the socket with chip instead of risking the IC's legs with every move. Those machine-pin sockets are tough. The PIC's pins, not so much.

So can i use my inputs to activate an output? if so i assume i will need to command the infomation through BASIC to do so?
You mean push a button and the MCU sees it and turns something on? Yes you can do that, and yes, you'll have to write code to make it happen.
 
Last edited:
Just for the record I tried out one of gramo's LED examples and the free Swordfish SE BASIC Compiler on the Junebugs 18F1320. Works like a charm.
**broken link removed**
Code:
// Blink the Junbug Tutor LED 1 at 1Hz
Device = 18F1320
Clock = 8
Config OSC = INTIO2            // Use the Internal Oscillator
Include "utils.bas"
Dim LED As PORTA.0            // Assign an alias for "LED"
// Start Of Program...
OSCCON = $72                // Sets up the internal oscillator
SetAllDigital                  // Make all Pins digital I/O's
Low(LED)                      // Make the LED pin an output and set it low
Low(PORTA.6)                // Make the LED Cathode an output and low
While True
    LED = 1                   // Turn on the LED
    DelayMS(500)            // Delay for half a second
    LED = 0                    // Turn off the LED
    DelayMS(500)            // Delay for half a second
Wend
 
Last edited:
so after the PIC has been sent infomation it can be removed and placed on a breaboard using a machine pin socket to keep the pins in good order.

and the only thing that needs connecting is +V, 0V, reset, and outputs?
 
Here's your (gramo's) 1wire program running on the Junebug using the PICkit 2 UART tool I'll update the image when I find one of my DS18B20s
PS the Junebug and many other blueroomelectronic kits are 1wire ready (the little 3pin connector on the lower left of the Junebug Tutor)
**broken link removed**
 
Last edited:
shaneshane1 said:
so after the PIC has been sent infomation it can be removed and placed on a breaboard using a machine pin socket to keep the pins in good order.

and the only thing that needs connecting is +V, 0V, reset, and outputs?
Pretty much. Once programmed, the chip will hold the program for... ever? (a long, long time anyway). And whenever powered up it will run the program.

You can reprogram it right on the breadboard. No need to move the chip back and forth. It's not like you'll just program it once. You'll do it hundreds and thousands of times as you make changes to your programs and work the bugs out of them and make new programs to do new things.
 
Ok thanks

iv looked at the data sheet for BASIC commands and thats seems faily straight forward :eek:

But i dont really know how to string these commands together

eg: if i want to use an input(button) to activate a output

i dont know where to start with things like that?
 
shaneshane1 said:
iv looked at the data sheet for BASIC commands and thats seems faily straight forward :eek:
I just installed the editor and am looking through the command set. Nice! Very complete. Looks like they've thought of almost everything. :) Well done! Looks like a really easy chip to use.

But i dont really know how to string these commands together
Well, stringing those commands together is what programming is. You'll pick it up. When you want to get something done, try to write down on paper in english (or pseudo-code), what you want to accomplish, step by step in the order you think it needs to be done. This is called an algorithm. This will get easier with practice. Be sure to double or triple space so you can stuff in more commands you think of later to fix the stuff you never thought of on the first pass.

You WILL crumple and throw away many poorly thought out algo's and will rewrite large sections as you write code and test it.

Then find commands that will accomplish the steps and start typing them in, checking off things on your scratch paper as you get each part coded. You'll be useless at it at first, and you'll spend a lot of time thrashing back and forth through the manual trying to find the right commands to use. Don't get discouraged. It gets much easier with practice. After a while you'll memorize the more common commands and you'll just know how to do things.

Don't aim too high at first. Start very small. Write lots of tiny programs. Modify them to see what happens. Get small sections of your code to work individually. After each part works, put em together.

You can't learn programming by reading alone. You MUST write code, and lots of it, even if it's crappy code. You'll get better with practice.

eg: if i want to use an input(button) to activate a output. I dont know where to start with things like that?
First thing is to make a "main" loop like the first LED blink demo. Inside that loop you'll "poll" (check it every time thru the loop) the input pin your switch is on with an "if/then" statement.

Read Manual 3 to learn how to interface a switch properly. It'll need a pull-up or pull-down resistor to hold the pin electrically in the "off" position until you actually switch the switch.

When the program sees the pin has changed and is low or high (however you've built your circuit) the "if" statement will branch to a part of the code that turns on your LED. As long as the switch is off this part of code gets skipped past.

Am I making any sense?
 
Last edited:
Yes it does make sense, thanks!!!

i understand all of what you are saying, its just a pitty i dont have the kit yet, still waiting to get the money for it :mad:

i can only just keep testing with the simulator, im just glad thats there to stop me going completly crazy

and least it gives me an indication that my code works.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top