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.
awsome!!!

let us know how it went, and if you end up using a input to activate a output, can you post a simple BASIC example?
 
shaneshane1 said:
awsome!!!

let us know how it went, and if you end up using a input to activate a output, can you post a simple BASIC example?
Here's a SwordFish BASIC example (running on Junebug)
Code:
// JUNEBUG lights LED 3 when pushbutton 2 is pressed 
Device = 18F1320
Clock = 0.031250          // default 31250 KHz Osc
Config OSC = INTIO2         // Use the Internal Oscillator
Dim     Switch As PORTB.2, 
        LED As PORTA.6      // 
Low(PORTA.7)                // LED 3 Gnd
INTCON2.7 = 0               // enable PORTB input pullups
Input(Switch)

Loop:
If Switch = 0 
        Then    High(LED)
        Else    Low(LED)
    EndIf
GoTo Loop
End
 
Last edited:
I like the use of aliasing the port pins for more "understandable terms

Code:
Dim     Switch As PORTB.2, 
        LED As PORTA.6


Just pointing it out because its something that when used on a larger scale, makes projects that much easier to maintain - that and I was just explaining it to a mate here.

eg, you had a program with 1500 lines of code, and reffered to "Switch" in 10 different locations. By aliasing you only need to change the declaration
 
They're based on your (gramo) examples. I've been wanting to use Swordfish with the Mongoose kit PIC18F2525. Too bad no debug support though but it seems like a very nice compiler. I use Swordfish's own editor and the PICkit 2 standalone software (program on push button works like a charm :) )

I guess what I'm trying to say to shaneshane1 is the PICAxe is interesting and certainly better than a BASIC Stamp but a good PIC compiler like Swordfish beats them both.

**broken link removed**
 
Last edited:
blueroomelectronics said:
They're based on your (gramo) examples. I've been wanting to use Swordfish with the Mongoose kit PIC18F2525. Too bad no debug support though but it seems like a very nice compiler. I use Swordfish's own editor and the PICkit 2 standalone software (program on push button works like a charm :) )

I guess what I'm trying to say to shaneshane1 is the PICAxe is interesting and certainly better than a BASIC Stamp but a good PIC compiler like Swordfish beats them both.

I agree and hope to someday to invest in Swordfish/Pickit2 as my hobby applications may require the speed and power of those tools.

However for a someone just starting out and wanting to try simple things to see if they really are going to like this stuff, then it's hard to beat the bang per buck that the Picaxe series can provide and I will continue to recommend it to raw beginners. Sometimes the journey of starting and learning with simple tools and working ones way up to more powerful tools is a better method to grow then starting with the latest state of the art tools and systems.

Lefty
 
Last edited:
shaneshane1 said:
awsome!!! let us know how it went,
Went fine. It's a PIC 16F88 with a bootloader, so it's a pretty trivial thing for me to get working. I soldered up a programming cable, which you can see in **broken link removed**.

**broken link removed**. You can see the huge old 1/2 watt resistor I still use for LEDs. Had those since I was a kid.

Now I guess I'll see if I can find a switch...
 
shaneshane1 said:
and if you end up using a input to activate a output, can you post a simple BASIC example?
Yup. Here ya go. :)
Code:
main:
	if pin1 = 1 then blink
	goto main

blink:	high 4
	pause 50
	low 4
	pause 50
	if pin1 = 0 then
		goto main
	else
		goto blink
	endif
Pretty basic little program. If you press the button the LED blinks until you stop pressing it.

Here's an **broken link removed** of the program in action! Don't fall off your chair. ;)

The blinky thing in the background is my new (unfinished) PIC 12F683 board blinkin a couple LEDs.
 
Last edited:
Remember this post?
futz said:
If I was in your place, I would go **broken link removed** and order the AXE002/030U --- PICAXE-18A Starter Pack - USB.
I had another look, and if you haven't already ordered, I'm going to change my recommendation to the **broken link removed**. It's a better chip and it's cheaper because you're not buying a USB to serial adapter with it (and it's the chip I have, so if you're asking questions I can help easier). Check if your computer has a **broken link removed** on the back first. Almost all computers do.

If you use a laptop then you need the USB one. In that case look at the AXE002/035XU or AXE002/030XU. The 030 is the CHI030 board with darlington array. The 035 comes with a socket for a L293D motor driver. I think that might be more interesting than the darlington board. Besides, darlington arrays are dirt cheap. Add your own later if you want one.
 
Last edited:
Thanks futz

I ran your BASIC code through the simulator, and i understand it :D

doesnt seem like it will be to hard to work out, i use to use a program called LUA, it was a program for the PSP (Playstation Portable) and it seems like BASIC and LUA are on the same level.

so where you have put the text >>main<< in the code, you can change that to whatever you want as long as its the same through out the code.

eg: replacing main with >>Start<< ???

and replacing Blink with >>flash<< ???

and so on.

I had a look at your pics and your video, and it has put things into prospective for me, thanks!!!


And as for your reply about the kit, i think i might stick with the AXE002/030U as its the lowest price at $73.65 (I need USB for Laptop)
 
shaneshane1 said:
so where you have put the text >>main<< in the code, you can change that to whatever you want as long as its the same through out the code.

eg: replacing main with >>Start<< ???

and replacing Blink with >>flash<< ???

and so on.
Those are just labels, or symbols, and they can be almost anything as long as you don't use BASIC's reserved words (commands). You'll find a reserved word list in the manuals.

And as for your reply about the kit, i think i might stick with the AXE002/030U as its the lowest price at $73.65 (I need USB for Laptop)
I would definitely switch that to a AXE002/030XU then. The X chip has lots more memory. Makes things easier and it's only another five bucks.

Here's how those **broken link removed** work: AXE002 is the starter kit. 030/035 tells you which project board (CHI030 or CHI035). X tells you it's an 18X model. If there's no X then it's an 18A. And U means USB. No U means serial.
 
Last edited:
I guess I'm missing something? What's wrong with using a free compiler like Swordfish SE or Great Cow BASIC and a standard PIC programmer?
 
blueroomelectronics said:
I guess I'm missing something? What's wrong with using a free compiler like Swordfish SE or Great Cow BASIC and a standard PIC programmer?

Nothing wrong with using them, i guess.

Im just starting out with this subject, and the picaxe programming editor is really easy to use

eg: I created this code for a toggle on/off switch and the code is very small and easy to understand

Code:
main:
	if pin1 = 1 then 
                         light
	            goto main

light:   
      high 4
      if pin2 = 1 then
	     low 4
	     goto main
	     endif
      goto light

Whats the equivalent in the code you use???
 
Last edited:
shaneshane1 said:
Code:
main:
	if pin1 = 1 then blink
	goto main

blink:   
      high 4
      if pin2 = 1 then
	low 4
	goto main
	endif
	goto blink

Whats the equivalent in the code you use???

With Swordfish;

Code:
[B]Device [/B]= 18F452
[B]Clock [/B]= 20

[B]Dim [/B]Switch [B]as [/B]PORTC.0
[B]Dim [/B]LED [B]as [/B]PORTC.1

// Make the Switch pin an input
[B]Input[/B](Switch)

// Main program loop;
[B]While [/B][B]True
    If [/B]Switch = 1 [B]Then[/B]
        [B]High[/B](LED)
    [B]Else
        Low[/B](LED)
    [B]Endif
Wend[/B]
** Note that "//" denotes the line is a comment, not code


The above program will simply mimic the status of the switch. It could be simplified too;

Code:
[B]Device [/B]= 18F452
[B]Clock [/B]= 20

[B]Dim [/B]Switch [B]as [/B]PORTC.0
[B]Dim [/B]LED [B]as [/B]PORTC.1

// Make the Switch pin an input
[B]Input[/B](Switch)

// Make LED and output and set it low
[B]Low[/B](LED)

// Main program loop;
[B]While True[/B]
    LED = Switch
[B]Wend[/B]
 
Last edited:
blueroomelectronics said:
I guess I'm missing something? What's wrong with using a free compiler like Swordfish SE or Great Cow BASIC and a standard PIC programmer?
Hehehe! :p I did try to push him (gently) into a Junebug. But after a while I realized that he was a complete newb and thought that a Picaxe might be (as I said earlier) "a kinder and gentler intro".

Once he has a handle on the basics, like simple programming and interfacing, and wants more power he can get a real programmer and dig in to slightly more advanced PIC use.

The Picaxes are SO easy to use that I think they'd bore me. Took me all of 2 minutes to get a 18B20 working on this thing last night. Ultra simple. But I didn't learn a damn thing. :D BASIC hides all the complexity from me. There's no challenge for someone like me.

On the other hand, that kind of simplicity is great for newbs. They don't get bogged down in complexity. They learn a bit about programming and interfacing. And they get some early success, which is good. Pretty soon maybe they find they need more speed and/or control and step up to the "real thing".
 
well ill keep using this until i need something bigger and better and harder to understand :rolleyes:

I dont need complex code that is harder to understand, when i have something that is easy to understand, and does more than i need it to do anyway.

for me at the moment, this is a huge space saver, it cuts down on the amount of IC'S im use to using to do the same job a PIC can do.
 
blueroomelectronics said:
I guess I'm missing something? What's wrong with using a free compiler like Swordfish SE or Great Cow BASIC and a standard PIC programmer?

The thing is you don't need a programmer with a PICAXE, it's very cheap and very easy to use.

Downside is it's fairly slow as it's interpreted, and they only have limited program size.
 
I have one more question that i think i already know the answer to,

on all my inputs, im assuming i need to put 10K pulldown on all my inputs for normal operation?
 
Nigel Goodwin said:
The thing is you don't need a programmer with a PICAXE, it's very cheap and very easy to use.

Downside is it's fairly slow as it's interpreted, and they only have limited program size.

Then what do you get for $73 that you don't need? A USB to RS232 is $14
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top